00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_search_donor_nnx_real (comp_info, search, var_id, &
00012 coords1, coords2, coords3, distance, &
00013 nfound, locations, n_send, nb_extra, &
00014 tol, ierror)
00015
00016
00017
00018 use PRISM
00019
00020 use PSMILe, dummy_interface => PSMILe_Search_donor_nnx_real
00021
00022 Implicit none
00023
00024
00025
00026 Type (Enddef_comp), Intent (In) :: comp_info
00027
00028
00029
00030
00031 Integer, Intent (In) :: var_id
00032
00033
00034
00035 Integer, Intent (In) :: n_send
00036
00037
00038
00039 Real, Intent (In) :: coords1 (n_send)
00040 Real, Intent (In) :: coords2 (n_send)
00041 Real, Intent (In) :: coords3 (n_send)
00042
00043
00044
00045 Integer, Intent (In) :: nb_extra
00046
00047
00048
00049 Real, Intent (In) :: tol
00050
00051
00052
00053
00054
00055
00056
00057 Type (Enddef_global_search), Intent (InOut) :: search
00058
00059
00060
00061 Real, Intent (InOut) :: distance (n_send)
00062
00063
00064
00065 Integer, Intent (InOut) :: nfound (n_send)
00066
00067
00068
00069
00070
00071 Integer, Intent (Out) :: locations (ndim_3d, n_send)
00072
00073
00074
00075 Integer, Intent (Out) :: ierror
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 Integer, Parameter :: lon = 1
00087 Integer, Parameter :: lat = 2
00088
00089
00090
00091
00092
00093
00094
00095
00096 Type (Gridfunction), Pointer :: field
00097
00098
00099
00100 Integer :: method_id
00101 Type (Method), Pointer :: mp
00102 Type (Coords_Block), Pointer :: coords_pointer
00103
00104
00105
00106 Type (Grid), Pointer :: grid_info
00107 Integer :: grid_id
00108 Type (real_vector) :: cosvec, sinvec
00109 Type (real_vector) :: sinvec_reg (ndim_2d)
00110 Type (real_vector) :: cosvec_reg (ndim_2d)
00111
00112
00113
00114
00115
00116 Integer :: len_item, len_rtem
00117 Integer :: irreg2_shape (2, ndim_3d)
00118
00119 Type (real_vector) :: cos_search, sin_search
00120
00121
00122
00123
00124
00125
00126
00127 Integer :: mask_id
00128 Logical :: src_mask_available
00129
00130 Logical, Target :: dummy_mask_array (1)
00131
00132 Integer :: dummy_mask_shape (2, ndim_3d)
00133
00134 Logical, Pointer :: mask_array (:)
00135
00136 Integer :: mask_shape (2, ndim_3d)
00137
00138
00139
00140 Integer, Parameter :: nerrp = 1
00141 Integer :: ierrp (nerrp)
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 Character(len=len_cvs_string), save :: mycvs =
00162 '$Id: psmile_search_donor_nnx_real.F90 2082 2009-10-21 13:31:19Z hanke $'
00163
00164
00165
00166
00167 #ifdef VERBOSE
00168 print 9990, trim(ch_id), comp_info%comp_id, search%sender
00169
00170 call psmile_flushstd
00171 #endif /* VERBOSE */
00172
00173 ierror = 0
00174
00175 field => Fields (var_id)
00176 method_id = field%method_id
00177 mask_id = field%mask_id
00178
00179 mp => Methods(method_id)
00180 grid_id = mp%grid_id
00181 coords_pointer => mp%coords_pointer
00182
00183 grid_info => Grids (grid_id)
00184
00185 src_mask_available = mask_id /= PRISM_UNDEFINED
00186
00187 if (src_mask_available) then
00188 mask_array => Masks(mask_id)%mask_array
00189
00190 mask_shape = Masks(mask_id)%mask_shape
00191 else
00192 mask_array => dummy_mask_array
00193
00194 mask_shape = dummy_mask_shape
00195 endif
00196
00197 #ifdef PRISM_ASSERTION
00198
00199
00200
00201 if (search%msg_extra(1) /= PSMILe_nnghbr3D) then
00202 call psmile_assert ( __FILE__, __LINE__, &
00203 'Interpolation method must be Nearest Neighbour')
00204 endif
00205
00206 if (grid_info%corner_pointer%corner_datatype /= MPI_REAL) then
00207 call psmile_assert ( __FILE__, __LINE__, &
00208 'Incorrect datatype for this routine')
00209 endif
00210
00211 if (n_send /= search%msg_extra (8)) then
00212 call psmile_assert ( __FILE__, __LINE__, &
00213 'Inconsistent number of points')
00214 endif
00215
00216 #endif
00217
00218 #ifdef DEBUG
00219 print *, trim(ch_id), ': search%msg_extra(1:4)', search%msg_extra(1:4)
00220
00221 call psmile_flushstd
00222 #endif /* DEBUG */
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 len_item = search%msg_extra (9)
00236 len_rtem = search%msg_extra (10)
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 irreg2_shape (1,1) = 1
00252 irreg2_shape (2,1) = n_send
00253 irreg2_shape (1,2) = 1
00254 irreg2_shape (2,2) = 1
00255 irreg2_shape (1,3) = 1
00256 irreg2_shape (2,3) = 1
00257
00258 call psmile_info_coords_irreg2_real ( &
00259 coords1, coords2, coords3, &
00260 irreg2_shape, irreg2_shape, &
00261 sin_search, cos_search, ierror)
00262 if (ierror > 0) return
00263
00264
00265
00266 select case ( Grids(grid_id)%grid_type )
00267
00268
00269
00270
00271
00272 case (PRISM_Reglonlatvrt)
00273
00274
00275
00276
00277
00278 call psmile_info_coords_3d_reg_real ( &
00279 coords_pointer%coords_real(1)%vector, &
00280 coords_pointer%coords_real(2)%vector, &
00281 coords_pointer%coords_real(3)%vector, &
00282 coords_pointer%coords_shape, &
00283 grid_info%grid_shape, &
00284 sinvec_reg, cosvec_reg, ierror)
00285 if (ierror > 0) return
00286
00287 call psmile_search_nn_3d_reg_real ( &
00288 sin_search%vector, cos_search%vector, coords3, &
00289 distance, &
00290 nfound, locations, n_send, &
00291 coords_pointer%coords_real(1)%vector, &
00292 coords_pointer%coords_real(2)%vector, &
00293 coords_pointer%coords_real(3)%vector, &
00294 coords_pointer%coords_shape, &
00295 sinvec_reg(lon)%vector, cosvec_reg(lon)%vector, &
00296 sinvec_reg(lat)%vector, cosvec_reg(lat)%vector, &
00297 grid_info%grid_shape, &
00298 mask_array, mask_shape, src_mask_available, &
00299 tol, ierror)
00300
00301 Deallocate (sinvec_reg(1)%vector, sinvec_reg(2)%vector)
00302 Deallocate (cosvec_reg(1)%vector, cosvec_reg(2)%vector)
00303
00304
00305
00306
00307
00308
00309 case (PRISM_Irrlonlat_regvrt)
00310
00311
00312
00313
00314
00315 call psmile_info_coords_irreg2_real ( &
00316 coords_pointer%coords_real(1)%vector, &
00317 coords_pointer%coords_real(2)%vector, &
00318 coords_pointer%coords_real(3)%vector, &
00319 coords_pointer%coords_shape, &
00320 grid_info%grid_shape, &
00321 sinvec, cosvec, ierror)
00322 if (ierror > 0) return
00323
00324 call psmile_search_nn_irreg2_real ( &
00325 sin_search%vector, cos_search%vector, coords3, &
00326 distance, &
00327 nfound, locations, n_send, &
00328 coords_pointer%coords_real(1)%vector, &
00329 coords_pointer%coords_real(2)%vector, &
00330 coords_pointer%coords_real(3)%vector, &
00331 coords_pointer%coords_shape, &
00332 sinvec%vector, cosvec%vector, &
00333 grid_info%grid_shape, &
00334 mask_array, mask_shape, src_mask_available, &
00335 tol, ierror)
00336
00337 Deallocate (sinvec%vector, cosvec%vector)
00338
00339
00340
00341
00342
00343 case (PRISM_Irrlonlatvrt)
00344
00345
00346
00347
00348
00349 call psmile_info_trf_coords_3d_real ( &
00350 coords_pointer%coords_real(1)%vector, &
00351 coords_pointer%coords_real(2)%vector, &
00352 coords_pointer%coords_real(3)%vector, &
00353 coords_pointer%coords_shape, &
00354 grid_info%grid_shape, &
00355 sinvec, cosvec, ierror)
00356 if (ierror > 0) return
00357
00358 call psmile_search_nn_3d_real ( &
00359 sin_search%vector, cos_search%vector, coords3, &
00360 distance, &
00361 nfound, locations, n_send, &
00362 coords_pointer%coords_real(1)%vector, &
00363 coords_pointer%coords_real(2)%vector, &
00364 coords_pointer%coords_real(3)%vector, &
00365 coords_pointer%coords_shape, &
00366 sinvec%vector, cosvec%vector, &
00367 grid_info%grid_shape, &
00368 mask_array, mask_shape, src_mask_available, &
00369 tol, ierror)
00370
00371 Deallocate (sinvec%vector, cosvec%vector)
00372
00373
00374
00375
00376
00377
00378 case (PRISM_Gaussreduced_regvrt)
00379
00380
00381
00382
00383
00384
00385
00386 call psmile_info_coords_irreg2_real ( &
00387 coords_pointer%coords_real(1)%vector, &
00388 coords_pointer%coords_real(2)%vector, &
00389 coords_pointer%coords_real(3)%vector, &
00390 coords_pointer%coords_shape, &
00391 grid_info%grid_shape, &
00392 sinvec, cosvec, ierror)
00393 if (ierror > 0) return
00394
00395
00396
00397
00398 call psmile_search_nn_irreg2_real ( &
00399 sin_search%vector, cos_search%vector, coords3, &
00400 distance, &
00401 nfound, locations, n_send, &
00402 coords_pointer%coords_real(1)%vector, &
00403 coords_pointer%coords_real(2)%vector, &
00404 coords_pointer%coords_real(3)%vector, &
00405 coords_pointer%coords_shape, &
00406 sinvec%vector, cosvec%vector, &
00407 grid_info%grid_shape, &
00408 mask_array, mask_shape, src_mask_available, &
00409 tol, ierror)
00410
00411 Deallocate (sinvec%vector, cosvec%vector)
00412
00413
00414
00415
00416
00417 case DEFAULT
00418
00419 ierrp (1) = Grids(grid_id)%grid_type
00420 ierror = PRISM_Error_Internal
00421
00422 call psmile_error ( ierror, 'unsupported grid generation type', &
00423 ierrp, 1, __FILE__, __LINE__ )
00424 end select
00425
00426
00427
00428 Deallocate (cos_search%vector, sin_search%vector)
00429
00430 #ifdef VERBOSE
00431 print 9980, trim(ch_id), grid_id, search%sender, ierror
00432
00433 call psmile_flushstd
00434 #endif /* VERBOSE */
00435
00436 return
00437
00438
00439
00440 #ifdef VERBOSE
00441 9990 format (1x, a, ': psmile_search_donor_nnx_real: comp_id =', i3, &
00442 '; sender =', i4)
00443 9980 format (1x, a, ': psmile_search_donor_nnx_real: grid id =', i3, &
00444 '; eof sender =', i3, ', ierror =', i4)
00445 #endif /* VERBOSE */
00446
00447 end subroutine PSMILe_Search_donor_nnx_real