psmile_mg_coarse_3d_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_MG_Coarse_3d_dble
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_mg_coarse_3d_dble (lev, chmin, chmax, &
00012                                            found, locations, coords1, &
00013                                            coords2, coords3, ibeg, iend)
00014 !
00015 ! !USES:
00016 !
00017       use PRISM_constants
00018 !
00019       use PSMILe, dummy_interface => PSMILe_mg_coarse_3d_dble
00020 
00021       implicit none
00022 !
00023 ! !INPUT/OUTPUT PARAMETERS:
00024 !
00025       Integer, Intent (InOut)          :: ibeg
00026 
00027 !     Input  value: First index in "coords" to be searched
00028 !     Output value: First index in "coords" for which a cell was found
00029 
00030       Integer, Intent (InOut)          :: iend
00031 
00032 !     Input  value: Last  index in "coords" to be searched
00033 !                   Dimension of "found" and "location".
00034 !     Output value: Last  index in "coords" for which a cell was found
00035       Integer, Intent (InOut)          :: found (iend)
00036 
00037 !     Finest level number on which a grid cell was found for point I.
00038 !     Level number = -(nlev+1): Never found (input value)
00039 
00040       Integer, Intent (InOut)          :: locations (iend)
00041 !
00042 !
00043 ! !INPUT PARAMETERS:
00044 !
00045       Integer, Intent (In)            :: lev
00046 
00047 !     Level number of the coarsest grid
00048 
00049       Type (dble_vector), Intent (In) :: chmin (ndim_3d)
00050 
00051 !     Minimum of grid coordinates per grid cell
00052 
00053       Type (dble_vector), Intent (In) :: chmax (ndim_3d)
00054 
00055 !     Maximum of grid coordinates per grid cell
00056 
00057 !     Indices of the grid cell in which the point was found.
00058 !     Assumed input value locations (:, :) = 0
00059 
00060       Double Precision, Intent (In)    :: coords1 (iend)
00061       Double Precision, Intent (In)    :: coords2 (iend)
00062       Double Precision, Intent (In)    :: coords3 (iend)
00063 
00064 !     Coordinates to be searched
00065 !
00066 !
00067 ! !LOCAL VARIABLES
00068 !
00069 !     ... for locations searched
00070 !
00071       Integer                          :: i, i2
00072 #ifdef VERBOSE
00073       Integer                          :: n
00074 #endif
00075 !
00076 ! !DESCRIPTION:
00077 !
00078 ! Subroutine "PSMILe_mg_coarse_3d_dble" searches the donor cells
00079 ! on the coarsest MG grid (only 1 cell) for the subgrid sent by the
00080 ! sending process.
00081 !
00082 !
00083 ! !REVISION HISTORY:
00084 !
00085 !   Date      Programmer   Description
00086 ! ----------  ----------   -----------
00087 ! 03.07.21    H. Ritzdorf  created
00088 !
00089 !EOP
00090 !----------------------------------------------------------------------
00091 !
00092 !  $Id: psmile_mg_coarse_3d_dble.F90 2325 2010-04-21 15:00:07Z valcke $
00093 !  $Author: valcke $
00094 !
00095    Character(len=len_cvs_string), save :: mycvs = 
00096        '$Id: psmile_mg_coarse_3d_dble.F90 2325 2010-04-21 15:00:07Z valcke $'
00097 !
00098 !----------------------------------------------------------------------
00099 !
00100 !  Initialization
00101 !
00102 #ifdef VERBOSE
00103       print 9990, trim(ch_id), lev, ibeg, iend
00104 
00105       call psmile_flushstd
00106 #endif /* VERBOSE */
00107 !
00108 #ifdef PRISM_ASSERTION
00109       if (chmin(1)%vector(1) > chmax(1)%vector (1) .or. &
00110           chmin(2)%vector(1) > chmax(2)%vector (1) .or. &
00111           chmin(3)%vector(1) > chmax(3)%vector (1) ) then
00112          print *, 'chmin', chmin(1)%vector(1), chmin(2)%vector(1), chmin(3)%vector(1)
00113          print *, 'chmax', chmax(1)%vector(1), chmax(2)%vector(1), chmax(3)%vector(1)
00114          call psmile_assert ( __FILE__, __LINE__, &
00115                               'incorrect coarsest box')
00116       endif
00117 #endif
00118 !
00119 !===> Is point I in the coarsest box ?
00120 !
00121 !cdir vector
00122          do i = ibeg, iend
00123          if (chmin(1)%vector(1) <= coords1(i) .and. &
00124              chmax(1)%vector(1) >= coords1(i) .and. &
00125              chmin(2)%vector(1) <= coords2(i) .and. &
00126              chmax(2)%vector(1) >= coords2(i) .and. &
00127              chmin(3)%vector(1) <= coords3(i) .and. &
00128              chmax(3)%vector(1) >= coords3(i)) then
00129             found (i) = lev
00130          endif
00131          end do
00132 !
00133 !===> Update ibeg, iend
00134 !
00135 !cdir vector
00136          do i = ibeg, iend
00137          if (found (i) == lev) exit
00138          enddo
00139 !
00140       if (i > iend) then
00141          iend = ibeg - 1
00142 !
00143       else
00144          ibeg = i
00145 !
00146          if (found(iend) /= lev) then
00147 !cdir vector
00148                do i = ibeg, iend
00149                if (found(i) == lev) then
00150                   i2 = i
00151                endif
00152                enddo
00153 !
00154             iend = i2
00155 
00156          endif
00157       endif
00158 !
00159 !===> All done
00160 !
00161 #ifdef VERBOSE
00162 !
00163 !===> Get number of points found
00164 !
00165       n = count (found(ibeg:iend) == lev)
00166 !
00167       print 9980, trim(ch_id), lev, n
00168 
00169       call psmile_flushstd
00170 #endif /* VERBOSE */
00171 !
00172 !  Formats:
00173 !
00174 9990 format (1x, a, ': PSMILe_mg_coarse_3d_dble: level', i3, &
00175                     ', ibeg, iend', 2i6)
00176 9980 format (1x, a, ': PSMILe_mg_coarse_3d_dble: eof, level', i3, &
00177                     ', found =', i9)
00178 
00179       end subroutine PSMILe_mg_coarse_3d_dble

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1