SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/pack_grid_lonlat_reg.F90
Go to the documentation of this file.
00001 !     ##############################################################
00002       SUBROUTINE PACK_GRID_LONLAT_REG(KMASK_SIZE,KMASK,KGRID_PAR1,PGRID_PAR1,KGRID_PAR2,OPACK,PGRID_PAR2)
00003 !     ##############################################################
00004 !
00005 !!**** *PACK_GRID_LONLAT_REG* packs the grid definition vector
00006 !!
00007 !!    PURPOSE
00008 !!    -------
00009 !!
00010 !!    METHOD
00011 !!    ------
00012 !!   
00013 !!    REFERENCE
00014 !!    ---------
00015 !!
00016 !!    AUTHOR
00017 !!    ------
00018 !!
00019 !!    V. Masson         Meteo-France
00020 !!
00021 !!    MODIFICATION
00022 !!    ------------
00023 !!
00024 !!    Original    03/2004
00025 !!
00026 !----------------------------------------------------------------------------
00027 !
00028 !*    0.     DECLARATION
00029 !            -----------
00030 !
00031 USE MODI_PACK_SAME_RANK
00032 USE MODE_GRIDTYPE_LONLAT_REG
00033 !
00034 !
00035 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00036 USE PARKIND1  ,ONLY : JPRB
00037 !
00038 IMPLICIT NONE
00039 !
00040 !*    0.1    Declaration of arguments
00041 !            ------------------------
00042 !
00043 INTEGER,                        INTENT(IN)    :: KMASK_SIZE ! size of mask
00044 INTEGER, DIMENSION(KMASK_SIZE), INTENT(IN)    :: KMASK      ! mask used
00045 INTEGER,                        INTENT(IN)    :: KGRID_PAR1 ! size of input grid vector
00046 REAL,    DIMENSION(KGRID_PAR1), INTENT(IN)    :: PGRID_PAR1 ! parameters of input grid
00047 INTEGER,                        INTENT(INOUT) :: KGRID_PAR2 ! size of output grid vector
00048 LOGICAL,                        INTENT(IN)    :: OPACK      ! flag to pack the grid vector
00049 REAL,    DIMENSION(KGRID_PAR2), INTENT(OUT)   :: PGRID_PAR2 ! parameters of output grid
00050 !
00051 !*    0.2    Declaration of other local variables
00052 !            ------------------------------------
00053 !
00054 REAL    :: ZLONMIN ! minimum longitude (degrees)
00055 REAL    :: ZLONMAX ! maximum longitude (degrees)
00056 REAL    :: ZLATMIN ! minimum latitude  (degrees)
00057 REAL    :: ZLATMAX ! maximum latitude  (degrees)
00058 INTEGER :: ILON    ! number of points in longitude
00059 INTEGER :: ILAT    ! number of points in latitude
00060 INTEGER :: IL      ! number of points used
00061 REAL, DIMENSION(:), ALLOCATABLE    :: ZLAT1     ! latitude of all grid points
00062 REAL, DIMENSION(:), ALLOCATABLE    :: ZLON1     ! longitude of all grid points
00063 REAL, DIMENSION(:), ALLOCATABLE    :: ZLAT2     ! latitude of subset of grid points
00064 REAL, DIMENSION(:), ALLOCATABLE    :: ZLON2     ! longitude of subset of grid points
00065 
00066 !
00067 REAL, DIMENSION(:), POINTER       :: ZGRID_PAR2 ! parameters of output grid
00068 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00069 !----------------------------------------------------------------------------
00070 !
00071 !*    1.     Computes grid parameters
00072 !            ------------------------
00073 !
00074 IF (LHOOK) CALL DR_HOOK('PACK_GRID_LONLAT_REG',0,ZHOOK_HANDLE)
00075  CALL GET_GRIDTYPE_LONLAT_REG(PGRID_PAR1,ZLONMIN,ZLONMAX,     &
00076                                ZLATMIN,ZLATMAX,ILON,ILAT, IL   )  
00077 ALLOCATE(ZLAT1(IL))
00078 ALLOCATE(ZLON1(IL))
00079 !
00080  CALL GET_GRIDTYPE_LONLAT_REG(PGRID_PAR1,PLON=ZLON1,PLAT=ZLAT1)
00081 !----------------------------------------------------------------------------
00082 !
00083 !*    2.     Packs latitude and longitude arrays
00084 !            -----------------------------------
00085 !
00086 !
00087 ALLOCATE(ZLAT2(KMASK_SIZE))
00088 ALLOCATE(ZLON2(KMASK_SIZE))
00089 !
00090  CALL PACK_SAME_RANK(KMASK,ZLAT1,ZLAT2)
00091  CALL PACK_SAME_RANK(KMASK,ZLON1,ZLON2)
00092 !
00093 DEALLOCATE(ZLAT1)
00094 DEALLOCATE(ZLON1)
00095 
00096 !----------------------------------------------------------------------------
00097 !
00098 !*    3.     Stores data in new grid vector
00099 !            ------------------------------
00100 !
00101  CALL PUT_GRIDTYPE_LONLAT_REG(ZGRID_PAR2,ZLONMIN,ZLONMAX,                     &
00102                                ZLATMIN,ZLATMAX,ILON,ILAT,KMASK_SIZE,ZLON2,ZLAT2)  
00103 
00104 DEALLOCATE(ZLAT2)
00105 DEALLOCATE(ZLON2)
00106 !----------------------------------------------------------------------------
00107 !
00108 IF (OPACK) THEN
00109   PGRID_PAR2(:) = ZGRID_PAR2(:)
00110 ELSE
00111   KGRID_PAR2    = SIZE(ZGRID_PAR2(:))
00112 END IF
00113 !
00114 DEALLOCATE(ZGRID_PAR2)
00115 IF (LHOOK) CALL DR_HOOK('PACK_GRID_LONLAT_REG',1,ZHOOK_HANDLE)
00116 !-------------------------------------------------------------------------------
00117 !
00118 END SUBROUTINE PACK_GRID_LONLAT_REG