SURFEX v7.3
General documentation of Surfex
 All Classes Files Functions Variables Typedefs
/home/dasprezs/EXPORT_v7_3/src/SURFEX/read_netcdf.F90
Go to the documentation of this file.
00001 !     #########
00002       SUBROUTINE READ_NETCDF(HPROGRAM,HSUBROUTINE,HFILENAME,HNCVARNAME)
00003 !     ##############################################################
00004 !
00005 !!**** *READ_NETCDF* reads a netcdf file and copy lat/lon/val then call treatment 
00006 !!                   subroutine
00007 !!
00008 !!    PURPOSE
00009 !!    -------
00010 !!
00011 !!    AUTHOR
00012 !!    ------
00013 !!
00014 !!    C. Lebeaupin Brossier Meteo-France
00015 !!
00016 !!    MODIFICATION
00017 !!    ------------
00018 !!
00019 !!    Original    01/2008
00020 !!
00021 !----------------------------------------------------------------------------
00022 !
00023 !*    0.     DECLARATION
00024 !            -----------
00025 !
00026 USE MODD_PGD_GRID,   ONLY : LLATLONMASK
00027 !
00028 USE MODI_PT_BY_PT_TREATMENT
00029 USE MODE_READ_CDF
00030 !
00031 !
00032 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
00033 USE PARKIND1  ,ONLY : JPRB
00034 !
00035 USE MODI_GET_LUOUT
00036 IMPLICIT NONE
00037 !
00038 !*    0.1    Declaration of arguments
00039 !            ------------------------
00040 !
00041  CHARACTER(LEN=6),  INTENT(IN) :: HPROGRAM      ! Type of program
00042  CHARACTER(LEN=6),  INTENT(IN) :: HSUBROUTINE   ! Name of the subroutine to call
00043  CHARACTER(LEN=28), INTENT(IN) :: HFILENAME     ! Name of the field file.
00044  CHARACTER(LEN=28), INTENT(IN) :: HNCVARNAME    ! Name of the variable in netcdf file
00045 !
00046 !
00047 !*    0.2    Declaration of local variables
00048 !            ------------------------------
00049 !
00050 INTEGER      :: JLAT, JLON                 ! indexes of OLATLONMASK array
00051 REAL         :: ZVALUE                     ! values of a data point
00052 REAL         :: ZLAT                       ! latitude of data point
00053 REAL         :: ZLON                       ! longitude of data point
00054 !
00055 REAL, DIMENSION(:),ALLOCATABLE :: ZVALU    ! array of values extract from netcdf file
00056 REAL, DIMENSION(:),ALLOCATABLE :: ZLONG    ! array of values extract from netcdf file
00057 REAL, DIMENSION(:),ALLOCATABLE :: ZLATI    ! array of values extract from netcdf file
00058 !
00059 INTEGER      :: ILUOUT                     ! output listing
00060 INTEGER      :: JLOOP                      ! loop indice
00061 INTEGER      :: JDIMENSION                 ! dimensions of ZVALU,ZLAT, 
00062 REAL(KIND=JPRB) :: ZHOOK_HANDLE
00063                                            ! and ZLON arrays
00064 !----------------------------------------------------------------------------
00065 !
00066 IF (LHOOK) CALL DR_HOOK('READ_NETCDF',0,ZHOOK_HANDLE)
00067  CALL GET_LUOUT(HPROGRAM,ILUOUT)
00068 !
00069 !
00070 !*    1.      Read the netcdf file and lat/lon/val arrays dimensions
00071 !             ------------------------------------------------------
00072  CALL READ_DIM_CDF(HFILENAME,HNCVARNAME,JDIMENSION)
00073 ALLOCATE(ZVALU(JDIMENSION))
00074 ALLOCATE(ZLATI(JDIMENSION))
00075 ALLOCATE(ZLONG(JDIMENSION))
00076 
00077 !*    1.      Read the netcdf file and extract lat/lon/val
00078 !             --------------------------------------------
00079  CALL READ_LATLONVAL_CDF(HFILENAME,HNCVARNAME,ZLONG(:),ZLATI(:),ZVALU(:))
00080 !
00081 !----------------------------------------------------------------------------
00082 !
00083 !*    4.     Test if point is in the domain
00084 !            ------------------------------
00085 !
00086 DO JLOOP=1,SIZE(ZVALU)
00087 ! 
00088   ZLON  = ZLONG(JLOOP)
00089   ZLAT  = ZLATI(JLOOP)
00090   ZVALUE= ZVALU(JLOOP)
00091 ! 
00092   ZLON=ZLON+NINT((180.-ZLON)/360.)*360.
00093   !
00094   JLAT = 1 + INT( ( ZLAT + 90. ) * 2. )
00095   JLAT = MIN(JLAT,360)
00096   JLON = 1 + INT( ( ZLON       ) * 2. )
00097   JLON = MIN(JLON,720)
00098   !
00099   IF (.NOT. LLATLONMASK(JLON,JLAT)) CYCLE
00100 !
00101 !-------------------------------------------------------------------------------
00102 !
00103 !*    5.     Call to the adequate subroutine (point by point treatment)
00104 !            ----------------------------------------------------------
00105 ! 
00106   CALL PT_BY_PT_TREATMENT(ILUOUT,  (/ ZLAT /) , (/ ZLON /) , (/ ZVALUE /) , &
00107                             HSUBROUTINE                                       )  
00108 !
00109 !-------------------------------------------------------------------------------
00110 ENDDO
00111 IF (ALLOCATED(ZVALU       ))  DEALLOCATE(ZVALU  )
00112 IF (ALLOCATED(ZLONG       ))  DEALLOCATE(ZLONG  )
00113 IF (ALLOCATED(ZLATI       ))  DEALLOCATE(ZLATI  )
00114 IF (LHOOK) CALL DR_HOOK('READ_NETCDF',1,ZHOOK_HANDLE)
00115 !
00116 !----------------------------------------------------------------------------
00117 !
00118 !-------------------------------------------------------------------------------
00119 !
00120 END SUBROUTINE READ_NETCDF