psmile_store_faces_gauss2_dble.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_gauss2_dble
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_store_faces_gauss2_dble (indices_req,      &
00012                       required, nreq,                              &
00013                       tgt_coords1, tgt_coords2, tgt_coords3, ncpl, &
00014                       corners1, corners2, corners3, corner_shape,  &
00015                       nbr_corners, grid_id, grid_valid_shape,      &
00016                       send_mask, srcloc_ind,                       &
00017                       virtual_ind, virtual_cell_available,         &
00018                       ibuf, len_item, ndibuf, ipia,                &
00019                       buf,  len_rtem, ndrbuf, ipa, ierror)
00020 !
00021 ! !USES:
00022 !
00023       use PRISM
00024 !
00025       use PSMILe, dummy_interface => PSMILe_Store_faces_gauss2_dble
00026 #ifdef DEBUG_TRACE
00027       use psmile_debug_trace
00028 #endif
00029 
00030       Implicit none
00031 !
00032 ! !INPUT PARAMETERS:
00033 
00034       Integer,           Intent (In)  :: nreq
00035 !
00036 !     Total number of extra points to be searched for the current partition.
00037 !     Dimension of "indices_req" and "send_mask"
00038 !
00039       Integer,            Intent (In) :: indices_req (nreq)
00040 !
00041 !     Indices of the extra points in entire list of all points to be
00042 !     searched (i.e. for all parts "ipart")
00043 !
00044       Integer,            Intent (In) :: required    (nreq)
00045 !
00046 !     Code for the extra points which are additionally required.
00047 !
00048       Integer,           Intent (In)  :: corner_shape (2, ndim_3d)
00049       
00050 !     Specifies the dimension of arrays "corners1", "corners2" and "corners3"
00051 
00052       Integer,           Intent (In)  :: nbr_corners
00053 
00054 !     Number of corners in control volume 
00055 !     Must be 8 for a grid of type "PRISM_Reglonlatvrt".
00056 
00057       Integer,           Intent (In)  :: grid_id
00058 
00059 !     Grid Id of the source grid (grid on which the points are searched)
00060 
00061 
00062       Integer,           Intent (In)  :: grid_valid_shape (2, ndim_3d)
00063       
00064 !     Specifies the valid block shape for the "ndim_3d"-dimensional block
00065 
00066       Integer,           Intent (In)  :: ncpl
00067 
00068 !     Total number of points to be transferred 
00069 !     = Dimensions of tgt_coords1, tgt_coords2, tgt_coords3
00070 
00071       Double Precision,  Intent (In)  :: tgt_coords1 (ncpl)
00072       Double Precision,  Intent (In)  :: tgt_coords2 (ncpl)
00073       Double Precision,  Intent (In)  :: tgt_coords3 (ncpl)
00074 
00075 !     Coordinates of the points to be searched
00076 
00077       Double Precision,   Intent (In) :: 
00078          corners1 ( corner_shape(1,1):corner_shape(2,1), 2)
00079 !        corners1 ( corner_shape(1,1):corner_shape(2,1), nbr_corners/2)
00080 
00081       Double Precision,   Intent (In) :: 
00082          corners2 ( corner_shape(1,1):corner_shape(2,1), 2)
00083 !        corners2 ( corner_shape(1,1):corner_shape(2,1), nbr_corners/2)
00084 
00085       Double Precision,   Intent (In) :: 
00086          corners3 ( corner_shape(1,3):corner_shape(2,3), 2)
00087 !
00088 !     Coordinates of corners of cell/control volume.
00089 !     Note: This is a grid of type PRISM_Gaussreduced_Regvrt, i.e. 
00090 !           2 corner coordinates per regular direction
00091 !
00092       Logical,           Intent (In)  :: send_mask (nreq)
00093 !
00094 !     Mask for the points (of "indices_req") to be sent.
00095 !
00096       Integer,           Intent (In)  :: ndibuf
00097 !
00098 !     Dimension of integer buffer "ibuf"
00099 !
00100       Integer,           Intent (In)  :: srcloc_ind (ndim_3d, ndibuf)
00101 !
00102 !     Indices of points in "corners" to be sent.
00103 !     The indices are indices in the GaussReduced Grid
00104 !     (Not in the auxiliary lonlat grid).
00105 !
00106       Integer,           Intent (In)  :: virtual_ind (ndibuf)
00107 !
00108 !     Virtual cell info
00109 !
00110       Logical,           Intent (In)  :: virtual_cell_available
00111 !
00112 !     Is virtual cell info available and should the info be stored ?
00113 !
00114       Integer,           Intent (In)  :: len_item
00115 !
00116 !     Length per data item in integer buffer "ibuf"
00117 !        1:3: (i,j,k) index of lower left corner
00118 !        4  : index in
00119 !        5  : code for points required
00120 !
00121       Integer,           Intent (In)  :: ndrbuf
00122 !
00123 !     Dimension of Double Precision buffer "buf"
00124 !
00125       Integer,           Intent (In)  :: len_rtem
00126 !
00127 !     Length per data item in Double Precision buffer "buf"
00128 !        1:3: Coordinates of the point to be searched
00129 !        :  : Coordinates of corners of control volume/cell
00130 !             (ndim_3d * nc_reg values)
00131 !
00132 ! !OUTPUT PARAMETERS:
00133 !
00134       Double Precision,  Intent (InOut) :: buf (len_rtem, ndrbuf)
00135 !
00136 !     Buffer returning the packed Double Precision data.
00137 !
00138       Integer,           Intent (InOut) :: ipa
00139 !
00140 !     Number of data items stored in "buf";
00141 !     i.e. buf(1:ipa) contains buffered data.
00142 !
00143       Integer,           Intent (InOut) :: ibuf (len_item, ndibuf)
00144 !
00145 !     Integer buffer returning the packed integer data.
00146 !
00147       Integer,           Intent (InOut) :: ipia
00148 !
00149 !     Number of data items stored in "ibuf";
00150 !     i.e. ibuf(:, 1:ipia) contains buffered data.
00151 !
00152       Integer,           Intent (Out)   :: ierror
00153 
00154 !     Returns the error code of PSMILe_Store_faces_gauss2_dble;
00155 !             ierror = 0 : No error
00156 !             ierror > 0 : Severe error
00157 !
00158 ! !LOCAL PARAMETERS
00159 !
00160 !  NC_REG = Number of corners for regular directions
00161 !
00162       Integer, Parameter              :: nc_reg = 2
00163 !
00164 ! !LOCAL VARIABLES
00165 !
00166 !     ... loop variables
00167 !
00168       Integer                         :: j, n
00169 !
00170       Integer                         :: nbc
00171 !
00172 !     ... for gaussian reduced grids
00173 !
00174       Integer                         :: nbr_lats
00175       Logical                         :: store_virtual
00176 !  
00177       Type (Grid), Pointer            :: gp
00178       Integer, Pointer                :: points_per_lat (:,:)
00179 
00180 !
00181 !     ... buffer pointers
00182 !
00183       Integer                         :: ip, ipi
00184 !
00185 !     ... for error handling
00186 !
00187 !     Integer, Parameter              :: nerrp = 3
00188 !     Integer                         :: ierrp (nerrp)
00189 !
00190 ! !DESCRIPTION:
00191 !
00192 ! Subroutine "PSMILe_Store_faces_gauss2_dble" computes
00193 !
00194 ! Subroutine "PSMILe_Store_faces_gauss2_dble" is designed for grids of
00195 ! type "PRISM_Gaussreduced_Regvrt"
00196 !
00197 !
00198 ! !REVISION HISTORY:
00199 !
00200 !   Date      Programmer   Description
00201 ! ----------  ----------   -----------
00202 ! 02.02.05    H. Ritzdorf  created
00203 !
00204 !EOP
00205 !----------------------------------------------------------------------
00206 !
00207 !  $Id: psmile_store_faces_gauss2_dble.F90 2966 2011-02-18 09:47:30Z hanke $
00208 !  $Author: hanke $
00209 !
00210    Character(len=len_cvs_string), save :: mycvs = 
00211        '$Id: psmile_store_faces_gauss2_dble.F90 2966 2011-02-18 09:47:30Z hanke $'
00212 !
00213 !----------------------------------------------------------------------
00214 !
00215 !  Initialization
00216 !
00217 #ifdef VERBOSE
00218       print 9990, trim(ch_id), nreq
00219 
00220       call psmile_flushstd
00221 #endif /* VERBOSE */
00222 !
00223       ierror = 0
00224 
00225 !     nbc = nbr_corners/nc_reg
00226       nbc = 2
00227 !
00228 #ifdef PRISM_ASSERTION
00229 !
00230       if (grid_valid_shape (1,2) /= 1 .or. &
00231           grid_valid_shape (2,2) /= 1) then
00232          call psmile_assert (__FILE__, __LINE__, &
00233               "Internal definition of GaussReduced grid not correct")
00234       endif
00235 !
00236       if (grid_valid_shape (1,1) /= corner_shape(1,1) .or. &
00237           grid_valid_shape (2,1) /= corner_shape(2,1) .or. &
00238           grid_valid_shape (1,2) /= corner_shape(1,2) .or. &
00239           grid_valid_shape (2,2) /= corner_shape(2,2)) then
00240 !
00241          print *, 'corner_shape    ', corner_shape
00242          print *, 'grid_valid_shape', grid_valid_shape
00243 !
00244          call psmile_assert (__FILE__, __LINE__, &
00245               "corner_shape /= grid_valid_shape; don't know to address")
00246       endif
00247 !
00248          do j = 1, nreq
00249          if (send_mask(j)) then
00250             if (required(j) == 0) exit
00251          endif
00252          end do
00253 !
00254       if (j < nreq) then
00255          print *, 'j, required', j, required (j)
00256          call psmile_assert (__FILE__, __LINE__, &
00257               "No points required")
00258       endif
00259 !
00260       if (len_item < ndim_3d + 2) then
00261          print *, 'len_item', len_item, ndim_3d + 2
00262          call psmile_assert (__FILE__, __LINE__, &
00263               "len_item is insufficicent")
00264       endif
00265 !
00266       if (len_rtem < ndim_3d + nbc*ndim_2d + ndim_2d) then
00267          print *, 'len_rtem', len_rtem, ndim_3d + nbc*ndim_2d + ndim_2d
00268          call psmile_assert (__FILE__, __LINE__, &
00269               "len_rtem is insufficicent")
00270       endif
00271 !
00272       ip = count(send_mask)
00273       if (ipa+ip > ndrbuf) then
00274          print *, 'ndrbuf, ip, ipa, nreq', &
00275                    ndrbuf, ip, ipa, nreq
00276          call psmile_assert (__FILE__, __LINE__, &
00277                     "ndrbuf is not sufficient")
00278       endif
00279 !
00280       if (ipia+ip > ndibuf) then
00281          print *, 'ndibuf, ip, ipia, nreq', &
00282                    ndibuf, ip, ipia, nreq
00283          call psmile_assert (__FILE__, __LINE__, &
00284                     "ndrbuf is not sufficient")
00285       endif
00286 #endif
00287 !
00288 !===> Get number of points per lat for Gaussian Reduce grid
00289 !
00290       gp => Grids(grid_id)
00291       points_per_lat => gp%extent
00292 !
00293       nbr_lats = size(gp%extent(:,1))
00294 !
00295       ipi = ipia
00296       ip  = ipa
00297 !
00298       store_virtual = virtual_cell_available ! Help the compiler
00299 !
00300 !===> Fill buffers
00301 !
00302 !cdir vector
00303       do j = 1, nreq
00304          if (send_mask(j)) then
00305 !
00306 !===> ... n-th domain is a potential partner
00307 !
00308 !===> ... Store data in Double Precision buffer "buf"
00309 !
00310 !  Storage sequence in "buf":
00311 !  buf (:) = Coordinates of the point to be searched
00312 !  buf (:) = Coordinates of corners of control volume/cell
00313 !
00314             ip = ip + 1
00315 !
00316             buf (1, ip) = tgt_coords1 (indices_req (j))
00317             buf (2, ip) = tgt_coords2 (indices_req (j))
00318             buf (3, ip) = tgt_coords3 (indices_req (j))
00319 !
00320 ! das ist unsinn
00321 ! box
00322             do n = 1, nbc
00323                buf (n*ndim_3d+1, ip) = corners1 (srcloc_ind(1,ip), n)
00324                buf (n*ndim_3d+2, ip) = corners2 (srcloc_ind(1,ip), n)
00325                buf (n*ndim_3d+3, ip) = corners3 (srcloc_ind(3,ip), n)
00326             end do
00327 !
00328 !===> ... Store logical coordinates of point to be searched in
00329 !         integer buffer "ibuf"
00330 !  ibuf (1:ndim_3d, :) = srcloc of extra point
00331 !  ibuf (4,         :) = Index of the extra point to be searched
00332 !                        This is a local index in the vectors
00333 !                        "required" and "indices_req" of the actual
00334 !                        partition "ipart".
00335 !  ibuf (5,         :) = Code for interpolation bases required
00336 !  ibuf (6,         :) = virtual_cell info
00337 !
00338             ipi = ipi + 1
00339 !
00340             ibuf (1, ipi) = srcloc_ind (1, ip)
00341             ibuf (2, ipi) = srcloc_ind (2, ip)
00342             ibuf (3, ipi) = srcloc_ind (3, ip)
00343 !
00344             ibuf (4, ipi) = j
00345             ibuf (5, ipi) = required (j)
00346             if (store_virtual) ibuf (6, ipi) = virtual_ind (ip)
00347 !
00348 #ifdef DEBUG_TRACE
00349             if (indices_req (j) == ictl) then
00350             print *, "psmile_store_faces_gauss2_dble: indices_req(j)", &
00351                      indices_req (j), ", ipi", ipi
00352             print *, 'required: j, ind, required', &
00353                      j, ibuf (1, ipi), ibuf (2, ipi), ibuf (3, ipi), &
00354                      required (j), 'virtual', ibuf (6, ipi)
00355             endif
00356 #endif
00357 !
00358 #ifdef DEBUGX
00359             print *, 'required: j, ind, required', &
00360                      j, ibuf (1, ipi), ibuf (2, ipi), ibuf (3, ipi), &
00361                      required (j), 'virtual', ibuf (6, ipi)
00362 #endif
00363 !
00364          endif
00365       end do ! j
00366 !
00367 !===> All done; return current length
00368 !
00369       ipia = ipi
00370       ipa  = ip
00371 !
00372 #ifdef VERBOSE
00373       print 9980, trim(ch_id), ierror
00374 
00375       call psmile_flushstd
00376 #endif /* VERBOSE */
00377 !
00378 !  Formats:
00379 !
00380 
00381 #ifdef VERBOSE
00382 
00383 9990 format (1x, a, ': psmile_store_faces_gauss2_dble: nreq ', i5)
00384 9980 format (1x, a, ': psmile_store_faces_gauss2_dble: eof ierror =', i3)
00385 
00386 #endif /* VERBOSE */
00387 
00388 #ifdef DEBUG
00389 #endif
00390 
00391       end subroutine PSMILe_Store_faces_gauss2_dble

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1