psmile_mg_ctrl_subgrid_2d_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_ctrl_subgrid_2d_dble
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_mg_ctrl_subgrid_2d_dble (array,  &
00012                     corner_shape, nbr_corners, range,    &
00013                     chmin, chmax, levdim,                &
00014                     period, grid_id, ind, ierror)
00015 !
00016 ! !USES:
00017 !
00018       use PRISM_constants
00019 !
00020       use PSMILe, dummy_interface => PSMILe_MG_ctrl_subgrid_2d_dble
00021 
00022       Implicit none
00023 !
00024 ! !INPUT PARAMETERS:
00025 !
00026       Integer, Intent (In)             :: corner_shape (2, 2)
00027       Integer, Intent (In)             :: nbr_corners
00028 
00029 !     Dimensions of "array"
00030 !
00031       Double Precision, Intent (In)    :: array ( 
00032                                            corner_shape(1,1):corner_shape(2,1), 
00033                                            corner_shape(1,2):corner_shape(2,2), 
00034                                            nbr_corners)
00035 
00036 !     Fully dimensioned array "array" for which the first MG level
00037 !     was be computed.
00038 
00039       Integer, Intent (In)             :: range (2, 2)
00040 
00041 !     Definintion of the subgrid
00042 
00043       Integer, Intent (In)             :: levdim (2)
00044 
00045 !     Dimensions of the first MG level
00046 
00047       Double Precision, Intent (In)    :: chmin (0:levdim(1), 0:levdim(2))
00048 !
00049 !     Minimum value of bounding box of coordinate array "array".
00050 !
00051       Double Precision, Intent (In)    :: chmax (0:levdim(1), 0:levdim(2))
00052 !
00053 !     Maximum value of bounding box of coordinate array "array".
00054 !
00055       Double Precision, Intent (In)    :: period
00056 !
00057 !     Period of cyclic coordinate
00058 
00059       Integer, Intent (In)             :: grid_id
00060 
00061 !     Grid id
00062 
00063       Integer, Intent (In)             :: ind
00064 
00065 !     Coordinate index of the grid
00066 !
00067 ! !OUTPUT PARAMETERS:
00068 !
00069       Integer, Intent (Out)            :: ierror
00070 
00071 !     Returns the error code of PSMILe_MG_ctrl_subgrid_2d_dble
00072 !             ierror = 0 : No error
00073 !             ierror > 0 : Severe error
00074 !
00075 ! !LOCAL VARIABLES
00076 !
00077       Integer                          :: i, j, jbeg
00078       Integer                          :: ijend (2)
00079       Double Precision                 :: dist_cyclic
00080 !
00081 ! !DESCRIPTION:
00082 !
00083 ! Subroutine "PSMILe_MG_ctrl_subgrid_2d_dble" controls whether
00084 ! the "control volumes" defined by the corner arrays "array" fulfill the
00085 ! internal requirements of the MG search.
00086 !
00087 ! !REVISION HISTORY:
00088 !
00089 !   Date      Programmer   Description
00090 ! ----------  ----------   -----------
00091 ! 03.06.25    H. Ritzdorf  created
00092 !
00093 !EOP
00094 !----------------------------------------------------------------------
00095 !
00096 !  $Id: psmile_mg_ctrl_subgrid_2d_dble.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_ctrl_subgrid_2d_dble.F90 2325 2010-04-21 15:00:07Z valcke $'
00101 !
00102 !----------------------------------------------------------------------
00103 !
00104 #ifdef VERBOSE
00105       print 9990, trim(ch_id)
00106 
00107       call psmile_flushstd
00108 #endif /* VERBOSE */
00109 !
00110 !  Initialization
00111 !
00112       ierror = 0
00113 !
00114       ijend(:) = min (range(1,:)+levdim(:), range (2,:)) - range (1,:)
00115 !
00116 !     Control cells and warn user
00117 !
00118       dist_cyclic = period * 0.5
00119 
00120 loopj:   do j = 0, ijend(2)
00121 !cdir vector
00122             do i = 0, ijend (1)
00123             if (chmax(i,j) - chmin (i,j) > dist_cyclic) exit loopj
00124             enddo
00125          enddo loopj
00126 !
00127       if (j <= ijend(2)) then
00128 !
00129 !     ... A cell violating the internal requirements was probably found
00130 !         Warn user !
00131 !
00132          print 9970, trim(ch_id), grid_id, trim(Grids(grid_id)%grid_name), &
00133                      name_coord(ind)
00134 !
00135          jbeg = j
00136             do j = jbeg, ijend(2)
00137                do i = 0, ijend (1)
00138                if (chmax(i,j) - chmin (i,j) > dist_cyclic) then
00139                   ierror = ierror - 1
00140                   print 9960, i+range(1,1), j+range(1,2), &
00141                        array (i+range(1,1), j+range(1,2), :)
00142                end if
00143                end do
00144             end do
00145 !
00146          print *
00147       endif
00148 !
00149 !===> All done
00150 !
00151 #ifdef VERBOSE
00152       if ( ierror == 0 ) then
00153          print 9980, trim(ch_id), ierror
00154       else
00155          print 9981, trim(ch_id), abs(ierror)     
00156       endif
00157 
00158       call psmile_flushstd
00159 #endif /* VERBOSE */
00160 !
00161 !  Formats:
00162 !
00163 9990  format (1x, a, ': psmile_mg_ctrl_subgrid_2d_dble')
00164 9980  format (1x, a, ': psmile_mg_ctrl_subgrid_2d_dble eof: ierror =', i4)
00165 9981  format (1x, a, ': psmile_mg_ctrl_subgrid_2d_dble eof: issue warning for', i8, ' cells.')
00166 
00167 9970  format (/1x, a, ': #### WARNING in psmile_mg_ctrl_subgrid_2d_dble:', &
00168               /10x, 'Cells with incorrect (periodic) corner coordinates ', &
00169                     'probably found !' &
00170               /10x, 'Grid id ', i4, '; name:', 1x, a, &
00171               /10x, 'Cell indices of ', a, ' coordinate direction:')
00172 9960  format (1x, 'Indices(', i7, ',', i7, '); coordinates', (1x, 4f16.9))
00173 !
00174       end subroutine PSMILe_MG_ctrl_subgrid_2d_dble

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1