SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
grid_modif_conf_proj.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 grid_modif_conf_proj(KLUOUT,KLUNAM,KGRID_PAR,KL,PGRID_PAR, &
7  kgrid_par2,kl2,omodif,pgrid_par2 )
8 ! ################################################################
9 !
10 !!**** *GRID_MODIF_CONF_PROJ* - routine to read in namelist the horizontal grid
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !!** METHOD
16 !! ------
17 !!
18 !! EXTERNAL
19 !! --------
20 !!
21 !!
22 !! IMPLICIT ARGUMENTS
23 !! ------------------
24 !!
25 !! REFERENCE
26 !! ---------
27 !!
28 !!
29 !! AUTHOR
30 !! ------
31 !! V. Masson *Meteo France*
32 !!
33 !! MODIFICATIONS
34 !! -------------
35 !! Original 01/2004
36 !-------------------------------------------------------------------------------
37 !
38 !* 0. DECLARATIONS
39 ! ------------
40 !
41 USE modd_surf_par, ONLY : nundef
42 
43 USE mode_pos_surf
45 !
46 !
47 USE yomhook ,ONLY : lhook, dr_hook
48 USE parkind1 ,ONLY : jprb
49 !
50 USE modi_regular_grid_spawn
51 !
52 IMPLICIT NONE
53 !
54 !* 0.1 Declarations of arguments
55 ! -------------------------
56 !
57 INTEGER, INTENT(IN) :: kluout ! output listing logical unit
58 INTEGER, INTENT(IN) :: klunam ! namelist file logical unit
59 INTEGER, INTENT(IN) :: kl ! number of points
60 INTEGER, INTENT(IN) :: kgrid_par ! size of PGRID_PAR
61 REAL, DIMENSION(KGRID_PAR), INTENT(IN) :: pgrid_par ! parameters defining the grid
62 INTEGER, INTENT(INOUT) :: kl2 ! number of points in modified grid
63 INTEGER, INTENT(INOUT) :: kgrid_par2 ! size of PGRID_PAR2
64 LOGICAL, INTENT(IN) :: omodif ! flag to modify the grid
65 REAL, DIMENSION(KGRID_PAR2), INTENT(OUT) :: pgrid_par2 ! parameters defining the modified grid
66 !
67 !* 0.2 Declarations of local variables
68 ! -------------------------------
69 !
70 !* initial grid
71 REAL :: zlat0 ! reference latitude
72 REAL :: zlon0 ! reference longitude
73 REAL :: zrpk ! projection parameter
74 ! ! K=1 : stereographic north pole
75 ! ! 0<K<1 : Lambert, north hemisphere
76 ! ! K=0 : Mercator
77 ! !-1<K<0 : Lambert, south hemisphere
78 ! ! K=-1: stereographic south pole
79 REAL :: zbeta ! angle between grid and reference longitude
80 REAL :: zlator ! latitude of point of coordinates X=0, Y=0
81 REAL :: zlonor ! longitude of point of coordinates X=0, Y=0
82 INTEGER :: iimax1 ! number of points in I direction
83 INTEGER :: ijmax1 ! number of points in J direction
84 REAL, DIMENSION(:), ALLOCATABLE :: zx1 ! X conformal coordinate of grid mesh
85 REAL, DIMENSION(:), ALLOCATABLE :: zy1 ! Y conformal coordinate of grid mesh
86 REAL, DIMENSION(:), ALLOCATABLE :: zdx1 ! X grid mesh size
87 REAL, DIMENSION(:), ALLOCATABLE :: zdy1 ! Y grid mesh size
88 !
89 !* new grid
90 INTEGER :: iimax2 ! number of points in I direction
91 INTEGER :: ijmax2 ! number of points in J direction
92 REAL, DIMENSION(:), ALLOCATABLE :: zx2 ! X conformal coordinate of grid mesh
93 REAL, DIMENSION(:), ALLOCATABLE :: zy2 ! Y conformal coordinate of grid mesh
94 REAL, DIMENSION(:), ALLOCATABLE :: zdx2 ! X grid mesh size
95 REAL, DIMENSION(:), ALLOCATABLE :: zdy2 ! Y grid mesh size
96 !
97 !* other variables
98 LOGICAL :: gfound
99 REAL, DIMENSION(:), POINTER :: zgrid_par
100 !
101 !
102 !* 0.3 Declarations of namelist
103 ! ------------------------
104 !
105 INTEGER :: ixor = 1 ! position of modified bottom left point
106 INTEGER :: iyor = 1 ! according to initial grid
107 INTEGER :: ixsize = -999 ! number of grid meshes in initial grid to be
108 INTEGER :: iysize = -999 ! covered by the modified grid
109 INTEGER :: idxratio = 1 ! resolution ratio between modified grid
110 INTEGER :: idyratio = 1 ! and initial grid
111 REAL(KIND=JPRB) :: zhook_handle
112 !
113 !
114 namelist/nam_inifile_conf_proj/ixor,iyor,ixsize,iysize,idxratio,idyratio
115 !
116 !------------------------------------------------------------------------------
117 !
118 !* 1. Reading of projection parameters
119 ! --------------------------------
120 !
121 IF (lhook) CALL dr_hook('GRID_MODIF_CONF_PROJ',0,zhook_handle)
122  CALL posnam(klunam,'NAM_INIFILE_CONF_PROJ',gfound,kluout)
123 IF (gfound) READ(unit=klunam,nml=nam_inifile_conf_proj)
124 !
125 !---------------------------------------------------------------------------
126 !
127 !* 2. All this information stored into pointer PGRID_PAR
128 ! --------------------------------------------------
129 !
130 ALLOCATE(zx1(kl))
131 ALLOCATE(zy1(kl))
132 ALLOCATE(zdx1(kl))
133 ALLOCATE(zdy1(kl))
134 !
135  CALL get_gridtype_conf_proj(pgrid_par,zlat0,zlon0,zrpk,zbeta, &
136  zlator,zlonor, &
137  iimax1,ijmax1, &
138  zx1,zy1,zdx1,zdy1 )
139 !
140 !---------------------------------------------------------------------------
141 !
142 !* 3. Default : no modification
143 ! -------------------------
144 !
145 IF (ixsize==-999) ixsize=iimax1
146 IF (iysize==-999) iysize=ijmax1
147 !
148 !---------------------------------------------------------------------------
149 !
150 !* 4. Modification of the grid
151 ! ------------------------
152 !
153 !* number of points
154 !
155 iimax2=ixsize*idxratio
156 ijmax2=iysize*idyratio
157 !
158 kl2 = iimax2 * ijmax2
159 !
160 ALLOCATE(zx2(iimax2*ijmax2))
161 ALLOCATE(zy2(iimax2*ijmax2))
162 ALLOCATE(zdx2(iimax2*ijmax2))
163 ALLOCATE(zdy2(iimax2*ijmax2))
164 !
165  CALL regular_grid_spawn(kluout, &
166  kl, iimax1,ijmax1,zx1,zy1,zdx1,zdy1, &
167  ixor, iyor, idxratio, idyratio, &
168  ixsize, iysize, &
169  kl2, iimax2,ijmax2,zx2,zy2,zdx2,zdy2 )
170 DEALLOCATE(zx1)
171 DEALLOCATE(zy1)
172 DEALLOCATE(zdx1)
173 DEALLOCATE(zdy1)
174 !
175 !---------------------------------------------------------------------------
176 !
177 !* 5. All this information stored into pointer PGRID_PAR
178 ! --------------------------------------------------
179 !
180  CALL put_gridtype_conf_proj(zgrid_par,zlat0,zlon0,zrpk,zbeta, &
181  zlator,zlonor, &
182  iimax2,ijmax2, &
183  zx2,zy2,zdx2,zdy2 )
184 !
185 !---------------------------------------------------------------------------
186 DEALLOCATE(zx2)
187 DEALLOCATE(zy2)
188 DEALLOCATE(zdx2)
189 DEALLOCATE(zdy2)
190 !---------------------------------------------------------------------------
191 !
192 !* 1st call : initializes dimension
193 !
194 IF (kgrid_par2==0) THEN
195  kgrid_par2 = SIZE(zgrid_par)
196 !
197 ELSE
198 !
199 !* 2nd call : initializes grid array
200 !
201  pgrid_par2(:) = 0.
202  pgrid_par2(:) = zgrid_par
203 END IF
204 !
205 DEALLOCATE(zgrid_par)
206 IF (lhook) CALL dr_hook('GRID_MODIF_CONF_PROJ',1,zhook_handle)
207 !
208 !---------------------------------------------------------------------------
209 !
210 END SUBROUTINE grid_modif_conf_proj
subroutine grid_modif_conf_proj(KLUOUT, KLUNAM, KGRID_PAR, KL, PGRID_PAR, KGRID_PAR2, KL2, OMODIF, PGRID_PAR2)
subroutine regular_grid_spawn(KLUOUT, KL1, KIMAX1, KJMAX1, PX1, PY1, PDX1, PDY1, KXOR, KYOR, KDXRATIO, KDYRATIO, KXSIZE, KYSIZE, KL2, KIMAX2, KJMAX2, PX2, PY2, PDX2, PDY2)
subroutine put_gridtype_conf_proj(PGRID_PAR, PLAT0, PLON0, PRPK, PBETA, PLATOR, PLONOR, KIMAX, KJMAX, PX, PY, PDX, PDY)
subroutine posnam(KULNAM, HDNAML, OFOUND, KLUOUT)
subroutine get_gridtype_conf_proj(PGRID_PAR, PLAT0, PLON0, PRPK, PBETA, PLATOR, PLONOR, KIMAX, KJMAX, PX, PY, PDX, PDY, KL)