SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
mode_read_buffer.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.
6 ! #####################
7 !-------------------------------------------------------------------
8 !
9 USE modi_abor1_sfx
10 !
11 USE yomhook ,ONLY : lhook, dr_hook
12 USE parkind1 ,ONLY : jprb
13 !
14  CONTAINS
15 !-------------------------------------------------------------------
16 ! ####################
17  SUBROUTINE read_buffer_land_mask(KLUOUT,HINMODEL,PMASK)
18 ! ####################
19 !
20 USE modd_grid_buffer, ONLY : nni
21 !
23 !
24 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
25  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! originating model
26 REAL, DIMENSION(:), POINTER :: pmask ! Land mask
27 !
28 INTEGER :: iret ! return code
29 REAL, DIMENSION(:), POINTER :: zfield ! field read
30 REAL(KIND=JPRB) :: zhook_handle
31 !-------------------------------------------------------------------
32 !
33 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_LAND_MASK',0,zhook_handle)
34 WRITE (kluout,'(A)') ' | Reading land mask'
35 SELECT CASE (hinmodel)
36  CASE ('ALADIN')
37 ALLOCATE (zfield(nni))
38  CALL read_buffer('LSM ',zfield,iret)
39 END SELECT
40 IF (iret /= 0) THEN
41  CALL abor1_sfx('MODE_READ_BUFFER: LAND SEA MASK MISSING')
42 END IF
43 !
44 ALLOCATE (pmask(nni))
45 WHERE (zfield>0.5)
46  pmask = 1.
47 ELSEWHERE
48  pmask = 0.
49 END WHERE
50 DEALLOCATE (zfield)
51 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_LAND_MASK',1,zhook_handle)
52 !
53 END SUBROUTINE read_buffer_land_mask
54 !-------------------------------------------------------------------
55 ! ############################
56  SUBROUTINE read_buffer_zs_land(KLUOUT,HINMODEL,PFIELD)
57 ! ############################
58 !
59 USE modd_surf_par, ONLY : xundef
60 USE modd_csts, ONLY : xg
61 USE modd_grid_buffer, ONLY : nni
62 !
64 !
65 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
66  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
67 REAL, DIMENSION(:), POINTER :: pfield !
68 !
69 INTEGER :: iret ! return code
70 REAL(KIND=JPRB) :: zhook_handle
71 !-------------------------------------------------------------------
72 !
73 !* Read orography
74 !
75 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_ZS_LAND',0,zhook_handle)
76 WRITE (kluout,'(A)') ' | Reading land orography'
77 SELECT CASE (hinmodel)
78  CASE ('ALADIN')
79  ALLOCATE (pfield(nni))
80  CALL read_buffer('LPHIS ',pfield,iret)
81 END SELECT
82 !
83 IF (iret /= 0) THEN
84  CALL abor1_sfx('MODE_READ_BUFFER: LAND OROGRAPHY MISSING')
85 END IF
86 !
87 ! Datas given in archives are multiplied by the gravity acceleration
88 pfield = pfield / xg
89 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_ZS_LAND',1,zhook_handle)
90 !
91 !
92 END SUBROUTINE read_buffer_zs_land
93 !-------------------------------------------------------------------
94 ! ############################
95  SUBROUTINE read_buffer_zs_sea(KLUOUT,HINMODEL,PFIELD)
96 ! ############################
97 !
98 USE modd_surf_par, ONLY : xundef
99 USE modd_csts, ONLY : xg
100 USE modd_grid_buffer, ONLY : nni
101 !
103 !
104 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
105  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Buffer originating model
106 REAL, DIMENSION(:), POINTER :: pfield !
107 !
108 INTEGER :: iret ! return code
109 REAL(KIND=JPRB) :: zhook_handle
110 !-------------------------------------------------------------------
111 !
112 !* Read orography
113 !
114 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_ZS_SEA',0,zhook_handle)
115 WRITE (kluout,'(A)') ' | Reading sea orography in buffer'
116 SELECT CASE (hinmodel)
117  CASE ('ALADIN')
118  ALLOCATE (pfield(nni))
119  CALL read_buffer('SPHIS ',pfield,iret)
120 END SELECT
121 !
122 IF (iret /= 0) THEN
123  CALL abor1_sfx('MODE_READ_BUFFER: SEA OROGRAPHY MISSING')
124 END IF
125 !
126 ! Datas given in archives are multiplied by the gravity acceleration
127 pfield = pfield / xg
128 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_ZS_SEA',1,zhook_handle)
129 !
130 !
131 END SUBROUTINE read_buffer_zs_sea
132 !
133 !-------------------------------------------------------------------
134 ! ############################
135  SUBROUTINE read_buffer_zs(KLUOUT,HINMODEL,PFIELD)
136 ! ############################
137 !
138 USE modd_surf_par, ONLY : xundef
139 USE modd_csts, ONLY : xg
140 USE modd_grid_buffer, ONLY : nni
141 !
143 !
144 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
145  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
146 REAL, DIMENSION(:), POINTER :: pfield !
147 !
148 INTEGER :: iret ! return code
149 REAL(KIND=JPRB) :: zhook_handle
150 !-------------------------------------------------------------------
151 !
152 !* Read orography
153 !
154 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_ZS',0,zhook_handle)
155 WRITE (kluout,'(A)') ' | Reading orography'
156 SELECT CASE (hinmodel)
157  CASE ('ALADIN')
158  ALLOCATE (pfield(nni))
159  CALL read_buffer('PHIS ',pfield,iret)
160 END SELECT
161 !
162 IF (iret /= 0) THEN
163  CALL abor1_sfx('MODE_READ_BUFFER: OROGRAPHY MISSING')
164 END IF
165 !
166 ! Datas given in archives are multiplied by the gravity acceleration
167 pfield = pfield / xg
168 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_ZS',1,zhook_handle)
169 !
170 END SUBROUTINE read_buffer_zs
171 !
172 ! ###########################
173  SUBROUTINE read_buffer_ts(KLUOUT,HINMODEL,PFIELD)
174 ! ###########################
175 !
176 USE modd_surf_par, ONLY : xundef
177 USE modd_grid_buffer, ONLY : nni
178 !
180 !
181 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
182  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
183 REAL, DIMENSION(:), POINTER :: pfield !
184 !
185 INTEGER :: iret ! return code
186 REAL(KIND=JPRB) :: zhook_handle
187 !-------------------------------------------------------------------
188 !
189 !* Read surface temperature
190 !
191 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_TS',0,zhook_handle)
192 WRITE (kluout,'(A)') ' | Reading surface temperature'
193 !
194 SELECT CASE (hinmodel)
195  CASE ('ALADIN')
196  ALLOCATE (pfield(nni))
197  CALL read_buffer('TG1 ',pfield,iret)
198 END SELECT
199 IF (iret /= 0) THEN
200  CALL abor1_sfx('MODE_READ_BUFFER: SURFACE TEMPERATURE MISSING')
201 END IF
202 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_TS',1,zhook_handle)
203 !
204 END SUBROUTINE read_buffer_ts
205 !
206 !-------------------------------------------------------------------
207 ! ###########################
208  SUBROUTINE read_buffer_sst(KLUOUT,HINMODEL,PFIELD)
209 ! ###########################
210 !
211 USE modd_surf_par, ONLY : xundef
212 USE modd_grid_buffer, ONLY : nni
213 !
215 !
216 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
217  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
218 REAL, DIMENSION(:), POINTER :: pfield !
219 !
220 INTEGER :: iret ! return code
221 REAL(KIND=JPRB) :: zhook_handle
222 !-------------------------------------------------------------------
223 !
224 !* Read surface temperature
225 !
226 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_SST',0,zhook_handle)
227 WRITE (kluout,'(A)') ' | Reading sea surface temperature'
228 !
229 SELECT CASE (hinmodel)
230  CASE ('ALADIN')
231  ALLOCATE (pfield(nni))
232  CALL read_buffer('SST ',pfield,iret)
233 !
234 END SELECT
235 !
236 IF (iret /= 0) THEN
237  CALL abor1_sfx('MODE_READ_BUFFER: SEA SURFACE TEMPERATURE MISSING')
238 END IF
239 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_SST',1,zhook_handle)
240 !
241 END SUBROUTINE read_buffer_sst
242 !
243 !-------------------------------------------------------------------
244 ! ###########################
245  SUBROUTINE read_buffer_t2(KLUOUT,HINMODEL,PFIELD)
246 ! ###########################
247 !
248 USE modd_surf_par, ONLY : xundef
249 USE modd_grid_buffer, ONLY : nni
250 !
252 !
253 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
254  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
255 REAL, DIMENSION(:), POINTER :: pfield !
256 !
257 INTEGER :: iret ! return code
258 REAL(KIND=JPRB) :: zhook_handle
259 !-------------------------------------------------------------------
260 !
261 !* Read surface temperature
262 !
263 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_T2',0,zhook_handle)
264 WRITE (kluout,'(A)') ' | Reading deep soil temperature'
265 !
266 SELECT CASE (hinmodel)
267 
268  CASE ('ALADIN')
269  ALLOCATE (pfield(nni))
270  CALL read_buffer('TG2 ',pfield,iret)
271 END SELECT
272 !
273 IF (iret /= 0) THEN
274  CALL abor1_sfx('MODE_READ_BUFFER: DEEP SOIL TEMPERATURE MISSING')
275 END IF
276 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_T2',1,zhook_handle)
277 !
278 !
279 END SUBROUTINE read_buffer_t2
280 !
281 ! #######################
282  SUBROUTINE read_buffer_wg(KLUOUT,HINMODEL,PFIELD,PD)
283 ! #######################
284 !
285 ! This tasks is divided in the following steps :
286 ! - computing the MesoNH constants
287 ! - reading the grib datas according to the type of file (ECMWF/Arpege/Aladin)
288 ! - converting from specific humidity to relative humidity
289 ! - interpolation with land mask
290 ! - converting back from relative humidity to specific humidity with MesoNH constants
291 ! Five different models are supported :
292 ! - ECMWF with 2 layers (untested)
293 ! - ECMWF with 3 layers (archive before 1991 - Blondin model)
294 ! - ECMWF with 4 layers (archive after 1991 - Viterbo model)
295 ! - Arpege/Aladin before ISBA (I don't know the name of this model)
296 ! - Arpege/Aladin with ISBA model
297 ! The available model is detect according to the fields which are presents :
298 ! - ECMWF archive : loads as many layers as possible
299 ! - Arpege/Aladin archive : ISBA model needs Clay and Sans fraction fields, if they
300 ! are present, they are used and the model is declared to be ISBA.
301 ! To detect the height of the layers, two methods are used :
302 ! - if level type is not 112, a default value is assumed and a warning message is
303 ! displayed
304 ! - if level type is ID 112, then the position of the top and bottom surface may be
305 ! given. If they are present, they are used, if not the default value is taken and
306 ! a warning message is issued.
307 !
308 USE modd_grid_buffer, ONLY : nni
309 USE modd_surf_par, ONLY : xundef
310 !
312 !
313 IMPLICIT NONE
314 !
315 !* dummy arguments
316 ! ---------------
317 !
318 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
319  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
320 REAL, DIMENSION(:,:), POINTER :: pfield ! field to initialize
321 REAL, DIMENSION(:,:), POINTER :: pd ! thickness of each layer
322 !
323 !
324 !* local variables
325 ! ---------------
326 !
327 LOGICAL :: gisba ! T: surface scheme in file is ISBA
328 INTEGER :: iret ! return code
329 REAL, DIMENSION(:), POINTER :: zfield ! field to read
330 REAL, DIMENSION(:,:), ALLOCATABLE:: zwg ! profile of soil water contents
331 REAL, DIMENSION(:), ALLOCATABLE:: zclay ! clay fraction
332 REAL, DIMENSION(:), ALLOCATABLE:: zsand ! sand fraction
333 REAL, DIMENSION(:), ALLOCATABLE:: zwwilt ! wilting point
334 REAL, DIMENSION(:), ALLOCATABLE:: zwfc ! field capacity
335 REAL, DIMENSION(:), ALLOCATABLE:: zwsat ! saturation
336 REAL(KIND=JPRB) :: zhook_handle
337 !
338 !-------------------------------------------------------------------------------
339 !
340 ! 1. Search and read clay fraction if available
341 ! ------------------------------------------
342 !
343 !
344 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_WG',0,zhook_handle)
345 ALLOCATE (zfield(nni))
346  CALL read_buffer('CLAY ',zfield,iret)
347 !
348 ! if not available, the model is not ISBA
349 IF (iret /= 0) THEN
350  gisba = .false.
351 ELSE
352  gisba = .true.
353  WRITE (kluout,'(A)') ' | The soil model is ISBA'
354  ALLOCATE (zclay(nni))
355  zclay(:) = zfield(:) / 100. ! this field is given in percent
356  DEALLOCATE (zfield)
357 END IF
358 !
359 !-------------------------------------------------------------------------------
360 !
361 ! 2. Search and read sand fraction if available
362 ! ------------------------------------------
363 !
364 ALLOCATE (zfield(nni))
365  CALL read_buffer('SAND ',zfield,iret)
366 !
367 ! if not available, the model is not ISBA (IWMODE=1)
368 IF (gisba) THEN
369  IF (iret /= 0) THEN
370  CALL abor1_sfx('MODE_READ_BUFFER: (WG) SAND FRACTION MISSING')
371  ELSE
372  ALLOCATE (zsand(nni))
373  zsand(:) = zfield(:) / 100. ! this field is given in percent
374  DEALLOCATE (zfield)
375  END IF
376 END IF
377 !
378 !-------------------------------------------------------------------------------
379 !
380 ! 3. Read layer 1 moisture
381 ! ---------------------
382 !
383 ALLOCATE (zfield(nni))
384  CALL read_buffer('WG1 ',zfield,iret)
385 IF (iret /= 0) THEN
386  CALL abor1_sfx('MODE_READ_BUFFER: SOIL MOISTURE LEVEL 1 MISSING')
387 END IF
388 !
389 ALLOCATE(zwg(nni,2))
390 zwg(:,1) = zfield(:)
391 DEALLOCATE(zfield)
392 !
393 !-------------------------------------------------------------------------------
394 !
395 ! 4. Read layer 2 moisture
396 ! ---------------------
397 !
398 ALLOCATE (zfield(nni))
399  CALL read_buffer('WG2 ',zfield,iret)
400 IF (iret /= 0) THEN
401  CALL abor1_sfx('MODE_READ_BUFFER: SOIL MOISTURE LEVEL 2 MISSING')
402 END IF
403 !
404 zwg(:,2) = zfield(:)
405 DEALLOCATE(zfield)
406 !
407 !-------------------------------------------------------------------------------
408 !
409 ! 5. Read layer 2 depth (ISBA only)
410 ! ------------------
411 !
412 ALLOCATE(pd(nni,3))
413 !
414 !* note that soil water reservoir is considered uniform between 0.2m and BUFFER soil depth
415 IF (gisba) THEN
416  ALLOCATE (zfield(nni))
417  CALL read_buffer('D2 ',zfield,iret)
418  IF (iret /= 0) THEN
419  CALL abor1_sfx('MODE_READ_BUFFER: LEVEL 2 DEPTH MISSING')
420  END IF
421  pd(:,1) = 0.01
422  pd(:,2) = 0.20
423  pd(:,3) = zfield(:)
424  !
425  !* updates Wg in m3/m3
426  !
427  zwg(:,1) = zwg(:,1) / 10.
428  zwg(:,2) = zwg(:,2) /(1000. * zfield(:))
429  DEALLOCATE(zfield)
430 ELSE
431  pd(:,1) = 0.01
432  pd(:,2) = 0.2
433  pd(:,3) = 2.0
434 END IF
435 !
436 !
437 !-------------------------------------------------------------------------------
438 !
439 ! 6. Compute relative humidity from units kg/m^2
440 ! -------------------------------------------
441 !
442 ALLOCATE(pfield(nni,3))
443 !
444 ! Compute ISBA model constants (if needed)
445 !
446 IF (gisba) THEN
447  ALLOCATE (zwfc(nni))
448  ALLOCATE (zwwilt(nni))
449  ALLOCATE (zwsat(nni))
450  !
451  zwsat(:) = (-1.08*100. * zsand(:) + 494.305) * 0.001
452  zwwilt(:) = 37.1342e-3 * sqrt( 100. * zclay(:) )
453  zwfc(:) = 89.0467e-3 * (100. * zclay(:) )**0.3496
454  !
455  DEALLOCATE (zsand)
456  DEALLOCATE (zclay)
457 
458  zwg(:,1) = max(min(zwg(:,1),zwsat),0.)
459  zwg(:,2) = max(min(zwg(:,2),zwsat),0.)
460  !
461  pfield(:,1) = (zwg(:,1) - zwwilt) / (zwfc - zwwilt)
462  pfield(:,2) = (zwg(:,2) - zwwilt) / (zwfc - zwwilt)
463  pfield(:,3) = pfield(:,2)
464  DEALLOCATE (zwsat)
465  DEALLOCATE (zwwilt)
466  DEALLOCATE (zwfc)
467  !
468 ELSE ! Non ISBA
469  pfield(:,1) = zwg(:,1) / 20.
470  pfield(:,2) = (zwg(:,1)+zwg(:,2)) / (20. + 100.)
471  pfield(:,3) = pfield(:,2)
472 END IF
473 !
474 DEALLOCATE(zwg)
475 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_WG',1,zhook_handle)
476 !
477 !-------------------------------------------------------------------------------
478 !
479 END SUBROUTINE read_buffer_wg
480 !
481 !-------------------------------------------------------------------
482 !
483 ! #######################
484  SUBROUTINE read_buffer_wgi(KLUOUT,HINMODEL,PFIELD,PD)
485 ! #######################
486 !
487 ! This tasks is divided in the following steps :
488 ! - computing the MesoNH constants
489 ! - reading the grib datas according to the type of file (ECMWF/Arpege/Aladin)
490 ! - converting from specific humidity to relative humidity
491 ! - interpolation with land mask
492 ! - converting back from relative humidity to specific humidity with MesoNH constants
493 ! Five different models are supported :
494 ! - ECMWF with 2 layers (untested)
495 ! - ECMWF with 3 layers (archive before 1991 - Blondin model)
496 ! - ECMWF with 4 layers (archive after 1991 - Viterbo model)
497 ! - Arpege/Aladin before ISBA (I don't know the name of this model)
498 ! - Arpege/Aladin with ISBA model
499 ! The available model is detect according to the fields which are presents :
500 ! - ECMWF archive : loads as many layers as possible
501 ! - Arpege/Aladin archive : ISBA model needs Clay and Sans fraction fields, if they
502 ! are present, they are used and the model is declared to be ISBA.
503 ! To detect the height of the layers, two methods are used :
504 ! - if level type is not 112, a default value is assumed and a warning message is
505 ! displayed
506 ! - if level type is ID 112, then the position of the top and bottom surface may be
507 ! given. If they are present, they are used, if not the default value is taken and
508 ! a warning message is issued.
509 !
510 USE modd_grid_buffer, ONLY : nni
511 USE modd_surf_par, ONLY : xundef
512 !
514 !
515 IMPLICIT NONE
516 !
517 !* dummy arguments
518 ! ---------------
519 !
520 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
521  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
522 REAL, DIMENSION(:,:), POINTER :: pfield ! field to initialize
523 REAL, DIMENSION(:,:), POINTER :: pd ! thickness of each layer
524 !
525 !
526 !* local variables
527 ! ---------------
528 !
529 LOGICAL :: gisba ! T: surface scheme in file is ISBA
530 INTEGER :: iret ! return code
531 REAL, DIMENSION(:), POINTER :: zfield ! field to read
532 REAL, DIMENSION(:,:), ALLOCATABLE:: zwgi ! profile of soil ice contents
533 REAL, DIMENSION(:), ALLOCATABLE:: zclay ! clay fraction
534 REAL, DIMENSION(:), ALLOCATABLE:: zsand ! sand fraction
535 REAL, DIMENSION(:), ALLOCATABLE:: zwwilt ! wilting point
536 REAL, DIMENSION(:), ALLOCATABLE:: zwfc ! field capacity
537 REAL, DIMENSION(:), ALLOCATABLE:: zwsat ! saturation
538 REAL(KIND=JPRB) :: zhook_handle
539 !
540 !-------------------------------------------------------------------------------
541 !
542 ! 1. Search and read clay fraction if available
543 ! ------------------------------------------
544 !
545 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_WGI',0,zhook_handle)
546 ALLOCATE (zfield(nni))
547  CALL read_buffer('CLAY ',zfield,iret)
548 !
549 ! if not available, the model is not ISBA (IWMODE=1)
550 IF (iret /= 0) THEN
551  gisba = .false.
552 ELSE
553  gisba = .true.
554  WRITE (kluout,'(A)') ' | The soil model is ISBA'
555  ALLOCATE (zclay(nni))
556  zclay(:) = zfield(:) / 100. ! this field is given in percent
557  DEALLOCATE (zfield)
558 END IF
559 !
560 !-------------------------------------------------------------------------------
561 !
562 ! 2. Search and read sand fraction if available
563 ! ------------------------------------------
564 !
565 ALLOCATE (zfield(nni))
566  CALL read_buffer('SAND ',zfield,iret)
567 !
568 ! if not available, the model is not ISBA (IWMODE=1)
569 IF (gisba) THEN
570  IF (iret /= 0) THEN
571  CALL abor1_sfx('MODE_READ_BUFFER: (WGI) SAND FRACTION MISSING')
572  ELSE
573  ALLOCATE (zsand(nni))
574  zsand(:) = zfield(:) / 100. ! this field is given in percent
575  DEALLOCATE (zfield)
576  END IF
577 END IF
578 !
579 !-------------------------------------------------------------------------------
580 !
581 ! 3. Allocate soil ice reservoir
582 ! ---------------------------
583 !
584 ALLOCATE(zwgi(nni,2))
585 !
586 !-------------------------------------------------------------------------------
587 !
588 ! 4. Read layer 1 soil ice
589 ! ---------------------
590 !
591 ALLOCATE (zfield(nni))
592  CALL read_buffer('WGI1 ',zfield,iret)
593 IF (iret == 0) THEN
594  WRITE (kluout,'(A)') ' -> Soil ice level 1 is present'
595  zwgi(:,1) = zfield(:)
596  DEALLOCATE(zfield)
597 ELSE
598  zwgi(:,1) = 0.
599 END IF
600 !
601 !
602 !-------------------------------------------------------------------------------
603 !
604 ! 5. Read layer 2 soil ice
605 ! ---------------------
606 !
607 ALLOCATE (zfield(nni))
608  CALL read_buffer('WGI2 ',zfield,iret)
609 IF (iret == 0) THEN
610  WRITE (kluout,'(A)') ' -> Soil ice level 2 is present'
611  zwgi(:,2) = zfield(:)
612  DEALLOCATE(zfield)
613 ELSE
614  zwgi(:,2) = 0.
615 END IF
616 !
617 !
618 !-------------------------------------------------------------------------------
619 !
620 ! 5. Read layer 2 depth (ISBA only)
621 ! ------------------
622 !
623 ALLOCATE(pd(nni,3))
624 !
625 IF (gisba) THEN
626  ALLOCATE (zfield(nni))
627  CALL read_buffer('D2 ',zfield,iret)
628  IF (iret /= 0) THEN
629  CALL abor1_sfx('MODE_READ_BUFFER: LEVEL 2 DEPTH FOR ICE MISSING')
630  END IF
631  pd(:,1) = 0.01
632  pd(:,2) = 0.20
633  pd(:,3) = zfield(:)
634  !
635  !* updates Wgi in m3/m3
636  !
637  zwgi(:,1) = zwgi(:,1) / 10.
638  zwgi(:,2) = zwgi(:,2) /(1000. * zfield(:))
639  DEALLOCATE(zfield)
640 ELSE
641  pd(:,1) = 0.01
642  pd(:,2) = 0.20
643  pd(:,3) = 2.0
644 END IF
645 !
646 !
647 !-------------------------------------------------------------------------------
648 !
649 ! 6. Compute relative humidity from units kg/m^2
650 ! -------------------------------------------
651 !
652 ALLOCATE(pfield(nni,3))
653 !
654 ! Compute ISBA model constants (if needed)
655 !
656 IF (gisba) THEN
657  ALLOCATE (zwfc(nni))
658  ALLOCATE (zwwilt(nni))
659  ALLOCATE (zwsat(nni))
660  !
661  zwsat(:) = (-1.08*100. * zsand(:) + 494.305) * 0.001
662  zwwilt(:) = 37.1342e-3 * sqrt( 100. * zclay(:) )
663  zwfc(:) = 89.0467e-3 * (100. * zclay(:) )**0.3496
664  !
665  DEALLOCATE (zsand)
666  DEALLOCATE (zclay)
667 
668  zwgi(:,1) = max(min(zwgi(:,1),zwsat),0.)
669  zwgi(:,2) = max(min(zwgi(:,2),zwsat),0.)
670  !
671  pfield(:,1) = zwgi(:,1) / zwsat
672  pfield(:,2) = zwgi(:,2) / zwsat
673  pfield(:,3) = pfield(:,2)
674  DEALLOCATE (zwsat)
675  DEALLOCATE (zwwilt)
676  DEALLOCATE (zwfc)
677  !
678 ELSE ! Non ISBA
679  pfield(:,1) = 0.
680  pfield(:,2) = 0.
681  pfield(:,3) = 0.
682 END IF
683 !
684 DEALLOCATE(zwgi)
685 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_WGI',1,zhook_handle)
686 !
687 !-------------------------------------------------------------------------------
688 !
689 END SUBROUTINE read_buffer_wgi
690 !
691 !-------------------------------------------------------------------
692 !
693 ! #######################
694  SUBROUTINE read_buffer_tg(KLUOUT,HINMODEL,PFIELD,PD)
695 ! #######################
696 !
697 !
698 USE modd_grid_buffer, ONLY : nni
699 USE modd_surf_par, ONLY : xundef
700 !
702 !
703 IMPLICIT NONE
704 !
705 !* dummy arguments
706 ! ---------------
707 !
708 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
709  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
710 REAL, DIMENSION(:,:), POINTER :: pfield ! field to initialize
711 REAL, DIMENSION(:,:), POINTER :: pd ! thickness of each layer
712 !
713 !
714 !* local variables
715 ! ---------------
716 !
717 REAL, DIMENSION(:), POINTER :: zfield ! field to read
718 REAL(KIND=JPRB) :: zhook_handle
719 !
720 !--------------------------------------------------------------------------------
721 !
722 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_TG',0,zhook_handle)
723 WRITE (kluout,'(A)') ' | Reading soil temperature'
724 !
725 !--------------------------------------------------------------------------------
726 !
727 ! 1. Allocate soil temperature profile
728 ! ---------------------------------
729 !
730 ALLOCATE(pfield(nni,3))
731 ALLOCATE(pd(nni,3))
732 !
733 !--------------------------------------------------------------------------------
734 !
735 ! 2. Search and read level 1 (and its depth)
736 ! -----------------------
737 !
738 ALLOCATE (zfield(nni))
739  CALL read_buffer_ts(kluout,hinmodel,zfield)
740 !
741 pfield(:,1) = zfield(:)
742 pd(:,1) = 0.01
743 DEALLOCATE(zfield)
744 !
745 !--------------------------------------------------------------------------------
746 !
747 ! 3. Deep soil temperature
748 ! ---------------------
749 !
750 ALLOCATE (zfield(nni))
751  CALL read_buffer_t2(kluout,hinmodel,zfield)
752 !
753 pfield(:,2) = zfield(:)
754 pd(:,2) = 0.4 ! deep temperature depth assumed equal to 0.2m
755 DEALLOCATE(zfield)
756 !
757 !--------------------------------------------------------------------------------
758 !
759 ! 4. Assumes uniform temperature profile below
760 ! -----------------------------------------
761 !
762 pfield(:,3) = pfield(:,2)
763 pd(:,3) = 5. ! temperature profile down to 5m
764 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_TG',1,zhook_handle)
765 !
766 !
767 !--------------------------------------------------------------------------------
768 !
769 END SUBROUTINE read_buffer_tg
770 !-------------------------------------------------------------------
771 !---------------------------------------------------------------------------------------
772 !
773 ! #######################
774  SUBROUTINE read_buffer_snow_veg_depth(KLUOUT,HINMODEL,PFIELD)
775 ! #######################
776 !
777 !
778 USE modd_grid_buffer, ONLY : nni
779 USE modd_surf_par, ONLY : xundef
780 USE modd_snow_par, ONLY : xrhosmax
781 !
783 !
784 IMPLICIT NONE
785 !
786 !* dummy arguments
787 ! ---------------
788 !
789 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
790  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
791 REAL, DIMENSION(:), POINTER :: pfield ! field to initialize
792 !
793 !
794 !* local variables
795 ! ---------------
796 !
797 INTEGER :: iret ! return code
798 REAL(KIND=JPRB) :: zhook_handle
799 
800 !
801 !--------------------------------------------------------------------------------
802 !
803 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_SNOW_VEG_DEPTH',0,zhook_handle)
804 WRITE (kluout,'(A)') ' | Reading snow depth'
805 !
806 !--------------------------------------------------------------------------------
807 !
808 ! 1. Allocate soil temperature profile
809 ! ---------------------------------
810 !
811 ALLOCATE(pfield(nni))
812 !
813 !--------------------------------------------------------------------------------
814 !
815 ! 2. Search and read level 1 (kg/m2)
816 ! -----------------------
817 !
818  CALL read_buffer('SNOW ',pfield,iret)
819 !
820 ! conversion to snow depth (meters)
821 !
822  pfield = pfield / xrhosmax
823 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_SNOW_VEG_DEPTH',1,zhook_handle)
824 !
825 !--------------------------------------------------------------------------------
826 !
827 END SUBROUTINE read_buffer_snow_veg_depth
828 !-------------------------------------------------------------------
829 !-------------------------------------------------------------------
830 !---------------------------------------------------------------------------------------
831 !
832 ! #######################
833  SUBROUTINE read_buffer_snow_veg(KLUOUT,HINMODEL,PFIELD)
834 ! #######################
835 !
836 !
837 USE modd_grid_buffer, ONLY : nni
838 USE modd_surf_par, ONLY : xundef
839 USE modd_snow_par, ONLY : xrhosmax
840 !
842 !
843 IMPLICIT NONE
844 !
845 !* dummy arguments
846 ! ---------------
847 !
848 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
849  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
850 REAL, DIMENSION(:), POINTER :: pfield ! field to initialize
851 !
852 !
853 !* local variables
854 ! ---------------
855 !
856 INTEGER :: iret ! return code
857 REAL(KIND=JPRB) :: zhook_handle
858 
859 !
860 !--------------------------------------------------------------------------------
861 !
862 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_SNOW_VEG',0,zhook_handle)
863 WRITE (kluout,'(A)') ' | Reading snow content (kg/m2)'
864 !
865 !--------------------------------------------------------------------------------
866 !
867 ! 1. Allocate soil temperature profile
868 ! ---------------------------------
869 !
870 ALLOCATE(pfield(nni))
871 !
872 !--------------------------------------------------------------------------------
873 !
874 ! 2. Search and read level 1 (and its depth)
875 ! -----------------------
876 !
877  CALL read_buffer('SNOW ',pfield,iret)
878 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_SNOW_VEG',1,zhook_handle)
879 !
880 !
881 !--------------------------------------------------------------------------------
882 !
883 END SUBROUTINE read_buffer_snow_veg
884 !-------------------------------------------------------------------
885 !-------------------------------------------------------------------
886 !---------------------------------------------------------------------------------------
887 !
888 ! #######################
889  SUBROUTINE read_buffer_t_teb(KLUOUT,HINMODEL,PTI,PFIELD,PD)
890 ! #######################
891 !
892 !
893 USE modd_grid_buffer, ONLY : nni
894 USE modd_surf_par, ONLY : xundef
895 !
896 IMPLICIT NONE
897 !
898 !* dummy arguments
899 ! ---------------
900 !
901 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
902  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
903 REAL, INTENT(IN) :: pti ! internal temperature
904 REAL, DIMENSION(:,:), POINTER :: pfield ! field to initialize
905 REAL, DIMENSION(:,:), POINTER :: pd ! normalized grid
906 !
907 !
908 !* local variables
909 ! ---------------
910 !
911 REAL, DIMENSION(:), POINTER :: zfield ! field to read
912 REAL(KIND=JPRB) :: zhook_handle
913 !
914 !--------------------------------------------------------------------------------
915 !
916 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_T_TEB',0,zhook_handle)
917 WRITE (kluout,'(A)') ' | Reading temperature for buildings'
918 !
919 !--------------------------------------------------------------------------------
920 !
921 ! 1. Allocate soil temperature profile
922 ! ---------------------------------
923 !
924 ALLOCATE(pfield(nni,3))
925 ALLOCATE(pd(nni,3))
926 !
927 !--------------------------------------------------------------------------------
928 !
929 ! 2. Search and read level 1
930 ! -----------------------
931 !
932 ALLOCATE (zfield(nni))
933  CALL read_buffer_ts(kluout,hinmodel,zfield)
934 !
935 pfield(:,1) = zfield(:)
936 pd(:,1) = 0.
937 DEALLOCATE(zfield)
938 !
939 !--------------------------------------------------------------------------------
940 !
941 ! 3. Deep temperature
942 ! ----------------
943 !
944 pfield(:,2) = pti
945 pd(:,2) = 0.5 ! deep temperature depth assumed at half of wall or roof
946 !
947 !--------------------------------------------------------------------------------
948 !
949 ! 4. Assumes uniform temperature profile below
950 ! -----------------------------------------
951 !
952 pfield(:,3) = pti
953 pd(:,3) = 1. ! temperature at building interior
954 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_T_TEB',1,zhook_handle)
955 !
956 !
957 !--------------------------------------------------------------------------------
958 !
959 END SUBROUTINE read_buffer_t_teb
960 !-------------------------------------------------------------------
961 !
962 ! #######################
963  SUBROUTINE read_buffer_tf_teb(KLUOUT,HINMODEL,PTI,PFIELD,PD)
964 ! #######################
965 !
966 !
967 USE modd_grid_buffer, ONLY : nni
968 USE modd_surf_par, ONLY : xundef
969 !
971 !
972 IMPLICIT NONE
973 !
974 !* dummy arguments
975 ! ---------------
976 !
977 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
978  CHARACTER(LEN=6), INTENT(IN) :: hinmodel ! Grib originating model
979 REAL, INTENT(IN) :: pti ! internal temperature
980 REAL, DIMENSION(:,:), POINTER :: pfield ! field to initialize
981 REAL, DIMENSION(:,:), POINTER :: pd ! thickness of each layer
982 !
983 !
984 !* local variables
985 ! ---------------
986 !
987 REAL, DIMENSION(:), POINTER :: zfield ! field to read
988 REAL(KIND=JPRB) :: zhook_handle
989 !
990 !--------------------------------------------------------------------------------
991 !
992 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_TF_TEB',0,zhook_handle)
993 WRITE (kluout,'(A)') ' | Reading soil temperature'
994 !
995 !--------------------------------------------------------------------------------
996 !
997 ! 1. Allocate soil temperature profile
998 ! ---------------------------------
999 !
1000 ALLOCATE(pfield(nni,3))
1001 ALLOCATE(pd(nni,3))
1002 !
1003 !--------------------------------------------------------------------------------
1004 !
1005 ! 2. use building internal temperature as first level
1006 ! -----------------------
1007 !
1008 ALLOCATE (zfield(nni))
1009 !
1010 pfield(:,1) = pti
1011 pd(:,1) = 0.
1012 DEALLOCATE(zfield)
1013 !
1014 !--------------------------------------------------------------------------------
1015 !
1016 ! 3. Deep soil temperature
1017 ! ---------------------
1018 !
1019 ALLOCATE (zfield(nni))
1020  CALL read_buffer_t2(kluout,hinmodel,zfield)
1021 !
1022 pfield(:,2) = zfield(:)
1023 pd(:,2) = 0.5 ! deep temperature depth assumed at half of the floor
1024 DEALLOCATE(zfield)
1025 !
1026 !--------------------------------------------------------------------------------
1027 !
1028 ! 4. Assumes uniform temperature profile below
1029 ! -----------------------------------------
1030 !
1031 pfield(:,3) = pfield(:,2)
1032 pd(:,3) = 1. ! temperature profile down to depth of the floor
1033 !
1034 !
1035 IF (lhook) CALL dr_hook('MODE_READ_BUFFER:READ_BUFFER_TF_TEB',1,zhook_handle)
1036 !
1037 !--------------------------------------------------------------------------------
1038 !
1039 END SUBROUTINE read_buffer_tf_teb
1040 !-------------------------------------------------------------------
1041 END MODULE mode_read_buffer
subroutine read_buffer_wgi(KLUOUT, HINMODEL, PFIELD, PD)
subroutine read_buffer_tg(KLUOUT, HINMODEL, PFIELD, PD)
subroutine read_buffer_snow_veg_depth(KLUOUT, HINMODEL, PFIELD)
subroutine read_buffer_land_mask(KLUOUT, HINMODEL, PMASK)
subroutine read_buffer_ts(KLUOUT, HINMODEL, PFIELD)
subroutine read_buffer_t_teb(KLUOUT, HINMODEL, PTI, PFIELD, PD)
subroutine read_buffer_sst(KLUOUT, HINMODEL, PFIELD)
subroutine read_buffer_wg(KLUOUT, HINMODEL, PFIELD, PD)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine read_buffer_snow_veg(KLUOUT, HINMODEL, PFIELD)
subroutine read_buffer_tf_teb(KLUOUT, HINMODEL, PTI, PFIELD, PD)
subroutine read_buffer_t2(KLUOUT, HINMODEL, PFIELD)
subroutine read_buffer_zs_sea(KLUOUT, HINMODEL, PFIELD)
subroutine read_buffer_zs_land(KLUOUT, HINMODEL, PFIELD)
subroutine read_buffer_zs(KLUOUT, HINMODEL, PFIELD)