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