SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/latlonmask_lonlatval.F90
Go to the documentation of this file.
00001 !     ##################################
00002       SUBROUTINE LATLONMASK_LONLATVAL(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_LONLATVAL
00045 !
00046 !
00047 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00048 USE PARKIND1  ,ONLY : JPRB
00049 !
00050 IMPLICIT NONE
00051 !
00052 !*    0.1    Declaration of arguments
00053 !            ------------------------
00054 !
00055 INTEGER,                       INTENT(IN)  :: KGRID_PAR   ! size of PGRID_PAR
00056 REAL,    DIMENSION(KGRID_PAR), INTENT(IN)  :: PGRID_PAR   ! parameters defining this grid
00057 LOGICAL, DIMENSION(720,360),   INTENT(OUT) :: OLATLONMASK ! mask where data are to be read
00058 !
00059 !*    0.2    Declaration of local variables
00060 !            ------------------------------
00061 !
00062 REAL                              :: ZXMIN    ! minimum of X for domain
00063 REAL                              :: ZXMAX    ! maximum of X for domain
00064 REAL                              :: ZLON0
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                           :: IL       ! Number og grid points
00077 INTEGER                           :: JLAT, JLON
00078 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00079 !----------------------------------------------------------------------------
00080 !
00081 IF (LHOOK) CALL DR_HOOK('LATLONMASK_LONLATVAL',0,ZHOOK_HANDLE)
00082 OLATLONMASK(:,:) = .FALSE.
00083 !
00084 !-------------------------------------------------------------------------------
00085 !
00086 !*      1.   Limits of the domain in lonlatval coordinates 
00087 !            ------------------------------------------------
00088 !
00089      CALL GET_GRIDTYPE_LONLATVAL(PGRID_PAR,KL=IL)
00090 !
00091      ALLOCATE(ZX (IL))
00092      ALLOCATE(ZY (IL))
00093      ALLOCATE(ZDX(IL))
00094      ALLOCATE(ZDY(IL))
00095 !
00096      CALL GET_GRIDTYPE_LONLATVAL(PGRID_PAR,PX=ZX,PY=ZY,PDX=ZDX,PDY=ZDY)
00097 !
00098 !*    2.     Limits of grid meshes in x and y
00099 !            --------------------------------
00100 !
00101      ZXMIN = MINVAL(ZX(:)-ZDX(:)/2.)
00102      ZXMAX = MAXVAL(ZX(:)+ZDX(:)/2.)
00103      ZYMIN = MINVAL(ZY(:)-ZDY(:)/2.)
00104      ZYMAX = MAXVAL(ZY(:)+ZDY(:)/2.)
00105      DEALLOCATE(ZX )
00106      DEALLOCATE(ZY )
00107      DEALLOCATE(ZDX)
00108      DEALLOCATE(ZDY)
00109 !
00110 !-------------------------------------------------------------------------------
00111 !
00112 !*      2.   Definition of the coordinates at center of the mask meshes
00113 !            ----------------------------------------------------------
00114 !
00115 !
00116 ZLON_MASK(:,:)= SPREAD( (/ (  JLON     /2. - 0.25 , JLON=1,720 ) /) , DIM=2, NCOPIES=360 )
00117 ZLAT_MASK(:,:)= SPREAD( (/ ( (JLAT-180)/2. - 0.25 , JLAT=1,360 ) /) , DIM=1, NCOPIES=720 )
00118 !
00119 !*      3.   Longitude correction (-180 /+180 )
00120 !            --------------------------------
00121 !
00122 ZLON0 = 0.5 * (ZXMIN+ZXMAX)
00123 ZLON_MASK(:,:)=ZLON_MASK(:,:)+NINT((ZLON0-ZLON_MASK(:,:))/360.)*360.
00124 !
00125 !*      5.   Are the points in the domain?
00126 !            ----------------------------
00127 !
00128 WHERE ((ZLON_MASK(:,:) >= ZXMIN .AND. ZLON_MASK(:,:) <= ZXMAX &
00129           .OR. ZLON_MASK(:,:) <= ZXMIN .AND. ZLON_MASK(:,:)+0.25 >= ZXMIN &
00130           .OR. ZLON_MASK(:,:) >= ZXMAX .AND. ZLON_MASK(:,:)-0.25 <= ZXMAX &
00131           .OR. ZLON_MASK(:,:)-0.25 <=ZXMIN .AND. ZLON_MASK(:,:)+0.25 >= ZXMAX) .AND. &
00132          (ZLAT_MASK(:,:) >= ZYMIN .AND. ZLAT_MASK(:,:) <= ZYMAX &
00133           .OR. ZLAT_MASK(:,:) <= ZYMIN .AND. ZLAT_MASK(:,:)+0.25 >= ZYMIN &
00134           .OR. ZLAT_MASK(:,:) >= ZYMAX .AND. ZLAT_MASK(:,:)-0.25 <= ZYMAX &
00135           .OR. ZLAT_MASK(:,:)-0.25 <=ZYMIN .AND. ZLAT_MASK(:,:)+0.25 >= ZYMAX))  
00136   OLATLONMASK(:,:) = .TRUE.
00137 END WHERE
00138 IF (LHOOK) CALL DR_HOOK('LATLONMASK_LONLATVAL',1,ZHOOK_HANDLE)
00139 !
00140 !-------------------------------------------------------------------------------
00141 END SUBROUTINE LATLONMASK_LONLATVAL