SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/read_nam_grid_ign.F90
Go to the documentation of this file.
00001 !     ################################################################
00002       SUBROUTINE READ_NAM_GRID_IGN(HPROGRAM,KGRID_PAR,KL,PGRID_PAR)
00003 !     ################################################################
00004 !
00005 !!****  *READ_NAM_GRID_IGN* - routine to read in namelist the horizontal grid
00006 !!
00007 !!    PURPOSE
00008 !!    -------
00009 !!
00010 !!**  METHOD
00011 !!    ------
00012 !!
00013 !!    EXTERNAL
00014 !!    --------
00015 !!
00016 !!
00017 !!    IMPLICIT ARGUMENTS
00018 !!    ------------------
00019 !!
00020 !!    REFERENCE
00021 !!    ---------
00022 !!
00023 !!
00024 !!    AUTHOR
00025 !!    ------
00026 !!      E. Martin   *Meteo France*      
00027 !!
00028 !!    MODIFICATIONS
00029 !!    -------------
00030 !!      Original    10/2007 
00031 !!      07/2011     add maximum domain dimension for output (B. Decharme)
00032 !-------------------------------------------------------------------------------
00033 !
00034 !*       0.    DECLARATIONS
00035 !              ------------
00036 !
00037 USE MODD_SURF_PAR, ONLY : XUNDEF
00038 !
00039 USE MODE_POS_SURF
00040 !
00041 USE MODI_OPEN_NAMELIST
00042 USE MODI_CLOSE_NAMELIST
00043 USE MODI_GET_LUOUT
00044 USE MODI_TEST_NAM_VAR_SURF
00045 !
00046 USE MODE_GRIDTYPE_IGN
00047 USE MODI_GET_XYALL_IGN
00048 !
00049 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00050 USE PARKIND1  ,ONLY : JPRB
00051 !
00052 IMPLICIT NONE
00053 !
00054 !*       0.1   Declarations of arguments
00055 !              -------------------------
00056 !
00057  CHARACTER(LEN=6),           INTENT(IN)    :: HPROGRAM   ! calling program
00058 INTEGER,                    INTENT(INOUT) :: KGRID_PAR  ! size of PGRID_PAR
00059 INTEGER,                    INTENT(OUT)   :: KL         ! number of points
00060 REAL, DIMENSION(KGRID_PAR), INTENT(OUT)   :: PGRID_PAR  ! parameters defining this grid
00061 !
00062 !*       0.2   Declarations of local variables
00063 !              -------------------------------
00064 !
00065 INTEGER :: ILUOUT ! output listing logical unit
00066 INTEGER :: ILUNAM ! namelist file  logical unit
00067 INTEGER :: ILAMBERT ! Lambert type
00068 
00069 REAL, DIMENSION(:),   ALLOCATABLE :: ZX       ! X conformal coordinate of grid mesh
00070 REAL, DIMENSION(:),   ALLOCATABLE :: ZY       ! Y conformal coordinate of grid mesh
00071 REAL, DIMENSION(:),   ALLOCATABLE :: ZDX      ! X grid mesh size
00072 REAL, DIMENSION(:),   ALLOCATABLE :: ZDY      ! Y grid mesh size
00073 !
00074 !*       0.3   Declarations of namelist
00075 !              ------------------------
00076 !
00077  CHARACTER(LEN=3) :: CLAMBERT  ! Lambert type
00078 INTEGER :: NPOINTS  ! number of points
00079 REAL, DIMENSION(100000) :: XX  ! X coordinate of grid mesh center (in meters)
00080 REAL, DIMENSION(100000) :: XY  ! Y coordinate of grid mesh center (in meters)
00081 REAL, DIMENSION(100000) :: XDX ! X mesh size (in meters)
00082 REAL, DIMENSION(100000) :: XDY ! Y mesh size (in meters)
00083 !
00084 REAL :: XX_LLCORNER ! X coordinate of left  side of the domain
00085 REAL :: XY_LLCORNER ! Y coordinate of lower side of the domain
00086 REAL :: XCELLSIZE   ! size of the cell (equal in X and Y)
00087 INTEGER :: NCOLS    ! number of columns
00088 INTEGER :: NROWS    ! number of rows
00089 !
00090 REAL, DIMENSION(:), ALLOCATABLE :: ZXALL  ! maximum domain X coordinate of grid mesh
00091 REAL, DIMENSION(:), ALLOCATABLE :: ZYALL  ! maximum domain Y coordinate of grid mesh
00092 INTEGER                         :: IDIMX  ! maximum domain length in X
00093 INTEGER                         :: IDIMY  ! maximum domain length in Y
00094 !
00095 REAL, DIMENSION(:), POINTER :: ZGRID_PAR
00096 !
00097 INTEGER :: JCOLS, JROWS, IINDEX ! loop counters
00098 LOGICAL :: GFOUND
00099 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00100 !
00101 NAMELIST/NAM_IGN/CLAMBERT,NPOINTS,XX,XY,XDX,XDY,      &
00102                  XX_LLCORNER, XY_LLCORNER, XCELLSIZE, &
00103                  NCOLS, NROWS
00104 !
00105 !------------------------------------------------------------------------------
00106 !
00107 !*       1.    opening of namelist
00108 ! 
00109 IF (LHOOK) CALL DR_HOOK('READ_NAM_GRID_IGN',0,ZHOOK_HANDLE)
00110  CALL GET_LUOUT(HPROGRAM,ILUOUT)
00111 !
00112  CALL OPEN_NAMELIST(HPROGRAM,ILUNAM)
00113 !
00114 XX_LLCORNER = XUNDEF
00115 XY_LLCORNER = XUNDEF
00116 XCELLSIZE   = XUNDEF
00117 NCOLS = 0
00118 NROWS = 0
00119 !
00120 !---------------------------------------------------------------------------
00121 !
00122 !*       2.    Reading of projection parameters
00123 !              --------------------------------
00124 !
00125  CALL POSNAM(ILUNAM,'NAM_IGN',GFOUND,ILUOUT)
00126 IF (GFOUND) READ(UNIT=ILUNAM,NML=NAM_IGN)
00127 !
00128 !---------------------------------------------------------------------------
00129  CALL CLOSE_NAMELIST(HPROGRAM,ILUNAM)
00130 !---------------------------------------------------------------------------
00131 !
00132 !*       3.    Initialisation for a regular grid
00133 !              ---------------------------------
00134 !
00135 IF (XCELLSIZE/=XUNDEF) THEN
00136   !
00137   WRITE(ILUOUT,*) 'Initialisation of IGN Coordinates for a regular grid'
00138   !      
00139   XDX(:) = XCELLSIZE
00140   XDY(:) = XCELLSIZE
00141   !
00142   IF ( XX_LLCORNER/=XUNDEF .AND. XY_LLCORNER/=XUNDEF &
00143             .AND. NCOLS>0 .AND. NROWS>0 ) THEN
00144     !
00145     NPOINTS = NCOLS * NROWS
00146     !
00147     DO JROWS=1,NROWS
00148       DO JCOLS=1,NCOLS
00149         !
00150         IINDEX = JCOLS + (JROWS-1) * NCOLS
00151         XX(IINDEX) = XX_LLCORNER + (JCOLS-0.5) * XCELLSIZE
00152         XY(IINDEX) = XY_LLCORNER + (JROWS-0.5) * XCELLSIZE
00153         !
00154       END DO
00155     END DO
00156     !
00157   ENDIF
00158   !
00159 END IF
00160 !
00161 !---------------------------------------------------------------------------
00162 !
00163 !*       3.    Number of points
00164 !              ----------------
00165 !
00166 KL = NPOINTS
00167 !
00168 !---------------------------------------------------------------------------
00169 !
00170 !*       3.    Array of X and Y coordinates
00171 !              ----------------------------
00172 !
00173 !
00174 ALLOCATE(ZX(KL))
00175 ALLOCATE(ZY(KL))
00176 ZX(:) = XX(:KL)
00177 ZY(:) = XY(:KL)
00178 !
00179 !---------------------------------------------------------------------------
00180 !
00181 !*       4.    Array of X and Y increments
00182 !              ---------------------------
00183 !
00184 ALLOCATE(ZDX(KL))
00185 ALLOCATE(ZDY(KL))
00186 ZDX(:) = XDX(:KL)
00187 ZDY(:) = XDY(:KL)
00188 !
00189 !---------------------------------------------------------------------------
00190 !
00191 !*       5.    Lambert type
00192 !              ------------
00193 !
00194  CALL TEST_NAM_VAR_SURF(ILUOUT,'CLAMBERT',CLAMBERT,'L1 ','L2 ','L3 ',&
00195                          'L4 ','L2E','L93' )  
00196 !
00197 SELECT CASE (CLAMBERT)
00198   CASE ('L1 ')
00199     ILAMBERT=1
00200   CASE ('L2 ')
00201     ILAMBERT=2
00202   CASE ('L3 ')
00203     ILAMBERT=3
00204   CASE ('L4 ')
00205     ILAMBERT=4
00206   CASE ('L2E')
00207     ILAMBERT=5
00208   CASE ('L93')
00209     ILAMBERT=6
00210 END SELECT
00211 !
00212 !---------------------------------------------------------------------------
00213 !
00214 !*       7.    maximum domain lengths
00215 !              ----------------------
00216 !
00217 ALLOCATE(ZXALL(KL*3))
00218 ALLOCATE(ZYALL(KL*3))
00219  CALL GET_XYALL_IGN(ZX,ZY,ZDX,ZDY,ZXALL,ZYALL,IDIMX,IDIMY)
00220 !
00221 !---------------------------------------------------------------------------
00222 !
00223 !*       8.    All this information stored into pointer PGRID_PAR
00224 !              --------------------------------------------------
00225 !
00226  CALL PUT_GRIDTYPE_IGN(ZGRID_PAR,ILAMBERT,ZX,ZY,ZDX,ZDY,        &
00227                       IDIMX,IDIMY,ZXALL(1:IDIMX),ZYALL(1:IDIMY))
00228 !
00229 !---------------------------------------------------------------------------
00230 DEALLOCATE(ZX)
00231 DEALLOCATE(ZY)
00232 DEALLOCATE(ZDX)
00233 DEALLOCATE(ZDY)
00234 DEALLOCATE(ZXALL)
00235 DEALLOCATE(ZYALL)
00236 !---------------------------------------------------------------------------
00237 !
00238 !* 1st call : initializes dimension
00239 !
00240 IF (KGRID_PAR==0) THEN
00241   KGRID_PAR = SIZE(ZGRID_PAR)
00242 !
00243 ELSE
00244 !
00245 !* 2nd call : initializes grid array
00246 !
00247   PGRID_PAR(:) = 0.
00248   PGRID_PAR(:) = ZGRID_PAR
00249 END IF
00250 !
00251 DEALLOCATE(ZGRID_PAR)
00252 IF (LHOOK) CALL DR_HOOK('READ_NAM_GRID_IGN',1,ZHOOK_HANDLE)
00253 !
00254 !---------------------------------------------------------------------------
00255 !
00256 END SUBROUTINE READ_NAM_GRID_IGN