SURFEX v8.1
General documentation of Surfex
read_netcdf.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE read_netcdf (UG, U, USS, &
7  HPROGRAM,HSUBROUTINE,HFILENAME,HNCVARNAME)
8 ! ##############################################################
9 !
10 !!**** *READ_NETCDF* reads a netcdf file and copy lat/lon/val then call treatment
11 !! subroutine
12 !!
13 !! PURPOSE
14 !! -------
15 !!
16 !! AUTHOR
17 !! ------
18 !!
19 !! C. Lebeaupin Brossier Meteo-France
20 !!
21 !! MODIFICATION
22 !! ------------
23 !!
24 !! Original 01/2008
25 !!
26 !----------------------------------------------------------------------------
27 !
28 !* 0. DECLARATION
29 ! -----------
30 !
31 !
33 USE modd_surf_atm_n, ONLY : surf_atm_t
34 USE modd_sso_n, ONLY : sso_t
35 !
36 USE modd_pgd_grid, ONLY : llatlonmask
37 !
38 USE modi_pt_by_pt_treatment
39 USE mode_read_cdf
40 !
41 !
42 USE yomhook ,ONLY : lhook, dr_hook
43 USE parkind1 ,ONLY : jprb
44 !
45 USE modi_get_luout
46 IMPLICIT NONE
47 !
48 !* 0.1 Declaration of arguments
49 ! ------------------------
50 !
51 !
52 TYPE(surf_atm_grid_t), INTENT(INOUT) :: UG
53 TYPE(surf_atm_t), INTENT(INOUT) :: U
54 TYPE(sso_t), INTENT(INOUT) :: USS
55 !
56  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! Type of program
57  CHARACTER(LEN=6), INTENT(IN) :: HSUBROUTINE ! Name of the subroutine to call
58  CHARACTER(LEN=28), INTENT(IN) :: HFILENAME ! Name of the field file.
59  CHARACTER(LEN=28), INTENT(IN) :: HNCVARNAME ! Name of the variable in netcdf file
60 !
61 !
62 !* 0.2 Declaration of local variables
63 ! ------------------------------
64 !
65 INTEGER :: JLAT, JLON ! indexes of OLATLONMASK array
66 REAL :: ZVALUE ! values of a data point
67 REAL :: ZLAT ! latitude of data point
68 REAL :: ZLON ! longitude of data point
69 !
70 REAL, DIMENSION(:),ALLOCATABLE :: ZVALU ! array of values extract from netcdf file
71 REAL, DIMENSION(:),ALLOCATABLE :: ZLONG ! array of values extract from netcdf file
72 REAL, DIMENSION(:),ALLOCATABLE :: ZLATI ! array of values extract from netcdf file
73 !
74 INTEGER :: ILUOUT ! output listing
75 INTEGER :: JLOOP ! loop indice
76 INTEGER :: JDIMENSION ! dimensions of ZVALU,ZLAT,
77 REAL(KIND=JPRB) :: ZHOOK_HANDLE
78  ! and ZLON arrays
79 !----------------------------------------------------------------------------
80 !
81 IF (lhook) CALL dr_hook('READ_NETCDF',0,zhook_handle)
82  CALL get_luout(hprogram,iluout)
83 !
84 !
85 !* 1. Read the netcdf file and lat/lon/val arrays dimensions
86 ! ------------------------------------------------------
87  CALL read_dim_cdf(hfilename,hncvarname,jdimension)
88 ALLOCATE(zvalu(jdimension))
89 ALLOCATE(zlati(jdimension))
90 ALLOCATE(zlong(jdimension))
91 
92 !* 1. Read the netcdf file and extract lat/lon/val
93 ! --------------------------------------------
94  CALL read_latlonval_cdf(hfilename,hncvarname,zlong(:),zlati(:),zvalu(:))
95 !
96 !----------------------------------------------------------------------------
97 !
98 !* 4. Test if point is in the domain
99 ! ------------------------------
100 !
101 DO jloop=1,SIZE(zvalu)
102 !
103  zlon = zlong(jloop)
104  zlat = zlati(jloop)
105  zvalue= zvalu(jloop)
106 !
107  zlon=zlon+nint((180.-zlon)/360.)*360.
108  !
109  jlat = 1 + int( ( zlat + 90. ) * 2. )
110  jlat = min(jlat,360)
111  jlon = 1 + int( ( zlon ) * 2. )
112  jlon = min(jlon,720)
113  !
114  IF (.NOT. llatlonmask(jlon,jlat)) cycle
115 !
116 !-------------------------------------------------------------------------------
117 !
118 !* 5. Call to the adequate subroutine (point by point treatment)
119 ! ----------------------------------------------------------
120 !
121  CALL pt_by_pt_treatment(ug, u, uss, &
122  iluout, (/ zlat /) , (/ zlon /) , (/ zvalue /) , &
123  hsubroutine )
124 !
125 !-------------------------------------------------------------------------------
126 ENDDO
127 IF (ALLOCATED(zvalu )) DEALLOCATE(zvalu )
128 IF (ALLOCATED(zlong )) DEALLOCATE(zlong )
129 IF (ALLOCATED(zlati )) DEALLOCATE(zlati )
130 IF (lhook) CALL dr_hook('READ_NETCDF',1,zhook_handle)
131 !
132 !----------------------------------------------------------------------------
133 !
134 !-------------------------------------------------------------------------------
135 !
136 END SUBROUTINE read_netcdf
logical, dimension(720, 360) llatlonmask
subroutine read_latlonval_cdf(HFILENAME, HNCVARNAME, PLON, PLAT, PVAL)
integer, parameter jprb
Definition: parkind1.F90:32
subroutine pt_by_pt_treatment(UG, U, USS, KLUOUT, PLAT, PLON, PVALUE, HSUBROUTINE
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15
subroutine read_netcdf(UG, U, USS, HPROGRAM, HSUBROUTINE, HFILENAME, HNCVARNAME)
Definition: read_netcdf.F90:8
subroutine read_dim_cdf(HFILENAME, HNCVARNAME, KDIM)