psmile_get_faces_gauss2_dble.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00003 ! Copyright 2011, DKRZ, Hamburg, Germany.
00004 ! All rights reserved. Use is subject to OASIS4 license terms.
00005 !-----------------------------------------------------------------------
00006 !BOP
00007 !
00008 ! !ROUTINE: PSMILe_Get_faces_gauss2_dble
00009 !
00010 ! !INTERFACE:
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 ! !USES:
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 ! !INPUT PARAMETERS:
00030 !
00031       Type (Enddef_search),     Intent (In) :: search
00032 
00033 !     Info's on coordinates to be searched
00034 !
00035       Type (Extra_search_info), Intent (In) :: extra_search
00036 !
00037 !     Number of locations where
00038 !       (*) required mask values were not true
00039 !
00040       Integer,            Intent (In) :: corner_shape (2, ndim_3d)
00041       
00042 !     Specifies the dimension of arrays "corners1", "corners2" and "corners3"
00043 
00044       Integer,            Intent (In) :: nbr_corners
00045 
00046 !     Number of corners in control volume 
00047 !     Must be 8 for a grid of type "PRISM_Reglonlatvrt".
00048 
00049       Integer,            Intent (In) :: grid_valid_shape (2, ndim_3d)
00050       
00051 !     Specifies the valid block shape for the "ndim_3d"-dimensional block
00052 
00053       Double Precision,   Intent (In) :: 
00054          corners1 ( corner_shape(1,1):corner_shape(2,1), 2)
00055 !        corners1 ( corner_shape(1,1):corner_shape(2,1), nbr_corners/2)
00056 
00057       Double Precision,   Intent (In) :: 
00058          corners2 ( corner_shape(1,1):corner_shape(2,1), 2)
00059 !        corners2 ( corner_shape(1,1):corner_shape(2,1), nbr_corners/2)
00060 
00061       Double Precision,   Intent (In) :: 
00062          corners3 ( corner_shape(1,3):corner_shape(2,3), 2) 
00063 
00064 !
00065 !     Coordinates of corners of cell/control volume
00066 !     Note: This is a grid of type PRISM_Gaussreduced_Regvrt, i.e. 
00067 !           2 corner coordinates per regular direction
00068 !
00069       Integer,            Intent (In)    :: nloc
00070 !
00071 !     Total  Number of locations to be transferred
00072 !
00073 !     Last dimension of neighbors array "neighbors_3d" and
00074 !     number of neighbors to be searched.
00075 
00076       Integer,            Intent (In)    :: num_neigh
00077 !
00078 !     Last dimension of neighbors array "neighbors_3d" and
00079 !     number of neighbors to be searched.
00080 
00081       Integer,            Intent (In)    :: neighbors_3d (ndim_3d, nloc, 
00082                                                           num_neigh)
00083 
00084 !     Indices of neighbor locations (interpolation bases)
00085 !
00086       Integer,            Intent (In) :: nreq
00087 !
00088 !     Total number of extra points to be searched.
00089 !     Dimension of "faces" and "nfaces".
00090 !
00091 ! !OUTPUT PARAMETERS:
00092 !
00093       Double Precision,  Intent (Out) :: faces (2, ndim_3d, nreq)
00094 
00095 !     Number of block faces which cell "i" is coinciding
00096 !
00097       Integer,           Intent (Out) :: ierror
00098 
00099 !     Returns the error code of PSMILe_Get_faces_gauss2_dble;
00100 !             ierror = 0 : No error
00101 !             ierror > 0 : Severe error
00102 !
00103 ! !LOCAL VARIABLES
00104 !
00105 !     ... loop variables
00106 !
00107       Integer                         :: i, j, k, n
00108 !
00109 !     ... for partitions
00110 !
00111       Integer                         :: ipart, nprev
00112 !
00113       Integer, Pointer                :: indices_req (:)
00114       Integer, Pointer                :: required (:)
00115       Integer, Pointer                :: len_req (:)
00116 !
00117 !     ... locations controlled
00118 !
00119       Integer                         :: code
00120 !
00121       Double Precision                :: box (2, ndim_3d)
00122 !
00123 !     ... for error handling
00124 !
00125 !     Integer, Parameter              :: nerrp = 3
00126 !     Integer                         :: ierrp (nerrp)
00127 !
00128 ! !DESCRIPTION:
00129 !
00130 ! Subroutine "PSMILe_Get_faces_gauss2_dble" computes
00131 !
00132 ! Subroutine "PSMILe_Get_faces_gauss2_dble" is designed for grids of
00133 ! type "PRISM_Gaussreduced_Regvrt"
00134 !
00135 !
00136 ! !REVISION HISTORY:
00137 !
00138 !   Date      Programmer   Description
00139 ! ----------  ----------   -----------
00140 ! 02.02.05    H. Ritzdorf  created
00141 ! 24.02.11    M. Hanke     changed neighbors_3d from 2d representation to 1d
00142 !
00143 !EOP
00144 !----------------------------------------------------------------------
00145 !
00146 !  $Id: psmile_get_faces_gauss2_dble.F90 2988 2011-02-24 14:36:19Z hanke $
00147 !  $Author: hanke $
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 !  Initialization
00155 !
00156 #ifdef VERBOSE
00157       print 9990, trim(ch_id)
00158 !     print *, 'corner_shape    ', corner_shape
00159 !     print *, 'grid_valid_shape', grid_valid_shape
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 !  For all part "ipart"
00195 !
00196 !  indices_req = Indices of the extra points in entire list of all points
00197 !                to be searched (i.e. for all parts "ipart")
00198 !  required    = Code for the extra points which are additionally required.
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 !               HR: This was already calculated. This is the finest multi-grid.
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 !                       ... first entry
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 ! neighbours_3d
00279 
00280                end do ! n
00281 
00282             end do ! j
00283 
00284          endif !( len_req (ipart) > 0)
00285          !
00286          nprev = nprev + len_req (ipart)
00287          !
00288       end do ! ipart
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 ! Hier muss ich noch die faces auf -180:180, .... mappen
00319 ! oder 
00320 !!
00321 !!
00322 !
00323 !===> Muss ich hier nicht die Faces mit der cyclic behandeln
00324 !     Oder mache ich das wieder dort, wo die Punkte gesucht werden.
00325 !
00326 !
00327 !===> All done
00328 !
00329 #ifdef VERBOSE
00330       print 9980, trim(ch_id), ierror
00331 
00332       call psmile_flushstd
00333 #endif /* VERBOSE */
00334 !
00335 !  Formats:
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

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1