SURFEX v8.1
General documentation of Surfex
writesurf_sbln.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 writesurf_sbl_n (HSELECT, OSBL, SB, HPROGRAM, HWRITE, HSURF)
7 ! ####################################
8 !
9 !!**** *WRITE_FLAKE_n* - writes FLAKE fields
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/2003
35 !! E. Martin 01/2012 avoid write of XUNDEF fields
36 !-------------------------------------------------------------------------------
37 !
38 !* 0. DECLARATIONS
39 ! ------------
40 !
41 USE modd_canopy_n, ONLY : canopy_t
42 !
44 USE modi_end_io_surf_n
45 USE modi_init_io_surf_n
46 !
47 USE yomhook ,ONLY : lhook, dr_hook
48 USE parkind1 ,ONLY : jprb
49 !
50 IMPLICIT NONE
51 !
52 !* 0.1 Declarations of arguments
53 ! -------------------------
54 !
55  CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: HSELECT
56  LOGICAL, INTENT(IN) :: OSBL
57 !
58 TYPE(canopy_t), INTENT(INOUT) :: SB
59 !
60  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! program calling
61  CHARACTER(LEN=3), INTENT(IN) :: HWRITE ! 'PREP' : does not write SBL XUNDEF fields
62 ! ! 'ALL' : all fields are written
63  CHARACTER(LEN=6), INTENT(IN) :: HSURF
64 !
65 !* 0.2 Declarations of local variables
66 ! -------------------------------
67 !
68 INTEGER :: IRESP ! IRESP : return-code if a problem appears
69  CHARACTER(LEN=8) :: YBASE
70  CHARACTER(LEN=12) :: YRECFM ! Name of the article to be read
71  CHARACTER(LEN=13) :: YFORMAT
72  CHARACTER(LEN=100):: YCOMMENT ! Comment string
73 !
74 INTEGER :: JL ! loop counter on layers
75 REAL(KIND=JPRB) :: ZHOOK_HANDLE
76 !-------------------------------------------------------------------------------
77 !
78 !* 1. Prognostic fields:
79 ! -----------------
80 !
81 !* flag to define if SBL is computed
82 !
83 IF (lhook) CALL dr_hook('WRITESURF_SBL_N',0,zhook_handle)
84 !
85 IF (hsurf=="TOWN ") THEN
86  yrecfm='TEB_CANOPY'
87 ELSEIF (hsurf=="WATER ") THEN
88  yrecfm='WAT_SBL'
89 ELSEIF (hsurf=="NATURE") THEN
90  yrecfm='ISBA_CANOPY'
91 ELSEIF (hsurf=="SEA ") THEN
92  yrecfm='SEA_SBL'
93 ENDIF
94 ycomment='flag to use SBL levels'
95  CALL write_surf(hselect,hprogram,yrecfm,osbl,iresp,hcomment=ycomment)
96 !
97 IF (.NOT. osbl .AND. lhook) CALL dr_hook('WRITESURF_SBL_N',1,zhook_handle)
98 IF (.NOT. osbl) RETURN
99 !
100 IF (hsurf=="TOWN ") THEN
101  ybase = "TEB_CAN "
102 ELSEIF (hsurf=="WATER ") THEN
103  ybase = "WAT_SBL "
104 ELSEIF (hsurf=="NATURE") THEN
105  ybase = "ISBA_CAN"
106 ELSEIF (hsurf=="SEA ") THEN
107  ybase = "SEA_SBL "
108 ENDIF
109 !
110 IF (hsurf=="NATURE") THEN
111  yformat='(A10,I2.2)'
112 ELSE
113  yformat='(A9,I2.2) '
114 ENDIF
115 !
116 !* number of levels
117 !
118 yrecfm=trim(ybase)//'_LVL'
119 ycomment='number of SBL levels'
120  CALL write_surf(hselect,hprogram,yrecfm,sb%NLVL,iresp,hcomment=ycomment)
121 !
122 !* altitudes
123 !
124 DO jl=1,sb%NLVL
125  WRITE(yrecfm,yformat) trim(ybase)//'_Z',jl
126  ycomment='altitudes of SBL levels (m)'
127  CALL write_surf(hselect,hprogram,yrecfm,sb%XZ(:,jl),iresp,hcomment=ycomment)
128 END DO
129 !
130 IF (hwrite/='PRE') THEN
131  !
132  !* wind in SBL
133  !
134  DO jl=1,sb%NLVL
135  WRITE(yrecfm,yformat) trim(ybase)//'_U',jl
136  ycomment='wind at SBL levels (m/s)'
137  CALL write_surf(hselect,hprogram,yrecfm,sb%XU(:,jl),iresp,hcomment=ycomment)
138  END DO
139  !
140  !* temperature in SBL
141  !
142  DO jl=1,sb%NLVL
143  WRITE(yrecfm,yformat) trim(ybase)//'_T',jl
144  ycomment='temperature at SBL levels (K)'
145  CALL write_surf(hselect,hprogram,yrecfm,sb%XT(:,jl),iresp,hcomment=ycomment)
146  END DO
147  !
148  !* humidity in SBL
149  !
150  DO jl=1,sb%NLVL
151  WRITE(yrecfm,yformat) trim(ybase)//'_Q',jl
152  ycomment='humidity at SBL levels (kg/m3)'
153  CALL write_surf(hselect,hprogram,yrecfm,sb%XQ(:,jl),iresp,hcomment=ycomment)
154  END DO
155  !
156  !* Tke in SBL
157  !
158  DO jl=1,sb%NLVL
159  WRITE(yrecfm,yformat) trim(ybase)//'_E',jl
160  ycomment='Tke at SBL levels (m2/s2)'
161  CALL write_surf(hselect,hprogram,yrecfm,sb%XTKE(:,jl),iresp,hcomment=ycomment)
162  END DO
163  !
164  !* Monin-Obhukov length
165  !
166  IF (hsurf=="TOWN ") THEN
167  !
168  DO jl=1,sb%NLVL
169  WRITE(yrecfm,'(A10,I2.2)') trim(ybase)//'_MO',jl
170  ycomment='Monin-Obukhov length (m)'
171  CALL write_surf(hselect,hprogram,yrecfm,sb%XLMO(:,jl),iresp,hcomment=ycomment)
172  END DO
173  !
174  !* mixing length
175  !
176  IF (ASSOCIATED(sb%XLM)) THEN
177  DO jl=1,sb%NLVL
178  WRITE(yrecfm,'(A10,I2.2)') trim(ybase)//'_LM',jl
179  ycomment='mixing length (m)'
180  CALL write_surf(hselect,hprogram,yrecfm,sb%XLM(:,jl),iresp,hcomment=ycomment)
181  END DO
182  END IF
183  !
184  !* dissipative length
185  !
186  IF (ASSOCIATED(sb%XLEPS)) THEN
187  DO jl=1,sb%NLVL
188  WRITE(yrecfm,'(A10,I2.2)') trim(ybase)//'_LE',jl
189  ycomment='mixing length (m)'
190  CALL write_surf(hselect,hprogram,yrecfm,sb%XLEPS(:,jl),iresp,hcomment=ycomment)
191  END DO
192  END IF
193  !
194  ELSE
195  yrecfm=trim(ybase)//'_LMO '
196  CALL write_surf(hselect,hprogram,yrecfm,sb%XLMO(:,sb%NLVL),iresp,hcomment=ycomment)
197  ENDIF
198  !
199  !* Air pressure in SBL
200  !
201  DO jl=1,sb%NLVL
202  WRITE(yrecfm,yformat) trim(ybase)//'_P',jl
203  ycomment='Pressure at SBL levels (Pa)'
204  CALL write_surf(hselect,hprogram,yrecfm,sb%XP(:,jl),iresp,hcomment=ycomment)
205  END DO
206  !
207 ENDIF
208 !
209 IF (lhook) CALL dr_hook('WRITESURF_SBL_N',1,zhook_handle)
210 !
211 !
212 !-------------------------------------------------------------------------------
213 !
214 END SUBROUTINE writesurf_sbl_n
static const char * trim(const char *name, int *n)
Definition: drhook.c:2383
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
subroutine writesurf_sbl_n(HSELECT, OSBL, SB, HPROGRAM, HWRITE, H