SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/latlonmask_ign.F90
Go to the documentation of this file.
00001 !     ##################################
00002       SUBROUTINE LATLONMASK_IGN(KGRID_PAR,PGRID_PAR,OLATLONMASK)
00003 !     ##################################
00004 !
00005 !!**** *LATLONMASK* builds the latitude and longitude mask including the grid
00006 !!
00007 !!    PURPOSE
00008 !!    -------
00009 !!
00010 !!    METHOD
00011 !!    ------
00012 !!
00013 !!    A simple method is used :
00014 !!
00015 !!   XMIN, XMAX, YMIN, YMAX are calculated for the grid 
00016 !!   This domain is extended to account for deformation between lambert and lat lon.
00017 !!   All lat lon values in this extended domains are set to true in the mask.
00018 !!   
00019 !!    EXTERNAL
00020 !!    --------
00021 !!
00022 !!
00023 !!    IMPLICIT ARGUMENTS
00024 !!    ------------------
00025 !!
00026 !!
00027 !!    REFERENCE
00028 !!    ---------
00029 !!
00030 !!    AUTHOR
00031 !!    ------
00032 !!
00033 !!      E. Martin       Meteo-France
00034 !!
00035 !!    MODIFICATION
00036 !!    ------------
00037 !!      
00038 !!      Original        10/2007  
00039 !----------------------------------------------------------------------------
00040 !
00041 !*    0.     DECLARATION
00042 !            -----------
00043 !
00044 USE MODE_GRIDTYPE_IGN
00045 USE MODD_IGN, ONLY : XEXPAND
00046 !
00047 !
00048 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00049 USE PARKIND1  ,ONLY : JPRB
00050 !
00051 IMPLICIT NONE
00052 !
00053 !*    0.1    Declaration of arguments
00054 !            ------------------------
00055 !
00056 INTEGER,                       INTENT(IN)  :: KGRID_PAR   ! size of PGRID_PAR
00057 REAL,    DIMENSION(KGRID_PAR), INTENT(IN)  :: PGRID_PAR   ! parameters defining this grid
00058 LOGICAL, DIMENSION(720,360),   INTENT(OUT) :: OLATLONMASK ! mask where data are to be read
00059 !
00060 !*    0.2    Declaration of local variables
00061 !            ------------------------------
00062 !
00063 REAL                              :: ZXMIN    ! minimum of X for domain
00064 REAL                              :: ZXMAX    ! maximum of X for domain
00065 REAL                              :: ZYMIN    ! minimum of Y for domain
00066 REAL                              :: ZYMAX    ! maximum of Y for domain
00067 REAL, DIMENSION(720,360)          :: ZX_MASK  ! mask points X value
00068 REAL, DIMENSION(720,360)          :: ZY_MASK  ! mask points Y value
00069 REAL, DIMENSION(720,360)          :: ZLON_MASK! mask points longitudes
00070 REAL, DIMENSION(720,360)          :: ZLAT_MASK! mask points latitudes
00071 REAL, DIMENSION(:), ALLOCATABLE   :: ZX       ! X Lambert   coordinate
00072 REAL, DIMENSION(:), ALLOCATABLE   :: ZY       ! Y Lambert   coordinate
00073 REAL, DIMENSION(:), ALLOCATABLE   :: ZDX      ! Grid dimension in X 
00074 REAL, DIMENSION(:), ALLOCATABLE   :: ZDY      ! Grid dimension in Y 
00075 !
00076 INTEGER                           :: ILAMBERT ! Lambert projection type
00077 INTEGER                           :: IL       ! Number og grid points
00078 INTEGER                           :: JLAT, JLON
00079 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00080 !----------------------------------------------------------------------------
00081 !
00082 IF (LHOOK) CALL DR_HOOK('LATLONMASK_IGN',0,ZHOOK_HANDLE)
00083 OLATLONMASK(:,:) = .FALSE.
00084 !
00085 !-------------------------------------------------------------------------------
00086 !
00087 !*      1.   Limits of the domain in Lambert IGN coordinates 
00088 !            (including expansion factor)
00089 !            ------------------------------------------------
00090 !
00091      CALL GET_GRIDTYPE_IGN(PGRID_PAR,KLAMBERT=ILAMBERT,KL=IL)
00092 !
00093      ALLOCATE(ZX (IL))
00094      ALLOCATE(ZY (IL))
00095      ALLOCATE(ZDX(IL))
00096      ALLOCATE(ZDY(IL))
00097 !
00098      CALL GET_GRIDTYPE_IGN(PGRID_PAR,PX=ZX,PY=ZY,PDX=ZDX,PDY=ZDY)
00099 !
00100 !*    2.     Limits of grid meshes in x and y
00101 !            --------------------------------
00102 !
00103      ZXMIN = MINVAL(ZX(:)-ZDX(:)/2.) - XEXPAND
00104      ZXMAX = MAXVAL(ZX(:)+ZDX(:)/2.) + XEXPAND
00105      ZYMIN = MINVAL(ZY(:)-ZDY(:)/2.) - XEXPAND
00106      ZYMAX = MAXVAL(ZY(:)+ZDY(:)/2.) + XEXPAND
00107      DEALLOCATE(ZX )
00108      DEALLOCATE(ZY )
00109      DEALLOCATE(ZDX)
00110      DEALLOCATE(ZDY)
00111 !
00112 !-------------------------------------------------------------------------------
00113 !
00114 !*      2.   Definition of the coordinates at center of the mask meshes
00115 !            ----------------------------------------------------------
00116 !
00117 !
00118 ZLON_MASK(:,:)= SPREAD( (/ (  JLON     /2. - 0.25 , JLON=1,720 ) /) , DIM=2, NCOPIES=360 )
00119 ZLAT_MASK(:,:)= SPREAD( (/ ( (JLAT-180)/2. - 0.25 , JLAT=1,360 ) /) , DIM=1, NCOPIES=720 )
00120 !
00121 !*      3.   Longitude correction (-180 /+180 )
00122 !            --------------------------------
00123 !
00124 ZLON_MASK(:,:)=ZLON_MASK(:,:)+NINT((-ZLON_MASK(:,:))/360.)*360.
00125 !
00126 !
00127 !*      4.   X and Y of the points of the mask
00128 !            ---------------------------------
00129 !
00130  CALL GET_GRIDTYPE_IGN (PGRID_PAR, KLAMBERT=ILAMBERT)
00131 DO JLAT=1,SIZE(ZLAT_MASK,2)
00132   CALL XY_IGN(ILAMBERT,ZX_MASK(:,JLAT),ZY_MASK(:,JLAT),          &
00133                 ZLAT_MASK(:,JLAT),ZLON_MASK(:,JLAT)   )  
00134 
00135 END DO
00136 !
00137 !*      5.   Are the points in the domain?
00138 !            ----------------------------
00139 !
00140 WHERE (        ZX_MASK(:,:) >= ZXMIN .AND. ZX_MASK(:,:) <= ZXMAX   &
00141            .AND. ZY_MASK(:,:) >= ZYMIN .AND. ZY_MASK(:,:) <= ZYMAX )  
00142   OLATLONMASK(:,:) = .TRUE.
00143 END WHERE
00144 IF (LHOOK) CALL DR_HOOK('LATLONMASK_IGN',1,ZHOOK_HANDLE)
00145 !
00146 !-------------------------------------------------------------------------------
00147 END SUBROUTINE LATLONMASK_IGN