SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/grid_modif_cartesian.F90
Go to the documentation of this file.
00001 !     ################################################################
00002       SUBROUTINE GRID_MODIF_CARTESIAN(KLUOUT,KLUNAM,KGRID_PAR,KL,PGRID_PAR, &
00003                                                KGRID_PAR2,KL2,OMODIF,PGRID_PAR2      )  
00004 !     ################################################################
00005 !
00006 !!****  *GRID_MODIF_CARTESIAN* - routine to read in namelist the horizontal grid
00007 !!
00008 !!    PURPOSE
00009 !!    -------
00010 !!
00011 !!**  METHOD
00012 !!    ------
00013 !!
00014 !!    EXTERNAL
00015 !!    --------
00016 !!
00017 !!
00018 !!    IMPLICIT ARGUMENTS
00019 !!    ------------------
00020 !!
00021 !!    REFERENCE
00022 !!    ---------
00023 !!
00024 !!
00025 !!    AUTHOR
00026 !!    ------
00027 !!      V. Masson   *Meteo France*      
00028 !!
00029 !!    MODIFICATIONS
00030 !!    -------------
00031 !!      Original    01/2004 
00032 !-------------------------------------------------------------------------------
00033 !
00034 !*       0.    DECLARATIONS
00035 !              ------------
00036 !
00037 USE MODD_SURF_PAR, ONLY : NUNDEF
00038 
00039 USE MODE_POS_SURF
00040 USE MODE_GRIDTYPE_CARTESIAN
00041 !
00042 !
00043 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00044 USE PARKIND1  ,ONLY : JPRB
00045 !
00046 USE MODI_REGULAR_GRID_SPAWN
00047 !
00048 IMPLICIT NONE
00049 !
00050 !*       0.1   Declarations of arguments
00051 !              -------------------------
00052 !
00053 INTEGER,                      INTENT(IN)    :: KLUOUT     ! output listing logical unit
00054 INTEGER,                      INTENT(IN)    :: KLUNAM     ! namelist file logical unit
00055 INTEGER,                      INTENT(IN)    :: KL         ! number of points
00056 INTEGER,                      INTENT(IN)    :: KGRID_PAR  ! size of PGRID_PAR
00057 REAL, DIMENSION(KGRID_PAR),   INTENT(IN)    :: PGRID_PAR  ! parameters defining the grid
00058 INTEGER,                      INTENT(INOUT) :: KL2        ! number of points in modified grid
00059 INTEGER,                      INTENT(INOUT) :: KGRID_PAR2 ! size of PGRID_PAR2
00060 LOGICAL,                      INTENT(IN)    :: OMODIF     ! flag to modify the grid
00061 REAL, DIMENSION(KGRID_PAR2),  INTENT(OUT)   :: PGRID_PAR2 ! parameters defining the modified grid
00062 !
00063 !*       0.2   Declarations of local variables
00064 !              -------------------------------
00065 !
00066 !* initial grid
00067 REAL                              :: ZLAT0    ! reference latitude
00068 REAL                              :: ZLON0    ! reference longitude
00069 INTEGER                           :: IIMAX1   ! number of points in I direction
00070 INTEGER                           :: IJMAX1   ! number of points in J direction
00071 REAL, DIMENSION(:),   ALLOCATABLE :: ZX1      ! X conformal coordinate of grid mesh
00072 REAL, DIMENSION(:),   ALLOCATABLE :: ZY1      ! Y conformal coordinate of grid mesh
00073 REAL, DIMENSION(:),   ALLOCATABLE :: ZDX1     ! X grid mesh size
00074 REAL, DIMENSION(:),   ALLOCATABLE :: ZDY1     ! Y grid mesh size
00075 !
00076 !* new grid
00077 INTEGER                           :: IIMAX2   ! number of points in I direction
00078 INTEGER                           :: IJMAX2   ! number of points in J direction
00079 REAL, DIMENSION(:),   ALLOCATABLE :: ZX2      ! X conformal coordinate of grid mesh
00080 REAL, DIMENSION(:),   ALLOCATABLE :: ZY2      ! Y conformal coordinate of grid mesh
00081 REAL, DIMENSION(:),   ALLOCATABLE :: ZDX2     ! X grid mesh size
00082 REAL, DIMENSION(:),   ALLOCATABLE :: ZDY2     ! Y grid mesh size
00083 !
00084 !* other variables
00085 LOGICAL :: GFOUND
00086 REAL, DIMENSION(:), POINTER       :: ZGRID_PAR
00087 !
00088 !
00089 !*       0.3   Declarations of namelist
00090 !              ------------------------
00091 !
00092 INTEGER :: IXOR = 1            ! position of modified bottom left point
00093 INTEGER :: IYOR = 1            ! according to initial grid
00094 INTEGER :: IXSIZE = -999       ! number of grid meshes in initial grid to be
00095 INTEGER :: IYSIZE = -999       ! covered by the modified grid
00096 INTEGER :: IDXRATIO = 1        ! resolution ratio between modified grid
00097 INTEGER :: IDYRATIO = 1        ! and initial grid
00098 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00099 !
00100 !
00101 NAMELIST/NAM_INIFILE_CARTESIAN/IXOR,IYOR,IXSIZE,IYSIZE,IDXRATIO,IDYRATIO
00102 !
00103 !------------------------------------------------------------------------------
00104 !
00105 !*       1.    Reading of projection parameters
00106 !              --------------------------------
00107 !
00108 IF (LHOOK) CALL DR_HOOK('GRID_MODIF_CARTESIAN',0,ZHOOK_HANDLE)
00109  CALL POSNAM(KLUNAM,'NAM_INIFILE_CARTESIAN',GFOUND,KLUOUT)
00110 IF (GFOUND) READ(UNIT=KLUNAM,NML=NAM_INIFILE_CARTESIAN)
00111 !
00112 !---------------------------------------------------------------------------
00113 !
00114 !*       2.    All this information stored into pointer PGRID_PAR
00115 !              --------------------------------------------------
00116 !
00117 ALLOCATE(ZX1 (KL))
00118 ALLOCATE(ZY1 (KL))
00119 ALLOCATE(ZDX1(KL))
00120 ALLOCATE(ZDY1(KL))
00121 !
00122  CALL GET_GRIDTYPE_CARTESIAN(PGRID_PAR,ZLAT0,ZLON0,               &
00123                               IIMAX1,IJMAX1,                       &
00124                               ZX1,ZY1,ZDX1,ZDY1                    )  
00125 !
00126 !---------------------------------------------------------------------------
00127 !
00128 !*       3.    Default : no modification
00129 !              -------------------------
00130 !
00131 IF (IXSIZE==-999) IXSIZE=IIMAX1
00132 IF (IYSIZE==-999) IYSIZE=IJMAX1
00133 !
00134 !---------------------------------------------------------------------------
00135 !
00136 !*       4.    Modification of the grid
00137 !              ------------------------
00138 !
00139 !* number of points
00140 !
00141 IIMAX2=IXSIZE*IDXRATIO
00142 IJMAX2=IYSIZE*IDYRATIO
00143 !
00144 KL2 = IIMAX2 * IJMAX2
00145 !
00146 ALLOCATE(ZX2 (IIMAX2*IJMAX2))
00147 ALLOCATE(ZY2 (IIMAX2*IJMAX2))
00148 ALLOCATE(ZDX2(IIMAX2*IJMAX2))
00149 ALLOCATE(ZDY2(IIMAX2*IJMAX2))
00150 !
00151  CALL REGULAR_GRID_SPAWN(KLUOUT,                               &
00152                           KL, IIMAX1,IJMAX1,ZX1,ZY1,ZDX1,ZDY1,  &
00153                           IXOR, IYOR, IDXRATIO, IDYRATIO,       &
00154                           IXSIZE, IYSIZE,                       &
00155                           KL2, IIMAX2,IJMAX2,ZX2,ZY2,ZDX2,ZDY2  )   
00156 DEALLOCATE(ZX1)
00157 DEALLOCATE(ZY1)
00158 DEALLOCATE(ZDX1)
00159 DEALLOCATE(ZDY1)
00160 !---------------------------------------------------------------------------
00161 !
00162 !*       5.    All this information stored into pointer PGRID_PAR
00163 !              --------------------------------------------------
00164 !
00165  CALL PUT_GRIDTYPE_CARTESIAN(ZGRID_PAR,ZLAT0,ZLON0,               &
00166                               IIMAX2,IJMAX2,                       &
00167                               ZX2,ZY2,ZDX2,ZDY2                    )  
00168 !
00169 !---------------------------------------------------------------------------
00170 DEALLOCATE(ZX2)
00171 DEALLOCATE(ZY2)
00172 DEALLOCATE(ZDX2)
00173 DEALLOCATE(ZDY2)
00174 !---------------------------------------------------------------------------
00175 !
00176 !* 1st call : initializes dimension
00177 !
00178 IF (KGRID_PAR2==0) THEN
00179   KGRID_PAR2 = SIZE(ZGRID_PAR)
00180 !
00181 ELSE
00182 !
00183 !* 2nd call : initializes grid array
00184 !
00185   PGRID_PAR2(:) = 0.
00186   PGRID_PAR2(:) = ZGRID_PAR
00187 END IF
00188 !
00189 DEALLOCATE(ZGRID_PAR)
00190 IF (LHOOK) CALL DR_HOOK('GRID_MODIF_CARTESIAN',1,ZHOOK_HANDLE)
00191 !
00192 !---------------------------------------------------------------------------
00193 !
00194 END SUBROUTINE GRID_MODIF_CARTESIAN