SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
writesurf_teb_canopyn.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_teb_canopy_n (DGU, U, &
7  tcp, top, &
8  hprogram,hwrite)
9 ! ####################################
10 !
11 !!**** *WRITE_TEB_n* - writes TEB fields
12 !!
13 !! PURPOSE
14 !! -------
15 !!
16 !!** METHOD
17 !! ------
18 !!
19 !! EXTERNAL
20 !! --------
21 !!
22 !!
23 !! IMPLICIT ARGUMENTS
24 !! ------------------
25 !!
26 !! REFERENCE
27 !! ---------
28 !!
29 !!
30 !! AUTHOR
31 !! ------
32 !! V. Masson *Meteo France*
33 !!
34 !! MODIFICATIONS
35 !! -------------
36 !! Original 01/2003
37 !! E. Martin 01/2012 avoid write of XUNDEF fields
38 !-------------------------------------------------------------------------------
39 !
40 !* 0. DECLARATIONS
41 ! ------------
42 !
43 !
44 !
45 !
46 !
47 !
49 USE modd_surf_atm_n, ONLY : surf_atm_t
50 !
53 !
54 USE modd_surf_par ,ONLY : xundef
55 !
57 !
58 USE yomhook ,ONLY : lhook, dr_hook
59 USE parkind1 ,ONLY : jprb
60 !
61 IMPLICIT NONE
62 !
63 !* 0.1 Declarations of arguments
64 ! -------------------------
65 !
66 !
67 !
68 TYPE(diag_surf_atm_t), INTENT(INOUT) :: dgu
69 TYPE(surf_atm_t), INTENT(INOUT) :: u
70 !
71 TYPE(teb_canopy_t), INTENT(INOUT) :: tcp
72 TYPE(teb_options_t), INTENT(INOUT) :: top
73 !
74  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling
75  CHARACTER(LEN=3), INTENT(IN) :: hwrite ! 'PREP' : does not write SBL XUNDEF fields
76 ! ! 'ALL' : all fields are written
77 !* 0.2 Declarations of local variables
78 ! -------------------------------
79 !
80 INTEGER :: iresp ! IRESP : return-code if a problem appears
81  CHARACTER(LEN=12) :: yrecfm ! Name of the article to be read
82  CHARACTER(LEN=100):: ycomment ! Comment string
83 !
84 INTEGER :: jlayer ! loop counter on layers
85 REAL(KIND=JPRB) :: zhook_handle
86 !
87 !-------------------------------------------------------------------------------
88 !
89 !* 1. Prognostic fields:
90 ! -----------------
91 !
92 !* flag to define if canopy is computed
93 !
94 IF (lhook) CALL dr_hook('WRITESURF_TEB_CANOPY_N',0,zhook_handle)
95 yrecfm='TEB_CANOPY'
96 ycomment='flag to use canopy levels'
97  CALL write_surf(dgu, u, &
98  hprogram,yrecfm,top%LCANOPY,iresp,hcomment=ycomment)
99 !
100 IF (.NOT. top%LCANOPY .AND. lhook) CALL dr_hook('WRITESURF_TEB_CANOPY_N',1,zhook_handle)
101 IF (.NOT. top%LCANOPY) RETURN
102 !
103 !* number of levels
104 !
105 yrecfm='TEB_CAN_LVL'
106 ycomment='number of canopy levels'
107  CALL write_surf(dgu, u, &
108  hprogram,yrecfm,tcp%NLVL,iresp,hcomment=ycomment)
109 !
110 !* altitudes
111 !
112 DO jlayer=1,tcp%NLVL
113  WRITE(yrecfm,'(A9,I2.2,A1)') 'TEB_CAN_Z',jlayer,' '
114  ycomment='altitudes of canopy levels (m)'
115  CALL write_surf(dgu, u, &
116  hprogram,yrecfm,tcp%XZ(:,jlayer),iresp,hcomment=ycomment)
117 END DO
118 !
119 IF (hwrite/='PRE') THEN
120  !
121  !* wind in canopy
122  !
123  DO jlayer=1,tcp%NLVL
124  WRITE(yrecfm,'(A9,I2.2,A1)') 'TEB_CAN_U',jlayer,' '
125  ycomment='wind at canopy levels (m/s)'
126  CALL write_surf(dgu, u, &
127  hprogram,yrecfm,tcp%XU(:,jlayer),iresp,hcomment=ycomment)
128  END DO
129  !
130  !* temperature in canopy
131  !
132  DO jlayer=1,tcp%NLVL
133  WRITE(yrecfm,'(A9,I2.2,A1)') 'TEB_CAN_T',jlayer,' '
134  ycomment='temperature at canopy levels (K)'
135  CALL write_surf(dgu, u, &
136  hprogram,yrecfm,tcp%XT(:,jlayer),iresp,hcomment=ycomment)
137  END DO
138  !
139  !* humidity in canopy
140  !
141  DO jlayer=1,tcp%NLVL
142  WRITE(yrecfm,'(A9,I2.2,A1)') 'TEB_CAN_Q',jlayer,' '
143  ycomment='humidity at canopy levels (kg/m3)'
144  CALL write_surf(dgu, u, &
145  hprogram,yrecfm,tcp%XQ(:,jlayer),iresp,hcomment=ycomment)
146  END DO
147  !
148  !* Tke in canopy
149  !
150  DO jlayer=1,tcp%NLVL
151  WRITE(yrecfm,'(A9,I2.2,A1)') 'TEB_CAN_E',jlayer,' '
152  ycomment='Tke at canopy levels (m2/s2)'
153  CALL write_surf(dgu, u, &
154  hprogram,yrecfm,tcp%XTKE(:,jlayer),iresp,hcomment=ycomment)
155  END DO
156  !
157  !* Monin-Obhukov length
158  !
159  DO jlayer=1,tcp%NLVL
160  WRITE(yrecfm,'(A10,I2.2)') 'TEB_CAN_MO',jlayer
161  ycomment='Monin-Obukhov length (m)'
162  CALL write_surf(dgu, u, &
163  hprogram,yrecfm,tcp%XLMO(:,jlayer),iresp,hcomment=ycomment)
164  END DO
165  !
166  !* mixing length
167  !
168  IF (ASSOCIATED(tcp%XLM)) THEN
169  DO jlayer=1,tcp%NLVL
170  WRITE(yrecfm,'(A10,I2.2)') 'TEB_CAN_LM',jlayer
171  ycomment='mixing length (m)'
172  CALL write_surf(dgu, u, &
173  hprogram,yrecfm,tcp%XLM(:,jlayer),iresp,hcomment=ycomment)
174  END DO
175  END IF
176  !
177  !* dissipative length
178  !
179  IF (ASSOCIATED(tcp%XLEPS)) THEN
180  DO jlayer=1,tcp%NLVL
181  WRITE(yrecfm,'(A10,I2.2)') 'TEB_CAN_LE',jlayer
182  ycomment='mixing length (m)'
183  CALL write_surf(dgu, u, &
184  hprogram,yrecfm,tcp%XLEPS(:,jlayer),iresp,hcomment=ycomment)
185  END DO
186  END IF
187  !
188  !* Air pressure in canopy
189  !
190  DO jlayer=1,tcp%NLVL
191  WRITE(yrecfm,'(A9,I2.2,A1)') 'TEB_CAN_P',jlayer,' '
192  ycomment='Pressure at canopy levels (Pa)'
193  CALL write_surf(dgu, u, &
194  hprogram,yrecfm,tcp%XP(:,jlayer),iresp,hcomment=ycomment)
195  END DO
196  !
197 ENDIF
198 !
199 IF (lhook) CALL dr_hook('WRITESURF_TEB_CANOPY_N',1,zhook_handle)
200 !-------------------------------------------------------------------------------
201 !
202 END SUBROUTINE writesurf_teb_canopy_n
subroutine writesurf_teb_canopy_n(DGU, U, TCP, TOP, HPROGRAM, HWRITE)