SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
read_prep_greenroof_snow.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_prep_greenroof_snow(HPROGRAM,HSNOW,KSNOW_LAYER,HFILE,HFILETYPE,HFILEPGD,HFILEPGDTYPE,OUNIF)
7 ! #######################################################
8 !
9 !!**** *READ_PREP_GREENROOF_SNOW* - routine to read the configuration for snow
10 !! in ISBA fields preparation
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !!** METHOD
16 !! ------
17 !!
18 !! EXTERNAL
19 !! --------
20 !!
21 !!
22 !! IMPLICIT ARGUMENTS
23 !! ------------------
24 !!
25 !! REFERENCE
26 !! ---------
27 !! Based on read_prep_garden_snow
28 !!
29 !! AUTHOR
30 !! ------
31 !! C. de Munck *Meteo France*
32 !!
33 !! MODIFICATIONS
34 !! -------------
35 !! Original 08/2011
36 !! M. Lafaysse 08/2013 init XZSNOW or XLWCSNOW
37 ! B. Decharme 07/2013 ES snow grid layer can be > to 3 (default 12)
38 !-------------------------------------------------------------------------------
39 !
40 !* 0. DECLARATIONS
41 ! ------------
42 !
44 USE modd_read_namelist, ONLY : lnam_read
45 !
46 USE modd_surf_par, ONLY : xundef
47 USE modd_snow_par, ONLY : xansmin, xrhosmax
48 USE modd_csts, ONLY : xtt
49 !
50 USE mode_pos_surf
52 USE modi_get_luout
53 USE modi_open_namelist
54 USE modi_close_namelist
55 USE modi_abor1_sfx
56 !
57 USE modd_prep_teb_greenroof, ONLY : cfile_snow_gr, ctype_snow, cfilepgd_snow_gr, &
58  ctypepgd_snow, lsnow_ideal_gr, &
59  xwsnow_p=>xwsnow_gr, xtsnow_p=>xtsnow_gr, xlwcsnow_p=>xlwcsnow_gr, &
60  xrsnow_p=>xrsnow_gr, xagesnow_p=>xagesnow_gr, xasnow_gr
61 !
62 USE modd_prep_snow, ONLY : nsnow_layer_max, lsnow_prep_perm
63 !
64 USE yomhook ,ONLY : lhook, dr_hook
65 USE parkind1 ,ONLY : jprb
66 !
67 IMPLICIT NONE
68 !
69 !* 0.1 Declarations of arguments
70 ! -------------------------
71 !
72  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling ISBA
73  CHARACTER(LEN=3), INTENT(OUT) :: hsnow ! snow scheme
74 INTEGER, INTENT(OUT) :: ksnow_layer ! number of snow layers
75  CHARACTER(LEN=28), OPTIONAL, INTENT(OUT) :: hfile ! file name
76  CHARACTER(LEN=6), OPTIONAL, INTENT(OUT) :: hfiletype ! file type
77  CHARACTER(LEN=28), OPTIONAL, INTENT(OUT) :: hfilepgd ! file name
78  CHARACTER(LEN=6), OPTIONAL, INTENT(OUT) :: hfilepgdtype ! file type
79  LOGICAL, OPTIONAL, INTENT(OUT) :: ounif ! uniform snow
80 !
81 !* 0.2 Declarations of local variables
82 ! -------------------------------
83 !
84  CHARACTER(LEN=3) :: csnow
85 INTEGER :: nsnow_layer
86  CHARACTER(LEN=28) :: cfile_snow, cfilepgd_snow
87 LOGICAL :: lsnow_ideal, lsnow_frac_tot, lswemax
88 REAL :: xasnow, xswemax
89 REAL, DIMENSION(NSNOW_LAYER_MAX) :: xwsnow, xzsnow, xrsnow, xtsnow, xlwcsnow, xsg1snow, xsg2snow,&
90  xhistsnow, xagesnow
91 INTEGER :: jlayer
92 !
93 REAL, DIMENSION(NSNOW_LAYER_MAX) :: xwsnow_gr, xzsnow_gr, xrsnow_gr, xtsnow_gr, xlwcsnow_gr, &
94  xsg1snow_gr, xsg2snow_gr, xhistsnow_gr, xagesnow_gr
95 !
96 LOGICAL :: lfile
97 !
98 LOGICAL :: gfound ! Return code when searching namelist
99 INTEGER :: iluout ! output file logical unit
100 INTEGER :: ilunam ! namelist file logical unit
101 REAL(KIND=JPRB) :: zhook_handle
102 !-------------------------------------------------------------------------------
103 namelist/nam_prep_isba_snow/csnow, nsnow_layer, cfile_snow, ctype_snow, &
104  cfilepgd_snow, ctypepgd_snow, &
105  lsnow_ideal, lsnow_frac_tot, lsnow_prep_perm,&
106  xwsnow, xzsnow, xtsnow, xlwcsnow, xrsnow, xasnow, &
107  xsg1snow, xsg2snow, xhistsnow, xagesnow, &
108  lswemax, xswemax
109 
110 namelist/nam_prep_greenroof_snow/csnow_gr, nsnow_layer_gr, cfile_snow_gr, ctype_snow, &
111  cfilepgd_snow_gr, ctypepgd_snow, &
112  lsnow_ideal_gr, xwsnow_gr, xzsnow_gr, xtsnow_gr, &
113  xlwcsnow_gr, xrsnow_gr, xasnow_gr
114 !-------------------------------------------------------------------------------
115 IF (lhook) CALL dr_hook('READ_PREP_GREENROOF_SNOW',0,zhook_handle)
116 !
117 !* default for greenroofs
118 ! ----------------------
119  csnow_gr = '3-L'
120 nsnow_layer_gr = 3
121 !
122 IF (lnam_read) THEN
123  !
124  csnow_gr = '3-L'
125  nsnow_layer_gr = 3
126  !
127  cfile_snow_gr = ' '
128  ctype_snow = ' '
129  cfilepgd_snow_gr = ' '
130  ctypepgd_snow = ' '
131  !
132  lsnow_ideal_gr = .false.
133  lsnow_prep_perm = .true.
134  !
135  xwsnow_gr(:) = 0.
136  xzsnow_gr(:) = xundef
137  xrsnow_gr(:) = xrhosmax
138  xtsnow_gr(:) = xtt
139  xlwcsnow_gr(:) = 0.
140  xasnow_gr = xansmin
141  xsg1snow_gr(:) = xundef
142  xsg2snow_gr(:) = xundef
143  xhistsnow_gr(:) = xundef
144  xagesnow_gr(:) = xundef
145  !
146  CALL get_luout(hprogram,iluout)
147  CALL open_namelist(hprogram,ilunam)
148  !
149  !* reading of namelist
150  ! -------------------
151  !
152  !* default can be provided by ISBA scheme variables
153  CALL posnam(ilunam,'NAM_PREP_ISBA_SNOW',gfound,iluout)
154  IF (gfound) THEN
155  !
156  csnow = '3-L'
157  nsnow_layer = 3
158  cfile_snow = ' '
159  lsnow_ideal = .false.
160  lsnow_frac_tot = .false.
161  xwsnow(:) = xundef
162  xzsnow(:) = xundef
163  xrsnow(:) = xrhosmax
164  xtsnow(:) = xtt
165  xlwcsnow(:) = 0.
166  xasnow = xansmin
167  xsg1snow(:) = xundef
168  xsg2snow(:) = xundef
169  xhistsnow(:) = xundef
170  xagesnow(:) = xundef
171  !
172  READ(unit=ilunam,nml=nam_prep_isba_snow)
173  CALL test_nam_var_surf(iluout,'CSNOW',csnow,'D95','3-L','EBA','NON','CRO')
174  !
175  csnow_gr = csnow
176  nsnow_layer_gr = nsnow_layer
177  cfile_snow_gr = cfile_snow
178  lsnow_ideal_gr = lsnow_ideal
179  xwsnow_gr(:) = xwsnow(:)
180  xzsnow_gr(:) = xzsnow(:)
181  xrsnow_gr(:) = xrsnow(:)
182  xtsnow_gr(:) = xtsnow(:)
183  xlwcsnow_gr(:) = xlwcsnow(:)
184  xasnow_gr = xasnow
185  xsg1snow_gr(:) = xsg1snow(:)
186  xsg2snow_gr(:) = xsg2snow(:)
187  xhistsnow_gr(:) = xhistsnow(:)
188  xagesnow_gr(:) = xagesnow(:)
189  !
190  ENDIF
191  !
192  !* It is erased by GREENROOF namelist if specified
193  CALL posnam(ilunam,'NAM_PREP_GREENROOF_SNOW',gfound,iluout)
194  IF (gfound) THEN
195  READ(unit=ilunam,nml=nam_prep_greenroof_snow)
196  !crocus can't be used in garden if not used in isba scheme
197  CALL test_nam_var_surf(iluout,'CSNOW',csnow_gr,'D95','3-L','EBA','NON')
198  ENDIF
199  !
200  IF ( csnow_gr=='NON') nsnow_layer_gr = 0
201  IF ( csnow_gr=='D95' .OR. csnow_gr=='EBA') nsnow_layer_gr = 1
202  IF (csnow_gr=='3-L' .AND. nsnow_layer_gr<=2) nsnow_layer_gr = 12
203  !
204  IF (nsnow_layer_gr > nsnow_layer_max) THEN
205  WRITE(iluout,*) '------------------------------------'
206  WRITE(iluout,*) 'Please update modd_prep_snow.f90 routine : '
207  WRITE(iluout,*) 'The maximum number of snow layers '
208  WRITE(iluout,*) 'in the declaration of the namelist variables '
209  WRITE(iluout,*) 'must be decreased to : ', nsnow_layer_max
210  WRITE(iluout,*) '------------------------------------'
211  CALL abor1_sfx('READ_PREP_GREENROOF_SNOW: NUMBER OF SNOW LAYERS MUST BE INCREASED IN NAMELIST DECLARATION')
212  ENDIF
213  !
214  ALLOCATE(xwsnow_p(nsnow_layer_gr))
215  ALLOCATE(xrsnow_p(nsnow_layer_gr))
216  ALLOCATE(xtsnow_p(nsnow_layer_gr))
217  ALLOCATE(xagesnow_p(nsnow_layer_gr))
218  ALLOCATE(xlwcsnow_p(nsnow_layer_gr))
219  !
220  DO jlayer=1,nsnow_layer_gr
221  IF ((xzsnow_gr(jlayer)>0) .AND.(xzsnow_gr(jlayer)/=xundef )) THEN
222  IF ((xwsnow_gr(jlayer)>0) .AND.(xwsnow_gr(jlayer)/=xundef )) THEN
223  WRITE(iluout,*) 'XWSNOW and XZSNOW are both defined.'
224  WRITE(iluout,*) 'You must define only one of them.'
225  WRITE(iluout,*) ' PLEASE CORRECT THAT '
226  CALL abor1_sfx('READ_PREP_GREENROOF_SNOW: ERROR IN INITIALIZATION OF SNOW DEPTH')
227  ELSE
228  xwsnow_p(jlayer)=xzsnow_gr(jlayer)*xrsnow_gr(jlayer)
229  ENDIF
230  ELSE
231  xwsnow_p(jlayer)=xwsnow_gr(jlayer)
232  ENDIF
233  ENDDO
234 
235  xrsnow_p=xrsnow_gr(1:nsnow_layer_gr)
236  xtsnow_p=xtsnow_gr(1:nsnow_layer_gr)
237  xagesnow_p=xagesnow_gr(1:nsnow_layer_gr)
238  xlwcsnow_p=xlwcsnow_gr(1:nsnow_layer_gr)
239  !
240  CALL close_namelist(hprogram,ilunam)
241  !
242 ENDIF
243 !
244 hsnow = csnow_gr
245 ksnow_layer = nsnow_layer_gr
246 !
247 IF(all(xwsnow_p(:)==xundef).AND.present(ounif))THEN
248  ounif=.false.
249 ELSEIF(present(ounif))THEN
250  ounif=.true.
251 ENDIF
252 !
253 lfile=(len_trim(cfile_snow_gr)>0.AND.len_trim(ctype_snow)>0 &
254  .AND.len_trim(cfilepgd_snow_gr)>0.AND.len_trim(ctypepgd_snow)>0)
255 !
256 IF (present(ounif)) lfile=(lfile .AND. .NOT.ounif)
257 !
258 IF(present(hfile))THEN
259  IF(lfile)THEN
260  hfile = cfile_snow_gr
261  ELSE
262  hfile = ' '
263  ENDIF
264 ENDIF
265 IF(present(hfiletype))THEN
266  IF(lfile)THEN
267  hfiletype = ctype_snow
268  ELSE
269  hfiletype = ' '
270  ENDIF
271 ENDIF
272 IF(present(hfilepgdtype))THEN
273  IF(lfile)THEN
274  hfilepgdtype = ctypepgd_snow
275  ELSE
276  hfilepgdtype = ' '
277  ENDIF
278 ENDIF
279 IF(present(hfilepgd))THEN
280  IF(lfile)THEN
281  hfilepgd = cfilepgd_snow_gr
282  ELSE
283  hfilepgd = ' '
284  ENDIF
285 ENDIF
286 IF (lfile.AND.present(ounif)) ounif=.false.
287 !
288 IF (lhook) CALL dr_hook('READ_PREP_GREENROOF_SNOW',1,zhook_handle)
289 !
290 !-------------------------------------------------------------------------------
291 !-------------------------------------------------------------------------------
292 !
293 END SUBROUTINE read_prep_greenroof_snow
subroutine read_prep_greenroof_snow(HPROGRAM, HSNOW, KSNOW_LAYER, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, OUNIF)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine close_namelist(HPROGRAM, KLUNAM)
subroutine posnam(KULNAM, HDNAML, OFOUND, KLUOUT)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine open_namelist(HPROGRAM, KLUNAM, HFILE)