1 | subroutine phyetat0 (fichnom,tab0,Lmodif,nsoil,ngrid,nlay,nq, & |
---|
2 | day_ini,time0,tsurf,tsoil,emis,q2,qsurf,co2ice, & |
---|
3 | tauscaling) |
---|
4 | ! use netcdf |
---|
5 | use infotrac, only: nqtot, tname |
---|
6 | use surfdat_h, only: phisfi, albedodat, z0, z0_default,& |
---|
7 | zmea, zstd, zsig, zgam, zthe |
---|
8 | use control_mod, only: timestart |
---|
9 | use iostart, only: nid_start, open_startphy, close_startphy, & |
---|
10 | get_field, get_var, inquire_field, & |
---|
11 | inquire_dimension, inquire_dimension_length |
---|
12 | |
---|
13 | implicit none |
---|
14 | !====================================================================== |
---|
15 | ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818 |
---|
16 | ! Adaptation à Mars : Yann Wanherdrick |
---|
17 | ! Objet: Lecture de l etat initial pour la physique |
---|
18 | ! Modifs: Aug.2010 EM : use NetCDF90 to load variables (enables using |
---|
19 | ! r4 or r8 restarts independently of having compiled |
---|
20 | ! the GCM in r4 or r8) |
---|
21 | ! June 2013 TN : Possibility to read files with a time axis |
---|
22 | ! November 2013 EM : Enabeling parallel, using iostart module |
---|
23 | !====================================================================== |
---|
24 | !#include "netcdf.inc" |
---|
25 | !#include "dimensions.h" |
---|
26 | !#include "dimphys.h" |
---|
27 | !#include "comgeomfi.h" |
---|
28 | !#include "surfdat.h" |
---|
29 | !#include "dimradmars.h" |
---|
30 | !#include "yomaer.h" |
---|
31 | !#include "tracer.h" |
---|
32 | !#include "advtrac.h" |
---|
33 | !#include "control.h" |
---|
34 | !====================================================================== |
---|
35 | INTEGER nbsrf !Mars nbsrf a 1 au lieu de 4 |
---|
36 | PARAMETER (nbsrf=1) ! nombre de sous-fractions pour une maille |
---|
37 | !====================================================================== |
---|
38 | ! Arguments: |
---|
39 | ! --------- |
---|
40 | ! inputs: |
---|
41 | character*(*),intent(in) :: fichnom ! "startfi.nc" file |
---|
42 | integer,intent(in) :: tab0 |
---|
43 | integer,intent(in) :: Lmodif |
---|
44 | integer,intent(in) :: nsoil ! # of soil layers |
---|
45 | integer,intent(in) :: ngrid ! # of atmospheric columns |
---|
46 | integer,intent(in) :: nlay ! # of atmospheric layers |
---|
47 | integer,intent(in) :: nq |
---|
48 | integer :: day_ini |
---|
49 | real :: time0 |
---|
50 | |
---|
51 | ! outputs: |
---|
52 | real,intent(out) :: tsurf(ngrid) ! surface temperature |
---|
53 | real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature |
---|
54 | real,intent(out) :: emis(ngrid) ! surface emissivity |
---|
55 | real,intent(out) :: q2(ngrid,nlay+1) ! |
---|
56 | real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface |
---|
57 | real,intent(out) :: co2ice(ngrid) ! co2 ice cover |
---|
58 | real,intent(out) :: tauscaling(ngrid) ! dust conversion factor |
---|
59 | |
---|
60 | !====================================================================== |
---|
61 | ! Local variables: |
---|
62 | |
---|
63 | real surffield(ngrid) ! to temporarily store a surface field |
---|
64 | real xmin,xmax ! to display min and max of a field |
---|
65 | ! |
---|
66 | INTEGER ig,iq,lmax |
---|
67 | INTEGER nid, nvarid |
---|
68 | INTEGER ierr, i, nsrf |
---|
69 | ! integer isoil |
---|
70 | ! INTEGER length |
---|
71 | ! PARAMETER (length=100) |
---|
72 | CHARACTER*7 str7 |
---|
73 | CHARACTER*2 str2 |
---|
74 | CHARACTER*1 yes |
---|
75 | ! |
---|
76 | REAL p_rad,p_omeg,p_g,p_mugaz,p_daysec |
---|
77 | INTEGER nqold |
---|
78 | |
---|
79 | ! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...) |
---|
80 | logical :: oldtracernames=.false. |
---|
81 | integer :: count |
---|
82 | character(len=30) :: txt ! to store some text |
---|
83 | |
---|
84 | ! specific for time |
---|
85 | REAL,ALLOCATABLE :: time(:) ! times stored in start |
---|
86 | INTEGER timelen ! number of times stored in the file |
---|
87 | INTEGER indextime ! index of selected time |
---|
88 | |
---|
89 | INTEGER :: edges(3),corner(3) |
---|
90 | LOGICAL :: found |
---|
91 | |
---|
92 | ! open physics initial state file: |
---|
93 | call open_startphy(fichnom) |
---|
94 | |
---|
95 | |
---|
96 | ! possibility to modify tab_cntrl in tabfi |
---|
97 | write(*,*) |
---|
98 | write(*,*) 'TABFI in phyeta0: Lmodif=',Lmodif," tab0=",tab0 |
---|
99 | call tabfi (nid_start,Lmodif,tab0,day_ini,lmax,p_rad, & |
---|
100 | p_omeg,p_g,p_mugaz,p_daysec,time0) |
---|
101 | |
---|
102 | |
---|
103 | ! Load surface geopotential: |
---|
104 | call get_field("phisfi",phisfi,found) |
---|
105 | if (.not.found) then |
---|
106 | write(*,*) "phyetat0: Failed loading <phisfi>" |
---|
107 | call abort |
---|
108 | else |
---|
109 | write(*,*) "phyetat0: surface geopotential <phisfi> range:", & |
---|
110 | minval(phisfi), maxval(phisfi) |
---|
111 | endif |
---|
112 | |
---|
113 | |
---|
114 | ! Load bare ground albedo: |
---|
115 | call get_field("albedodat",albedodat,found) |
---|
116 | if (.not.found) then |
---|
117 | write(*,*) "phyetat0: Failed loading <albedodat>" |
---|
118 | call abort |
---|
119 | else |
---|
120 | write(*,*) "phyetat0: Bare ground albedo <albedodat> range:", & |
---|
121 | minval(albedodat), maxval(albedodat) |
---|
122 | endif |
---|
123 | |
---|
124 | ! ZMEA |
---|
125 | call get_field("ZMEA",zmea,found) |
---|
126 | if (.not.found) then |
---|
127 | write(*,*) "phyetat0: Failed loading <ZMEA>" |
---|
128 | call abort |
---|
129 | else |
---|
130 | write(*,*) "phyetat0: <ZMEA> range:", & |
---|
131 | minval(zmea), maxval(zmea) |
---|
132 | endif |
---|
133 | |
---|
134 | |
---|
135 | ! ZSTD |
---|
136 | call get_field("ZSTD",zstd,found) |
---|
137 | if (.not.found) then |
---|
138 | write(*,*) "phyetat0: Failed loading <ZSTD>" |
---|
139 | call abort |
---|
140 | else |
---|
141 | write(*,*) "phyetat0: <ZSTD> range:", & |
---|
142 | minval(zstd), maxval(zstd) |
---|
143 | endif |
---|
144 | |
---|
145 | |
---|
146 | ! ZSIG |
---|
147 | call get_field("ZSIG",zsig,found) |
---|
148 | if (.not.found) then |
---|
149 | write(*,*) "phyetat0: Failed loading <ZSIG>" |
---|
150 | call abort |
---|
151 | else |
---|
152 | write(*,*) "phyetat0: <ZSIG> range:", & |
---|
153 | minval(zsig), maxval(zsig) |
---|
154 | endif |
---|
155 | |
---|
156 | |
---|
157 | ! ZGAM |
---|
158 | call get_field("ZGAM",zgam,found) |
---|
159 | if (.not.found) then |
---|
160 | write(*,*) "phyetat0: Failed loading <ZGAM>" |
---|
161 | call abort |
---|
162 | else |
---|
163 | write(*,*) "phyetat0: <ZGAM> range:", & |
---|
164 | minval(zgam), maxval(zgam) |
---|
165 | endif |
---|
166 | |
---|
167 | |
---|
168 | ! ZTHE |
---|
169 | call get_field("ZTHE",zthe,found) |
---|
170 | if (.not.found) then |
---|
171 | write(*,*) "phyetat0: Failed loading <ZTHE>" |
---|
172 | call abort |
---|
173 | else |
---|
174 | write(*,*) "phyetat0: <ZTHE> range:", & |
---|
175 | minval(zthe), maxval(zthe) |
---|
176 | endif |
---|
177 | |
---|
178 | |
---|
179 | ! Time axis |
---|
180 | found=inquire_dimension("Time") |
---|
181 | if (.not.found) then |
---|
182 | indextime = 1 |
---|
183 | write(*,*) "phyetat0: No time axis found in "//trim(fichnom) |
---|
184 | else |
---|
185 | write(*,*) "phyetat0: Time axis found in "//trim(fichnom) |
---|
186 | timelen=inquire_dimension_length("Time") |
---|
187 | allocate(time(timelen)) |
---|
188 | ! load "Time" array: |
---|
189 | call get_var("Time",time,found) |
---|
190 | if (.not.found) then |
---|
191 | write(*,*) "phyetat0: Failed loading <Time>" |
---|
192 | call abort |
---|
193 | endif |
---|
194 | ! seclect the desired time index |
---|
195 | IF (timestart .lt. 0) THEN ! default: we use the last time value |
---|
196 | indextime = timelen |
---|
197 | ELSE ! else we look for the desired value in the time axis |
---|
198 | indextime = 0 |
---|
199 | DO i=1,timelen |
---|
200 | IF (abs(time(i) - timestart) .lt. 0.01) THEN |
---|
201 | indextime = i |
---|
202 | EXIT |
---|
203 | ENDIF |
---|
204 | ENDDO |
---|
205 | IF (indextime .eq. 0) THEN |
---|
206 | PRINT*, "Time", timestart," is not in "//trim(fichnom)//"!!" |
---|
207 | PRINT*, "Stored times are:" |
---|
208 | DO i=1,timelen |
---|
209 | PRINT*, time(i) |
---|
210 | ENDDO |
---|
211 | CALL abort |
---|
212 | ENDIF |
---|
213 | ENDIF ! of IF (timestart .lt. 0) |
---|
214 | ! In startfi the absolute date is day_ini + time0 + time |
---|
215 | ! For now on, in the GCM physics, it is day_ini + time0 |
---|
216 | time0 = time(indextime) + time0 |
---|
217 | day_ini = day_ini + INT(time0) |
---|
218 | time0 = time0 - INT(time0) |
---|
219 | |
---|
220 | PRINT*, "phyetat0: Selected time ",time(indextime), & |
---|
221 | " at index ",indextime |
---|
222 | |
---|
223 | DEALLOCATE(time) |
---|
224 | endif ! of if Time not found in file |
---|
225 | |
---|
226 | |
---|
227 | ! CO2 ice cover |
---|
228 | call get_field("co2ice",co2ice,found,indextime) |
---|
229 | if (.not.found) then |
---|
230 | write(*,*) "phyetat0: Failed loading <co2ice>" |
---|
231 | call abort |
---|
232 | else |
---|
233 | write(*,*) "phyetat0: CO2 ice cover <co2ice> range:", & |
---|
234 | minval(co2ice), maxval(co2ice) |
---|
235 | endif |
---|
236 | |
---|
237 | |
---|
238 | ! Dust conversion factor |
---|
239 | call get_field("tauscaling",tauscaling,found,indextime) |
---|
240 | if (.not.found) then |
---|
241 | write(*,*) "phyetat0: <tauscaling> not in file" |
---|
242 | tauscaling(:) = -1 |
---|
243 | else |
---|
244 | write(*,*) "phyetat0: dust conversion factor <tauscaling> range:", & |
---|
245 | minval(tauscaling), maxval(tauscaling) |
---|
246 | endif |
---|
247 | |
---|
248 | |
---|
249 | ! Surface temperature : |
---|
250 | call get_field("tsurf",tsurf,found,indextime) |
---|
251 | if (.not.found) then |
---|
252 | write(*,*) "phyetat0: Failed loading <tsurf>" |
---|
253 | call abort |
---|
254 | else |
---|
255 | write(*,*) "phyetat0: Surface temperature <tsurf> range:", & |
---|
256 | minval(tsurf), maxval(tsurf) |
---|
257 | endif |
---|
258 | |
---|
259 | ! Surface emissivity |
---|
260 | call get_field("emis",emis,found,indextime) |
---|
261 | if (.not.found) then |
---|
262 | write(*,*) "phyetat0: Failed loading <emis>" |
---|
263 | call abort |
---|
264 | else |
---|
265 | write(*,*) "phyetat0: Surface emissivity <emis> range:", & |
---|
266 | minval(emis), maxval(emis) |
---|
267 | endif |
---|
268 | |
---|
269 | |
---|
270 | ! surface roughness length (NB: z0 is a common in surfdat_h) |
---|
271 | call get_field("z0",z0,found) |
---|
272 | if (.not.found) then |
---|
273 | write(*,*) "phyetat0: Failed loading <z0>" |
---|
274 | write(*,*) 'will use constant value of z0_default:',z0_default |
---|
275 | z0(:)=z0_default |
---|
276 | else |
---|
277 | write(*,*) "phyetat0: Surface roughness <z0> range:", & |
---|
278 | minval(z0), maxval(z0) |
---|
279 | endif |
---|
280 | |
---|
281 | |
---|
282 | ! pbl wind variance |
---|
283 | call get_field("q2",q2,found,indextime) |
---|
284 | if (.not.found) then |
---|
285 | write(*,*) "phyetat0: Failed loading <q2>" |
---|
286 | call abort |
---|
287 | else |
---|
288 | write(*,*) "phyetat0: PBL wind variance <q2> range:", & |
---|
289 | minval(q2), maxval(q2) |
---|
290 | endif |
---|
291 | |
---|
292 | |
---|
293 | ! tracer on surface |
---|
294 | if (nq.ge.1) then |
---|
295 | do iq=1,nq |
---|
296 | txt=tname(iq) |
---|
297 | if (txt.eq."h2o_vap") then |
---|
298 | ! There is no surface tracer for h2o_vap; |
---|
299 | ! "h2o_ice" should be loaded instead |
---|
300 | txt="h2o_ice" |
---|
301 | write(*,*) 'phyetat0: loading surface tracer', & |
---|
302 | ' h2o_ice instead of h2o_vap' |
---|
303 | endif |
---|
304 | call get_field(txt,qsurf(:,iq),found,indextime) |
---|
305 | if (.not.found) then |
---|
306 | write(*,*) "phyetat0: Failed loading <",trim(txt),">" |
---|
307 | write(*,*) " ",trim(txt)," is set to zero" |
---|
308 | else |
---|
309 | write(*,*) "phyetat0: Surface tracer <",trim(txt),"> range:", & |
---|
310 | minval(qsurf(:,iq)), maxval(qsurf(:,iq)) |
---|
311 | endif |
---|
312 | enddo |
---|
313 | endif ! of if (nq.ge.1) |
---|
314 | |
---|
315 | ! Call to soil_settings, in order to read soil temperatures, |
---|
316 | ! as well as thermal inertia and volumetric heat capacity |
---|
317 | |
---|
318 | call soil_settings(nid_start,ngrid,nsoil,tsurf,tsoil,indextime) |
---|
319 | |
---|
320 | ! |
---|
321 | ! close file: |
---|
322 | ! |
---|
323 | call close_startphy |
---|
324 | |
---|
325 | END |
---|