1 | ! |
---|
2 | ! $Id: dynredem.F 1635 2012-07-12 11:37:16Z lguez $ |
---|
3 | ! |
---|
4 | c |
---|
5 | SUBROUTINE dynredem0(fichnom,iday_end,phis) |
---|
6 | #ifdef CPP_IOIPSL |
---|
7 | USE IOIPSL |
---|
8 | #endif |
---|
9 | USE infotrac |
---|
10 | use netcdf95, only: NF95_PUT_VAR |
---|
11 | use control_mod, only : planet_type |
---|
12 | |
---|
13 | IMPLICIT NONE |
---|
14 | c======================================================================= |
---|
15 | c Ecriture du fichier de redemarrage sous format NetCDF (initialisation) |
---|
16 | c======================================================================= |
---|
17 | c Declarations: |
---|
18 | c ------------- |
---|
19 | #include "dimensions.h" |
---|
20 | #include "paramet.h" |
---|
21 | #include "comconst.h" |
---|
22 | #include "comvert.h" |
---|
23 | #include "comgeom2.h" |
---|
24 | #include "temps.h" |
---|
25 | #include "ener.h" |
---|
26 | #include "logic.h" |
---|
27 | #include "netcdf.inc" |
---|
28 | #include "description.h" |
---|
29 | #include "serre.h" |
---|
30 | #include "iniprint.h" |
---|
31 | |
---|
32 | c Arguments: |
---|
33 | c ---------- |
---|
34 | INTEGER iday_end |
---|
35 | REAL phis(iip1, jjp1) |
---|
36 | CHARACTER*(*) fichnom |
---|
37 | |
---|
38 | c Local: |
---|
39 | c ------ |
---|
40 | INTEGER iq,l |
---|
41 | INTEGER length |
---|
42 | PARAMETER (length = 100) |
---|
43 | REAL tab_cntrl(length) ! tableau des parametres du run |
---|
44 | INTEGER ierr |
---|
45 | character*20 modname |
---|
46 | character*80 abort_message |
---|
47 | |
---|
48 | c Variables locales pour NetCDF: |
---|
49 | c |
---|
50 | INTEGER dims2(2), dims3(3), dims4(4) |
---|
51 | INTEGER idim_index |
---|
52 | INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv |
---|
53 | INTEGER idim_s, idim_sig |
---|
54 | INTEGER idim_tim |
---|
55 | INTEGER nid,nvarid |
---|
56 | |
---|
57 | REAL zan0,zjulian,hours |
---|
58 | INTEGER yyears0,jjour0, mmois0 |
---|
59 | character*30 unites |
---|
60 | |
---|
61 | character(len=12) :: start_file_type="earth" ! default start file type |
---|
62 | INTEGER idecal |
---|
63 | |
---|
64 | c----------------------------------------------------------------------- |
---|
65 | modname='dynredem0' |
---|
66 | |
---|
67 | #ifdef CPP_IOIPSL |
---|
68 | call ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian) |
---|
69 | call ju2ymds(zjulian, yyears0, mmois0, jjour0, hours) |
---|
70 | #else |
---|
71 | ! set yyears0, mmois0, jjour0 to 0,1,1 (hours is not used) |
---|
72 | yyears0=0 |
---|
73 | mmois0=1 |
---|
74 | jjour0=1 |
---|
75 | #endif |
---|
76 | |
---|
77 | !!! AS: idecal is a hack to be able to read planeto starts... |
---|
78 | !!! .... while keeping everything OK for LMDZ EARTH |
---|
79 | if ((planet_type.eq."generic").or.(planet_type.eq."mars")) then |
---|
80 | write(lunout,*) trim(modname),' : Planeto-like start file' |
---|
81 | start_file_type="planeto" |
---|
82 | idecal = 4 |
---|
83 | else |
---|
84 | write(lunout,*) trim(modname),' : Earth-like start file' |
---|
85 | idecal = 5 |
---|
86 | endif |
---|
87 | |
---|
88 | DO l=1,length |
---|
89 | tab_cntrl(l) = 0. |
---|
90 | ENDDO |
---|
91 | tab_cntrl(1) = REAL(iim) |
---|
92 | tab_cntrl(2) = REAL(jjm) |
---|
93 | tab_cntrl(3) = REAL(llm) |
---|
94 | if (start_file_type.eq."earth") then |
---|
95 | tab_cntrl(4)=REAL(day_ref) |
---|
96 | else |
---|
97 | !tab_cntrl(4)=REAL(day_end) |
---|
98 | tab_cntrl(4)=REAL(iday_end) |
---|
99 | endif |
---|
100 | tab_cntrl(5) = REAL(annee_ref) |
---|
101 | tab_cntrl(idecal+1) = rad |
---|
102 | tab_cntrl(idecal+2) = omeg |
---|
103 | tab_cntrl(idecal+3) = g |
---|
104 | tab_cntrl(idecal+4) = cpp |
---|
105 | tab_cntrl(idecal+5) = kappa |
---|
106 | tab_cntrl(idecal+6) = daysec |
---|
107 | tab_cntrl(idecal+7) = dtvr |
---|
108 | tab_cntrl(idecal+8) = etot0 |
---|
109 | tab_cntrl(idecal+9) = ptot0 |
---|
110 | tab_cntrl(idecal+10) = ztot0 |
---|
111 | tab_cntrl(idecal+11) = stot0 |
---|
112 | tab_cntrl(idecal+12) = ang0 |
---|
113 | tab_cntrl(idecal+13) = pa |
---|
114 | tab_cntrl(idecal+14) = preff |
---|
115 | c |
---|
116 | c ..... parametres pour le zoom ...... |
---|
117 | |
---|
118 | tab_cntrl(idecal+15) = clon |
---|
119 | tab_cntrl(idecal+16) = clat |
---|
120 | tab_cntrl(idecal+17) = grossismx |
---|
121 | tab_cntrl(idecal+18) = grossismy |
---|
122 | c |
---|
123 | IF ( fxyhypb ) THEN |
---|
124 | tab_cntrl(idecal+19) = 1. |
---|
125 | tab_cntrl(idecal+20) = dzoomx |
---|
126 | tab_cntrl(idecal+21) = dzoomy |
---|
127 | tab_cntrl(idecal+22) = 0. |
---|
128 | tab_cntrl(idecal+23) = taux |
---|
129 | tab_cntrl(idecal+24) = tauy |
---|
130 | ELSE |
---|
131 | tab_cntrl(idecal+19) = 0. |
---|
132 | tab_cntrl(idecal+20) = dzoomx |
---|
133 | tab_cntrl(idecal+21) = dzoomy |
---|
134 | tab_cntrl(idecal+22) = 0. |
---|
135 | tab_cntrl(idecal+23) = 0. |
---|
136 | tab_cntrl(idecal+24) = 0. |
---|
137 | IF( ysinus ) tab_cntrl(idecal+22) = 1. |
---|
138 | ENDIF |
---|
139 | |
---|
140 | if (start_file_type.eq."earth") then |
---|
141 | tab_cntrl(idecal+25) = REAL(iday_end) |
---|
142 | tab_cntrl(idecal+26) = REAL(itau_dyn + itaufin) |
---|
143 | c start_time: start_time of simulation (not necessarily 0.) |
---|
144 | tab_cntrl(idecal+27) = start_time |
---|
145 | endif |
---|
146 | |
---|
147 | if (planet_type=="mars") then ! For Mars only |
---|
148 | tab_cntrl(29)=hour_ini |
---|
149 | endif |
---|
150 | c |
---|
151 | c ......................................................... |
---|
152 | c |
---|
153 | c Creation du fichier: |
---|
154 | c |
---|
155 | ierr = NF_CREATE(fichnom, NF_CLOBBER, nid) |
---|
156 | IF (ierr.NE.NF_NOERR) THEN |
---|
157 | write(lunout,*)"dynredem0: Pb d ouverture du fichier " |
---|
158 | & //trim(fichnom) |
---|
159 | write(lunout,*)' ierr = ', ierr |
---|
160 | CALL ABORT |
---|
161 | ENDIF |
---|
162 | c |
---|
163 | c Preciser quelques attributs globaux: |
---|
164 | c |
---|
165 | ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 27, |
---|
166 | . "Fichier demmarage dynamique") |
---|
167 | c |
---|
168 | c Definir les dimensions du fichiers: |
---|
169 | c |
---|
170 | if (start_file_type.eq."earth") then |
---|
171 | ierr = NF_DEF_DIM (nid, "index", length, idim_index) |
---|
172 | ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) |
---|
173 | ierr = NF_DEF_DIM (nid, "rlatu", jjp1, idim_rlatu) |
---|
174 | ierr = NF_DEF_DIM (nid, "rlonv", iip1, idim_rlonv) |
---|
175 | ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) |
---|
176 | ierr = NF_DEF_DIM (nid, "sigs", llm, idim_s) |
---|
177 | ierr = NF_DEF_DIM (nid, "sig", llmp1, idim_sig) |
---|
178 | ierr = NF_DEF_DIM (nid, "temps", NF_UNLIMITED, idim_tim) |
---|
179 | else |
---|
180 | ierr = NF_DEF_DIM (nid, "index", length, idim_index) |
---|
181 | ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) |
---|
182 | ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu) |
---|
183 | ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv) |
---|
184 | ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) |
---|
185 | ierr = NF_DEF_DIM (nid, "altitude", llm, idim_s) |
---|
186 | ierr = NF_DEF_DIM (nid, "interlayer", llmp1, idim_sig) |
---|
187 | ierr = NF_DEF_DIM (nid, "Time", NF_UNLIMITED, idim_tim) |
---|
188 | endif |
---|
189 | c |
---|
190 | ierr = NF_ENDDEF(nid) ! sortir du mode de definition |
---|
191 | c |
---|
192 | c Definir et enregistrer certains champs invariants: |
---|
193 | c |
---|
194 | ierr = NF_REDEF (nid) |
---|
195 | cIM 220306 BEG |
---|
196 | #ifdef NC_DOUBLE |
---|
197 | ierr = NF_DEF_VAR (nid,"controle",NF_DOUBLE,1,idim_index,nvarid) |
---|
198 | #else |
---|
199 | ierr = NF_DEF_VAR (nid,"controle",NF_FLOAT,1,idim_index,nvarid) |
---|
200 | #endif |
---|
201 | cIM 220306 END |
---|
202 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22, |
---|
203 | . "Parametres de controle") |
---|
204 | ierr = NF_ENDDEF(nid) |
---|
205 | call NF95_PUT_VAR(nid,nvarid,tab_cntrl) |
---|
206 | c |
---|
207 | ierr = NF_REDEF (nid) |
---|
208 | cIM 220306 BEG |
---|
209 | #ifdef NC_DOUBLE |
---|
210 | ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid) |
---|
211 | #else |
---|
212 | ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid) |
---|
213 | #endif |
---|
214 | cIM 220306 END |
---|
215 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23, |
---|
216 | . "Longitudes des points U") |
---|
217 | ierr = NF_ENDDEF(nid) |
---|
218 | call NF95_PUT_VAR(nid,nvarid,rlonu) |
---|
219 | c |
---|
220 | ierr = NF_REDEF (nid) |
---|
221 | cIM 220306 BEG |
---|
222 | #ifdef NC_DOUBLE |
---|
223 | ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid) |
---|
224 | #else |
---|
225 | ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid) |
---|
226 | #endif |
---|
227 | cIM 220306 END |
---|
228 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22, |
---|
229 | . "Latitudes des points U") |
---|
230 | ierr = NF_ENDDEF(nid) |
---|
231 | call NF95_PUT_VAR (nid,nvarid,rlatu) |
---|
232 | c |
---|
233 | ierr = NF_REDEF (nid) |
---|
234 | cIM 220306 BEG |
---|
235 | #ifdef NC_DOUBLE |
---|
236 | ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid) |
---|
237 | #else |
---|
238 | ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid) |
---|
239 | #endif |
---|
240 | cIM 220306 END |
---|
241 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23, |
---|
242 | . "Longitudes des points V") |
---|
243 | ierr = NF_ENDDEF(nid) |
---|
244 | call NF95_PUT_VAR(nid,nvarid,rlonv) |
---|
245 | c |
---|
246 | ierr = NF_REDEF (nid) |
---|
247 | cIM 220306 BEG |
---|
248 | #ifdef NC_DOUBLE |
---|
249 | ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid) |
---|
250 | #else |
---|
251 | ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid) |
---|
252 | #endif |
---|
253 | cIM 220306 END |
---|
254 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22, |
---|
255 | . "Latitudes des points V") |
---|
256 | ierr = NF_ENDDEF(nid) |
---|
257 | call NF95_PUT_VAR(nid,nvarid,rlatv) |
---|
258 | c |
---|
259 | if (start_file_type.eq."earth") then |
---|
260 | ierr = NF_REDEF (nid) |
---|
261 | cIM 220306 BEG |
---|
262 | #ifdef NC_DOUBLE |
---|
263 | ierr = NF_DEF_VAR (nid,"nivsigs",NF_DOUBLE,1,idim_s,nvarid) |
---|
264 | #else |
---|
265 | ierr = NF_DEF_VAR (nid,"nivsigs",NF_FLOAT,1,idim_s,nvarid) |
---|
266 | #endif |
---|
267 | cIM 220306 END |
---|
268 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 28, |
---|
269 | . "Numero naturel des couches s") |
---|
270 | ierr = NF_ENDDEF(nid) |
---|
271 | call NF95_PUT_VAR(nid,nvarid,nivsigs) |
---|
272 | c |
---|
273 | ierr = NF_REDEF (nid) |
---|
274 | cIM 220306 BEG |
---|
275 | #ifdef NC_DOUBLE |
---|
276 | ierr = NF_DEF_VAR (nid,"nivsig",NF_DOUBLE,1,idim_sig,nvarid) |
---|
277 | #else |
---|
278 | ierr = NF_DEF_VAR (nid,"nivsig",NF_FLOAT,1,idim_sig,nvarid) |
---|
279 | #endif |
---|
280 | cIM 220306 END |
---|
281 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 32, |
---|
282 | . "Numero naturel des couches sigma") |
---|
283 | ierr = NF_ENDDEF(nid) |
---|
284 | call NF95_PUT_VAR(nid,nvarid,nivsig) |
---|
285 | endif ! of if (start_file_type.eq."earth") |
---|
286 | c |
---|
287 | ierr = NF_REDEF (nid) |
---|
288 | cIM 220306 BEG |
---|
289 | #ifdef NC_DOUBLE |
---|
290 | ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_sig,nvarid) |
---|
291 | #else |
---|
292 | ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_sig,nvarid) |
---|
293 | #endif |
---|
294 | cIM 220306 END |
---|
295 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 26, |
---|
296 | . "Coefficient A pour hybride") |
---|
297 | ierr = NF_ENDDEF(nid) |
---|
298 | call NF95_PUT_VAR(nid,nvarid,ap) |
---|
299 | c |
---|
300 | ierr = NF_REDEF (nid) |
---|
301 | cIM 220306 BEG |
---|
302 | #ifdef NC_DOUBLE |
---|
303 | ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_sig,nvarid) |
---|
304 | #else |
---|
305 | ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_sig,nvarid) |
---|
306 | #endif |
---|
307 | cIM 220306 END |
---|
308 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 26, |
---|
309 | . "Coefficient B pour hybride") |
---|
310 | ierr = NF_ENDDEF(nid) |
---|
311 | call NF95_PUT_VAR(nid,nvarid,bp) |
---|
312 | c |
---|
313 | if (start_file_type.ne."earth") then |
---|
314 | ierr = NF_REDEF (nid) |
---|
315 | cIM 220306 BEG |
---|
316 | #ifdef NC_DOUBLE |
---|
317 | ierr = NF_DEF_VAR (nid,"aps",NF_DOUBLE,1,idim_s,nvarid) |
---|
318 | #else |
---|
319 | ierr = NF_DEF_VAR (nid,"aps",NF_FLOAT,1,idim_s,nvarid) |
---|
320 | #endif |
---|
321 | cIM 220306 END |
---|
322 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 37, |
---|
323 | . "Coef AS: hybrid pressure at midlayers") |
---|
324 | ierr = NF_ENDDEF(nid) |
---|
325 | call NF95_PUT_VAR(nid,nvarid,aps) |
---|
326 | c |
---|
327 | ierr = NF_REDEF (nid) |
---|
328 | cIM 220306 BEG |
---|
329 | #ifdef NC_DOUBLE |
---|
330 | ierr = NF_DEF_VAR (nid,"bps",NF_DOUBLE,1,idim_s,nvarid) |
---|
331 | #else |
---|
332 | ierr = NF_DEF_VAR (nid,"bps",NF_FLOAT,1,idim_s,nvarid) |
---|
333 | #endif |
---|
334 | cIM 220306 END |
---|
335 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 34, |
---|
336 | . "Coef BS: hybrid sigma at midlayers") |
---|
337 | ierr = NF_ENDDEF(nid) |
---|
338 | call NF95_PUT_VAR(nid,nvarid,bps) |
---|
339 | endif ! of if (start_file_type.ne."earth") |
---|
340 | c |
---|
341 | ierr = NF_REDEF (nid) |
---|
342 | cIM 220306 BEG |
---|
343 | #ifdef NC_DOUBLE |
---|
344 | ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_s,nvarid) |
---|
345 | #else |
---|
346 | ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_s,nvarid) |
---|
347 | #endif |
---|
348 | cIM 220306 END |
---|
349 | ierr = NF_ENDDEF(nid) |
---|
350 | call NF95_PUT_VAR(nid,nvarid,presnivs) |
---|
351 | c |
---|
352 | if (start_file_type.ne."earth") then |
---|
353 | ierr = NF_REDEF (nid) |
---|
354 | #ifdef NC_DOUBLE |
---|
355 | ierr = NF_DEF_VAR(nid,"latitude",NF_DOUBLE,1,idim_rlatu,nvarid) |
---|
356 | #else |
---|
357 | ierr = NF_DEF_VAR(nid,"latitude",NF_FLOAT,1,idim_rlatu,nvarid) |
---|
358 | #endif |
---|
359 | ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north") |
---|
360 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14, |
---|
361 | . "North latitude") |
---|
362 | ierr = NF_ENDDEF(nid) |
---|
363 | call NF95_PUT_VAR(nid,nvarid,rlatu*180/pi) |
---|
364 | c |
---|
365 | ierr = NF_REDEF (nid) |
---|
366 | #ifdef NC_DOUBLE |
---|
367 | ierr=NF_DEF_VAR(nid,"longitude",NF_DOUBLE,1,idim_rlonv,nvarid) |
---|
368 | #else |
---|
369 | ierr=NF_DEF_VAR(nid,"longitude",NF_FLOAT,1,idim_rlonv,nvarid) |
---|
370 | #endif |
---|
371 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14, |
---|
372 | . "East longitude") |
---|
373 | ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east") |
---|
374 | ierr = NF_ENDDEF(nid) |
---|
375 | call NF95_PUT_VAR(nid,nvarid,rlonv*180/pi) |
---|
376 | c |
---|
377 | ierr = NF_REDEF (nid) |
---|
378 | #ifdef NC_DOUBLE |
---|
379 | ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1, |
---|
380 | . idim_s,nvarid) |
---|
381 | #else |
---|
382 | ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1, |
---|
383 | . idim_s,nvarid) |
---|
384 | #endif |
---|
385 | ierr = NF_PUT_ATT_TEXT(nid,nvarid,"long_name",10,"pseudo-alt") |
---|
386 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km") |
---|
387 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up") |
---|
388 | ierr = NF_ENDDEF(nid) |
---|
389 | call NF95_PUT_VAR(nid,nvarid,pseudoalt) |
---|
390 | endif ! of if (start_file_type.ne."earth") |
---|
391 | c |
---|
392 | c Coefficients de passage cov. <-> contra. <--> naturel |
---|
393 | c |
---|
394 | ierr = NF_REDEF (nid) |
---|
395 | dims2(1) = idim_rlonu |
---|
396 | dims2(2) = idim_rlatu |
---|
397 | cIM 220306 BEG |
---|
398 | #ifdef NC_DOUBLE |
---|
399 | ierr = NF_DEF_VAR (nid,"cu",NF_DOUBLE,2,dims2,nvarid) |
---|
400 | #else |
---|
401 | ierr = NF_DEF_VAR (nid,"cu",NF_FLOAT,2,dims2,nvarid) |
---|
402 | #endif |
---|
403 | cIM 220306 END |
---|
404 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29, |
---|
405 | . "Coefficient de passage pour U") |
---|
406 | ierr = NF_ENDDEF(nid) |
---|
407 | call NF95_PUT_VAR(nid,nvarid,cu) |
---|
408 | c |
---|
409 | ierr = NF_REDEF (nid) |
---|
410 | dims2(1) = idim_rlonv |
---|
411 | dims2(2) = idim_rlatv |
---|
412 | cIM 220306 BEG |
---|
413 | #ifdef NC_DOUBLE |
---|
414 | ierr = NF_DEF_VAR (nid,"cv",NF_DOUBLE,2,dims2,nvarid) |
---|
415 | #else |
---|
416 | ierr = NF_DEF_VAR (nid,"cv",NF_FLOAT,2,dims2,nvarid) |
---|
417 | #endif |
---|
418 | cIM 220306 END |
---|
419 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29, |
---|
420 | . "Coefficient de passage pour V") |
---|
421 | ierr = NF_ENDDEF(nid) |
---|
422 | call NF95_PUT_VAR(nid,nvarid,cv) |
---|
423 | c |
---|
424 | c Aire de chaque maille: |
---|
425 | c |
---|
426 | ierr = NF_REDEF (nid) |
---|
427 | dims2(1) = idim_rlonv |
---|
428 | dims2(2) = idim_rlatu |
---|
429 | cIM 220306 BEG |
---|
430 | #ifdef NC_DOUBLE |
---|
431 | ierr = NF_DEF_VAR (nid,"aire",NF_DOUBLE,2,dims2,nvarid) |
---|
432 | #else |
---|
433 | ierr = NF_DEF_VAR (nid,"aire",NF_FLOAT,2,dims2,nvarid) |
---|
434 | #endif |
---|
435 | cIM 220306 END |
---|
436 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22, |
---|
437 | . "Aires de chaque maille") |
---|
438 | ierr = NF_ENDDEF(nid) |
---|
439 | call NF95_PUT_VAR(nid,nvarid,aire) |
---|
440 | c |
---|
441 | c Geopentiel au sol: |
---|
442 | c |
---|
443 | ierr = NF_REDEF (nid) |
---|
444 | dims2(1) = idim_rlonv |
---|
445 | dims2(2) = idim_rlatu |
---|
446 | cIM 220306 BEG |
---|
447 | #ifdef NC_DOUBLE |
---|
448 | ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid) |
---|
449 | #else |
---|
450 | ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid) |
---|
451 | #endif |
---|
452 | cIM 220306 END |
---|
453 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19, |
---|
454 | . "Geopotentiel au sol") |
---|
455 | ierr = NF_ENDDEF(nid) |
---|
456 | call NF95_PUT_VAR(nid,nvarid,phis) |
---|
457 | c |
---|
458 | c Definir les variables pour pouvoir les enregistrer plus tard: |
---|
459 | c |
---|
460 | ierr = NF_REDEF (nid) ! entrer dans le mode de definition |
---|
461 | c |
---|
462 | if (start_file_type.eq."earth") then |
---|
463 | cIM 220306 BEG |
---|
464 | #ifdef NC_DOUBLE |
---|
465 | ierr = NF_DEF_VAR (nid,"temps",NF_DOUBLE,1,idim_tim,nvarid) |
---|
466 | #else |
---|
467 | ierr = NF_DEF_VAR (nid,"temps",NF_FLOAT,1,idim_tim,nvarid) |
---|
468 | #endif |
---|
469 | cIM 220306 END |
---|
470 | else ! start_file_type=="planeto" |
---|
471 | #ifdef NC_DOUBLE |
---|
472 | ierr = NF_DEF_VAR (nid,"Time",NF_DOUBLE,1,idim_tim,nvarid) |
---|
473 | #else |
---|
474 | ierr = NF_DEF_VAR (nid,"Time",NF_FLOAT,1,idim_tim,nvarid) |
---|
475 | #endif |
---|
476 | endif ! of if (start_file_type.eq."earth") |
---|
477 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19, |
---|
478 | . "Temps de simulation") |
---|
479 | write(unites,200)yyears0,mmois0,jjour0 |
---|
480 | 200 format('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00') |
---|
481 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "units", 30, |
---|
482 | . unites) |
---|
483 | |
---|
484 | c |
---|
485 | dims4(1) = idim_rlonu |
---|
486 | dims4(2) = idim_rlatu |
---|
487 | dims4(3) = idim_s |
---|
488 | dims4(4) = idim_tim |
---|
489 | cIM 220306 BEG |
---|
490 | #ifdef NC_DOUBLE |
---|
491 | ierr = NF_DEF_VAR (nid,"ucov",NF_DOUBLE,4,dims4,nvarid) |
---|
492 | #else |
---|
493 | ierr = NF_DEF_VAR (nid,"ucov",NF_FLOAT,4,dims4,nvarid) |
---|
494 | #endif |
---|
495 | cIM 220306 END |
---|
496 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9, |
---|
497 | . "Vitesse U") |
---|
498 | c |
---|
499 | dims4(1) = idim_rlonv |
---|
500 | dims4(2) = idim_rlatv |
---|
501 | dims4(3) = idim_s |
---|
502 | dims4(4) = idim_tim |
---|
503 | cIM 220306 BEG |
---|
504 | #ifdef NC_DOUBLE |
---|
505 | ierr = NF_DEF_VAR (nid,"vcov",NF_DOUBLE,4,dims4,nvarid) |
---|
506 | #else |
---|
507 | ierr = NF_DEF_VAR (nid,"vcov",NF_FLOAT,4,dims4,nvarid) |
---|
508 | #endif |
---|
509 | cIM 220306 END |
---|
510 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9, |
---|
511 | . "Vitesse V") |
---|
512 | c |
---|
513 | dims4(1) = idim_rlonv |
---|
514 | dims4(2) = idim_rlatu |
---|
515 | dims4(3) = idim_s |
---|
516 | dims4(4) = idim_tim |
---|
517 | cIM 220306 BEG |
---|
518 | #ifdef NC_DOUBLE |
---|
519 | ierr = NF_DEF_VAR (nid,"teta",NF_DOUBLE,4,dims4,nvarid) |
---|
520 | #else |
---|
521 | ierr = NF_DEF_VAR (nid,"teta",NF_FLOAT,4,dims4,nvarid) |
---|
522 | #endif |
---|
523 | cIM 220306 END |
---|
524 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 11, |
---|
525 | . "Temperature") |
---|
526 | c |
---|
527 | dims4(1) = idim_rlonv |
---|
528 | dims4(2) = idim_rlatu |
---|
529 | dims4(3) = idim_s |
---|
530 | dims4(4) = idim_tim |
---|
531 | IF(nqtot.GE.1) THEN |
---|
532 | DO iq=1,nqtot |
---|
533 | cIM 220306 BEG |
---|
534 | #ifdef NC_DOUBLE |
---|
535 | ierr = NF_DEF_VAR (nid,tname(iq),NF_DOUBLE,4,dims4,nvarid) |
---|
536 | #else |
---|
537 | ierr = NF_DEF_VAR (nid,tname(iq),NF_FLOAT,4,dims4,nvarid) |
---|
538 | #endif |
---|
539 | cIM 220306 END |
---|
540 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12,ttext(iq)) |
---|
541 | ENDDO |
---|
542 | ENDIF |
---|
543 | c |
---|
544 | dims4(1) = idim_rlonv |
---|
545 | dims4(2) = idim_rlatu |
---|
546 | dims4(3) = idim_s |
---|
547 | dims4(4) = idim_tim |
---|
548 | cIM 220306 BEG |
---|
549 | #ifdef NC_DOUBLE |
---|
550 | ierr = NF_DEF_VAR (nid,"masse",NF_DOUBLE,4,dims4,nvarid) |
---|
551 | #else |
---|
552 | ierr = NF_DEF_VAR (nid,"masse",NF_FLOAT,4,dims4,nvarid) |
---|
553 | #endif |
---|
554 | cIM 220306 END |
---|
555 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12, |
---|
556 | . "C est quoi ?") |
---|
557 | c |
---|
558 | dims3(1) = idim_rlonv |
---|
559 | dims3(2) = idim_rlatu |
---|
560 | dims3(3) = idim_tim |
---|
561 | cIM 220306 BEG |
---|
562 | #ifdef NC_DOUBLE |
---|
563 | ierr = NF_DEF_VAR (nid,"ps",NF_DOUBLE,3,dims3,nvarid) |
---|
564 | #else |
---|
565 | ierr = NF_DEF_VAR (nid,"ps",NF_FLOAT,3,dims3,nvarid) |
---|
566 | #endif |
---|
567 | cIM 220306 END |
---|
568 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 15, |
---|
569 | . "Pression au sol") |
---|
570 | c |
---|
571 | ierr = NF_ENDDEF(nid) ! sortir du mode de definition |
---|
572 | ierr = NF_CLOSE(nid) ! fermer le fichier |
---|
573 | |
---|
574 | write(lunout,*)'dynredem0: iim,jjm,llm,iday_end', |
---|
575 | & iim,jjm,llm,iday_end |
---|
576 | write(lunout,*)'dynredem0: rad,omeg,g,cpp,kappa', |
---|
577 | & rad,omeg,g,cpp,kappa |
---|
578 | |
---|
579 | RETURN |
---|
580 | END |
---|
581 | |
---|
582 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
583 | |
---|
584 | SUBROUTINE dynredem1(fichnom,time, |
---|
585 | . vcov,ucov,teta,q,masse,ps) |
---|
586 | USE infotrac |
---|
587 | USE control_mod, only : planet_type |
---|
588 | use netcdf, only: NF90_get_VAR |
---|
589 | use netcdf95, only: NF95_PUT_VAR |
---|
590 | |
---|
591 | IMPLICIT NONE |
---|
592 | c================================================================= |
---|
593 | c Ecriture du fichier de redemarrage sous format NetCDF |
---|
594 | c================================================================= |
---|
595 | #include "dimensions.h" |
---|
596 | #include "paramet.h" |
---|
597 | #include "description.h" |
---|
598 | #include "netcdf.inc" |
---|
599 | #include "comvert.h" |
---|
600 | #include "comgeom.h" |
---|
601 | #include "temps.h" |
---|
602 | #include "iniprint.h" |
---|
603 | |
---|
604 | |
---|
605 | INTEGER l |
---|
606 | REAL vcov(iip1,jjm,llm),ucov(iip1, jjp1,llm) |
---|
607 | REAL teta(iip1, jjp1,llm) |
---|
608 | REAL ps(iip1, jjp1),masse(iip1, jjp1,llm) |
---|
609 | REAL q(iip1, jjp1, llm, nqtot) |
---|
610 | CHARACTER*(*) fichnom |
---|
611 | |
---|
612 | REAL time |
---|
613 | INTEGER nid, nvarid, nid_trac, nvarid_trac |
---|
614 | REAL trac_tmp(ip1jmp1,llm) |
---|
615 | INTEGER ierr, ierr_file |
---|
616 | INTEGER iq |
---|
617 | INTEGER length |
---|
618 | PARAMETER (length = 100) |
---|
619 | REAL tab_cntrl(length) ! tableau des parametres du run |
---|
620 | character(len=*),parameter :: modname='dynredem1' |
---|
621 | character*80 abort_message |
---|
622 | c |
---|
623 | INTEGER nb |
---|
624 | SAVE nb |
---|
625 | DATA nb / 0 / |
---|
626 | character(len=12) :: start_file_type="earth" ! default start file type |
---|
627 | |
---|
628 | if ((planet_type.eq."generic").or.(planet_type.eq."mars")) then |
---|
629 | write(lunout,*) trim(modname),' : Planeto-like start file' |
---|
630 | start_file_type="planeto" |
---|
631 | else |
---|
632 | write(lunout,*) trim(modname),' : Earth-like start file' |
---|
633 | endif |
---|
634 | |
---|
635 | ierr = NF_OPEN(fichnom, NF_WRITE, nid) |
---|
636 | IF (ierr .NE. NF_NOERR) THEN |
---|
637 | PRINT*, "dynredem1: Pb. d ouverture "//trim(fichnom) |
---|
638 | CALL abort |
---|
639 | ENDIF |
---|
640 | |
---|
641 | c Ecriture/extension de la coordonnee temps |
---|
642 | |
---|
643 | nb = nb + 1 |
---|
644 | if (start_file_type.eq."earth") then |
---|
645 | ierr = NF_INQ_VARID(nid, "temps", nvarid) |
---|
646 | IF (ierr .NE. NF_NOERR) THEN |
---|
647 | write(lunout,*) NF_STRERROR(ierr) |
---|
648 | abort_message='Variable temps n est pas definie' |
---|
649 | CALL abort_gcm(modname,abort_message,ierr) |
---|
650 | ENDIF |
---|
651 | else |
---|
652 | ierr = NF_INQ_VARID(nid,"Time", nvarid) |
---|
653 | IF (ierr .NE. NF_NOERR) THEN |
---|
654 | write(lunout,*) NF_STRERROR(ierr) |
---|
655 | abort_message='Variable Time not found' |
---|
656 | CALL abort_gcm(modname,abort_message,ierr) |
---|
657 | ENDIF |
---|
658 | endif ! of if (start_file_type.eq."earth") |
---|
659 | call NF95_PUT_VAR(nid,nvarid,time,start=(/nb/)) |
---|
660 | write(lunout,*) "dynredem1: Enregistrement pour ", nb, time |
---|
661 | |
---|
662 | c |
---|
663 | c Re-ecriture du tableau de controle, itaufin n'est plus defini quand |
---|
664 | c on passe dans dynredem0 |
---|
665 | ierr = NF_INQ_VARID (nid, "controle", nvarid) |
---|
666 | IF (ierr .NE. NF_NOERR) THEN |
---|
667 | abort_message="dynredem1: Le champ <controle> est absent" |
---|
668 | ierr = 1 |
---|
669 | CALL abort_gcm(modname,abort_message,ierr) |
---|
670 | ENDIF |
---|
671 | ierr = NF90_GET_VAR(nid, nvarid, tab_cntrl) |
---|
672 | if (start_file_type=="earth") then |
---|
673 | tab_cntrl(31) = REAL(itau_dyn + itaufin) |
---|
674 | else |
---|
675 | tab_cntrl(31) = 0 |
---|
676 | endif |
---|
677 | call NF95_PUT_VAR(nid,nvarid,tab_cntrl) |
---|
678 | |
---|
679 | c Ecriture des champs |
---|
680 | c |
---|
681 | ierr = NF_INQ_VARID(nid, "ucov", nvarid) |
---|
682 | IF (ierr .NE. NF_NOERR) THEN |
---|
683 | abort_message="Variable ucov n est pas definie" |
---|
684 | ierr=1 |
---|
685 | CALL abort_gcm(modname,abort_message,ierr) |
---|
686 | ENDIF |
---|
687 | call NF95_PUT_VAR(nid,nvarid,ucov,start=(/1,1,1,nb/)) |
---|
688 | |
---|
689 | ierr = NF_INQ_VARID(nid, "vcov", nvarid) |
---|
690 | IF (ierr .NE. NF_NOERR) THEN |
---|
691 | abort_message="Variable vcov n est pas definie" |
---|
692 | ierr=1 |
---|
693 | CALL abort_gcm(modname,abort_message,ierr) |
---|
694 | ENDIF |
---|
695 | call NF95_PUT_VAR(nid,nvarid,vcov,start=(/1,1,1,nb/)) |
---|
696 | |
---|
697 | ierr = NF_INQ_VARID(nid, "teta", nvarid) |
---|
698 | IF (ierr .NE. NF_NOERR) THEN |
---|
699 | abort_message="Variable teta n est pas definie" |
---|
700 | ierr=1 |
---|
701 | CALL abort_gcm(modname,abort_message,ierr) |
---|
702 | ENDIF |
---|
703 | call NF95_PUT_VAR(nid,nvarid,teta,start=(/1,1,1,nb/)) |
---|
704 | |
---|
705 | IF (type_trac == 'inca') THEN |
---|
706 | ! Ajout Anne pour lecture valeurs traceurs dans un fichier start_trac.nc |
---|
707 | ierr_file = NF_OPEN ("start_trac.nc", NF_NOWRITE,nid_trac) |
---|
708 | IF (ierr_file .NE.NF_NOERR) THEN |
---|
709 | write(lunout,*)'dynredem1: Pb d''ouverture du fichier', |
---|
710 | & ' start_trac.nc' |
---|
711 | write(lunout,*)' ierr = ', ierr_file |
---|
712 | ENDIF |
---|
713 | END IF |
---|
714 | |
---|
715 | IF(nqtot.GE.1) THEN |
---|
716 | do iq=1,nqtot |
---|
717 | |
---|
718 | IF (type_trac /= 'inca') THEN |
---|
719 | ierr = NF_INQ_VARID(nid, tname(iq), nvarid) |
---|
720 | IF (ierr .NE. NF_NOERR) THEN |
---|
721 | abort_message="Variable tname(iq) n est pas definie" |
---|
722 | ierr=1 |
---|
723 | CALL abort_gcm(modname,abort_message,ierr) |
---|
724 | ENDIF |
---|
725 | call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq),start=(/1,1,1,nb/)) |
---|
726 | ELSE ! type_trac = inca |
---|
727 | ! lecture de la valeur du traceur dans start_trac.nc |
---|
728 | IF (ierr_file .ne. 2) THEN |
---|
729 | ierr = NF_INQ_VARID (nid_trac, tname(iq), nvarid_trac) |
---|
730 | IF (ierr .NE. NF_NOERR) THEN |
---|
731 | write(lunout,*) "dynredem1: ",trim(tname(iq)), |
---|
732 | & " est absent de start_trac.nc" |
---|
733 | ierr = NF_INQ_VARID(nid, tname(iq), nvarid) |
---|
734 | IF (ierr .NE. NF_NOERR) THEN |
---|
735 | abort_message="dynredem1: Variable "// |
---|
736 | & trim(tname(iq))//" n est pas definie" |
---|
737 | ierr=1 |
---|
738 | CALL abort_gcm(modname,abort_message,ierr) |
---|
739 | ENDIF |
---|
740 | call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq)) |
---|
741 | |
---|
742 | ELSE |
---|
743 | write(lunout,*) "dynredem1: ",trim(tname(iq)), |
---|
744 | & " est present dans start_trac.nc" |
---|
745 | ierr = NF90_GET_VAR(nid_trac, nvarid_trac, trac_tmp) |
---|
746 | IF (ierr .NE. NF_NOERR) THEN |
---|
747 | abort_message="dynredem1: Lecture echouee pour"// |
---|
748 | & trim(tname(iq)) |
---|
749 | ierr=1 |
---|
750 | CALL abort_gcm(modname,abort_message,ierr) |
---|
751 | ENDIF |
---|
752 | ierr = NF_INQ_VARID(nid, tname(iq), nvarid) |
---|
753 | IF (ierr .NE. NF_NOERR) THEN |
---|
754 | abort_message="dynredem1: Variable "// |
---|
755 | & trim(tname(iq))//" n est pas definie" |
---|
756 | ierr=1 |
---|
757 | CALL abort_gcm(modname,abort_message,ierr) |
---|
758 | ENDIF |
---|
759 | call NF95_PUT_VAR(nid, nvarid, trac_tmp) |
---|
760 | |
---|
761 | ENDIF ! IF (ierr .NE. NF_NOERR) |
---|
762 | ! fin lecture du traceur |
---|
763 | ELSE ! si il n'y a pas de fichier start_trac.nc |
---|
764 | ! print *, 'il n y a pas de fichier start_trac' |
---|
765 | ierr = NF_INQ_VARID(nid, tname(iq), nvarid) |
---|
766 | IF (ierr .NE. NF_NOERR) THEN |
---|
767 | abort_message="dynredem1: Variable "// |
---|
768 | & trim(tname(iq))//" n est pas definie" |
---|
769 | ierr=1 |
---|
770 | CALL abort_gcm(modname,abort_message,ierr) |
---|
771 | ENDIF |
---|
772 | call NF95_PUT_VAR(nid,nvarid,q(:,:,:,iq), |
---|
773 | & start=(/1,1,1,nb/)) |
---|
774 | ENDIF ! (ierr_file .ne. 2) |
---|
775 | END IF !type_trac |
---|
776 | |
---|
777 | ENDDO |
---|
778 | ENDIF |
---|
779 | c |
---|
780 | ierr = NF_INQ_VARID(nid, "masse", nvarid) |
---|
781 | IF (ierr .NE. NF_NOERR) THEN |
---|
782 | abort_message="dynredem1: Variable masse n est pas definie" |
---|
783 | ierr=1 |
---|
784 | CALL abort_gcm(modname,abort_message,ierr) |
---|
785 | ENDIF |
---|
786 | call NF95_PUT_VAR(nid,nvarid,masse,start=(/1,1,1,nb/)) |
---|
787 | c |
---|
788 | ierr = NF_INQ_VARID(nid, "ps", nvarid) |
---|
789 | IF (ierr .NE. NF_NOERR) THEN |
---|
790 | abort_message="dynredem1: Variable ps n est pas definie" |
---|
791 | ierr=1 |
---|
792 | CALL abort_gcm(modname,abort_message,ierr) |
---|
793 | ENDIF |
---|
794 | call NF95_PUT_VAR(nid,nvarid,ps,start=(/1,1,nb/)) |
---|
795 | |
---|
796 | ierr = NF_CLOSE(nid) |
---|
797 | c |
---|
798 | RETURN |
---|
799 | END |
---|
800 | |
---|