SURFEX v8.1
General documentation of Surfex
write_data.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 write_data(HPROGRAM)
7 ! #########################
8 !
9 !!**** *WRITE_DATA* initializes cover-field correspondance arrays
10 !!
11 !! PURPOSE
12 !! -------
13 !!
14 !! METHOD
15 !! ------
16 !!
17 !!
18 !! EXTERNAL
19 !! --------
20 !!
21 !! IMPLICIT ARGUMENTS
22 !! ------------------
23 !!
24 !! REFERENCE
25 !! ---------
26 !!
27 !! AUTHOR
28 !! ------
29 !!
30 !! V. Masson Meteo-France
31 !!
32 !! MODIFICATION
33 !! ------------
34 !!
35 !! Original 15/12/97
36 !! F.solmon 01/06/00 adaptation for patch approach
37 !! R. Alkama 05/2012 : add new vegtypes (from 12 to 19)
38 !----------------------------------------------------------------------------
39 !
40 !* 0. DECLARATION
41 ! -----------
42 
43 USE modd_surf_par, ONLY : xundef
44 !
50 USE modd_data_cover_par, ONLY : cnames, nvegtype
51 !
52 
53 USE modd_data_cover_par, ONLY : nvegtype, jpcover, nvt_irr
54 !
55 !
56 USE yomhook ,ONLY : lhook, dr_hook
57 USE parkind1 ,ONLY : jprb
58 !
59 IMPLICIT NONE
60 !
61 !* 0.1 Declaration of arguments
62 ! ------------------------
63 !
64  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! Type of program
65 !
66 !
67 !* 0.2 Declaration of local variables
68 ! ------------------------------
69 !
70 !
71 INTEGER :: JCOVER,JDEC,JK ! loop counters on covers, decades and vegtypes
72 INTEGER :: JBEG
73 !
74 !* 0.3 Declaration of namelists
75 ! ------------------------
76 !
77  CHARACTER(LEN=8), DIMENSION(NVEGTYPE) :: CNVT
78  CHARACTER(LEN=2) :: CF
79 REAL(KIND=JPRB) :: ZHOOK_HANDLE
80 !-------------------------------------------------------------------------------
81 IF (lhook) CALL dr_hook('WRITE_DATA',0,zhook_handle)
82 IF (nvt_irr/=0) THEN
83  jbeg = 301
84  cnvt(1) = "NVT_NO " ! no vegetation (smooth)
85  cnvt(2) = "NVT_ROCK" ! no vegetation (rocks)
86  cnvt(3) = "NVT_SNOW" ! permanent snow and ice
87  cnvt(4) = "NVT_TEBD" ! temperate broadleaf deciduous trees
88  cnvt(5) = "NVT_BONE" ! boreal needleleaf evergreen trees
89  cnvt(6) = "NVT_TRBE" ! tropical broadleaf evergreen trees
90  cnvt(7) = "NVT_C3 " ! C3 cultures types
91  cnvt(8) = "NVT_C4 " ! C4 cultures types
92  cnvt(9) = "NVT_IRR " ! irrigated crops
93  cnvt(10)= "NVT_GRAS" ! temperate grassland C3
94  cnvt(11)= "NVT_TROG" ! tropical grassland C4
95  cnvt(12)= "NVT_PARK" ! peat bogs, parks and gardens (irrigated grass)
96  cnvt(13)= "NVT_TRBD" ! tropical broadleaf deciduous trees
97  cnvt(14)= "NVT_TEBE" ! temperate broadleaf evergreen trees
98  cnvt(15)= "NVT_TENE" ! temperate needleleaf evergreen trees
99  cnvt(16)= "NVT_BOBD" ! boreal broadleaf deciduous trees
100  cnvt(17)= "NVT_BOND" ! boreal needleleaf deciduous trees
101  cnvt(18)= "NVT_BOGR" ! boreal grassland C3
102  cnvt(19)= "NVT_SHRB" ! broadleaf shrub
103 ELSE
104  jbeg = 1
105  cnvt(1) = "NVT_NO " ! no vegetation (smooth)
106  cnvt(2) = "NVT_ROCK" ! no vegetation (rocks)
107  cnvt(3) = "NVT_SNOW" ! permanent snow and ice
108  cnvt(4) = "NVT_BOBD" ! boreal broadleaf deciduous trees
109  cnvt(5) = "NVT_TEBD" ! temperate broadleaf deciduous trees
110  cnvt(6) = "NVT_TRBD" ! tropical broadleaf deciduous trees
111  cnvt(7) = "NVT_TEBE" ! temperate broadleaf evergreen trees
112  cnvt(8) = "NVT_TRBE" ! tropical broadleaf evergreen trees
113  cnvt(9) = "NVT_BONE" ! boreal needleleaf evergreen trees
114  cnvt(10)= "NVT_TENE" ! temperate needleleaf evergreen trees
115  cnvt(11)= "NVT_BOND" ! boreal needleleaf deciduous trees
116  cnvt(12)= "NVT_GRAS" ! temperate grassland C3
117  cnvt(13)= "NVT_TROG" ! tropical grassland C4
118  cnvt(14)= "NVT_BOGR" ! boreal grassland C3
119  cnvt(15)= "NVT_SHRB" ! broadleaf shrub
120  cnvt(16)= "NVT_C3W " ! winter C3 cultures types
121  cnvt(17)= "NVT_C3E " ! summer C3 cultures types
122  cnvt(18)= "NVT_C4 " ! C4 cultures types
123  cnvt(19)= "NVT_FLTR" ! flooded trees
124  cnvt(20)= "NVT_FLGR" ! flooded grassland
125 ENDIF
126 !
127 DO jcover=jbeg,jpcover
128 WRITE(*,fmt='(A80)') '!-------------------------------------------------------------------------------'
129 WRITE(*,fmt='(A16,I3.3)') 'SUBROUTINE COVER',jcover
130 WRITE(*,fmt='(A1)') '!'
131 WRITE(*,fmt='(A10,I3.3)') '!* cover',jcover
132 WRITE(*,fmt='(A5,A60)') '! ',cnames(jcover,1)
133 WRITE(*,fmt='(A1)') '!'
134 WRITE(*,fmt='(A7,I3)') 'ICOVER=',jcover
135 WRITE(*,fmt='(A1)') '!'
136 WRITE(*,fmt='(A21,F4.2)') 'XDATA_TOWN (ICOVER)=',xdata_town(jcover)
137 WRITE(*,fmt='(A21,F4.2)') 'XDATA_NATURE(ICOVER)=',xdata_nature(jcover)
138 WRITE(*,fmt='(A21,F4.2)') 'XDATA_WATER (ICOVER)=',xdata_water(jcover)
139 WRITE(*,fmt='(A21,F4.2)') 'XDATA_SEA (ICOVER)=',xdata_sea(jcover)
140 WRITE(*,fmt='(A1)') '!'
141 DO jk=1,19
142  IF (xdata_vegtype(jcover,jk)==0.) cycle
143  IF (all(xdata_lai_all_years(jcover,:,jk)==0.)) THEN
144  WRITE(*,fmt='(A29,A8,A5)') &
145  'XDATA_LAI_ALL_YEARS(ICOVER,:,',cnvt(jk),')= 0.'
146  cycle
147  END IF
148  WRITE(*,fmt='(A29,A8,A7)') &
149  'XDATA_LAI_ALL_YEARS(ICOVER,:,',cnvt(jk),')= (/ &'
150  DO jdec=1,18
151  cf=', '
152  IF (jdec==18) cf=' '
153  WRITE(*,fmt='(A7,12(F4.1,A2),A1)') ' ', &
154  max(xdata_lai_all_years(jcover,(jdec-1)*12+1,jk),0.1),', ', &
155  max(xdata_lai_all_years(jcover,(jdec-1)*12+2,jk),0.1),', ', &
156  max(xdata_lai_all_years(jcover,(jdec-1)*12+3,jk),0.1),', ', &
157  max(xdata_lai_all_years(jcover,(jdec-1)*12+4,jk),0.1),', ', &
158  max(xdata_lai_all_years(jcover,(jdec-1)*12+5,jk),0.1),', ', &
159  max(xdata_lai_all_years(jcover,(jdec-1)*12+6,jk),0.1),', ', &
160  max(xdata_lai_all_years(jcover,(jdec-1)*12+7,jk),0.1),', ', &
161  max(xdata_lai_all_years(jcover,(jdec-1)*12+8,jk),0.1),', ', &
162  max(xdata_lai_all_years(jcover,(jdec-1)*12+9,jk),0.1),', ', &
163  max(xdata_lai_all_years(jcover,(jdec-1)*12+10,jk),0.1),', ', &
164  max(xdata_lai_all_years(jcover,(jdec-1)*12+11,jk),0.1),', ', &
165  max(xdata_lai_all_years(jcover,(jdec-1)*12+12,jk),0.1),cf,'&'
166  END DO
167  WRITE(*,fmt='(A7)') ' /)'
168 END DO
169 WRITE(*,fmt='(A1)') '!'
170 DO jk=1,19
171  IF (xdata_vegtype(jcover,jk)==0.) cycle
172  WRITE(*,fmt='(A21,A8,A3,F4.2)') &
173  'XDATA_VEGTYPE(ICOVER,',cnvt(jk),')= ',xdata_vegtype(jcover,jk)
174 END DO
175 WRITE(*,fmt='(A1)') '!'
176 DO jk=4,6
177  IF (xdata_vegtype(jcover,jk)==0.) cycle
178  WRITE(*,fmt='(A20,A8,A3,F4.1)') &
179  'XDATA_H_TREE(ICOVER,',cnvt(jk),')= ',xdata_h_tree(jcover,jk)
180 END DO
181 WRITE(*,fmt='(A1)') '!'
182 DO jk=1,19
183  IF (xdata_vegtype(jcover,jk)==0.) cycle
184  WRITE(*,fmt='(A24,A8,A3,F4.1)') &
185  'XDATA_ROOT_DEPTH(ICOVER,',cnvt(jk),')= ',xdata_root_depth(jcover,jk)
186 END DO
187 WRITE(*,fmt='(A1)') '!'
188 DO jk=1,19
189  IF (xdata_vegtype(jcover,jk)==0.) cycle
190  WRITE(*,fmt='(A26,A8,A3,F4.1)') &
191  'XDATA_GROUND_DEPTH(ICOVER,',cnvt(jk),')= ',xdata_ground_depth(jcover,jk)
192 END DO
193 WRITE(*,fmt='(A1)') '!'
194 IF (xdata_vegtype(jcover,9)/=0.) THEN
195  WRITE(*,fmt='(A18,A8,A15,I2.2)') &
196  'TDATA_SEED(ICOVER,',cnvt(9),')%TDATE%MONTH= ',tdata_seed(jcover,9)%TDATE%MONTH
197  WRITE(*,fmt='(A18,A8,A15,I2.2)') &
198  'TDATA_SEED(ICOVER,',cnvt(9),')%TDATE%DAY = ',tdata_seed(jcover,9)%TDATE%DAY
199  WRITE(*,fmt='(A18,A8,A15,I2.2)') &
200  'TDATA_REAP(ICOVER,',cnvt(9),')%TDATE%MONTH= ',tdata_reap(jcover,9)%TDATE%MONTH
201  WRITE(*,fmt='(A18,A8,A15,I2.2)') &
202  'TDATA_REAP(ICOVER,',cnvt(9),')%TDATE%DAY = ',tdata_reap(jcover,9)%TDATE%DAY
203  WRITE(*,fmt='(A20,A8,A3,F4.1)') &
204  'XDATA_WATSUP(ICOVER,',cnvt(9),')= ',xdata_watsup(jcover,9)
205  WRITE(*,fmt='(A20,A8,A3,F4.1)') &
206  'XDATA_IRRIG (ICOVER,',cnvt(9),')= ',xdata_irrig(jcover,9)
207 END IF
208 WRITE(*,fmt='(A20,I3.3)') 'END SUBROUTINE COVER',jcover
209 END DO
210 !-------------------------------------------------------------------------------
211 !-------------------------------------------------------------------------------
212 !-------------------------------------------------------------------------------
213 !
214 DO jcover=jbeg,jpcover
215  WRITE(*,fmt='(A10,I3.3)') 'CALL COVER',jcover
216 END DO
217 IF (lhook) CALL dr_hook('WRITE_DATA',1,zhook_handle)
218 !-------------------------------------------------------------------------------
219 !
220 END SUBROUTINE write_data
real, dimension(:,:), allocatable xdata_irrig
type(date_time), dimension(:,:), pointer tdata_seed
real, dimension(:,:,:), allocatable xdata_lai_all_years
real, dimension(:,:), allocatable xdata_root_depth
real, dimension(:,:), allocatable xdata_vegtype
real, dimension(:), allocatable xdata_water
real, parameter xundef
real, dimension(:), allocatable xdata_sea
type(date_time), dimension(:,:), pointer tdata_reap
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
real, dimension(:,:), allocatable xdata_h_tree
subroutine write_data(HPROGRAM)
Definition: write_data.F90:7
real, dimension(:,:,:), allocatable xdata_lai
real, dimension(:,:), allocatable xdata_watsup
real, dimension(:,:), allocatable xdata_ground_depth
real, dimension(:), allocatable xdata_town
real, dimension(:), allocatable xdata_nature