00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_search_donor_extra (search, tol, ierror)
00012
00013
00014
00015 use PRISM
00016
00017 use PSMILe, dummy_interface => PSMILe_Search_donor_extra
00018
00019 implicit none
00020
00021
00022
00023
00024
00025
00026
00027 Double Precision, Intent (In) :: tol
00028
00029
00030
00031
00032
00033
00034
00035 Type (Enddef_global_search), Intent (InOut) :: search
00036
00037
00038
00039
00040
00041 Integer, Intent (Out) :: ierror
00042
00043
00044
00045
00046
00047
00048
00049 Real :: rtol
00050 #if defined ( PRISM_QUAD_TYPE )
00051 Real (kind=PRISM_QUAD_TYPE) :: qtol
00052 #endif
00053
00054
00055
00056
00057
00058
00059 Integer :: comp_id, grid_id
00060 Integer :: icomp
00061
00062
00063
00064 Integer :: j
00065 Integer :: var_id
00066 Integer :: transi_id
00067 Type (Taskout_type), Pointer :: Taskout(:)
00068
00069
00070
00071 Integer :: method_id
00072
00073
00074
00075 Integer, parameter :: nerrp = 3
00076 Integer :: ierrp (nerrp)
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 Character(len=len_cvs_string), save :: mycvs =
00099 '$Id: psmile_search_donor_extra.F90 3112 2011-04-07 15:03:18Z hanke $'
00100
00101
00102
00103
00104
00105 #ifdef VERBOSE
00106 print 9990, trim(ch_id), search%msg_extra%global_comp_id, search%sender
00107
00108 call psmile_flushstd
00109 #endif /* VERBOSE */
00110
00111 rtol = tol
00112
00113 #if defined ( PRISM_QUAD_TYPE )
00114 qtol = tol
00115 #endif
00116
00117
00118
00119 do icomp = 1, n_act_comp
00120 if (comp_infos(icomp)%global_comp_id == search%msg_extra%global_comp_id) exit
00121 enddo
00122
00123 if (icomp > n_act_comp) then
00124 ierror = PRISM_Error_internal
00125 ierrp (1) = search%msg_extra%global_comp_id
00126 ierrp (2) = n_act_comp
00127
00128 call psmile_error ( ierror, &
00129 'Cannot found global comp_id in active components', &
00130 ierrp, 2, __FILE__, __LINE__ )
00131 return
00132 endif
00133
00134 comp_id = comp_infos(icomp)%comp_id
00135
00136 #ifdef PRISM_ASSERTION
00137
00138
00139
00140 if (comp_id < 1 .or. &
00141 comp_id > Number_of_Comps_allocated .or. &
00142 Comps(comp_id)%status /= PSMILe_status_defined) then
00143
00144 print *, trim(ch_id), ": comp id =", &
00145 comp_id, Number_of_Comps_allocated, &
00146 Comps(comp_id)%status
00147 call psmile_assert ( __FILE__, __LINE__, &
00148 'invalid comp id')
00149 endif
00150 #endif
00151
00152
00153
00154
00155
00156
00157
00158
00159 transi_id = search%msg_extra%transi_out_id
00160 grid_id = search%msg_extra%local_grid_id
00161
00162 getv: do var_id = 1, Number_of_Fields_allocated
00163 if (Associated (Fields(var_id)%Taskout)) then
00164
00165 if ( Methods(Fields(var_id)%method_id)%grid_id /= grid_id ) cycle
00166 Taskout => Fields(var_id)%Taskout
00167
00168 #ifdef DEBUGX
00169 do j = 1, size (Taskout)
00170 print 9960, j, &
00171 Taskout(j)%origin_type, &
00172 Taskout(j)%remote_transi_id, &
00173 Taskout(j)%global_transi_id, &
00174 Taskout(j)%remote_comp_id
00175 enddo
00176 #endif
00177
00178 do j = 1, size (Taskout)
00179 if ( Taskout(j)%global_transi_id == transi_id ) exit getv
00180 enddo
00181 endif
00182 enddo getv
00183
00184 if (var_id > Number_of_Fields_allocated) then
00185
00186
00187 print *, 'comp_id, global var_id OUT', comp_id, transi_id
00188
00189 #ifdef DEBUG
00190 do var_id = 1, Number_of_Fields_allocated
00191 if (Associated (Fields(var_id)%Taskout)) then
00192 Taskout => Fields(var_id)%Taskout
00193
00194 do j = 1, size (Taskout)
00195 print 9960, j, &
00196 Taskout(j)%origin_type, &
00197 Taskout(j)%remote_transi_id, &
00198 Taskout(j)%global_transi_id, &
00199 Taskout(j)%remote_comp_id
00200 end do
00201 endif
00202 enddo
00203 #endif
00204 ierror = PRISM_Error_Internal
00205 ierrp (1) = comp_id
00206 ierrp (2) = transi_id
00207
00208 call psmile_error ( ierror, "Cannot find field on this process", &
00209 ierrp, 2, __FILE__, __LINE__ )
00210 return
00211
00212 endif
00213
00214 if (Fields(var_id)%comp_id /= comp_id) then
00215 print *, 'comp_id, var_id', &
00216 comp_id, var_id, transi_id, Fields(var_id)%comp_id
00217 ierror = PRISM_Error_Internal
00218 ierrp (1) = comp_id
00219 ierrp (2) = transi_id
00220 ierrp (3) = Fields(var_id)%comp_id
00221 call psmile_error ( ierror, "Inconsitent components for field", &
00222 ierrp, 2, __FILE__, __LINE__ )
00223 return
00224 endif
00225
00226 method_id = Fields(var_id)%method_id
00227
00228 #ifdef PRISM_ASSERTION
00229
00230
00231
00232 if (Grids(grid_id)%grid_type == PRISM_Gridless) then
00233 print *, trim(ch_id), ": comp id, grid_id", &
00234 comp_id, grid_id
00235 call psmile_assert ( __FILE__, __LINE__, &
00236 'Extra search not for Gridless Grids')
00237 endif
00238 #endif
00239
00240
00241
00242
00243
00244 if (search%msg_extra%partition_avail .and. &
00245 Associated (Grids(grid_id)%partition)) then
00246
00247 call psmile_search_donor_extra_off (comp_infos(icomp), &
00248 search, var_id, tol, ierror)
00249 #ifdef VERBOSE
00250 print 9980, trim(ch_id), grid_id, search%sender, ierror
00251 call psmile_flushstd
00252 #endif /* VERBOSE */
00253 return
00254 endif
00255
00256
00257
00258
00259
00260 if (search%msg_extra%reqest_type == PSMILe_nnghbr3D) then
00261
00262 call psmile_search_donor_extra_nn (comp_infos(icomp), &
00263 search, var_id, tol, ierror)
00264 #ifdef VERBOSE
00265 print 9980, trim(ch_id), grid_id, search%sender, ierror
00266 call psmile_flushstd
00267 #endif /* VERBOSE */
00268 return
00269 endif
00270
00271
00272
00273
00274
00275 ierror = PRISM_Error_Internal
00276 call psmile_error ( ierror, 'Global search currently support only if partition info is available', &
00277 ierrp, 0, __FILE__, __LINE__ )
00278
00279
00280
00281 #ifdef VERBOSE
00282 print 9980, trim(ch_id), grid_id, search%sender, ierror
00283 call psmile_flushstd
00284 #endif /* VERBOSE */
00285
00286
00287
00288 9990 format (1x, a, ': psmile_search_donor_extra: global comp_id =', i3, &
00289 '; sender =', i4)
00290 9980 format (1x, a, ': psmile_search_donor_extra: eof grid id =', i3, &
00291 '; sender =', i3, ', ierror =', i4)
00292
00293 #ifdef DEBUG
00294 9960 format (1x, 'Taskout%In_channel(', i3, '): origin_type', i5, &
00295 ', remote_transi_id', i4, &
00296 ', global_transi_id', i4, ', remote_comp_id', i4)
00297 #endif
00298
00299 end subroutine PSMILe_Search_donor_extra