psmile_mg_coarse_2d_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_mg_coarse_2d_real
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_mg_coarse_2d_real (lev, chmin, chmax, &
00012                                            found, locations, coords1, coords2, &
00013                                            ibeg, iend)
00014 !
00015 ! !USES:
00016 !
00017       use PRISM_constants
00018 !
00019       use PSMILe, dummy_interface => PSMILe_mg_coarse_2d_real
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 
00036       Integer, Intent (InOut)         :: found (iend)
00037 
00038 !     Finest level number on which a grid cell was found for point I.
00039 !     Level number = -(nlev+1): Never found (input value)
00040 
00041       Integer, Intent (InOut)         :: locations (iend)
00042 
00043 !     Indices of the grid cell in which the point was found.
00044 !     Assumed input value locations (:, :) = 0
00045 !
00046 !
00047 ! !INPUT PARAMETERS:
00048 !
00049       Integer, Intent (In)            :: lev
00050 !
00051 !     Level number of the coarsest grid
00052 !
00053       Type (real_vector), Intent (In) :: chmin (ndim_2d)
00054 !
00055 !     Minimum of grid coordinates per grid cell
00056 !
00057       Type (real_vector), Intent (In) :: chmax (ndim_2d)
00058 
00059 !     Maximum of grid coordinates per grid cell
00060 
00061       Real, Intent (In)               :: coords1 (iend)
00062       Real, Intent (In)               :: coords2 (iend)
00063 
00064 !     Coordinates to be searched
00065 !
00066 ! !LOCAL VARIABLES
00067 !
00068 !     ... for locations searched
00069 !
00070       Integer                      :: i, i2
00071 #ifdef VERBOSE
00072       Integer                      :: n
00073 #endif
00074 !
00075 !
00076 ! !DESCRIPTION:
00077 !
00078 ! Subroutine "PSMILe_mg_coarse_2d_real" 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_2d_real.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_2d_real.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)) then
00111          print *, 'chmin', chmin(1)%vector(1), chmin(2)%vector(1)
00112          print *, 'chmax', chmax(1)%vector(1), chmax(2)%vector(1)
00113          call psmile_assert ( __FILE__, __LINE__, &
00114                               'incorrect coarsest box')
00115       endif
00116 #endif
00117 !
00118 !===> Is point I in the coarsest box ?
00119 !
00120 !cdir vector
00121          do i = ibeg, iend
00122          if (chmin(1)%vector(1) <= coords1(i) .and. &
00123              chmax(1)%vector(1) >= coords1(i) .and. &
00124              chmin(2)%vector(1) <= coords2(i) .and. &
00125              chmax(2)%vector(1) >= coords2(i)) then
00126             found (i) = lev
00127          endif
00128          end do
00129 !
00130 !===> Update ibeg, iend
00131 !
00132 !cdir vector
00133          do i = ibeg, iend
00134          if (found (i) == lev) exit
00135          enddo
00136 !
00137       if (i > iend) then
00138          iend = ibeg - 1
00139 !
00140       else
00141       ibeg = i
00142 !
00143       if (found(iend) /= lev) then
00144 !cdir vector
00145             do i = ibeg, iend
00146             if (found(i) == lev) then
00147                i2 = i
00148             endif
00149             enddo
00150 !
00151          iend = i2
00152 
00153       endif
00154       endif
00155 !
00156 !===> All done
00157 !
00158 #ifdef VERBOSE
00159 !
00160 !===> Get number of points found
00161 !
00162 #ifdef DONT_USE_COUNT
00163       n = 0
00164 !cdir vector
00165          do i = ibeg, iend
00166          if (found(i) == lev) n = n + 1
00167          end do
00168 #else
00169       n = count (found(ibeg:iend) == lev)
00170 
00171 #ifdef DEBUG
00172       print *, 'chmin', chmin(1)%vector(1), chmin(2)%vector(1)
00173       print *, 'chmax', chmax(1)%vector(1), chmax(2)%vector(1)
00174 
00175          do i = ibeg, iend
00176          if (found(i) /= lev) then
00177             print *, i
00178             print *, coords1(i)
00179             print *, coords2(i)
00180             exit
00181          endif 
00182          end do
00183 #endif
00184 #endif
00185 !
00186       print 9980, trim(ch_id), lev, n
00187 
00188       call psmile_flushstd
00189 #endif /* VERBOSE */
00190 !
00191 !  Formats:
00192 !
00193 9990 format (1x, a, ': PSMILe_mg_coarse_2d_real: level', i3, &
00194                     ', ibeg, iend', 2i6)
00195 9980 format (1x, a, ': PSMILe_mg_coarse_2d_real: eof, level', i3, &
00196                     ', found =', i9)
00197 
00198       end subroutine PSMILe_mg_coarse_2d_real

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1