psmile_range_subgrid_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_Range_Subgrid_2d_real
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_range_subgrid_2d_real (           &
00012                     array1, array2,                       &
00013                             idlow, idhigh, jdlow, jdhigh, &
00014                             nbr_corners,                  &
00015                             ibeg, iend, jbeg, jend,       &
00016                     rinter, inter, ierror)
00017 !
00018 ! !USES:
00019 !
00020       use PRISM_constants
00021 !
00022       use PSMILe, dummy_interface => PSMILe_Range_Subgrid_2d_real
00023 
00024       implicit none
00025 !
00026 ! !INPUT PARAMETERS:
00027 !
00028       integer, Intent (In)             :: idlow, idhigh
00029       integer, Intent (In)             :: jdlow, jdhigh
00030       integer, Intent (In)             :: nbr_corners
00031 
00032 !     Dimensions of "array1" and "array2"
00033 
00034       real, Intent (In)                :: array1 (idlow:idhigh, 
00035                                                   jdlow:jdhigh, 
00036                                                   nbr_corners)
00037       real, Intent (In)                :: array2 (idlow:idhigh, 
00038                                                   jdlow:jdhigh, 
00039                                                   nbr_corners)
00040 
00041 !     Fully dimensioned arrays for which the range of 2d-intersection
00042 !     should be computed.
00043 
00044       integer, Intent (In)             :: ibeg, iend, jbeg, jend
00045 
00046 !     Definintion of the subgrid
00047 
00048       Real, Intent (In)                :: rinter (2, 2)
00049 
00050 !     Specifies the intersection for which the range should be found.
00051 !
00052 ! !OUTPUT PARAMETERS:
00053 !
00054       Integer, Intent (Out)            :: inter (2, 2)
00055 
00056 !     Returns the range of the intersection
00057 
00058       integer, Intent (Out)            :: ierror
00059 
00060 !     Returns the error code of PSMILe_Range_Subgrid_2d_real;
00061 !             ierror = 0 : No error
00062 !             ierror > 0 : Severe error
00063 !
00064 ! !DEFINED PARAMETERS:
00065 !
00066       logical, parameter :: all = .true. ! Brut force
00067 !
00068 ! !LOCAL VARIABLES
00069 !
00070       integer            :: i, j
00071 !
00072       logical            :: same
00073 !
00074 ! !DESCRIPTION:
00075 !
00076 ! Subroutine "PSMILe_Range_Subgrid_2d_Real" computes the range of
00077 ! of grid contained in array~(ibeg:iend,~jbeg:jend,~nbr_corners) which contains
00078 ! the intersection "rinter"
00079 !
00080 !
00081 ! !REVISION HISTORY:
00082 !   Date      Programmer   Description
00083 ! ----------  ----------   -----------
00084 ! 01.12.03    H. Ritzdorf  created
00085 !
00086 !EOP
00087 !----------------------------------------------------------------------
00088 !
00089 ! $Id: psmile_range_subgrid_2d_real.F90 2325 2010-04-21 15:00:07Z valcke $
00090 ! $Author: valcke $
00091 !
00092    Character(len=len_cvs_string), save :: mycvs = 
00093        '$Id: psmile_range_subgrid_2d_real.F90 2325 2010-04-21 15:00:07Z valcke $'
00094 !
00095 !----------------------------------------------------------------------
00096 
00097 #ifdef VERBOSE
00098       print *, trim(ch_id), ': PSMILe_Range_Subgrid_2d_real'
00099 
00100       call psmile_flushstd
00101 #endif /* VERBOSE */
00102 !
00103 !  Initialization
00104 !
00105       ierror = 0
00106 !
00107       inter (1, 1) = iend + 1
00108       inter (2, 1) = ibeg - 1
00109       inter (1, 2) = jend + 1
00110       inter (2, 2) = jbeg - 1
00111 !
00112       same = ibeg == idlow .and. iend == idhigh
00113 !
00114       if (same .or. all) then
00115 !
00116          do j = jbeg, jend
00117 !cdir vector
00118             do i = idlow, idhigh
00119             if (maxval(array1(i,j,:)) >= rinter (1,1) .and. &
00120                 minval(array1(i,j,:)) <= rinter (2,1) .and. &
00121                 maxval(array2(i,j,:)) >= rinter (1,2) .and. &
00122                 minval(array2(i,j,:)) <= rinter (2,2)) then
00123                inter (1, 1) = min (inter (1,1), i)
00124                inter (2, 1) = max (inter (2,1), i)
00125                inter (1, 2) = min (inter (1,2), j)
00126                inter (2, 2) = max (inter (2,2), j)
00127             endif
00128             end do
00129          end do
00130 !
00131          if (all .and. .not. same) then
00132             inter (1, 1) = max (inter (1,1), ibeg)
00133             inter (2, 1) = min (inter (2,1), iend)
00134          endif
00135 !
00136       else
00137 !
00138          do j = jbeg, jend
00139 !cdir vector
00140             do i = ibeg, iend
00141             if (maxval(array1(i,j,:)) >= rinter (1,1) .and. &
00142                 minval(array1(i,j,:)) <= rinter (2,1) .and. &
00143                 maxval(array2(i,j,:)) >= rinter (1,2) .and. &
00144                 minval(array2(i,j,:)) <= rinter (2,2)) then
00145                inter (1, 1) = min (inter (1,1), i)
00146                inter (2, 1) = max (inter (2,1), i)
00147                inter (1, 2) = min (inter (1,2), j)
00148                inter (2, 2) = max (inter (2,2), j)
00149             endif
00150             end do
00151          end do
00152       endif
00153 !
00154 !===> All done
00155 !
00156 #ifdef VERBOSE
00157       print *, trim(ch_id), ': PSMILe_Range_Subgrid_2d_real eof', &
00158                             ': ierror =', ierror &
00159                           , '; inter  =', inter
00160 
00161       call psmile_flushstd
00162 #endif /* VERBOSE */
00163 !
00164       end subroutine PSMILe_Range_Subgrid_2d_real

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1