00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 subroutine psmile_get_faces_gauss2_dble (search, extra_search, &
00013 corners1, corners2, corners3, &
00014 corner_shape, nbr_corners, grid_valid_shape, &
00015 neighbors_3d, nloc, num_neigh, &
00016 faces, nreq, ierror)
00017
00018
00019
00020 use PRISM
00021
00022 use PSMILe, dummy_interface => PSMILe_Get_faces_gauss2_dble
00023 #ifdef DEBUG_TRACE
00024 use psmile_debug_trace
00025 #endif
00026
00027 Implicit none
00028
00029
00030
00031 Type (Enddef_search), Intent (In) :: search
00032
00033
00034
00035 Type (Extra_search_info), Intent (In) :: extra_search
00036
00037
00038
00039
00040 Integer, Intent (In) :: corner_shape (2, ndim_3d)
00041
00042
00043
00044 Integer, Intent (In) :: nbr_corners
00045
00046
00047
00048
00049 Integer, Intent (In) :: grid_valid_shape (2, ndim_3d)
00050
00051
00052
00053 Double Precision, Intent (In) ::
00054 corners1 ( corner_shape(1,1):corner_shape(2,1), 2)
00055
00056
00057 Double Precision, Intent (In) ::
00058 corners2 ( corner_shape(1,1):corner_shape(2,1), 2)
00059
00060
00061 Double Precision, Intent (In) ::
00062 corners3 ( corner_shape(1,3):corner_shape(2,3), 2)
00063
00064
00065
00066
00067
00068
00069 Integer, Intent (In) :: nloc
00070
00071
00072
00073
00074
00075
00076 Integer, Intent (In) :: num_neigh
00077
00078
00079
00080
00081 Integer, Intent (In) :: neighbors_3d (ndim_3d, nloc,
00082 num_neigh)
00083
00084
00085
00086 Integer, Intent (In) :: nreq
00087
00088
00089
00090
00091
00092
00093 Double Precision, Intent (Out) :: faces (2, ndim_3d, nreq)
00094
00095
00096
00097 Integer, Intent (Out) :: ierror
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 Integer :: i, j, k, n
00108
00109
00110
00111 Integer :: ipart, nprev
00112
00113 Integer, Pointer :: indices_req (:)
00114 Integer, Pointer :: required (:)
00115 Integer, Pointer :: len_req (:)
00116
00117
00118
00119 Integer :: code
00120
00121 Double Precision :: box (2, ndim_3d)
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 Character(len=len_cvs_string), save :: mycvs =
00150 '$Id: psmile_get_faces_gauss2_dble.F90 2988 2011-02-24 14:36:19Z hanke $'
00151
00152
00153
00154
00155
00156 #ifdef VERBOSE
00157 print 9990, trim(ch_id)
00158
00159
00160
00161 call psmile_flushstd
00162 #endif /* VERBOSE */
00163
00164 #ifdef PRISM_ASSERTION
00165 if (grid_valid_shape (1,2) /= 1 .or. &
00166 grid_valid_shape (2,2) /= 1) then
00167 call psmile_assert (__FILE__, __LINE__, &
00168 "Internal definition of GaussReduced grid not correct")
00169 endif
00170
00171 if (grid_valid_shape (1,1) /= corner_shape(1,1) .or. &
00172 grid_valid_shape (2,1) /= corner_shape(2,1) .or. &
00173 grid_valid_shape (1,2) /= corner_shape(1,2) .or. &
00174 grid_valid_shape (2,2) /= corner_shape(2,2)) then
00175
00176 print *, 'corner_shape ', corner_shape
00177 print *, 'grid_valid_shape', grid_valid_shape
00178
00179 call psmile_assert (__FILE__, __LINE__, &
00180 "corner_shape /= grid_valid_shape; don't know to address")
00181 endif
00182 #endif
00183
00184 ierror = 0
00185
00186 len_req => extra_search%len_req
00187
00188
00189
00190
00191 faces (1, 1, :) = 1.0
00192 faces (2, 1, :) = 0.0
00193
00194
00195
00196
00197
00198
00199
00200 nprev = 0
00201 do ipart = 1, search%npart
00202
00203 if (len_req (ipart) > 0) then
00204 indices_req => extra_search%indices_req(ipart)%vector
00205 required => extra_search%required(ipart)%vector
00206
00207 code = 1
00208
00209 do j = 1, len_req(ipart)
00210
00211 i = indices_req (j)
00212
00213 do n = 1, num_neigh
00214 #ifdef DEBUG_TRACE
00215 if ( indices_req (j) == ictl ) then
00216 print *, ' j, i, required ', j, indices_req(j), required(j)
00217 print *, ' neighs ', neighbors_3d (1,i,n)
00218 print *, ' required -code ', required (j), code, IAND (required (j), code)
00219 print *, ' grid_valid_shape (2,1) ', grid_valid_shape (2,1)
00220 code = code * 2
00221 endif
00222 #endif
00223 if ( neighbors_3d (1,i,n) >= 1 .and. &
00224 neighbors_3d (1,i,n) <= grid_valid_shape (2,1) ) then
00225
00226 #ifdef PRISM_ASSERTION
00227 if (neighbors_3d (1,i,n) < 1 .or. &
00228 neighbors_3d (1,i,n) > grid_valid_shape(2,1)) then
00229 print *, "neighbors_3d (1,i,n)", neighbors_3d (1,i,n)
00230 call psmile_assert (__FILE__, __LINE__, &
00231 "Index out of range")
00232 endif
00233 #endif
00234 if (neighbors_3d (3,i,n) < grid_valid_shape(1,3)) then
00235 k = grid_valid_shape (1,3)
00236 else
00237 k = min (grid_valid_shape(2,3), neighbors_3d (3,i,n))
00238 endif
00239
00240
00241
00242 box (1, 1) = minval(corners1 (neighbors_3d (1,i,n), :))
00243 box (2, 1) = maxval(corners1 (neighbors_3d (1,i,n), :))
00244
00245 box (1, 2) = minval(corners2 (neighbors_3d (1,i,n), :))
00246 box (2, 2) = maxval(corners2 (neighbors_3d (1,i,n), :))
00247
00248 box (1, 3) = minval(corners3 (k, :))
00249 box (2, 3) = maxval(corners3 (k, :))
00250
00251 if (faces (1, 1, nprev+j) > faces (2, 1, nprev+j)) then
00252
00253
00254
00255 faces (:, :, nprev+j) = box (:, :)
00256 #ifdef DEBUG_TRACE
00257 if ( indices_req (j) == ictl ) then
00258 print *, ' face first entry '
00259 print *, faces (:, :, nprev+j)
00260 endif
00261 #endif
00262 else
00263
00264 faces (1, 1, nprev+j) = min (faces (1,1,nprev+j), box (1,1))
00265 faces (2, 1, nprev+j) = max (faces (2,1,nprev+j), box (2,1))
00266 faces (1, 2, nprev+j) = min (faces (1,2,nprev+j), box (1,2))
00267 faces (2, 2, nprev+j) = max (faces (2,2,nprev+j), box (2,2))
00268 faces (1, 3, nprev+j) = min (faces (1,3,nprev+j), box (1,3))
00269 faces (2, 3, nprev+j) = max (faces (2,3,nprev+j), box (2,3))
00270 #ifdef DEBUG_TRACE
00271 if ( indices_req (j) == ictl ) then
00272 print *, ' face following entries ', n
00273 print *, faces (:, :, nprev+j)
00274 endif
00275 #endif
00276 endif
00277
00278 endif
00279
00280 end do
00281
00282 end do
00283
00284 endif
00285
00286 nprev = nprev + len_req (ipart)
00287
00288 end do
00289
00290 #ifdef PRISM_ASSERTION
00291 do j = 1, nreq
00292 if (faces (1,1,j) > faces (2,1,j)) exit
00293 end do
00294
00295 if (j < nreq) then
00296 nprev = 0
00297 do ipart = 1, search%npart
00298 if (nprev + len_req(ipart) >= j) exit
00299 nprev = nprev + len_req(ipart)
00300 end do
00301
00302 indices_req => extra_search%indices_req(ipart)%vector
00303 i = indices_req (j)
00304 print *, 'i, j, nreq', i, j, nreq, grid_valid_shape
00305 do n = 1, num_neigh
00306 print *, 'i, n, ng', i, n, &
00307 neighbors_3d (1,j,n), &
00308 neighbors_3d (2,j,n), &
00309 neighbors_3d (3,j,n)
00310 end do
00311 print *, ' x faces ', faces (:,1,j)
00312 print *, ' y faces ', faces (:,2,j)
00313 call psmile_assert (__FILE__, __LINE__, &
00314 "neighbour info is not consistent")
00315 endif
00316 #endif
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 #ifdef VERBOSE
00330 print 9980, trim(ch_id), ierror
00331
00332 call psmile_flushstd
00333 #endif /* VERBOSE */
00334
00335
00336
00337
00338 #ifdef VERBOSE
00339
00340 9990 format (1x, a, ': psmile_get_faces_gauss2_dble:')
00341 9980 format (1x, a, ': psmile_get_faces_gauss2_dble: eof ierror =', i3)
00342
00343 #endif /* VERBOSE */
00344
00345 #ifdef DEBUG
00346 #endif
00347
00348 end subroutine PSMILe_Get_faces_gauss2_dble