00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 subroutine psmile_locations_3d_mask (search, inter, shift, method_id, &
00012 dir_index, ierror)
00013
00014
00015
00016 use PRISM_constants
00017
00018 use PSMILe, dummy_interface => PSMILe_Locations_3d_mask
00019
00020 implicit none
00021
00022
00023
00024 Type (Enddef_search), Intent (InOut) :: search
00025
00026
00027
00028 Integer, Intent (In) :: inter (2, ndim_3d, search%search_data%npart)
00029
00030
00031
00032 Integer, Intent (In) :: shift (ndim_3d)
00033
00034
00035
00036
00037
00038 Integer, Intent (In) :: method_id
00039
00040
00041
00042
00043
00044 Integer, Intent (Out) :: dir_index
00045
00046
00047
00048
00049
00050 Integer, Intent (Out) :: ierror
00051
00052
00053
00054
00055
00056
00057
00058 Integer, Parameter :: send_direct_index = 2
00059
00060
00061
00062
00063
00064 Type (Method), Pointer :: mp
00065
00066
00067
00068 Integer :: n, nadd, ndir, nprev
00069 Integer :: index
00070
00071
00072
00073 Integer :: ipart
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 Character(len=len_cvs_string), save :: mycvs =
00104 '$Id: psmile_locations_3d_mask.F90 3248 2011-06-23 13:03:19Z coquart $'
00105
00106
00107
00108
00109
00110 #ifdef VERBOSE
00111 print 9990, trim(ch_id), method_id, search%msg_intersections%field_info%tgt_method_id, &
00112 search%sender
00113
00114 call psmile_flushstd
00115 #endif /* VERBOSE */
00116
00117 ierror = 0
00118
00119 dir_index = PRISM_undefined
00120
00121 mp => Methods(method_id)
00122
00123 #ifdef PRISM_ASSERTION
00124 if ( mp%status == PSMILe_Status_free .or. &
00125 mp%status == PSMILe_Status_undefined ) then
00126 call psmile_assert (__FILE__, __LINE__, "Incorrect method")
00127 endif
00128
00129 do ipart = 1, search%search_data%npart
00130 if (inter (1,1,ipart) < search%search_data%range (1,1,ipart) .or. &
00131 search%search_data%range (2,1,ipart) < inter (2,1,ipart) .or. &
00132 inter (1,2,ipart) < search%search_data%range (1,2,ipart) .or. &
00133 search%search_data%range (2,2,ipart) < inter (2,2,ipart) .or. &
00134 inter (1,3,ipart) < search%search_data%range (1,3,ipart) .or. &
00135 search%search_data%range (2,3,ipart) < inter (2,3,ipart)) then
00136 print *, ipart, inter (:,:,ipart), search%search_data%range (:,:,ipart)
00137 call psmile_assert (__FILE__, __LINE__, "inter is out of range")
00138 endif
00139 end do
00140 #endif
00141
00142
00143
00144
00145
00146
00147 ndir = 0
00148
00149 do ipart = 1, search%search_data%npart
00150 if (maxval(search%search_data%shape(:,:,ipart)-inter(:,:,ipart)) == 0) then
00151
00152
00153
00154 ndir = ndir + count (search%search_mask(ipart)%vector(:))
00155 else
00156
00157
00158
00159 call psmile_get_true_mask_entries ( &
00160 search%search_mask(ipart)%vector, &
00161 search%search_data%shape (:, :, ipart), &
00162 inter (:, :, ipart), n, ierror)
00163 if (ierror > 0) return
00164
00165 ndir = ndir + n
00166 endif
00167
00168 end do
00169
00170
00171
00172
00173
00174
00175
00176 if (ndir > 0) then
00177
00178 call psmile_get_info_index (method_id, send_direct_index, index, ierror)
00179 if (ierror > 0) return
00180
00181 dir_index = index
00182
00183 mp%send_infos_direct(index)%dest = search%sender
00184 mp%send_infos_direct(index)%nvec = 1
00185 mp%send_infos_direct(index)%nparts = 1
00186
00187 mp%send_infos_direct(index)%nrecv = 0
00188 mp%send_infos_direct(index)%num2recv = 0
00189
00190 mp%send_infos_direct(index)%remote_method_id = &
00191 search%msg_intersections%field_info%tgt_method_id
00192
00193
00194
00195
00196
00197 call psmile_locations_alloc (mp%send_infos_direct(index), ierror)
00198 if (ierror > 0) return
00199
00200 nprev = 0
00201
00202 do ipart = 1, search%search_data%npart
00203 call psmile_store_dest_locs_3d_msk ( &
00204 search%search_mask(ipart)%vector, &
00205 search%search_data%shape (:, :, ipart), &
00206 inter (:, :, ipart), &
00207 mp%send_infos_direct(index), ndir, &
00208 nprev, nadd, ierror)
00209 if (ierror > 0) return
00210
00211 call psmile_store_source_locs_3d_msk ( &
00212 search%search_mask(ipart)%vector, &
00213 search%search_data%shape (:, :, ipart), &
00214 inter (:, :, ipart), &
00215 mp%send_infos_direct(index), ndir, &
00216 nprev, nadd, ierror)
00217 if (ierror > 0) return
00218
00219 nprev = nprev + nadd
00220 end do
00221
00222 mp%send_infos_direct(index)%nloc = nprev
00223
00224
00225
00226 do n = 1, ndim_3d
00227 mp%send_infos_direct(index)%dstijk (n, 1:nprev) = &
00228 mp%send_infos_direct(index)%dstijk (n, 1:nprev) - shift (n)
00229 end do
00230
00231 endif
00232
00233
00234
00235 #ifdef VERBOSE
00236 print 9980, trim(ch_id), ierror, dir_index
00237
00238 call psmile_flushstd
00239 #endif /* VERBOSE */
00240
00241
00242
00243
00244 #ifdef VERBOSE
00245
00246 9990 format (1x, a, ': psmile_locations_3d_mask: method_id', i3, &
00247 ' to ', i3, '(', i2, ')')
00248 9980 format (1x, a, ': psmile_locations_3d_mask: eof ierror =', i3, &
00249 '; dir_index', i7)
00250
00251 #endif /* VERBOSE */
00252
00253 end subroutine PSMILe_Locations_3d_mask