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 2993 2011-02-25 10:34:50Z hanke $'
00100
00101
00102
00103
00104
00105 #ifdef VERBOSE
00106 print 9990, trim(ch_id), search%msg_extra(5), 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(5)) exit
00121 enddo
00122
00123 if (icomp > n_act_comp) then
00124 ierror = PRISM_Error_internal
00125 ierrp (1) = search%msg_extra(5)
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
00160 transi_id = search%msg_extra (6)
00161 grid_id = search%msg_extra (17)
00162
00163 getv: do var_id = 1, Number_of_Fields_allocated
00164 if (Associated (Fields(var_id)%Taskout)) then
00165
00166 if ( Methods(Fields(var_id)%method_id)%grid_id /= grid_id ) cycle
00167 Taskout => Fields(var_id)%Taskout
00168
00169 #ifdef DEBUGX
00170 do j = 1, size (Taskout)
00171 print 9960, j, &
00172 Taskout(j)%origin_type, &
00173 Taskout(j)%remote_transi_id, &
00174 Taskout(j)%global_transi_id, &
00175 Taskout(j)%remote_comp_id
00176 enddo
00177 #endif
00178
00179 do j = 1, size (Taskout)
00180 if ( Taskout(j)%global_transi_id == transi_id ) exit getv
00181 enddo
00182 endif
00183 enddo getv
00184
00185 if (var_id > Number_of_Fields_allocated) then
00186
00187
00188 print *, 'comp_id, global var_id OUT', comp_id, transi_id
00189
00190 #ifdef DEBUG
00191 do var_id = 1, Number_of_Fields_allocated
00192 if (Associated (Fields(var_id)%Taskout)) then
00193 Taskout => Fields(var_id)%Taskout
00194
00195 do j = 1, size (Taskout)
00196 print 9960, j, &
00197 Taskout(j)%origin_type, &
00198 Taskout(j)%remote_transi_id, &
00199 Taskout(j)%global_transi_id, &
00200 Taskout(j)%remote_comp_id
00201 end do
00202 endif
00203 enddo
00204 #endif
00205 ierror = PRISM_Error_Internal
00206 ierrp (1) = comp_id
00207 ierrp (2) = transi_id
00208
00209 call psmile_error ( ierror, "Cannot find field on this process", &
00210 ierrp, 2, __FILE__, __LINE__ )
00211 return
00212
00213 endif
00214
00215 if (Fields(var_id)%comp_id /= comp_id) then
00216 print *, 'comp_id, var_id', &
00217 comp_id, var_id, transi_id, Fields(var_id)%comp_id
00218 ierror = PRISM_Error_Internal
00219 ierrp (1) = comp_id
00220 ierrp (2) = transi_id
00221 ierrp (3) = Fields(var_id)%comp_id
00222 call psmile_error ( ierror, "Inconsitent components for field", &
00223 ierrp, 2, __FILE__, __LINE__ )
00224 return
00225 endif
00226
00227 method_id = Fields(var_id)%method_id
00228
00229 #ifdef PRISM_ASSERTION
00230
00231
00232
00233 if (Grids(grid_id)%grid_type == PRISM_Gridless) then
00234 print *, trim(ch_id), ": comp id, grid_id", &
00235 comp_id, grid_id
00236 call psmile_assert ( __FILE__, __LINE__, &
00237 'Extra search not for Gridless Grids')
00238 endif
00239 #endif
00240
00241
00242
00243
00244
00245 if (search%msg_extra (11) == 1 .and. &
00246 Associated (Grids(grid_id)%partition)) then
00247
00248 call psmile_search_donor_extra_off (comp_infos(icomp), &
00249 search, var_id, tol, ierror)
00250 #ifdef VERBOSE
00251 print 9980, trim(ch_id), grid_id, search%sender, ierror
00252 call psmile_flushstd
00253 #endif /* VERBOSE */
00254 return
00255 endif
00256
00257
00258
00259
00260
00261 if (search%msg_extra(1) == PSMILe_nnghbr3D) then
00262
00263 call psmile_search_donor_extra_nn (comp_infos(icomp), &
00264 search, var_id, tol, ierror)
00265 #ifdef VERBOSE
00266 print 9980, trim(ch_id), grid_id, search%sender, ierror
00267 call psmile_flushstd
00268 #endif /* VERBOSE */
00269 return
00270 endif
00271
00272
00273
00274
00275
00276 ierror = PRISM_Error_Internal
00277 call psmile_error ( ierror, 'Global search currently support only if partition info is available', &
00278 ierrp, 0, __FILE__, __LINE__ )
00279
00280
00281
00282 #ifdef VERBOSE
00283 print 9980, trim(ch_id), grid_id, search%sender, ierror
00284 call psmile_flushstd
00285 #endif /* VERBOSE */
00286
00287
00288
00289 9990 format (1x, a, ': psmile_search_donor_extra: global comp_id =', i3, &
00290 '; sender =', i4)
00291 9980 format (1x, a, ': psmile_search_donor_extra: eof grid id =', i3, &
00292 '; sender =', i3, ', ierror =', i4)
00293
00294 #ifdef DEBUG
00295 9960 format (1x, 'Taskout%In_channel(', i3, '): origin_type', i5, &
00296 ', remote_transi_id', i4, &
00297 ', global_transi_id', i4, ', remote_comp_id', i4)
00298 #endif
00299
00300 end subroutine PSMILe_Search_donor_extra