psmile_store_faces_irreg2_real.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00003 ! All rights reserved. Use is subject to OASIS4 license terms.
00004 !-----------------------------------------------------------------------
00005 !BOP
00006 !
00007 ! !ROUTINE: PSMILe_Store_faces_irreg2_real
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_store_faces_irreg2_real (indices_req,      &
00012                       required, nreq,                              &
00013                       tgt_coords1, tgt_coords2, tgt_coords3, ncpl, &
00014                       corners1, corners2, corners3,                &
00015                       corner_shape, nbr_corners, grid_valid_shape, &
00016                       send_mask, srcloc_ind,                       &
00017                       ibuf, len_item, ndibuf, ipia,                &
00018                       buf,  len_rtem, ndrbuf, ipa, ierror)
00019 !
00020 ! !USES:
00021 !
00022       use PRISM
00023 !
00024       use PSMILe, dummy_interface => PSMILe_Store_faces_irreg2_real
00025 
00026       Implicit none
00027 !
00028 ! !INPUT PARAMETERS:
00029 
00030       Integer,           Intent (In)  :: nreq
00031 !
00032 !     Total number of extra points to be searched for the current partition.
00033 !     Dimension of "indices_req" and "send_mask"
00034 !
00035       Integer,            Intent (In) :: indices_req (nreq)
00036 !
00037 !     Indices of the extra points in entire list of all points to be
00038 !     searched (i.e. for all parts "ipart")
00039 !
00040       Integer,            Intent (In) :: required    (nreq)
00041 !
00042 !     Code for the extra points which are additionally required.
00043 !
00044       Integer,           Intent (In)  :: corner_shape (2, ndim_3d)
00045       
00046 !     Specifies the dimension of arrays "corners1", "corners2" and "corners3"
00047 
00048       Integer,           Intent (In)  :: nbr_corners
00049 
00050 !     Number of corners in control volume 
00051 !     Must be 8 for a grid of type "PRISM_Reglonlatvrt".
00052 
00053       Integer,           Intent (In)  :: grid_valid_shape (2, ndim_3d)
00054       
00055 !     Specifies the valid block shape for the "ndim_3d"-dimensional block
00056 
00057       Integer,           Intent (In)  :: ncpl
00058 
00059 !     Total number of points to be transferred 
00060 !     = Dimensions of tgt_coords1, tgt_coords2, tgt_coords3
00061 
00062       Real,             Intent (In)  :: tgt_coords1 (ncpl)
00063       Real,             Intent (In)  :: tgt_coords2 (ncpl)
00064       Real,             Intent (In)  :: tgt_coords3 (ncpl)
00065 
00066 !     Coordinates of the points to be searched
00067 
00068       Real,             Intent (In)  ::                
00069          corners1 (corner_shape(1,1):corner_shape(2,1), 
00070                    corner_shape(1,2):corner_shape(2,2), nbr_corners/2)
00071 
00072       Real,             Intent (In)  ::                
00073          corners2 (corner_shape(1,1):corner_shape(2,1), 
00074                    corner_shape(1,2):corner_shape(2,2), nbr_corners/2)
00075 
00076       Real,             Intent (In)  ::                
00077          corners3 (corner_shape(1,3):corner_shape(2,3), 2)
00078 !
00079 !     Coordinates of corners of cell/control volume
00080 !
00081       Logical,           Intent (In)  :: send_mask (nreq)
00082 !
00083 !     Mask for the points (of "indices_req") to be sent.
00084 !
00085       Integer,           Intent (In)  :: ndibuf
00086 !
00087 !     Dimension of integer buffer "ibuf"
00088 !
00089       Integer,           Intent (In)  :: srcloc_ind (ndim_3d, ndibuf)
00090 !
00091 !     Indices of points in "corners" to be sent.
00092 !
00093       Integer,           Intent (In)  :: len_item
00094 !
00095 !     Length per data item in integer buffer "ibuf"
00096 !        1:3: (i,j,k) index of lower left corner
00097 !        4  : index in
00098 !        5  : code for points required
00099 !
00100       Integer,           Intent (In)  :: ndrbuf
00101 !
00102 !     Dimension of Real buffer "buf"
00103 !
00104       Integer,           Intent (In)  :: len_rtem
00105 !
00106 !     Length per data item in Real buffer "buf"
00107 !        1:3: Coordinates of the point to be searched
00108 !        :  : Coordinates of corners of control volume/cell
00109 !             (ndim_3d * nc_reg values)
00110 !
00111 ! !OUTPUT PARAMETERS:
00112 !
00113       Real,             Intent (InOut) :: buf (len_rtem, ndrbuf)
00114 !
00115 !     Buffer returning the packed Real data.
00116 !
00117       Integer,           Intent (InOut) :: ipa
00118 !
00119 !     Number of data items stored in "buf";
00120 !     i.e. buf(1:ipa) contains buffered data.
00121 !
00122       Integer,           Intent (InOut) :: ibuf (len_item, ndibuf)
00123 !
00124 !     Integer buffer returning the packed integer data.
00125 !
00126       Integer,           Intent (InOut) :: ipia
00127 !
00128 !     Number of data items stored in "ibuf";
00129 !     i.e. ibuf(:, 1:ipia) contains buffered data.
00130 !
00131       Integer,           Intent (Out)   :: ierror
00132 
00133 !     Returns the error code of PSMILe_Store_faces_irreg2_real;
00134 !             ierror = 0 : No error
00135 !             ierror > 0 : Severe error
00136 !
00137 ! !LOCAL PARAMETERS
00138 !
00139 !  NC_REG = Number of corners for regular directions
00140 !
00141       Integer, Parameter              :: nc_reg = 2
00142 !
00143 ! !LOCAL VARIABLES
00144 !
00145 !     ... loop variables
00146 !
00147       Integer                         :: j, n
00148 !
00149       Integer                         :: nbc
00150 !
00151 !     ... buffer pointers
00152 !
00153       Integer                         :: ip, ipb, ipi
00154       Integer                         :: ind (ndim_3d, ipa+1:ipa+nreq)
00155 !
00156 !     ... for error handling
00157 !
00158 !     Integer, Parameter              :: nerrp = 3
00159 !     Integer                         :: ierrp (nerrp)
00160 !
00161 ! !DESCRIPTION:
00162 !
00163 ! Subroutine "PSMILe_Store_faces_irreg2_real" stores the face info on
00164 ! (corner) cells to be transferred to neighbouring process for 
00165 ! global search of interpolation bases.
00166 !
00167 ! Subroutine "PSMILe_Store_faces_irreg2_real" is designed for grids of
00168 ! type "PRISM_Irrlonlat_Regvrt"
00169 !
00170 !
00171 ! !REVISION HISTORY:
00172 !
00173 !   Date      Programmer   Description
00174 ! ----------  ----------   -----------
00175 ! 02.02.05    H. Ritzdorf  created
00176 !
00177 !EOP
00178 !----------------------------------------------------------------------
00179 !
00180 !  $Id: psmile_store_faces_irreg2_real.F90 2082 2009-10-21 13:31:19Z hanke $
00181 !  $Author: hanke $
00182 !
00183    Character(len=len_cvs_string), save :: mycvs = 
00184        '$Id: psmile_store_faces_irreg2_real.F90 2082 2009-10-21 13:31:19Z hanke $'
00185 !
00186 !----------------------------------------------------------------------
00187 !
00188 !  Initialization
00189 !
00190 #ifdef VERBOSE
00191       print 9990, trim(ch_id), nreq
00192 
00193       call psmile_flushstd
00194 #endif /* VERBOSE */
00195 !
00196       ierror = 0
00197 !
00198       nbc = nbr_corners / nc_reg
00199 !
00200 #ifdef PRISM_ASSERTION
00201          do j = 1, nreq
00202          if (send_mask(j)) then
00203             if (required(j) == 0) exit
00204          endif
00205          end do
00206 !
00207       if (j < nreq) then
00208          print *, 'j, required', j, required (j)
00209          call psmile_assert (__FILE__, __LINE__, &
00210               "No points required")
00211       endif
00212 !
00213       if (len_item < ndim_3d + 2) then
00214          print *, 'len_item', len_item, ndim_3d + 2
00215          call psmile_assert (__FILE__, __LINE__, &
00216               "len_item is insufficicent")
00217       endif
00218 !
00219       if (len_rtem < ndim_3d + nbc*ndim_2d + ndim_2d) then
00220          print *, 'len_rtem', len_rtem, ndim_3d + nbc*ndim_2d + ndim_2d
00221          call psmile_assert (__FILE__, __LINE__, &
00222               "len_rtem is insufficicent")
00223       endif
00224 
00225       ip = count(send_mask)
00226       if (ipa+ip > ndrbuf) then
00227          print *, 'ndrbuf, ip, ipa, nreq', &
00228                    ndrbuf, ip, ipa, nreq
00229          call psmile_assert (__FILE__, __LINE__, &
00230                     "ndrbuf is not sufficient")
00231       endif
00232 !
00233       if (ipia+ip > ndibuf) then
00234          print *, 'ndibuf, ip, ipia, nreq', &
00235                    ndibuf, ip, ipia, nreq
00236          call psmile_assert (__FILE__, __LINE__, &
00237                     "ndrbuf is not sufficient")
00238       endif
00239 #endif
00240 !
00241       ipi = ipia
00242       ip  = ipa
00243 !
00244 !===> Get indices of last corner cell within domain
00245 !     Note: srcloc_ind may be indices of a virtual cell
00246 !  HUHU  ? should be use virtual_cell info (gauss grid) instead
00247 !  HUHU    and let srcloc_ind an index within the domain !
00248 
00249       do j = 1, nreq
00250       if (send_mask(j)) then
00251          ip = ip + 1
00252          ind (:, ip) = max (srcloc_ind(:,ip), grid_valid_shape (1,:))
00253          ind (:, ip) = min (ind(:, ip),       grid_valid_shape (2,:))
00254       endif
00255       end do
00256 !
00257       ip = ipa
00258 !
00259 !===> Fill buffers
00260 !
00261          do j = 1, nreq
00262          if (send_mask(j)) then
00263 !
00264 !===> ... n-th domain is a potential partner
00265 !
00266 !===> ... Store data in Real buffer "buf"
00267 !
00268 !  Storage sequence in "buf":
00269 !  buf (:) = Coordinates of the point to be searched
00270 !  buf (:) = Coordinates of corners of control volume/cell
00271 !
00272             ip = ip + 1
00273 !
00274             buf (1, ip) = tgt_coords1 (indices_req(j))
00275             buf (2, ip) = tgt_coords2 (indices_req(j))
00276             buf (3, ip) = tgt_coords3 (indices_req(j))
00277 !
00278 !  HUHU: Does it make really sense to transfer the box !?!
00279 !
00280                do n = 1, nbc
00281                buf (ndim_3d+(n-1)*ndim_2d+1, ip) = &
00282                    corners1 (ind(1,ip), ind (2,ip), n)
00283                buf (ndim_3d+(n-1)*ndim_2d+2, ip) = &
00284                    corners2 (ind(1,ip), ind (2,ip), n)
00285                end do
00286 !
00287             ipb = ndim_3d + nbc * ndim_2d
00288             buf (ipb+1, ip) = corners3 (ind(3, ip), 1)
00289             buf (ipb+2, ip) = corners3 (ind(3, ip), 2)
00290 !
00291 !===> ... Store logical coordinates of point to be searched in
00292 !         integer buffer "ibuf"
00293 !
00294 !  ibuf (1:ndim_3d, :) = srcloc of extra point
00295 !  ibuf (4,         :) = Index of the extra point to be searched
00296 !                        This is a local index in the vectors
00297 !                        "required" and "indices_req" of the actual
00298 !                        partition "ipart".
00299 !  ibuf (5,         :) = Code for interpolation bases required
00300 !
00301             ipi = ipi + 1
00302 !
00303             ibuf (1, ipi) = srcloc_ind (1, ip)
00304             ibuf (2, ipi) = srcloc_ind (2, ip)
00305             ibuf (3, ipi) = srcloc_ind (3, ip)
00306 !
00307             ibuf (4, ipi) = j
00308             ibuf (5, ipi) = required (j)
00309 !
00310          endif
00311          end do ! j
00312 !
00313 !===> All done; return current length
00314 !
00315       ipia = ipi
00316       ipa  = ip
00317 !
00318 #ifdef VERBOSE
00319       print 9980, trim(ch_id), ierror
00320 
00321       call psmile_flushstd
00322 #endif /* VERBOSE */
00323 !
00324 !  Formats:
00325 !
00326 
00327 #ifdef VERBOSE
00328 
00329 9990 format (1x, a, ': psmile_store_faces_irreg2_real: nreq ', i5)
00330 9980 format (1x, a, ': psmile_store_faces_irreg2_real: eof ierror =', i3)
00331 
00332 #endif /* VERBOSE */
00333 
00334 #ifdef DEBUG
00335 #endif
00336 
00337       end subroutine PSMILe_Store_faces_irreg2_real

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1