SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
read_nam_grid_gauss.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_nam_grid_gauss(HPROGRAM,KGRID_PAR,KL,PGRID_PAR)
7 !################################################################
8 !
9 !!**** *READ_NAM_GRID_GAUSS* - routine to read in namelist the horizontal grid
10 !!
11 !! PURPOSE
12 !! -------
13 !!
14 !!** METHOD
15 !! ------
16 !!
17 !! EXTERNAL
18 !! --------
19 !!
20 !!
21 !! IMPLICIT ARGUMENTS
22 !! ------------------
23 !!
24 !! REFERENCE
25 !! ---------
26 !!
27 !!
28 !! AUTHOR
29 !! ------
30 !! V. Masson *Meteo France*
31 !!
32 !! MODIFICATIONS
33 !! -------------
34 !! Original 01/2004
35 !! B. Decharme 2008 Comput and save the Mesh size
36 !! 2013 Bug lat and lon for non rotat-strech grid
37 !! Grid corner (used with oasis)
38 !-------------------------------------------------------------------------------
39 !
40 !* 0. DECLARATIONS
41 ! ------------
42 !
43 USE modd_csts, ONLY : xpi
44 USE modd_surf_par, ONLY : xundef
45 !
46 USE mode_pos_surf
47 !
48 USE modi_open_namelist
49 USE modi_close_namelist
50 USE modi_get_luout
51 !
53 !
54 USE eggangles , ONLY : p_asin
55 !
56 !
57 USE yomhook ,ONLY : lhook, dr_hook
58 USE parkind1 ,ONLY : jprb
59 !
60 USE modi_abor1_sfx
61 !
62 IMPLICIT NONE
63 !
64 !* 0.1 Declarations of arguments
65 ! -------------------------
66 !
67  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! calling program
68 INTEGER, INTENT(INOUT) :: kgrid_par ! size of PGRID_PAR
69 INTEGER, INTENT(OUT) :: kl ! number of points
70 REAL, DIMENSION(KGRID_PAR), INTENT(OUT) :: pgrid_par ! parameters defining this grid
71 !
72 !* 0.2 Declarations of local variables
73 ! -------------------------------
74 !
75 INTEGER :: iluout ! output listing logical unit
76 INTEGER :: ilunam ! namelist file logical unit
77 REAL, DIMENSION(:), ALLOCATABLE :: zlat_xy ! pseudo-latitudes
78 REAL, DIMENSION(:), ALLOCATABLE :: zlon_xy ! pseudo-longitudes
79 REAL, DIMENSION(:), ALLOCATABLE :: zlat ! latitudes
80 REAL, DIMENSION(:), ALLOCATABLE :: zlon ! longitudes
81 REAL, DIMENSION(:), ALLOCATABLE :: zmesh_size ! Mesh size
82 ! _____ Sup
83 REAL, DIMENSION(:), ALLOCATABLE :: zlatsup ! Grid corner Latitude | |
84 REAL, DIMENSION(:), ALLOCATABLE :: zlonsup ! Grid corner Longitude | |
85 REAL, DIMENSION(:), ALLOCATABLE :: zlatinf ! Grid corner Latitude |_____|
86 REAL, DIMENSION(:), ALLOCATABLE :: zloninf ! Grid corner Longitude Inf
87 !
88 REAL, DIMENSION(:), ALLOCATABLE :: zxinf ! pseudo-longitude western limit of grid mesh
89 REAL, DIMENSION(:), ALLOCATABLE :: zxsup ! pseudo-longitude eastern limit of grid mesh
90 REAL, DIMENSION(:), ALLOCATABLE :: zyinf ! pseudo-latitude southern limit of grid mesh
91 REAL, DIMENSION(:), ALLOCATABLE :: zysup ! pseudo-latitude northern limit of grid mesh
92 !
93 !* 0.3 Declarations of namelist
94 ! ------------------------
95 !
96 INTEGER :: ndglg ! number of pseudo-latitudes
97 REAL :: rmucen ! sine of the latitude of the rotated pole
98 REAL :: rlocen ! longitude of the rotated pole (radian)
99 REAL :: rstret ! stretching factor (must be greater than or equal to 1)
100 INTEGER, DIMENSION(1000) :: nrgri ! number of pseudo-longitudes on each
101  ! pseudo-latitude circle on pseau
102  ! northern hemisphere (starting from
103  ! the rotated pole)
104 !
105 REAL :: zlapo ! latitude of the rotated pole (deg)
106 REAL :: zlopo ! longitude of the rotated pole (deg)
107 REAL :: zcodil ! stretching factor (must be greater than or equal to 1)
108 INTEGER :: ityp ! type of transform (0 --> no rotation, 1 otherwise)
109 INTEGER :: inlati ! number of latitudes
110 INTEGER, DIMENSION(:), ALLOCATABLE :: inlopa ! number of pseudo-longitudes on each
111  ! pseudo-latitude circle
112 
113 INTEGER :: jstglo
114 
115 !
116 REAL, DIMENSION(:), POINTER :: zgrid_par
117 !
118 LOGICAL :: gfound
119 REAL(KIND=JPRB) :: zhook_handle
120 !
121 namelist/namdim/ndglg
122 namelist/namgem/rmucen, rlocen, rstret
123 namelist/namrgri/nrgri
124 !
125 !------------------------------------------------------------------------------
126 !
127 !* 1. Default values
128 !
129 IF (lhook) CALL dr_hook('READ_NAM_GRID_GAUSS',0,zhook_handle)
130 ndglg = 0
131 rmucen = 1.
132 rlocen = xpi
133 rstret = 1.
134 !
135 nrgri(:) = 0
136 !------------------------------------------------------------------------------
137 !
138 !* 2. opening of namelist
139 !
140  CALL get_luout(hprogram,iluout)
141 !
142  CALL open_namelist(hprogram,ilunam)
143 !
144 !---------------------------------------------------------------------------
145 !
146 !* 3. Reading of projection parameters
147 ! --------------------------------
148 !
149  CALL posnam(ilunam,'NAMGEM',gfound,iluout)
150 IF (gfound) READ(unit=ilunam,nml=namgem)
151 !
152 IF (rstret<1.) THEN
153  WRITE(iluout,*) '****************************************************'
154  WRITE(iluout,*) 'stretching factor RSTRET for the Gaussian grid'
155  WRITE(iluout,*) 'definition must be greater than or equal to 1'
156  WRITE(iluout,*) 'You have set RSTRET=', rstret
157  WRITE(iluout,*) 'Please modify the value of RSTRET in namelist NAMGEM'
158  WRITE(iluout,*) '****************************************************'
159  CALL abor1_sfx('READ_NAM_GRID_GAUSS: STRETCHING FACTOR MUST BE >= 1.')
160 END IF
161 !
162 zlapo = 180. / xpi * p_asin(rmucen)
163 zlopo = 180. / xpi * rlocen
164 !
165 zcodil = rstret
166 !
167 !---------------------------------------------------------------------------
168 !
169 !* 4. Reading parameters of the grid
170 ! ------------------------------
171 !
172  CALL posnam(ilunam,'NAMDIM',gfound,iluout)
173 IF (gfound) READ(unit=ilunam,nml=namdim)
174  CALL posnam(ilunam,'NAMRGRI',gfound,iluout)
175 IF (gfound) READ(unit=ilunam,nml=namrgri)
176 !
177 inlati = ndglg
178 ALLOCATE(inlopa(inlati))
179 inlopa(1:inlati/2) = nrgri(1:inlati/2)
180 inlopa(inlati/2+1:inlati) = nrgri(inlati/2:1:-1)
181 !
182 !---------------------------------------------------------------------------
183  CALL close_namelist(hprogram,ilunam)
184 !---------------------------------------------------------------------------
185 !
186 !* 5. Computes pseudo-latitudes and pseudo-longitudes of all points
187 ! -------------------------------------------------------------
188 !
189 !* number of points
190 kl = sum(inlopa)
191 
192 !
193 !* type of transform
194 IF (zlapo>89.99 .AND. abs(zlopo)<0.00001) THEN
195  ityp=0
196 ELSE
197  ityp=1
198 ENDIF
199 !
200 ALLOCATE(zlat_xy(kl))
201 ALLOCATE(zlon_xy(kl))
202 zlat_xy(:) = xundef
203 zlon_xy(:) = xundef
204 !
205  CALL comp_gridtype_gauss(inlati,inlopa,kl,ityp,zlat_xy,zlon_xy)
206 !
207 !---------------------------------------------------------------------------
208 !
209 !* 6. Computes latitudes and longitudes
210 ! ---------------------------------
211 !
212 !* all points are used
213 ALLOCATE(zlat(kl))
214 ALLOCATE(zlon(kl))
215 !
216 zlat(:) = xundef
217 zlon(:) = xundef
218 !
219 IF(zcodil==1.0.AND.ityp==0)THEN
220  zlon(:)=zlon_xy(:)
221  zlat(:)=zlat_xy(:)
222 ELSE
223  CALL latlon_gauss(zlon_xy,zlat_xy,kl,zlopo,zlapo,zcodil,zlon,zlat)
224 ENDIF
225 !
226 !---------------------------------------------------------------------------
227 !
228 !* 7. Computes grid corner latitudes and longitudes
229 ! ---------------------------------------------
230 !
231 ALLOCATE(zxinf(kl))
232 ALLOCATE(zyinf(kl))
233 ALLOCATE(zxsup(kl))
234 ALLOCATE(zysup(kl))
235 !
236 ALLOCATE(zloninf(kl))
237 ALLOCATE(zlatinf(kl))
238 ALLOCATE(zlonsup(kl))
239 ALLOCATE(zlatsup(kl))
240 !
241 zxinf(:) = xundef
242 zyinf(:) = xundef
243 zxsup(:) = xundef
244 zysup(:) = xundef
245 zloninf(:) = xundef
246 zlatinf(:) = xundef
247 zlonsup(:) = xundef
248 zlatsup(:) = xundef
249 !
250  CALL gauss_grid_limits(inlati,inlopa,zxinf,zxsup,zyinf,zysup)
251 !
252 IF(zcodil==1.0.AND.ityp==0)THEN
253  zloninf(:) = zxinf(:)
254  zlatinf(:) = zyinf(:)
255  zlonsup(:) = zxsup(:)
256  zlatsup(:) = zysup(:)
257 ELSE
258  CALL latlon_gauss(zxinf,zyinf,kl,zlopo,zlapo,zcodil,zloninf,zlatinf)
259  CALL latlon_gauss(zxsup,zysup,kl,zlopo,zlapo,zcodil,zlonsup,zlatsup)
260 ENDIF
261 !
262 !---------------------------------------------------------------------------
263 !
264 !* 8. Computes mesh size
265 ! ---------------------------------
266 !
267 ALLOCATE(zmesh_size(kl))
268 zmesh_size(:) = xundef
269 !
270  CALL mesh_size_gauss(kl,inlati,inlopa,zlapo,zlopo,zcodil,&
271  zlat_xy,zlon,zlat,zmesh_size)
272 !
273 !---------------------------------------------------------------------------
274 !
275 !* 9. All this information stored into pointer PGRID_PAR
276 ! --------------------------------------------------
277 !
278  CALL put_gridtype_gauss(zgrid_par,inlati,zlapo,zlopo,zcodil,inlopa, &
279  kl,zlat,zlon,zlat_xy,zlon_xy,zmesh_size, &
280  zloninf,zlatinf,zlonsup,zlatsup )
281 !
282 !---------------------------------------------------------------------------
283 !
284 !* 9. All this information stored into pointer PGRID_PAR
285 ! --------------------------------------------------
286 !
287 DEALLOCATE(zlat)
288 DEALLOCATE(zlon)
289 DEALLOCATE(zlat_xy)
290 DEALLOCATE(zlon_xy)
291 DEALLOCATE(inlopa)
292 DEALLOCATE(zmesh_size)
293 DEALLOCATE(zlatinf)
294 DEALLOCATE(zloninf)
295 DEALLOCATE(zlatsup)
296 DEALLOCATE(zlonsup)
297 DEALLOCATE(zxinf)
298 DEALLOCATE(zyinf)
299 DEALLOCATE(zxsup)
300 DEALLOCATE(zysup)
301 !
302 !---------------------------------------------------------------------------
303 !
304 !* 1st call : initializes dimension
305 !
306 IF (kgrid_par==0) THEN
307  kgrid_par = SIZE(zgrid_par)
308 !
309 ELSE
310 !
311 !* 2nd call : initializes grid array
312 !
313  pgrid_par(:) = 0.
314  pgrid_par(:) = zgrid_par
315 END IF
316 !
317 DEALLOCATE(zgrid_par)
318 IF (lhook) CALL dr_hook('READ_NAM_GRID_GAUSS',1,zhook_handle)
319 
320 !
321 !---------------------------------------------------------------------------
322 !
323 END SUBROUTINE read_nam_grid_gauss
subroutine read_nam_grid_gauss(HPROGRAM, KGRID_PAR, KL, PGRID_PAR)
subroutine put_gridtype_gauss(PGRID_PAR, KNLATI, PLAPO, PLOPO, PCODIL, KNLOPA, KL, PLAT, PLON, PLAT_XY, PLON_XY, PMESH_SIZE, PLONINF, PLATINF, PLONSUP, PLATSUP)
subroutine gauss_grid_limits(KNLATI, KNLOPA, PXINF, PXSUP, PYINF, PYSUP)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine mesh_size_gauss(KL, KNLATI, KNLOPA, PLAPO, PLOPO, PCODIL, PLAT_XY, PLAT, PLON, PMESH_SIZE)
subroutine close_namelist(HPROGRAM, KLUNAM)
subroutine posnam(KULNAM, HDNAML, OFOUND, KLUOUT)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine latlon_gauss(PLON_XY, PLAT_XY, KL, PLOPO, PLAPO, PCODIL, PLON, PLAT)
subroutine open_namelist(HPROGRAM, KLUNAM, HFILE)
subroutine comp_gridtype_gauss(KNLATI, KNLOPA, KL, KTYP, PLAT_XY, PLON_XY)