SURFEX v8.1
General documentation of Surfex
read_nam_grid_lonlat_reg.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_lonlat_reg(PGRID_FULL_PAR,KDIM_FULL,HPROGRAM,KGRID_PAR,KL,PGRID_PAR,HDIR)
7 ! ################################################################
8 !
9 !!**** *READ_NAM_GRID_LONLAT_REG* - 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 !-------------------------------------------------------------------------------
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 :: ZLAT, ZLAT0 ! latitude of all points
75 REAL, DIMENSION(:), ALLOCATABLE :: ZLON, ZLON0 ! longitude of all points
76 !
77 REAL, DIMENSION(:), POINTER :: ZGRID_PAR
78 !
79 LOGICAL :: GFOUND
80 !
81 !
82 !* 0.3 Declarations of namelist
83 ! ------------------------
84 !
85 REAL :: XLONMIN ! minimum longitude (degrees)
86 REAL :: XLONMAX ! maximum longitude (degrees)
87 REAL :: XLATMIN ! minimum latitude (degrees)
88 REAL :: XLATMAX ! maximum latitude (degrees)
89 INTEGER :: NLON ! number of points in longitude
90 INTEGER :: NLAT ! number of points in latitude
91 REAL(KIND=JPRB) :: ZHOOK_HANDLE
92 NAMELIST/nam_lonlat_reg/xlonmin, xlonmax, xlatmin, xlatmax, nlon, nlat
93 !
94 !------------------------------------------------------------------------------
95 !
96 !* 1. opening of namelist
97 !
98 IF (lhook) CALL dr_hook('READ_NAM_GRID_LONLAT_REG',0,zhook_handle)
99  CALL get_luout(hprogram,iluout)
100 !
101 IF (hdir/='H') THEN
102  !
103  CALL open_namelist(hprogram,ilunam)
104  !
105  !---------------------------------------------------------------------------
106  !
107  !* 2. Reading of projection parameters
108  ! --------------------------------
109  !
110  CALL posnam(ilunam,'NAM_LONLAT_REG',gfound,iluout)
111  IF (gfound) READ(unit=ilunam,nml=nam_lonlat_reg)
112  !
113  !---------------------------------------------------------------------------
114  !
115  !* 3. Number of points
116  ! ----------------
117  !
118  kl = nlon * nlat
119  !
120  !---------------------------------------------------------------------------
121  CALL close_namelist(hprogram,ilunam)
122  !---------------------------------------------------------------------------
123  !
124  !* 4. All this information stored into pointer PGRID_PAR
125  ! --------------------------------------------------
126  !
127  ALLOCATE(zlat(kl))
128  ALLOCATE(zlon(kl))
129  !
130  CALL latlon_lonlat_reg(xlonmin,xlonmax,xlatmin,xlatmax,&
131  nlon,nlat,zlon,zlat )
132  !
133 ELSE
134  !
135  ALLOCATE(zlon0(kdim_full),zlat0(kdim_full))
136  !
137  CALL get_gridtype_lonlat_reg(pgrid_full_par,plonmin=xlonmin,plonmax=xlonmax,&
138  platmin=xlatmin,platmax=xlatmax,klon=nlon,&
139  klat=nlat,plon=zlon0,plat=zlat0)
140  !
141  kl = nsize_task(nrank)
142  ALLOCATE(zlon(kl),zlat(kl))
143  !
144  CALL read_and_send_mpi(zlon0,zlon)
145  CALL read_and_send_mpi(zlat0,zlat)
146  !
147  DEALLOCATE(zlon0,zlat0)
148  !
149 ENDIF
150 !
151  CALL put_gridtype_lonlat_reg(zgrid_par,xlonmin,xlonmax,xlatmin,xlatmax, &
152  nlon,nlat,kl,zlon,zlat )
153 !
154 DEALLOCATE(zlat)
155 DEALLOCATE(zlon)
156 !
157 !---------------------------------------------------------------------------
158 !
159 !* 1st call : initializes dimension
160 !
161 IF (kgrid_par==0) THEN
162  kgrid_par = SIZE(zgrid_par)
163 !
164 ELSE
165 !
166 !* 2nd call : initializes grid array
167 !
168  pgrid_par(:) = 0.
169  pgrid_par(:) = zgrid_par
170 END IF
171 !
172 DEALLOCATE(zgrid_par)
173 IF (lhook) CALL dr_hook('READ_NAM_GRID_LONLAT_REG',1,zhook_handle)
174 !
175 !---------------------------------------------------------------------------
176 !
177 END SUBROUTINE read_nam_grid_lonlat_reg
subroutine read_nam_grid_lonlat_reg(PGRID_FULL_PAR, KDIM_FULL, HPROG
subroutine put_gridtype_lonlat_reg(PGRID_PAR, PLONMIN, PLONMAX,
subroutine posnam(KULNAM, HDNAML, OFOUND, KLUOUT)
integer, parameter jprb
Definition: parkind1.F90:32
subroutine get_gridtype_lonlat_reg(PGRID_PAR, PLONMIN, PLONMAX, PLATMIN, PLATMAX, KLON, KLAT, KL, PLON, PLAT)
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 latlon_lonlat_reg(PLONMIN, PLONMAX, PLATMIN, PLATMAX, KLON, KLAT, PLON, PLAT)
subroutine open_namelist(HPROGRAM, KLUNAM, HFILE)