SURFEX v8.1
General documentation of Surfex
read_nam_grid_lonlatval.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_lonlatval(PGRID_FULL_PAR,KDIM_FULL,HPROGRAM,KGRID_PAR,KL,PGRID_PAR,HDIR)
7 ! ################################################################
8 !
9 !!**** *READ_NAM_GRID_LONLATVAL* - 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 !! E. Martin *Meteo France*
31 !!
32 !! MODIFICATIONS
33 !! -------------
34 !! Original 10/2007
35 !-------------------------------------------------------------------------------
36 !
37 !* 0. DECLARATIONS
38 ! ------------
39 !
40 USE modd_surfex_mpi, ONLY : nrank, nsize_task
41 !
42 USE mode_pos_surf
43 !
44 USE modi_open_namelist
45 USE modi_close_namelist
46 USE modi_get_luout
47 !
50 !
51 USE yomhook ,ONLY : lhook, dr_hook
52 USE parkind1 ,ONLY : jprb
53 !
54 IMPLICIT NONE
55 !
56 !* 0.1 Declarations of arguments
57 ! -------------------------
58 !
59 REAL, DIMENSION(:), POINTER :: PGRID_FULL_PAR
60 INTEGER, INTENT(IN) :: KDIM_FULL
61 !
62  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! calling program
63 INTEGER, INTENT(INOUT) :: KGRID_PAR ! size of PGRID_PAR
64 INTEGER, INTENT(OUT) :: KL ! number of points
65 REAL, DIMENSION(KGRID_PAR), INTENT(OUT) :: PGRID_PAR ! parameters defining this grid
66  CHARACTER(LEN=1), INTENT(IN) :: HDIR
67 !
68 !* 0.2 Declarations of local variables
69 ! -------------------------------
70 !
71 INTEGER :: ILUOUT ! output listing logical unit
72 INTEGER :: ILUNAM ! namelist file logical unit
73 !
74 REAL, DIMENSION(:), ALLOCATABLE :: ZX, ZX0 ! X conformal coordinate of grid mesh
75 REAL, DIMENSION(:), ALLOCATABLE :: ZY, ZY0 ! Y conformal coordinate of grid mesh
76 REAL, DIMENSION(:), ALLOCATABLE :: ZDX, ZDX0 ! X grid mesh size
77 REAL, DIMENSION(:), ALLOCATABLE :: ZDY, ZDY0 ! Y grid mesh size
78 !
79 !* 0.3 Declarations of namelist
80 ! ------------------------
81 !
82 INTEGER :: NPOINTS ! number of points
83 REAL, DIMENSION(100000) :: XX ! X coordinate of grid mesh center (in meters)
84 REAL, DIMENSION(100000) :: XY ! Y coordinate of grid mesh center (in meters)
85 REAL, DIMENSION(100000) :: XDX ! X mesh size (in meters)
86 REAL, DIMENSION(100000) :: XDY ! Y mesh size (in meters)
87 !
88 REAL, DIMENSION(:), POINTER :: ZGRID_PAR
89 !
90 LOGICAL :: GFOUND
91 REAL(KIND=JPRB) :: ZHOOK_HANDLE
92 !
93 NAMELIST/nam_lonlatval/npoints,xx,xy,xdx,xdy
94 !
95 !------------------------------------------------------------------------------
96 !
97 !* 1. opening of namelist
98 !
99 IF (lhook) CALL dr_hook('READ_NAM_GRID_LONLATVAL',0,zhook_handle)
100  CALL get_luout(hprogram,iluout)
101 !
102 IF (hdir/='H') THEN
103  !
104  CALL open_namelist(hprogram,ilunam)
105  !
106  !---------------------------------------------------------------------------
107  !
108  !* 2. Reading of projection parameters
109  ! --------------------------------
110  !
111  CALL posnam(ilunam,'NAM_LONLATVAL',gfound,iluout)
112  IF (gfound) READ(unit=ilunam,nml=nam_lonlatval)
113  !
114  !---------------------------------------------------------------------------
115  CALL close_namelist(hprogram,ilunam)
116  !---------------------------------------------------------------------------
117  !
118  !* 3. Number of points
119  ! ----------------
120  !
121  kl = npoints
122  !
123  !---------------------------------------------------------------------------
124  !
125  !* 3. Array of X and Y coordinates
126  ! ----------------------------
127  !
128  !
129  ALLOCATE(zx(kl))
130  ALLOCATE(zy(kl))
131  zx(:) = xx(:kl)
132  zy(:) = xy(:kl)
133  !
134  !---------------------------------------------------------------------------
135  !
136  !* 4. Array of X and Y increments
137  ! ---------------------------
138  !
139  ALLOCATE(zdx(kl))
140  ALLOCATE(zdy(kl))
141  zdx(:) = xdx(:kl)
142  zdy(:) = xdy(:kl)
143  !
144 ELSE
145  !
146  ALLOCATE(zx0(kdim_full),zy0(kdim_full),zdx0(kdim_full),zdy0(kdim_full))
147  !
148  CALL get_gridtype_lonlatval(pgrid_full_par,&
149  px=zx0,py=zy0,pdx=zdx0,pdy=zdy0)
150  !
151  kl = nsize_task(nrank)
152  ALLOCATE(zx(kl),zy(kl),zdx(kl),zdy(kl))
153  !
154  CALL read_and_send_mpi(zx0,zx)
155  CALL read_and_send_mpi(zy0,zy)
156  CALL read_and_send_mpi(zdx0,zdx)
157  CALL read_and_send_mpi(zdy0,zdy)
158  !
159  DEALLOCATE(zx0,zy0,zdx0,zdy0)
160  !
161 ENDIF
162 !---------------------------------------------------------------------------
163 !
164 !* 8. All this information stored into pointer PGRID_PAR
165 ! --------------------------------------------------
166 !
167  CALL put_gridtype_lonlatval(zgrid_par,zx,zy,zdx,zdy)
168 !
169 !---------------------------------------------------------------------------
170 DEALLOCATE(zx)
171 DEALLOCATE(zy)
172 DEALLOCATE(zdx)
173 DEALLOCATE(zdy)
174 !---------------------------------------------------------------------------
175 !
176 !* 1st call : initializes dimension
177 !
178 IF (kgrid_par==0) THEN
179  kgrid_par = SIZE(zgrid_par)
180 !
181 ELSE
182 !
183 !* 2nd call : initializes grid array
184 !
185  pgrid_par(:) = 0.
186  pgrid_par(:) = zgrid_par
187 END IF
188 !
189 DEALLOCATE(zgrid_par)
190 IF (lhook) CALL dr_hook('READ_NAM_GRID_LONLATVAL',1,zhook_handle)
191 !
192 !---------------------------------------------------------------------------
193 !
194 END SUBROUTINE read_nam_grid_lonlatval
subroutine get_gridtype_lonlatval(PGRID_PAR, KL, PX, PY, PDX, PDY)
subroutine put_gridtype_lonlatval(PGRID_PAR, PX, PY, PDX, PDY)
subroutine posnam(KULNAM, HDNAML, OFOUND, KLUOUT)
integer, parameter jprb
Definition: parkind1.F90:32
subroutine read_nam_grid_lonlatval(PGRID_FULL_PAR, KDIM_FULL, HPROGR
subroutine close_namelist(HPROGRAM, KLUNAM)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
integer, dimension(:), allocatable nsize_task
logical lhook
Definition: yomhook.F90:15
subroutine open_namelist(HPROGRAM, KLUNAM, HFILE)