00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_search_donor_nnx_dble (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_dble
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 Double Precision, Intent (In) :: coords1 (n_send)
00040 Double Precision, Intent (In) :: coords2 (n_send)
00041 Double Precision, Intent (In) :: coords3 (n_send)
00042
00043
00044
00045 Integer, Intent (In) :: nb_extra
00046
00047
00048
00049 Double Precision, Intent (In) :: tol
00050
00051
00052
00053
00054
00055
00056
00057 Type (Enddef_global_search), Intent (InOut) :: search
00058
00059
00060
00061 Double Precision, 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 (dble_vector) :: cosvec, sinvec
00109 Type (dble_vector) :: sinvec_reg (ndim_2d)
00110 Type (dble_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 (dble_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_dble.F90 3112 2011-04-07 15:03:18Z 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%reqest_type /= 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_DOUBLE_PRECISION) then
00207 call psmile_assert ( __FILE__, __LINE__, &
00208 'Incorrect datatype for this routine')
00209 endif
00210
00211 if (n_send /= search%msg_extra%num_volumes) then
00212 call psmile_assert ( __FILE__, __LINE__, &
00213 'Inconsistent number of points')
00214 endif
00215
00216 #endif
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 len_item = search%msg_extra%num_int_per_vol
00230 len_rtem = search%msg_extra%num_items_per_coord
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 irreg2_shape (1,1) = 1
00246 irreg2_shape (2,1) = n_send
00247 irreg2_shape (1,2) = 1
00248 irreg2_shape (2,2) = 1
00249 irreg2_shape (1,3) = 1
00250 irreg2_shape (2,3) = 1
00251
00252 call psmile_info_coords_irreg2_dble ( &
00253 coords1, coords2, coords3, &
00254 irreg2_shape, irreg2_shape, &
00255 sin_search, cos_search, ierror)
00256 if (ierror > 0) return
00257
00258
00259
00260 select case ( Grids(grid_id)%grid_type )
00261
00262
00263
00264
00265
00266 case (PRISM_Reglonlatvrt)
00267
00268
00269
00270
00271
00272 call psmile_info_coords_3d_reg_dble ( &
00273 coords_pointer%coords_dble(1)%vector, &
00274 coords_pointer%coords_dble(2)%vector, &
00275 coords_pointer%coords_dble(3)%vector, &
00276 coords_pointer%coords_shape, &
00277 grid_info%grid_shape, &
00278 sinvec_reg, cosvec_reg, ierror)
00279 if (ierror > 0) return
00280
00281 call psmile_search_nn_3d_reg_dble ( &
00282 sin_search%vector, cos_search%vector, coords3, &
00283 distance, &
00284 nfound, locations, n_send, &
00285 coords_pointer%coords_dble(1)%vector, &
00286 coords_pointer%coords_dble(2)%vector, &
00287 coords_pointer%coords_dble(3)%vector, &
00288 coords_pointer%coords_shape, &
00289 sinvec_reg(lon)%vector, cosvec_reg(lon)%vector, &
00290 sinvec_reg(lat)%vector, cosvec_reg(lat)%vector, &
00291 grid_info%grid_shape, &
00292 mask_array, mask_shape, src_mask_available, &
00293 tol, ierror)
00294
00295 Deallocate (sinvec_reg(1)%vector, sinvec_reg(2)%vector)
00296 Deallocate (cosvec_reg(1)%vector, cosvec_reg(2)%vector)
00297
00298
00299
00300
00301
00302
00303 case (PRISM_Irrlonlat_regvrt)
00304
00305
00306
00307
00308
00309 call psmile_info_coords_irreg2_dble ( &
00310 coords_pointer%coords_dble(1)%vector, &
00311 coords_pointer%coords_dble(2)%vector, &
00312 coords_pointer%coords_dble(3)%vector, &
00313 coords_pointer%coords_shape, &
00314 grid_info%grid_shape, &
00315 sinvec, cosvec, ierror)
00316 if (ierror > 0) return
00317
00318 call psmile_search_nn_irreg2_dble ( &
00319 sin_search%vector, cos_search%vector, coords3, &
00320 distance, &
00321 nfound, locations, n_send, &
00322 coords_pointer%coords_dble(1)%vector, &
00323 coords_pointer%coords_dble(2)%vector, &
00324 coords_pointer%coords_dble(3)%vector, &
00325 coords_pointer%coords_shape, &
00326 sinvec%vector, cosvec%vector, &
00327 grid_info%grid_shape, &
00328 mask_array, mask_shape, src_mask_available, &
00329 tol, ierror)
00330
00331 Deallocate (sinvec%vector, cosvec%vector)
00332
00333
00334
00335
00336
00337 case (PRISM_Irrlonlatvrt)
00338
00339
00340
00341
00342
00343 call psmile_info_trf_coords_3d_dble ( &
00344 coords_pointer%coords_dble(1)%vector, &
00345 coords_pointer%coords_dble(2)%vector, &
00346 coords_pointer%coords_dble(3)%vector, &
00347 coords_pointer%coords_shape, &
00348 grid_info%grid_shape, &
00349 sinvec, cosvec, ierror)
00350 if (ierror > 0) return
00351
00352 call psmile_search_nn_3d_dble ( &
00353 sin_search%vector, cos_search%vector, coords3, &
00354 distance, &
00355 nfound, locations, n_send, &
00356 coords_pointer%coords_dble(1)%vector, &
00357 coords_pointer%coords_dble(2)%vector, &
00358 coords_pointer%coords_dble(3)%vector, &
00359 coords_pointer%coords_shape, &
00360 sinvec%vector, cosvec%vector, &
00361 grid_info%grid_shape, &
00362 mask_array, mask_shape, src_mask_available, &
00363 tol, ierror)
00364
00365 Deallocate (sinvec%vector, cosvec%vector)
00366
00367
00368
00369
00370
00371
00372 case (PRISM_Gaussreduced_regvrt)
00373
00374
00375
00376
00377
00378
00379
00380 call psmile_info_coords_irreg2_dble ( &
00381 coords_pointer%coords_dble(1)%vector, &
00382 coords_pointer%coords_dble(2)%vector, &
00383 coords_pointer%coords_dble(3)%vector, &
00384 coords_pointer%coords_shape, &
00385 grid_info%grid_shape, &
00386 sinvec, cosvec, ierror)
00387 if (ierror > 0) return
00388
00389
00390
00391
00392 call psmile_search_nn_irreg2_dble ( &
00393 sin_search%vector, cos_search%vector, coords3, &
00394 distance, &
00395 nfound, locations, n_send, &
00396 coords_pointer%coords_dble(1)%vector, &
00397 coords_pointer%coords_dble(2)%vector, &
00398 coords_pointer%coords_dble(3)%vector, &
00399 coords_pointer%coords_shape, &
00400 sinvec%vector, cosvec%vector, &
00401 grid_info%grid_shape, &
00402 mask_array, mask_shape, src_mask_available, &
00403 tol, ierror)
00404
00405 Deallocate (sinvec%vector, cosvec%vector)
00406
00407
00408
00409
00410
00411 case DEFAULT
00412
00413 ierrp (1) = Grids(grid_id)%grid_type
00414 ierror = PRISM_Error_Internal
00415
00416 call psmile_error ( ierror, 'unsupported grid generation type', &
00417 ierrp, 1, __FILE__, __LINE__ )
00418 end select
00419
00420
00421
00422 Deallocate (cos_search%vector, sin_search%vector)
00423
00424 #ifdef VERBOSE
00425 print 9980, trim(ch_id), grid_id, search%sender, ierror
00426
00427 call psmile_flushstd
00428 #endif /* VERBOSE */
00429
00430 return
00431
00432
00433
00434 #ifdef VERBOSE
00435 9990 format (1x, a, ': psmile_search_donor_nnx_dble: comp_id =', i3, &
00436 '; sender =', i4)
00437 9980 format (1x, a, ': psmile_search_donor_nnx_dble: grid id =', i3, &
00438 '; eof sender =', i3, ', ierror =', i4)
00439 #endif /* VERBOSE */
00440
00441 end subroutine PSMILe_Search_donor_nnx_dble