psmile_mg_prev_levels_3d_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_Prev_levels_3d_real
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_mg_prev_levels_3d_real (grid_id, lev, nlev, &
00012                            lstijk, xyz, found, newijk)
00013 !
00014 ! !USES:
00015 !
00016       use PRISM_constants
00017 !
00018       use PSMILe, dummy_interface => PSMILe_mg_prev_levels_3d_real
00019 
00020       Implicit none
00021 !
00022 ! !INPUT PARAMETERS:
00023 !
00024       Integer, Intent (In)            :: grid_id
00025 !
00026 !     Grid Id for which the donor cells should be searched.
00027 !
00028       Integer, Intent (In)            :: lev
00029 !
00030 !     Level number of the next (fine) grid
00031 !
00032       Integer, Intent (In)            :: nlev
00033 !
00034 !     Total number of levels
00035 !
00036       Integer, Intent (In)            :: lstijk (ndim_3d)
00037 !
00038 !     Last indices of cell on coarse level LEV+1.
00039 !     !!! This routine assumes that all parts on the fine grid "LEV"
00040 !     of these cells, were already controlled and point "xyz"
00041 !     was not found.
00042 !
00043       Real, Intent (In)               :: xyz (ndim_3d)
00044 !
00045 !     Coordinates of the points to be searched
00046 !
00047 ! !OUTPUT PARAMETERS:
00048 !
00049       Integer, Intent (Out)           :: found
00050 !
00051 !     Was the point xyz found ?
00052 !     found = 0: Not found
00053 !     found > 0: Part of the cell where point XYZ was found.
00054 !
00055       Integer, Intent (Out)           :: newijk (ndim_3d)
00056 !
00057 !     Indices on level LEV if found > 0 is returned.
00058 !
00059 ! !DEFINED PARAMETERS:
00060 !
00061       Logical, Parameter              :: wide = .true.
00062       Logical, Parameter              :: small = .false.
00063 !
00064 ! !LOCAL VARIABLES
00065 !
00066       Integer                      :: i
00067 
00068 !     ... for Grid
00069 
00070       Type (Grid), Pointer            :: grid_info
00071 
00072 !     ... for levels
00073 
00074       Integer                      :: levc, levd, levdbg, levu, levubg
00075       Integer                      :: nlev1
00076       Integer                      :: nold (nlev), ijk (ndim_3d, nlev)
00077       Logical                      :: all (nlev)
00078 !
00079 ! !DESCRIPTION:
00080 !
00081 ! Subroutine "PSMILe_mg_prev_levels_3d_real" searches for the donor cell
00082 ! of point "sent".  The point was last found on level LEVC in donor cell (IC).
00083 !
00084 ! TODO: Improvements of "psmile_mg_prev_levels_2d_real.F90" to be integrated.
00085 !
00086 !
00087 ! !REVISION HISTORY:
00088 !
00089 !   Date      Programmer   Description
00090 ! ----------  ----------   -----------
00091 ! 03.07.21    H. Ritzdorf  created
00092 !
00093 !EOP
00094 !----------------------------------------------------------------------
00095 !
00096 !  $Id: psmile_mg_prev_levels_3d_real.F90 2325 2010-04-21 15:00:07Z valcke $
00097 !  $Author: valcke $
00098 !
00099    Character(len=len_cvs_string), save :: mycvs = 
00100        '$Id: psmile_mg_prev_levels_3d_real.F90 2325 2010-04-21 15:00:07Z valcke $'
00101 !
00102 !----------------------------------------------------------------------
00103 !
00104 !  Initialization
00105 !
00106 #ifdef VERBOSE
00107       print 9990, trim(ch_id), lev
00108 
00109       call psmile_flushstd
00110 #endif /* VERBOSE */
00111 !
00112       grid_info => Grids(grid_id)
00113 
00114       levc = lev + 1
00115       nlev1 = nlev - 1
00116 
00117 #ifdef PRISM_ASSERTION
00118       if (levc >= nlev) then
00119          call psmile_assert (__FILE__, __LINE__, 'incorrect level')
00120       endif
00121 #endif
00122 !
00123       ijk (:, levc) = lstijk (:)
00124 !
00125          do levd = levc, nlev1
00126          all  (levd) = .false.
00127          nold (levd) = 1
00128          end do
00129 !
00130 !===> ... Compute indices on the coarser levels
00131 !         for coarsening factor 2 !
00132 !
00133          do levd = levc+1, nlev1
00134             do i = 1, ndim_3d
00135             if (grid_info%mg_infos(levd  )%levdim(i) /= &
00136                 grid_info%mg_infos(levd-1)%levdim(i) ) then
00137                ijk (i, levd) = ijk (i, levd-1) / 2
00138             else
00139                ijk (i, levd) = ijk (i, levd-1)
00140             endif
00141             end do
00142          end do
00143 !
00144 !---------------------------------------------------------------------
00145 !     Go down in the level hierarchie
00146 !---------------------------------------------------------------------
00147 !
00148       levdbg = levc
00149 !
00150 100   continue
00151 !
00152          do levd = levdbg, nlev1
00153 !
00154          call psmile_mg_control_cell_3d_real ( &
00155              grid_info%mg_infos(levd)%real_arrays%chmin(1)%vector, &
00156              grid_info%mg_infos(levd)%real_arrays%chmin(2)%vector, &
00157              grid_info%mg_infos(levd)%real_arrays%chmin(3)%vector, &
00158              grid_info%mg_infos(levd)%real_arrays%chmax(1)%vector, &
00159              grid_info%mg_infos(levd)%real_arrays%chmax(2)%vector, &
00160              grid_info%mg_infos(levd)%real_arrays%chmax(3)%vector, &
00161              grid_info%mg_infos(levd)%real_arrays%midp (1)%vector, &
00162              grid_info%mg_infos(levd)%real_arrays%midp (2)%vector, &
00163              grid_info%mg_infos(levd)%real_arrays%midp (3)%vector, &
00164              grid_info%mg_infos(levd)%levdim, &
00165              ijk(1, levd), xyz, nold(levd), all(levd), wide, found, newijk)
00166 !
00167          if (found > 0) go to 1990
00168 !
00169          end do
00170 !
00171 !===> Not found
00172 !
00173 
00174 #ifdef VERBOSE
00175       print 9980, trim(ch_id), lev
00176 
00177       call psmile_flushstd
00178 #endif /* VERBOSE */
00179 
00180       return
00181 !
00182 !---------------------------------------------------------------------
00183 !     Up again; startpoint is newijk on level "levd"
00184 !---------------------------------------------------------------------
00185 !
00186 1990  nold (levd) = found
00187       all (levd) = .true.
00188 !
00189       levdbg = levd
00190       levubg = levd - 1
00191 !
00192       nold (levubg) = 0
00193       all  (levubg) = .true.
00194 !
00195          do i = 1, ndim_3d
00196          if (grid_info%mg_infos(levubg)%levdim(i) > &
00197              grid_info%mg_infos(levubg+1)%levdim(i)) then
00198             ijk (i, levubg) = min (newijk(i)*2, grid_info%mg_infos(levubg)%levdim(i))
00199          else
00200             ijk (i, levubg) = newijk (i)
00201          endif
00202          enddo
00203 !
00204 1995  continue
00205 !
00206          do levu = levubg, lev, -1
00207          if (levu .ne. levubg) then
00208             do i = 1, ndim_3d
00209                if (grid_info%mg_infos(levu)%levdim(i) > &
00210                    grid_info%mg_infos(levu+1)%levdim(i)) then
00211                   ijk (i, levu) = min (newijk(i)*2, grid_info%mg_infos(levu)%levdim(i))
00212                else
00213                   ijk (i, levu) = newijk (i)
00214                endif
00215             enddo
00216          endif
00217 !
00218          call psmile_mg_control_cell_3d_real ( &
00219              grid_info%mg_infos(levu)%real_arrays%chmin(1)%vector, &
00220              grid_info%mg_infos(levu)%real_arrays%chmin(2)%vector, &
00221              grid_info%mg_infos(levu)%real_arrays%chmin(3)%vector, &
00222              grid_info%mg_infos(levu)%real_arrays%chmax(1)%vector, &
00223              grid_info%mg_infos(levu)%real_arrays%chmax(2)%vector, &
00224              grid_info%mg_infos(levu)%real_arrays%chmax(3)%vector, &
00225              grid_info%mg_infos(levu)%real_arrays%midp (1)%vector, &
00226              grid_info%mg_infos(levu)%real_arrays%midp (2)%vector, &
00227              grid_info%mg_infos(levu)%real_arrays%midp (3)%vector, &
00228              grid_info%mg_infos(levu)%levdim,                   &
00229              ijk(1, levu), xyz, nold(levu), all(levu), small, found, newijk)
00230 !
00231          if (found == 0) then
00232             if (levu < levd-1) then
00233 !
00234 !===> ... go back to the previous level; and try again
00235 !
00236                levubg = levu + 1
00237                go to 1995
00238             else
00239 !
00240 !===> ... go down
00241 !
00242                go to 100
00243             endif
00244 !
00245          else if (levu > lev) then
00246             all (levu) = .true.
00247             nold (levu) = found
00248 !
00249             nold (levu-1) = 0
00250             all (levu-1) = .true.
00251          endif
00252          end do ! levu
00253 !
00254 !===> All done
00255 !
00256 #ifdef VERBOSE
00257       print 9980, trim(ch_id), lev
00258 
00259       call psmile_flushstd
00260 #endif /* VERBOSE */
00261 !
00262       return
00263 !
00264 !  Formats:
00265 !
00266 9990 format (1x, a, ': psmile_mg_prev_levels_3d_real: level', i3, &
00267                     ', ibeg, iend', 2i6)
00268 9980 format (1x, a, ': psmile_mg_prev_levels_3d_real: eof, level', i3)
00269 
00270       end subroutine PSMILe_mg_prev_levels_3d_real

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1