1 | ! |
---|
2 | ! $Id: conf_unicol.F 1279 2010-08-04 17:20:56Z lahellec $ |
---|
3 | ! |
---|
4 | c |
---|
5 | c |
---|
6 | SUBROUTINE conf_unicol( tapedef ) |
---|
7 | c |
---|
8 | #ifdef CPP_IOIPSL |
---|
9 | use IOIPSL |
---|
10 | #else |
---|
11 | ! if not using IOIPSL, we still need to use (a local version of) getin |
---|
12 | use ioipsl_getincom |
---|
13 | #endif |
---|
14 | IMPLICIT NONE |
---|
15 | c----------------------------------------------------------------------- |
---|
16 | c Auteurs : A. Lahellec . |
---|
17 | c |
---|
18 | c Arguments : |
---|
19 | c |
---|
20 | c tapedef : |
---|
21 | |
---|
22 | INTEGER tapedef |
---|
23 | c |
---|
24 | c Declarations : |
---|
25 | c -------------- |
---|
26 | |
---|
27 | #include "compar1d.h" |
---|
28 | #include "flux_arp.h" |
---|
29 | #include "fcg_gcssold.h" |
---|
30 | #include "fcg_racmo.h" |
---|
31 | #include "iniprint.h" |
---|
32 | c |
---|
33 | c |
---|
34 | c local: |
---|
35 | c ------ |
---|
36 | |
---|
37 | c CHARACTER ch1*72,ch2*72,ch3*72,ch4*12 |
---|
38 | |
---|
39 | c |
---|
40 | c ------------------------------------------------------------------- |
---|
41 | c |
---|
42 | c ......... Initilisation parametres du lmdz1D .......... |
---|
43 | c |
---|
44 | c--------------------------------------------------------------------- |
---|
45 | c initialisations: |
---|
46 | c ---------------- |
---|
47 | |
---|
48 | !Config Key = lunout |
---|
49 | !Config Desc = unite de fichier pour les impressions |
---|
50 | !Config Def = 6 |
---|
51 | !Config Help = unite de fichier pour les impressions |
---|
52 | !Config (defaut sortie standard = 6) |
---|
53 | lunout=6 |
---|
54 | ! CALL getin('lunout', lunout) |
---|
55 | IF (lunout /= 5 .and. lunout /= 6) THEN |
---|
56 | OPEN(lunout,FILE='lmdz.out') |
---|
57 | ENDIF |
---|
58 | |
---|
59 | !Config Key = prt_level |
---|
60 | !Config Desc = niveau d'impressions de débogage |
---|
61 | !Config Def = 0 |
---|
62 | !Config Help = Niveau d'impression pour le débogage |
---|
63 | !Config (0 = minimum d'impression) |
---|
64 | c prt_level = 0 |
---|
65 | c CALL getin('prt_level',prt_level) |
---|
66 | |
---|
67 | c----------------------------------------------------------------------- |
---|
68 | c Parametres de controle du run: |
---|
69 | c----------------------------------------------------------------------- |
---|
70 | |
---|
71 | !Config Key = restart |
---|
72 | !Config Desc = on repart des startphy et start1dyn |
---|
73 | !Config Def = false |
---|
74 | !Config Help = les fichiers restart doivent etre renomme en start |
---|
75 | restart = .FALSE. |
---|
76 | CALL getin('restart',restart) |
---|
77 | |
---|
78 | !Config Key = forcing_type |
---|
79 | !Config Desc = defines the way the SCM is forced: |
---|
80 | !Config Def = 0 |
---|
81 | !!Config Help = 0 ==> forcing_les = .true. |
---|
82 | ! initial profiles from file prof.inp.001 |
---|
83 | ! no forcing by LS convergence ; |
---|
84 | ! surface temperature imposed ; |
---|
85 | ! radiative cooling may be imposed (iflag_radia=0 in physiq.def) |
---|
86 | ! = 1 ==> forcing_radconv = .true. |
---|
87 | ! idem forcing_type = 0, but the imposed radiative cooling |
---|
88 | ! is set to 0 (hence, if iflag_radia=0 in physiq.def, |
---|
89 | ! then there is no radiative cooling at all) |
---|
90 | ! = 2 ==> forcing_toga = .true. |
---|
91 | ! initial profiles from TOGA-COARE IFA files |
---|
92 | ! LS convergence and SST imposed from TOGA-COARE IFA files |
---|
93 | ! = 3 ==> forcing_GCM2SCM = .true. |
---|
94 | ! initial profiles from the GCM output |
---|
95 | ! LS convergence imposed from the GCM output |
---|
96 | ! = 4 ==> forcing_twpi = .true. |
---|
97 | ! initial profiles from TWPICE nc files |
---|
98 | ! LS convergence and SST imposed from TWPICE nc files |
---|
99 | ! = 5 ==> forcing_rico = .true. |
---|
100 | ! initial profiles from RICO idealized |
---|
101 | ! LS convergence imposed from RICO (cst) |
---|
102 | ! = 40 ==> forcing_GCSSold = .true. |
---|
103 | ! initial profile from GCSS file |
---|
104 | ! LS convergence imposed from GCSS file |
---|
105 | ! |
---|
106 | forcing_type = 0 |
---|
107 | CALL getin('forcing_type',forcing_type) |
---|
108 | imp_fcg_gcssold = .false. |
---|
109 | ts_fcg_gcssold = .false. |
---|
110 | Tp_fcg_gcssold = .false. |
---|
111 | Tp_ini_gcssold = .false. |
---|
112 | xTurb_fcg_gcssold = .false. |
---|
113 | IF (forcing_type .eq.40) THEN |
---|
114 | CALL getin('imp_fcg',imp_fcg_gcssold) |
---|
115 | CALL getin('ts_fcg',ts_fcg_gcssold) |
---|
116 | CALL getin('tp_fcg',Tp_fcg_gcssold) |
---|
117 | CALL getin('tp_ini',Tp_ini_gcssold) |
---|
118 | CALL getin('turb_fcg',xTurb_fcg_gcssold) |
---|
119 | ENDIF |
---|
120 | |
---|
121 | !Config Key = ok_flux_surf |
---|
122 | !Config Desc = forcage ou non par les flux de surface |
---|
123 | !Config Def = false |
---|
124 | !Config Help = forcage ou non par les flux de surface |
---|
125 | ok_flux_surf = .FALSE. |
---|
126 | CALL getin('ok_flux_surf',ok_flux_surf) |
---|
127 | |
---|
128 | !Config Key = ok_old_disvert |
---|
129 | !Config Desc = utilisation de l ancien programme disvert0 (dans 1DUTILS.h) |
---|
130 | !Config Def = false |
---|
131 | !Config Help = utilisation de l ancien programme disvert0 (dans 1DUTILS.h) |
---|
132 | ok_old_disvert = .FALSE. |
---|
133 | CALL getin('ok_old_disvert',ok_old_disvert) |
---|
134 | |
---|
135 | !Config Key = time_ini |
---|
136 | !Config Desc = meaningless in this case |
---|
137 | !Config Def = 0. |
---|
138 | !Config Help = |
---|
139 | tsurf = 0. |
---|
140 | CALL getin('time_ini',time_ini) |
---|
141 | |
---|
142 | !Config Key = rlat et rlon |
---|
143 | !Config Desc = latitude et longitude |
---|
144 | !Config Def = 0.0 0.0 |
---|
145 | !Config Help = fixe la position de la colonne |
---|
146 | xlat = 0. |
---|
147 | xlon = 0. |
---|
148 | CALL getin('rlat',xlat) |
---|
149 | CALL getin('rlon',xlon) |
---|
150 | |
---|
151 | !Config Key = airephy |
---|
152 | !Config Desc = Grid cell area |
---|
153 | !Config Def = 1.e11 |
---|
154 | !Config Help = |
---|
155 | airefi = 1.e11 |
---|
156 | CALL getin('airephy',airefi) |
---|
157 | |
---|
158 | !Config Key = nat_surf |
---|
159 | !Config Desc = surface type |
---|
160 | !Config Def = 0 (ocean) |
---|
161 | !Config Help = 0=ocean,1=land,2=glacier,3=banquise |
---|
162 | nat_surf = 0. |
---|
163 | CALL getin('nat_surf',nat_surf) |
---|
164 | |
---|
165 | !Config Key = tsurf |
---|
166 | !Config Desc = surface temperature |
---|
167 | !Config Def = 290. |
---|
168 | !Config Help = not used if type_ts_forcing=1 in lmdz1d.F |
---|
169 | tsurf = 290. |
---|
170 | CALL getin('tsurf',tsurf) |
---|
171 | |
---|
172 | !Config Key = psurf |
---|
173 | !Config Desc = surface pressure |
---|
174 | !Config Def = 102400. |
---|
175 | !Config Help = |
---|
176 | psurf = 102400. |
---|
177 | CALL getin('psurf',psurf) |
---|
178 | |
---|
179 | !Config Key = zsurf |
---|
180 | !Config Desc = surface altitude |
---|
181 | !Config Def = 0. |
---|
182 | !Config Help = |
---|
183 | zsurf = 0. |
---|
184 | CALL getin('zsurf',zsurf) |
---|
185 | |
---|
186 | !Config Key = rugos |
---|
187 | !Config Desc = coefficient de frottement |
---|
188 | !Config Def = 0.0001 |
---|
189 | !Config Help = calcul du Cdrag |
---|
190 | rugos = 0.0001 |
---|
191 | CALL getin('rugos',rugos) |
---|
192 | |
---|
193 | !Config Key = wtsurf et wqsurf |
---|
194 | !Config Desc = ??? |
---|
195 | !Config Def = 0.0 0.0 |
---|
196 | !Config Help = |
---|
197 | wtsurf = 0.0 |
---|
198 | wqsurf = 0.0 |
---|
199 | CALL getin('wtsurf',wtsurf) |
---|
200 | CALL getin('wqsurf',wqsurf) |
---|
201 | |
---|
202 | !Config Key = albedo |
---|
203 | !Config Desc = albedo |
---|
204 | !Config Def = 0.09 |
---|
205 | !Config Help = |
---|
206 | albedo = 0.09 |
---|
207 | CALL getin('albedo',albedo) |
---|
208 | |
---|
209 | !Config Key = agesno |
---|
210 | !Config Desc = age de la neige |
---|
211 | !Config Def = 30.0 |
---|
212 | !Config Help = |
---|
213 | xagesno = 30.0 |
---|
214 | CALL getin('agesno',xagesno) |
---|
215 | |
---|
216 | !Config Key = restart_runoff |
---|
217 | !Config Desc = age de la neige |
---|
218 | !Config Def = 30.0 |
---|
219 | !Config Help = |
---|
220 | restart_runoff = 0.0 |
---|
221 | CALL getin('restart_runoff',restart_runoff) |
---|
222 | |
---|
223 | !Config Key = qsolinp |
---|
224 | !Config Desc = initial bucket water content (kg/m2) when land (5std) |
---|
225 | !Config Def = 30.0 |
---|
226 | !Config Help = |
---|
227 | qsolinp = 1. |
---|
228 | CALL getin('qsolinp',qsolinp) |
---|
229 | |
---|
230 | !Config Key = zpicinp |
---|
231 | !Config Desc = denivellation orographie |
---|
232 | !Config Def = 300. |
---|
233 | !Config Help = input brise |
---|
234 | zpicinp = 300. |
---|
235 | CALL getin('zpicinp',zpicinp) |
---|
236 | |
---|
237 | |
---|
238 | write(lunout,*)' +++++++++++++++++++++++++++++++++++++++' |
---|
239 | write(lunout,*)' Configuration des parametres du gcm1D: ' |
---|
240 | write(lunout,*)' +++++++++++++++++++++++++++++++++++++++' |
---|
241 | write(lunout,*)' restart = ', restart |
---|
242 | write(lunout,*)' forcing_type = ', forcing_type |
---|
243 | write(lunout,*)' time_ini = ', time_ini |
---|
244 | write(lunout,*)' rlat = ', xlat |
---|
245 | write(lunout,*)' rlon = ', xlon |
---|
246 | write(lunout,*)' airephy = ', airefi |
---|
247 | write(lunout,*)' nat_surf = ', nat_surf |
---|
248 | write(lunout,*)' tsurf = ', tsurf |
---|
249 | write(lunout,*)' psurf = ', psurf |
---|
250 | write(lunout,*)' zsurf = ', zsurf |
---|
251 | write(lunout,*)' rugos = ', rugos |
---|
252 | write(lunout,*)' wtsurf = ', wtsurf |
---|
253 | write(lunout,*)' wqsurf = ', wqsurf |
---|
254 | write(lunout,*)' albedo = ', albedo |
---|
255 | write(lunout,*)' xagesno = ', xagesno |
---|
256 | write(lunout,*)' restart_runoff = ', restart_runoff |
---|
257 | write(lunout,*)' qsolinp = ', qsolinp |
---|
258 | write(lunout,*)' zpicinp = ', zpicinp |
---|
259 | IF (forcing_type .eq.40) THEN |
---|
260 | write(lunout,*) '--- Forcing type GCSS Old --- with:' |
---|
261 | write(lunout,*)'imp_fcg',imp_fcg_gcssold |
---|
262 | write(lunout,*)'ts_fcg',ts_fcg_gcssold |
---|
263 | write(lunout,*)'tp_fcg',Tp_fcg_gcssold |
---|
264 | write(lunout,*)'tp_ini',Tp_ini_gcssold |
---|
265 | write(lunout,*)'xturb_fcg',xTurb_fcg_gcssold |
---|
266 | ENDIF |
---|
267 | |
---|
268 | write(lunout,*)' +++++++++++++++++++++++++++++++++++++++' |
---|
269 | write(lunout,*) |
---|
270 | c |
---|
271 | RETURN |
---|
272 | END |
---|
273 | ! |
---|
274 | ! $Id: dyn1deta0.F 1279 2010/07/30 A Lahellec$ |
---|
275 | ! |
---|
276 | c |
---|
277 | SUBROUTINE dyn1deta0(fichnom,plev,play,phi,phis,presnivs, |
---|
278 | & ucov,vcov,temp,q,omega2) |
---|
279 | USE dimphy |
---|
280 | USE mod_grid_phy_lmdz |
---|
281 | USE mod_phys_lmdz_para |
---|
282 | USE iophy |
---|
283 | USE phys_state_var_mod |
---|
284 | USE iostart |
---|
285 | USE write_field_phy |
---|
286 | USE infotrac |
---|
287 | use control_mod |
---|
288 | |
---|
289 | IMPLICIT NONE |
---|
290 | c======================================================= |
---|
291 | c Ecriture du fichier de redemarrage sous format NetCDF |
---|
292 | c======================================================= |
---|
293 | c Declarations: |
---|
294 | c ------------- |
---|
295 | #include "dimensions.h" |
---|
296 | #include "comconst.h" |
---|
297 | #include "temps.h" |
---|
298 | !!#include "control.h" |
---|
299 | #include "logic.h" |
---|
300 | #include "netcdf.inc" |
---|
301 | |
---|
302 | c Arguments: |
---|
303 | c ---------- |
---|
304 | CHARACTER*(*) fichnom |
---|
305 | cAl1 plev tronque pour .nc mais plev(klev+1):=0 |
---|
306 | real :: plev(klon,klev),play (klon,klev),phi(klon,klev) |
---|
307 | real :: presnivs(klon,klev) |
---|
308 | real :: ucov(klon,klev),vcov(klon,klev),temp(klon,klev) |
---|
309 | real :: q(klon,klev,nqtot),omega2(klon,klev) |
---|
310 | c real :: ug(klev),vg(klev),fcoriolis |
---|
311 | real :: phis(klon) |
---|
312 | |
---|
313 | c Variables locales pour NetCDF: |
---|
314 | c ------------------------------ |
---|
315 | INTEGER nid, nvarid |
---|
316 | INTEGER idim_s |
---|
317 | INTEGER ierr, ierr_file |
---|
318 | INTEGER iq |
---|
319 | INTEGER length |
---|
320 | PARAMETER (length = 100) |
---|
321 | REAL tab_cntrl(length) ! tableau des parametres du run |
---|
322 | character*4 nmq(nqtot) |
---|
323 | character*12 modname |
---|
324 | character*80 abort_message |
---|
325 | LOGICAL found |
---|
326 | c |
---|
327 | INTEGER nb |
---|
328 | |
---|
329 | modname = 'dyn1deta0 : ' |
---|
330 | nmq(1)="vap" |
---|
331 | nmq(2)="cond" |
---|
332 | do iq=3,nqtot |
---|
333 | write(nmq(iq),'("tra",i1)') iq-2 |
---|
334 | enddo |
---|
335 | print*,'in dyn1deta0 ',fichnom,klon,klev,nqtot |
---|
336 | CALL open_startphy(fichnom) |
---|
337 | print*,'after open startphy ',fichnom,nmq |
---|
338 | |
---|
339 | c |
---|
340 | c Lecture des parametres de controle: |
---|
341 | c |
---|
342 | CALL get_var("controle",tab_cntrl) |
---|
343 | |
---|
344 | |
---|
345 | im = tab_cntrl(1) |
---|
346 | jm = tab_cntrl(2) |
---|
347 | lllm = tab_cntrl(3) |
---|
348 | day_ref = tab_cntrl(4) |
---|
349 | annee_ref = tab_cntrl(5) |
---|
350 | c rad = tab_cntrl(6) |
---|
351 | c omeg = tab_cntrl(7) |
---|
352 | c g = tab_cntrl(8) |
---|
353 | c cpp = tab_cntrl(9) |
---|
354 | c kappa = tab_cntrl(10) |
---|
355 | c daysec = tab_cntrl(11) |
---|
356 | c dtvr = tab_cntrl(12) |
---|
357 | c etot0 = tab_cntrl(13) |
---|
358 | c ptot0 = tab_cntrl(14) |
---|
359 | c ztot0 = tab_cntrl(15) |
---|
360 | c stot0 = tab_cntrl(16) |
---|
361 | c ang0 = tab_cntrl(17) |
---|
362 | c pa = tab_cntrl(18) |
---|
363 | c preff = tab_cntrl(19) |
---|
364 | c |
---|
365 | c clon = tab_cntrl(20) |
---|
366 | c clat = tab_cntrl(21) |
---|
367 | c grossismx = tab_cntrl(22) |
---|
368 | c grossismy = tab_cntrl(23) |
---|
369 | c |
---|
370 | IF ( tab_cntrl(24).EQ.1. ) THEN |
---|
371 | fxyhypb = . TRUE . |
---|
372 | c dzoomx = tab_cntrl(25) |
---|
373 | c dzoomy = tab_cntrl(26) |
---|
374 | c taux = tab_cntrl(28) |
---|
375 | c tauy = tab_cntrl(29) |
---|
376 | ELSE |
---|
377 | fxyhypb = . FALSE . |
---|
378 | ysinus = . FALSE . |
---|
379 | IF( tab_cntrl(27).EQ.1. ) ysinus = . TRUE. |
---|
380 | ENDIF |
---|
381 | |
---|
382 | day_ini = tab_cntrl(30) |
---|
383 | itau_dyn = tab_cntrl(31) |
---|
384 | c ................................................................. |
---|
385 | c |
---|
386 | c |
---|
387 | c PRINT*,'rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa |
---|
388 | cAl1 |
---|
389 | Print*,'day_ref,annee_ref,day_ini,itau_dyn', |
---|
390 | & day_ref,annee_ref,day_ini,itau_dyn |
---|
391 | |
---|
392 | c Lecture des champs |
---|
393 | c |
---|
394 | plev(1,klev+1)=0. |
---|
395 | CALL get_field("plev",plev,found) |
---|
396 | IF (.NOT. found) PRINT*, modname//'Le champ <Plev> est absent' |
---|
397 | CALL get_field("play",play,found) |
---|
398 | IF (.NOT. found) PRINT*, modname//'Le champ <Play> est absent' |
---|
399 | CALL get_field("phi",phi,found) |
---|
400 | IF (.NOT. found) PRINT*, modname//'Le champ <Phi> est absent' |
---|
401 | CALL get_field("phis",phis,found) |
---|
402 | IF (.NOT. found) PRINT*, modname//'Le champ <Phis> est absent' |
---|
403 | CALL get_field("presnivs",presnivs,found) |
---|
404 | IF (.NOT. found) PRINT*, modname//'Le champ <Presnivs> est absent' |
---|
405 | CALL get_field("ucov",ucov,found) |
---|
406 | IF (.NOT. found) PRINT*, modname//'Le champ <ucov> est absent' |
---|
407 | CALL get_field("vcov",vcov,found) |
---|
408 | IF (.NOT. found) PRINT*, modname//'Le champ <vcov> est absent' |
---|
409 | CALL get_field("temp",temp,found) |
---|
410 | IF (.NOT. found) PRINT*, modname//'Le champ <temp> est absent' |
---|
411 | CALL get_field("omega2",omega2,found) |
---|
412 | IF (.NOT. found) PRINT*, modname//'Le champ <omega2> est absent' |
---|
413 | |
---|
414 | Do iq=1,nqtot |
---|
415 | CALL get_field("q"//nmq(iq),q(:,:,iq),found) |
---|
416 | IF (.NOT. found) |
---|
417 | & PRINT*, modname//'Le champ <q'//nmq//'> est absent' |
---|
418 | EndDo |
---|
419 | |
---|
420 | CALL close_startphy |
---|
421 | print*,' close startphy' |
---|
422 | . ,fichnom,play(1,1),play(1,klev),temp(1,klev) |
---|
423 | c |
---|
424 | RETURN |
---|
425 | END |
---|
426 | ! |
---|
427 | ! $Id: dyn1dredem.F 1279 2010/07/29 A Lahellec$ |
---|
428 | ! |
---|
429 | c |
---|
430 | SUBROUTINE dyn1dredem(fichnom,plev,play,phi,phis,presnivs, |
---|
431 | & ucov,vcov,temp,q,omega2) |
---|
432 | USE dimphy |
---|
433 | USE mod_grid_phy_lmdz |
---|
434 | USE mod_phys_lmdz_para |
---|
435 | USE phys_state_var_mod |
---|
436 | USE iostart |
---|
437 | USE infotrac |
---|
438 | use control_mod |
---|
439 | |
---|
440 | IMPLICIT NONE |
---|
441 | c======================================================= |
---|
442 | c Ecriture du fichier de redemarrage sous format NetCDF |
---|
443 | c======================================================= |
---|
444 | c Declarations: |
---|
445 | c ------------- |
---|
446 | #include "dimensions.h" |
---|
447 | #include "comconst.h" |
---|
448 | #include "temps.h" |
---|
449 | !!#include "control.h" |
---|
450 | #include "logic.h" |
---|
451 | #include "netcdf.inc" |
---|
452 | |
---|
453 | c Arguments: |
---|
454 | c ---------- |
---|
455 | CHARACTER*(*) fichnom |
---|
456 | REAL time |
---|
457 | cAl1 plev tronque pour .nc mais plev(klev+1):=0 |
---|
458 | real :: plev(klon,klev),play (klon,klev),phi(klon,klev) |
---|
459 | real :: presnivs(klon,klev) |
---|
460 | real :: ucov(klon,klev),vcov(klon,klev),temp(klon,klev) |
---|
461 | real :: q(klon,klev,nqtot) |
---|
462 | real :: omega2(klon,klev),rho(klon,klev+1) |
---|
463 | c real :: ug(klev),vg(klev),fcoriolis |
---|
464 | real :: phis(klon) |
---|
465 | |
---|
466 | c Variables locales pour NetCDF: |
---|
467 | c ------------------------------ |
---|
468 | INTEGER nid, nvarid |
---|
469 | INTEGER idim_s |
---|
470 | INTEGER ierr, ierr_file |
---|
471 | INTEGER iq,l |
---|
472 | INTEGER length |
---|
473 | PARAMETER (length = 100) |
---|
474 | REAL tab_cntrl(length) ! tableau des parametres du run |
---|
475 | character*4 nmq(nqtot) |
---|
476 | character*20 modname |
---|
477 | character*80 abort_message |
---|
478 | c |
---|
479 | INTEGER nb |
---|
480 | SAVE nb |
---|
481 | DATA nb / 0 / |
---|
482 | |
---|
483 | REAL zan0,zjulian,hours |
---|
484 | INTEGER yyears0,jjour0, mmois0 |
---|
485 | character*30 unites |
---|
486 | |
---|
487 | cDbg |
---|
488 | CALL open_restartphy(fichnom) |
---|
489 | print*,'redm1 ',fichnom,klon,klev,nqtot |
---|
490 | nmq(1)="vap" |
---|
491 | nmq(2)="cond" |
---|
492 | nmq(3)="tra1" |
---|
493 | nmq(4)="tra2" |
---|
494 | |
---|
495 | modname = 'dyn1dredem' |
---|
496 | ierr = NF_OPEN(fichnom, NF_WRITE, nid) |
---|
497 | IF (ierr .NE. NF_NOERR) THEN |
---|
498 | PRINT*, "Pb. d ouverture "//fichnom |
---|
499 | CALL abort |
---|
500 | ENDIF |
---|
501 | |
---|
502 | DO l=1,length |
---|
503 | tab_cntrl(l) = 0. |
---|
504 | ENDDO |
---|
505 | tab_cntrl(1) = FLOAT(iim) |
---|
506 | tab_cntrl(2) = FLOAT(jjm) |
---|
507 | tab_cntrl(3) = FLOAT(llm) |
---|
508 | tab_cntrl(4) = FLOAT(day_ref) |
---|
509 | tab_cntrl(5) = FLOAT(annee_ref) |
---|
510 | tab_cntrl(6) = rad |
---|
511 | tab_cntrl(7) = omeg |
---|
512 | tab_cntrl(8) = g |
---|
513 | tab_cntrl(9) = cpp |
---|
514 | tab_cntrl(10) = kappa |
---|
515 | tab_cntrl(11) = daysec |
---|
516 | tab_cntrl(12) = dtvr |
---|
517 | c tab_cntrl(13) = etot0 |
---|
518 | c tab_cntrl(14) = ptot0 |
---|
519 | c tab_cntrl(15) = ztot0 |
---|
520 | c tab_cntrl(16) = stot0 |
---|
521 | c tab_cntrl(17) = ang0 |
---|
522 | c tab_cntrl(18) = pa |
---|
523 | c tab_cntrl(19) = preff |
---|
524 | c |
---|
525 | c ..... parametres pour le zoom ...... |
---|
526 | |
---|
527 | c tab_cntrl(20) = clon |
---|
528 | c tab_cntrl(21) = clat |
---|
529 | c tab_cntrl(22) = grossismx |
---|
530 | c tab_cntrl(23) = grossismy |
---|
531 | c |
---|
532 | IF ( fxyhypb ) THEN |
---|
533 | tab_cntrl(24) = 1. |
---|
534 | c tab_cntrl(25) = dzoomx |
---|
535 | c tab_cntrl(26) = dzoomy |
---|
536 | tab_cntrl(27) = 0. |
---|
537 | c tab_cntrl(28) = taux |
---|
538 | c tab_cntrl(29) = tauy |
---|
539 | ELSE |
---|
540 | tab_cntrl(24) = 0. |
---|
541 | c tab_cntrl(25) = dzoomx |
---|
542 | c tab_cntrl(26) = dzoomy |
---|
543 | tab_cntrl(27) = 0. |
---|
544 | tab_cntrl(28) = 0. |
---|
545 | tab_cntrl(29) = 0. |
---|
546 | IF( ysinus ) tab_cntrl(27) = 1. |
---|
547 | ENDIF |
---|
548 | CAl1 iday_end -> day_end |
---|
549 | tab_cntrl(30) = FLOAT(day_end) |
---|
550 | tab_cntrl(31) = FLOAT(itau_dyn + itaufin) |
---|
551 | c |
---|
552 | CALL put_var("controle","Param. de controle Dyn1D",tab_cntrl) |
---|
553 | c |
---|
554 | |
---|
555 | c Ecriture/extension de la coordonnee temps |
---|
556 | |
---|
557 | nb = nb + 1 |
---|
558 | |
---|
559 | c Ecriture des champs |
---|
560 | c |
---|
561 | CALL put_field("plev","p interfaces sauf la nulle",plev) |
---|
562 | CALL put_field("play","",play) |
---|
563 | CALL put_field("phi","geopotentielle",phi) |
---|
564 | CALL put_field("phis","geopotentiell de surface",phis) |
---|
565 | CALL put_field("presnivs","",presnivs) |
---|
566 | CALL put_field("ucov","",ucov) |
---|
567 | CALL put_field("vcov","",vcov) |
---|
568 | CALL put_field("temp","",temp) |
---|
569 | CALL put_field("omega2","",omega2) |
---|
570 | |
---|
571 | Do iq=1,nqtot |
---|
572 | CALL put_field("q"//nmq(iq),"eau vap ou condens et traceurs", |
---|
573 | . q(:,:,iq)) |
---|
574 | EndDo |
---|
575 | CALL close_restartphy |
---|
576 | |
---|
577 | c |
---|
578 | RETURN |
---|
579 | END |
---|
580 | SUBROUTINE gr_fi_dyn(nfield,ngrid,im,jm,pfi,pdyn) |
---|
581 | IMPLICIT NONE |
---|
582 | !======================================================================= |
---|
583 | ! passage d'un champ de la grille scalaire a la grille physique |
---|
584 | !======================================================================= |
---|
585 | |
---|
586 | !----------------------------------------------------------------------- |
---|
587 | ! declarations: |
---|
588 | ! ------------- |
---|
589 | |
---|
590 | INTEGER im,jm,ngrid,nfield |
---|
591 | REAL pdyn(im,jm,nfield) |
---|
592 | REAL pfi(ngrid,nfield) |
---|
593 | |
---|
594 | INTEGER i,j,ifield,ig |
---|
595 | |
---|
596 | !----------------------------------------------------------------------- |
---|
597 | ! calcul: |
---|
598 | ! ------- |
---|
599 | |
---|
600 | DO ifield=1,nfield |
---|
601 | ! traitement des poles |
---|
602 | DO i=1,im |
---|
603 | pdyn(i,1,ifield)=pfi(1,ifield) |
---|
604 | pdyn(i,jm,ifield)=pfi(ngrid,ifield) |
---|
605 | ENDDO |
---|
606 | |
---|
607 | ! traitement des point normaux |
---|
608 | DO j=2,jm-1 |
---|
609 | ig=2+(j-2)*(im-1) |
---|
610 | CALL SCOPY(im-1,pfi(ig,ifield),1,pdyn(1,j,ifield),1) |
---|
611 | pdyn(im,j,ifield)=pdyn(1,j,ifield) |
---|
612 | ENDDO |
---|
613 | ENDDO |
---|
614 | |
---|
615 | RETURN |
---|
616 | END |
---|
617 | |
---|
618 | |
---|
619 | |
---|
620 | SUBROUTINE abort_gcm(modname, message, ierr) |
---|
621 | |
---|
622 | USE IOIPSL |
---|
623 | ! |
---|
624 | ! Stops the simulation cleanly, closing files and printing various |
---|
625 | ! comments |
---|
626 | ! |
---|
627 | ! Input: modname = name of calling program |
---|
628 | ! message = stuff to print |
---|
629 | ! ierr = severity of situation ( = 0 normal ) |
---|
630 | |
---|
631 | character*20 modname |
---|
632 | integer ierr |
---|
633 | character*80 message |
---|
634 | |
---|
635 | write(*,*) 'in abort_gcm' |
---|
636 | call histclo |
---|
637 | ! call histclo(2) |
---|
638 | ! call histclo(3) |
---|
639 | ! call histclo(4) |
---|
640 | ! call histclo(5) |
---|
641 | write(*,*) 'out of histclo' |
---|
642 | write(*,*) 'Stopping in ', modname |
---|
643 | write(*,*) 'Reason = ',message |
---|
644 | call getin_dump |
---|
645 | ! |
---|
646 | if (ierr .eq. 0) then |
---|
647 | write(*,*) 'Everything is cool' |
---|
648 | else |
---|
649 | write(*,*) 'Houston, we have a problem ', ierr |
---|
650 | endif |
---|
651 | STOP |
---|
652 | END |
---|
653 | REAL FUNCTION q_sat(kelvin, millibar) |
---|
654 | ! |
---|
655 | IMPLICIT none |
---|
656 | !====================================================================== |
---|
657 | ! Autheur(s): Z.X. Li (LMD/CNRS) |
---|
658 | ! Objet: calculer la vapeur d'eau saturante (formule Centre Euro.) |
---|
659 | !====================================================================== |
---|
660 | ! Arguments: |
---|
661 | ! kelvin---input-R: temperature en Kelvin |
---|
662 | ! millibar--input-R: pression en mb |
---|
663 | ! |
---|
664 | ! q_sat----output-R: vapeur d'eau saturante en kg/kg |
---|
665 | !====================================================================== |
---|
666 | ! |
---|
667 | REAL kelvin, millibar |
---|
668 | ! |
---|
669 | REAL r2es |
---|
670 | PARAMETER (r2es=611.14 *18.0153/28.9644) |
---|
671 | ! |
---|
672 | REAL r3les, r3ies, r3es |
---|
673 | PARAMETER (R3LES=17.269) |
---|
674 | PARAMETER (R3IES=21.875) |
---|
675 | ! |
---|
676 | REAL r4les, r4ies, r4es |
---|
677 | PARAMETER (R4LES=35.86) |
---|
678 | PARAMETER (R4IES=7.66) |
---|
679 | ! |
---|
680 | REAL rtt |
---|
681 | PARAMETER (rtt=273.16) |
---|
682 | ! |
---|
683 | REAL retv |
---|
684 | PARAMETER (retv=28.9644/18.0153 - 1.0) |
---|
685 | ! |
---|
686 | REAL zqsat |
---|
687 | REAL temp, pres |
---|
688 | ! ------------------------------------------------------------------ |
---|
689 | ! |
---|
690 | ! |
---|
691 | temp = kelvin |
---|
692 | pres = millibar * 100.0 |
---|
693 | ! write(*,*)'kelvin,millibar=',kelvin,millibar |
---|
694 | ! write(*,*)'temp,pres=',temp,pres |
---|
695 | ! |
---|
696 | IF (temp .LE. rtt) THEN |
---|
697 | r3es = r3ies |
---|
698 | r4es = r4ies |
---|
699 | ELSE |
---|
700 | r3es = r3les |
---|
701 | r4es = r4les |
---|
702 | ENDIF |
---|
703 | ! |
---|
704 | zqsat=r2es/pres * EXP ( r3es*(temp-rtt) / (temp-r4es) ) |
---|
705 | zqsat=MIN(0.5,ZQSAT) |
---|
706 | zqsat=zqsat/(1.-retv *zqsat) |
---|
707 | ! |
---|
708 | q_sat = zqsat |
---|
709 | ! |
---|
710 | RETURN |
---|
711 | END |
---|
712 | subroutine scopy(n,sx,incx,sy,incy) |
---|
713 | ! |
---|
714 | IMPLICIT NONE |
---|
715 | ! |
---|
716 | integer n,incx,incy,ix,iy,i |
---|
717 | real sx((n-1)*incx+1),sy((n-1)*incy+1) |
---|
718 | ! |
---|
719 | iy=1 |
---|
720 | ix=1 |
---|
721 | do 10 i=1,n |
---|
722 | sy(iy)=sx(ix) |
---|
723 | ix=ix+incx |
---|
724 | iy=iy+incy |
---|
725 | 10 continue |
---|
726 | ! |
---|
727 | return |
---|
728 | end |
---|
729 | subroutine wrgradsfi(if,nl,field,name,titlevar) |
---|
730 | implicit none |
---|
731 | |
---|
732 | ! Declarations |
---|
733 | |
---|
734 | #include "gradsdef.h" |
---|
735 | |
---|
736 | ! arguments |
---|
737 | integer if,nl |
---|
738 | real field(imx*jmx*lmx) |
---|
739 | character*10 name,file |
---|
740 | character*10 titlevar |
---|
741 | |
---|
742 | ! local |
---|
743 | |
---|
744 | integer im,jm,lm,i,j,l,iv,iii,iji,iif,ijf |
---|
745 | |
---|
746 | logical writectl |
---|
747 | |
---|
748 | |
---|
749 | writectl=.false. |
---|
750 | |
---|
751 | ! print*,if,iid(if),jid(if),ifd(if),jfd(if) |
---|
752 | iii=iid(if) |
---|
753 | iji=jid(if) |
---|
754 | iif=ifd(if) |
---|
755 | ijf=jfd(if) |
---|
756 | im=iif-iii+1 |
---|
757 | jm=ijf-iji+1 |
---|
758 | lm=lmd(if) |
---|
759 | |
---|
760 | |
---|
761 | ! print*,'im,jm,lm,name,firsttime(if)' |
---|
762 | ! print*,im,jm,lm,name,firsttime(if) |
---|
763 | |
---|
764 | if(firsttime(if)) then |
---|
765 | if(name.eq.var(1,if)) then |
---|
766 | firsttime(if)=.false. |
---|
767 | ivar(if)=1 |
---|
768 | print*,'fin de l initialiation de l ecriture du fichier' |
---|
769 | print*,file |
---|
770 | print*,'fichier no: ',if |
---|
771 | print*,'unit ',unit(if) |
---|
772 | print*,'nvar ',nvar(if) |
---|
773 | print*,'vars ',(var(iv,if),iv=1,nvar(if)) |
---|
774 | else |
---|
775 | ivar(if)=ivar(if)+1 |
---|
776 | nvar(if)=ivar(if) |
---|
777 | var(ivar(if),if)=name |
---|
778 | tvar(ivar(if),if)=trim(titlevar) |
---|
779 | nld(ivar(if),if)=nl |
---|
780 | print*,'initialisation ecriture de ',var(ivar(if),if) |
---|
781 | print*,'if ivar(if) nld ',if,ivar(if),nld(ivar(if),if) |
---|
782 | endif |
---|
783 | writectl=.true. |
---|
784 | itime(if)=1 |
---|
785 | else |
---|
786 | ivar(if)=mod(ivar(if),nvar(if))+1 |
---|
787 | if (ivar(if).eq.nvar(if)) then |
---|
788 | writectl=.true. |
---|
789 | itime(if)=itime(if)+1 |
---|
790 | endif |
---|
791 | |
---|
792 | if(var(ivar(if),if).ne.name) then |
---|
793 | print*,'Il faut stoker la meme succession de champs a chaque' |
---|
794 | print*,'pas de temps' |
---|
795 | print*,'fichier no: ',if |
---|
796 | print*,'unit ',unit(if) |
---|
797 | print*,'nvar ',nvar(if) |
---|
798 | print*,'vars ',(var(iv,if),iv=1,nvar(if)) |
---|
799 | |
---|
800 | stop |
---|
801 | endif |
---|
802 | endif |
---|
803 | |
---|
804 | ! print*,'ivar(if),nvar(if),var(ivar(if),if),writectl' |
---|
805 | ! print*,ivar(if),nvar(if),var(ivar(if),if),writectl |
---|
806 | do l=1,nl |
---|
807 | irec(if)=irec(if)+1 |
---|
808 | ! print*,'Ecrit rec=',irec(if),iii,iif,iji,ijf, |
---|
809 | ! s (l-1)*imd(if)*jmd(if)+(iji-1)*imd(if)+iii |
---|
810 | ! s ,(l-1)*imd(if)*jmd(if)+(ijf-1)*imd(if)+iif |
---|
811 | write(unit(if)+1,rec=irec(if)) |
---|
812 | s ((field((l-1)*imd(if)*jmd(if)+(j-1)*imd(if)+i) |
---|
813 | s ,i=iii,iif),j=iji,ijf) |
---|
814 | enddo |
---|
815 | if (writectl) then |
---|
816 | |
---|
817 | file=fichier(if) |
---|
818 | ! WARNING! on reecrase le fichier .ctl a chaque ecriture |
---|
819 | open(unit(if),file=trim(file)//'.ctl', |
---|
820 | & form='formatted',status='unknown') |
---|
821 | write(unit(if),'(a5,1x,a40)') |
---|
822 | & 'DSET ','^'//trim(file)//'.dat' |
---|
823 | |
---|
824 | write(unit(if),'(a12)') 'UNDEF 1.0E30' |
---|
825 | write(unit(if),'(a5,1x,a40)') 'TITLE ',title(if) |
---|
826 | call formcoord(unit(if),im,xd(iii,if),1.,.false.,'XDEF') |
---|
827 | call formcoord(unit(if),jm,yd(iji,if),1.,.true.,'YDEF') |
---|
828 | call formcoord(unit(if),lm,zd(1,if),1.,.false.,'ZDEF') |
---|
829 | write(unit(if),'(a4,i10,a30)') |
---|
830 | & 'TDEF ',itime(if),' LINEAR 07AUG1998 30MN ' |
---|
831 | write(unit(if),'(a4,2x,i5)') 'VARS',nvar(if) |
---|
832 | do iv=1,nvar(if) |
---|
833 | ! print*,'if,var(iv,if),nld(iv,if),nld(iv,if)-1/nld(iv,if)' |
---|
834 | ! print*,if,var(iv,if),nld(iv,if),nld(iv,if)-1/nld(iv,if) |
---|
835 | write(unit(if),1000) var(iv,if),nld(iv,if)-1/nld(iv,if) |
---|
836 | & ,99,tvar(iv,if) |
---|
837 | enddo |
---|
838 | write(unit(if),'(a7)') 'ENDVARS' |
---|
839 | ! |
---|
840 | 1000 format(a5,3x,i4,i3,1x,a39) |
---|
841 | |
---|
842 | close(unit(if)) |
---|
843 | |
---|
844 | endif ! writectl |
---|
845 | |
---|
846 | return |
---|
847 | |
---|
848 | END |
---|
849 | |
---|
850 | subroutine inigrads(if,im |
---|
851 | s ,x,fx,xmin,xmax,jm,y,ymin,ymax,fy,lm,z,fz |
---|
852 | s ,dt,file,titlel) |
---|
853 | |
---|
854 | |
---|
855 | implicit none |
---|
856 | |
---|
857 | integer if,im,jm,lm,i,j,l |
---|
858 | real x(im),y(jm),z(lm),fx,fy,fz,dt |
---|
859 | real xmin,xmax,ymin,ymax |
---|
860 | integer nf |
---|
861 | |
---|
862 | character file*10,titlel*40 |
---|
863 | |
---|
864 | #include "gradsdef.h" |
---|
865 | |
---|
866 | data unit/24,32,34,36,38,40,42,44,46,48/ |
---|
867 | data nf/0/ |
---|
868 | |
---|
869 | if (if.le.nf) stop'verifier les appels a inigrads' |
---|
870 | |
---|
871 | print*,'Entree dans inigrads' |
---|
872 | |
---|
873 | nf=if |
---|
874 | title(if)=titlel |
---|
875 | ivar(if)=0 |
---|
876 | |
---|
877 | fichier(if)=trim(file) |
---|
878 | |
---|
879 | firsttime(if)=.true. |
---|
880 | dtime(if)=dt |
---|
881 | |
---|
882 | iid(if)=1 |
---|
883 | ifd(if)=im |
---|
884 | imd(if)=im |
---|
885 | do i=1,im |
---|
886 | xd(i,if)=x(i)*fx |
---|
887 | if(xd(i,if).lt.xmin) iid(if)=i+1 |
---|
888 | if(xd(i,if).le.xmax) ifd(if)=i |
---|
889 | enddo |
---|
890 | print*,'On stoke du point ',iid(if),' a ',ifd(if),' en x' |
---|
891 | |
---|
892 | jid(if)=1 |
---|
893 | jfd(if)=jm |
---|
894 | jmd(if)=jm |
---|
895 | do j=1,jm |
---|
896 | yd(j,if)=y(j)*fy |
---|
897 | if(yd(j,if).gt.ymax) jid(if)=j+1 |
---|
898 | if(yd(j,if).ge.ymin) jfd(if)=j |
---|
899 | enddo |
---|
900 | print*,'On stoke du point ',jid(if),' a ',jfd(if),' en y' |
---|
901 | |
---|
902 | print*,'Open de dat' |
---|
903 | print*,'file=',file |
---|
904 | print*,'fichier(if)=',fichier(if) |
---|
905 | |
---|
906 | print*,4*(ifd(if)-iid(if))*(jfd(if)-jid(if)) |
---|
907 | print*,trim(file)//'.dat' |
---|
908 | |
---|
909 | OPEN (unit(if)+1,FILE=trim(file)//'.dat', |
---|
910 | s FORM='UNFORMATTED', |
---|
911 | s ACCESS='DIRECT' |
---|
912 | s ,RECL=4*(ifd(if)-iid(if)+1)*(jfd(if)-jid(if)+1)) |
---|
913 | |
---|
914 | print*,'Open de dat ok' |
---|
915 | |
---|
916 | lmd(if)=lm |
---|
917 | do l=1,lm |
---|
918 | zd(l,if)=z(l)*fz |
---|
919 | enddo |
---|
920 | |
---|
921 | irec(if)=0 |
---|
922 | !CR |
---|
923 | ! print*,if,imd(if),jmd(if),lmd(if) |
---|
924 | ! print*,'if,imd(if),jmd(if),lmd(if)' |
---|
925 | |
---|
926 | return |
---|
927 | end |
---|
928 | SUBROUTINE gr_dyn_fi(nfield,im,jm,ngrid,pdyn,pfi) |
---|
929 | IMPLICIT NONE |
---|
930 | !======================================================================= |
---|
931 | ! passage d'un champ de la grille scalaire a la grille physique |
---|
932 | !======================================================================= |
---|
933 | |
---|
934 | !----------------------------------------------------------------------- |
---|
935 | ! declarations: |
---|
936 | ! ------------- |
---|
937 | |
---|
938 | INTEGER im,jm,ngrid,nfield |
---|
939 | REAL pdyn(im,jm,nfield) |
---|
940 | REAL pfi(ngrid,nfield) |
---|
941 | |
---|
942 | INTEGER j,ifield,ig |
---|
943 | |
---|
944 | !----------------------------------------------------------------------- |
---|
945 | ! calcul: |
---|
946 | ! ------- |
---|
947 | |
---|
948 | IF(ngrid.NE.2+(jm-2)*(im-1).AND.ngrid.NE.1) |
---|
949 | s STOP 'probleme de dim' |
---|
950 | ! traitement des poles |
---|
951 | CALL SCOPY(nfield,pdyn,im*jm,pfi,ngrid) |
---|
952 | CALL SCOPY(nfield,pdyn(1,jm,1),im*jm,pfi(ngrid,1),ngrid) |
---|
953 | |
---|
954 | ! traitement des point normaux |
---|
955 | DO ifield=1,nfield |
---|
956 | DO j=2,jm-1 |
---|
957 | ig=2+(j-2)*(im-1) |
---|
958 | CALL SCOPY(im-1,pdyn(1,j,ifield),1,pfi(ig,ifield),1) |
---|
959 | ENDDO |
---|
960 | ENDDO |
---|
961 | |
---|
962 | RETURN |
---|
963 | END |
---|
964 | |
---|
965 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
966 | subroutine writelim |
---|
967 | s (phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,phy_ice, |
---|
968 | s phy_fter,phy_foce,phy_flic,phy_fsic) |
---|
969 | |
---|
970 | use dimphy |
---|
971 | implicit none |
---|
972 | ! |
---|
973 | #include "dimensions.h" |
---|
974 | #include "netcdf.inc" |
---|
975 | |
---|
976 | integer klon1d |
---|
977 | integer k |
---|
978 | parameter (klon1d=1) |
---|
979 | REAL phy_nat(klon1d,360) |
---|
980 | REAL phy_alb(klon1d,360) |
---|
981 | REAL phy_sst(klon1d,360) |
---|
982 | REAL phy_bil(klon1d,360) |
---|
983 | REAL phy_rug(klon1d,360) |
---|
984 | REAL phy_ice(klon1d,360) |
---|
985 | REAL phy_fter(klon1d,360) |
---|
986 | REAL phy_foce(klon1d,360) |
---|
987 | REAL phy_flic(klon1d,360) |
---|
988 | REAL phy_fsic(klon1d,360) |
---|
989 | |
---|
990 | INTEGER ierr |
---|
991 | INTEGER dimfirst(3) |
---|
992 | INTEGER dimlast(3) |
---|
993 | ! |
---|
994 | INTEGER nid, ndim, ntim |
---|
995 | INTEGER dims(2), debut(2), epais(2) |
---|
996 | INTEGER id_tim |
---|
997 | INTEGER id_NAT, id_SST, id_BILS, id_RUG, id_ALB |
---|
998 | INTEGER id_FTER,id_FOCE,id_FSIC,id_FLIC |
---|
999 | |
---|
1000 | PRINT*, 'Ecriture du fichier limit' |
---|
1001 | ! |
---|
1002 | ierr = NF_CREATE ("limit.nc", NF_CLOBBER, nid) |
---|
1003 | ! |
---|
1004 | ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 30, |
---|
1005 | . "Fichier conditions aux limites") |
---|
1006 | ierr = NF_DEF_DIM (nid, "points_physiques", klon1d, ndim) |
---|
1007 | ierr = NF_DEF_DIM (nid, "time", NF_UNLIMITED, ntim) |
---|
1008 | ! |
---|
1009 | dims(1) = ndim |
---|
1010 | dims(2) = ntim |
---|
1011 | ! |
---|
1012 | !cc ierr = NF_DEF_VAR (nid, "TEMPS", NF_DOUBLE, 1,ntim, id_tim) |
---|
1013 | ierr = NF_DEF_VAR (nid, "TEMPS", NF_FLOAT, 1,ntim, id_tim) |
---|
1014 | ierr = NF_PUT_ATT_TEXT (nid, id_tim, "title", 17, |
---|
1015 | . "Jour dans l annee") |
---|
1016 | !cc ierr = NF_DEF_VAR (nid, "NAT", NF_DOUBLE, 2,dims, id_NAT) |
---|
1017 | ierr = NF_DEF_VAR (nid, "NAT", NF_FLOAT, 2,dims, id_NAT) |
---|
1018 | ierr = NF_PUT_ATT_TEXT (nid, id_NAT, "title", 23, |
---|
1019 | . "Nature du sol (0,1,2,3)") |
---|
1020 | !cc ierr = NF_DEF_VAR (nid, "SST", NF_DOUBLE, 2,dims, id_SST) |
---|
1021 | ierr = NF_DEF_VAR (nid, "SST", NF_FLOAT, 2,dims, id_SST) |
---|
1022 | ierr = NF_PUT_ATT_TEXT (nid, id_SST, "title", 35, |
---|
1023 | . "Temperature superficielle de la mer") |
---|
1024 | !cc ierr = NF_DEF_VAR (nid, "BILS", NF_DOUBLE, 2,dims, id_BILS) |
---|
1025 | ierr = NF_DEF_VAR (nid, "BILS", NF_FLOAT, 2,dims, id_BILS) |
---|
1026 | ierr = NF_PUT_ATT_TEXT (nid, id_BILS, "title", 32, |
---|
1027 | . "Reference flux de chaleur au sol") |
---|
1028 | !cc ierr = NF_DEF_VAR (nid, "ALB", NF_DOUBLE, 2,dims, id_ALB) |
---|
1029 | ierr = NF_DEF_VAR (nid, "ALB", NF_FLOAT, 2,dims, id_ALB) |
---|
1030 | ierr = NF_PUT_ATT_TEXT (nid, id_ALB, "title", 19, |
---|
1031 | . "Albedo a la surface") |
---|
1032 | !cc ierr = NF_DEF_VAR (nid, "RUG", NF_DOUBLE, 2,dims, id_RUG) |
---|
1033 | ierr = NF_DEF_VAR (nid, "RUG", NF_FLOAT, 2,dims, id_RUG) |
---|
1034 | ierr = NF_PUT_ATT_TEXT (nid, id_RUG, "title", 8, |
---|
1035 | . "Rugosite") |
---|
1036 | |
---|
1037 | ierr = NF_DEF_VAR (nid, "FTER", NF_FLOAT, 2,dims, id_FTER) |
---|
1038 | ierr = NF_PUT_ATT_TEXT (nid, id_FTER, "title", 8,"Frac. Terre") |
---|
1039 | ierr = NF_DEF_VAR (nid, "FOCE", NF_FLOAT, 2,dims, id_FOCE) |
---|
1040 | ierr = NF_PUT_ATT_TEXT (nid, id_FOCE, "title", 8,"Frac. Terre") |
---|
1041 | ierr = NF_DEF_VAR (nid, "FSIC", NF_FLOAT, 2,dims, id_FSIC) |
---|
1042 | ierr = NF_PUT_ATT_TEXT (nid, id_FSIC, "title", 8,"Frac. Terre") |
---|
1043 | ierr = NF_DEF_VAR (nid, "FLIC", NF_FLOAT, 2,dims, id_FLIC) |
---|
1044 | ierr = NF_PUT_ATT_TEXT (nid, id_FLIC, "title", 8,"Frac. Terre") |
---|
1045 | ! |
---|
1046 | ierr = NF_ENDDEF(nid) |
---|
1047 | ! |
---|
1048 | DO k = 1, 360 |
---|
1049 | ! |
---|
1050 | debut(1) = 1 |
---|
1051 | debut(2) = k |
---|
1052 | epais(1) = klon1d |
---|
1053 | epais(2) = 1 |
---|
1054 | ! |
---|
1055 | #ifdef NC_DOUBLE |
---|
1056 | ierr = NF_PUT_VAR1_DOUBLE (nid,id_tim,k,DBLE(k)) |
---|
1057 | ierr = NF_PUT_VARA_DOUBLE (nid,id_NAT,debut,epais,phy_nat(1,k)) |
---|
1058 | ierr = NF_PUT_VARA_DOUBLE (nid,id_SST,debut,epais,phy_sst(1,k)) |
---|
1059 | ierr = NF_PUT_VARA_DOUBLE (nid,id_BILS,debut,epais,phy_bil(1,k)) |
---|
1060 | ierr = NF_PUT_VARA_DOUBLE (nid,id_ALB,debut,epais,phy_alb(1,k)) |
---|
1061 | ierr = NF_PUT_VARA_DOUBLE (nid,id_RUG,debut,epais,phy_rug(1,k)) |
---|
1062 | ierr = NF_PUT_VARA_DOUBLE (nid,id_FTER,debut,epais,phy_fter(1,k)) |
---|
1063 | ierr = NF_PUT_VARA_DOUBLE (nid,id_FOCE,debut,epais,phy_foce(1,k)) |
---|
1064 | ierr = NF_PUT_VARA_DOUBLE (nid,id_FSIC,debut,epais,phy_fsic(1,k)) |
---|
1065 | ierr = NF_PUT_VARA_DOUBLE (nid,id_FLIC,debut,epais,phy_flic(1,k)) |
---|
1066 | #else |
---|
1067 | ierr = NF_PUT_VAR1_REAL (nid,id_tim,k,FLOAT(k)) |
---|
1068 | ierr = NF_PUT_VARA_REAL (nid,id_NAT,debut,epais,phy_nat(1,k)) |
---|
1069 | ierr = NF_PUT_VARA_REAL (nid,id_SST,debut,epais,phy_sst(1,k)) |
---|
1070 | ierr = NF_PUT_VARA_REAL (nid,id_BILS,debut,epais,phy_bil(1,k)) |
---|
1071 | ierr = NF_PUT_VARA_REAL (nid,id_ALB,debut,epais,phy_alb(1,k)) |
---|
1072 | ierr = NF_PUT_VARA_REAL (nid,id_RUG,debut,epais,phy_rug(1,k)) |
---|
1073 | ierr = NF_PUT_VARA_REAL (nid,id_FTER,debut,epais,phy_fter(1,k)) |
---|
1074 | ierr = NF_PUT_VARA_REAL (nid,id_FOCE,debut,epais,phy_foce(1,k)) |
---|
1075 | ierr = NF_PUT_VARA_REAL (nid,id_FSIC,debut,epais,phy_fsic(1,k)) |
---|
1076 | ierr = NF_PUT_VARA_REAL (nid,id_FLIC,debut,epais,phy_flic(1,k)) |
---|
1077 | |
---|
1078 | #endif |
---|
1079 | ! |
---|
1080 | ENDDO |
---|
1081 | ! |
---|
1082 | ierr = NF_CLOSE(nid) |
---|
1083 | ! |
---|
1084 | return |
---|
1085 | end |
---|
1086 | |
---|
1087 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
1088 | SUBROUTINE disvert0(pa,preff,ap,bp,dpres,presnivs,nivsigs,nivsig) |
---|
1089 | |
---|
1090 | ! Auteur : P. Le Van . |
---|
1091 | ! |
---|
1092 | IMPLICIT NONE |
---|
1093 | |
---|
1094 | #include "dimensions.h" |
---|
1095 | #include "paramet.h" |
---|
1096 | ! |
---|
1097 | !======================================================================= |
---|
1098 | ! |
---|
1099 | ! |
---|
1100 | ! s = sigma ** kappa : coordonnee verticale |
---|
1101 | ! dsig(l) : epaisseur de la couche l ds la coord. s |
---|
1102 | ! sig(l) : sigma a l'interface des couches l et l-1 |
---|
1103 | ! ds(l) : distance entre les couches l et l-1 en coord.s |
---|
1104 | ! |
---|
1105 | !======================================================================= |
---|
1106 | ! |
---|
1107 | REAL pa,preff |
---|
1108 | REAL ap(llmp1),bp(llmp1),dpres(llm),nivsigs(llm),nivsig(llmp1) |
---|
1109 | REAL presnivs(llm) |
---|
1110 | ! |
---|
1111 | ! declarations: |
---|
1112 | ! ------------- |
---|
1113 | ! |
---|
1114 | REAL sig(llm+1),dsig(llm) |
---|
1115 | ! |
---|
1116 | INTEGER l |
---|
1117 | REAL snorm |
---|
1118 | REAL alpha,beta,gama,delta,deltaz,h |
---|
1119 | INTEGER np,ierr |
---|
1120 | REAL pi,x |
---|
1121 | |
---|
1122 | !----------------------------------------------------------------------- |
---|
1123 | ! |
---|
1124 | pi=2.*ASIN(1.) |
---|
1125 | |
---|
1126 | OPEN(99,file='sigma.def',status='old',form='formatted', |
---|
1127 | s iostat=ierr) |
---|
1128 | |
---|
1129 | !----------------------------------------------------------------------- |
---|
1130 | ! cas 1 on lit les options dans sigma.def: |
---|
1131 | ! ---------------------------------------- |
---|
1132 | |
---|
1133 | IF (ierr.eq.0) THEN |
---|
1134 | |
---|
1135 | print*,'WARNING!!! on lit les options dans sigma.def' |
---|
1136 | READ(99,*) deltaz |
---|
1137 | READ(99,*) h |
---|
1138 | READ(99,*) beta |
---|
1139 | READ(99,*) gama |
---|
1140 | READ(99,*) delta |
---|
1141 | READ(99,*) np |
---|
1142 | CLOSE(99) |
---|
1143 | alpha=deltaz/(llm*h) |
---|
1144 | ! |
---|
1145 | |
---|
1146 | DO 1 l = 1, llm |
---|
1147 | dsig(l) = (alpha+(1.-alpha)*exp(-beta*(llm-l)))* |
---|
1148 | $ ( (tanh(gama*l)/tanh(gama*llm))**np + |
---|
1149 | $ (1.-l/FLOAT(llm))*delta ) |
---|
1150 | 1 CONTINUE |
---|
1151 | |
---|
1152 | sig(1)=1. |
---|
1153 | DO 101 l=1,llm-1 |
---|
1154 | sig(l+1)=sig(l)*(1.-dsig(l))/(1.+dsig(l)) |
---|
1155 | 101 CONTINUE |
---|
1156 | sig(llm+1)=0. |
---|
1157 | |
---|
1158 | DO 2 l = 1, llm |
---|
1159 | dsig(l) = sig(l)-sig(l+1) |
---|
1160 | 2 CONTINUE |
---|
1161 | ! |
---|
1162 | |
---|
1163 | ELSE |
---|
1164 | !----------------------------------------------------------------------- |
---|
1165 | ! cas 2 ancienne discretisation (LMD5...): |
---|
1166 | ! ---------------------------------------- |
---|
1167 | |
---|
1168 | PRINT*,'WARNING!!! Ancienne discretisation verticale' |
---|
1169 | |
---|
1170 | h=7. |
---|
1171 | snorm = 0. |
---|
1172 | DO l = 1, llm |
---|
1173 | x = 2.*asin(1.) * (FLOAT(l)-0.5) / float(llm+1) |
---|
1174 | dsig(l) = 1.0 + 7.0 * SIN(x)**2 |
---|
1175 | snorm = snorm + dsig(l) |
---|
1176 | ENDDO |
---|
1177 | snorm = 1./snorm |
---|
1178 | DO l = 1, llm |
---|
1179 | dsig(l) = dsig(l)*snorm |
---|
1180 | ENDDO |
---|
1181 | sig(llm+1) = 0. |
---|
1182 | DO l = llm, 1, -1 |
---|
1183 | sig(l) = sig(l+1) + dsig(l) |
---|
1184 | ENDDO |
---|
1185 | |
---|
1186 | ENDIF |
---|
1187 | |
---|
1188 | |
---|
1189 | DO l=1,llm |
---|
1190 | nivsigs(l) = FLOAT(l) |
---|
1191 | ENDDO |
---|
1192 | |
---|
1193 | DO l=1,llmp1 |
---|
1194 | nivsig(l)= FLOAT(l) |
---|
1195 | ENDDO |
---|
1196 | |
---|
1197 | ! |
---|
1198 | ! .... Calculs de ap(l) et de bp(l) .... |
---|
1199 | ! ......................................... |
---|
1200 | ! |
---|
1201 | ! |
---|
1202 | ! ..... pa et preff sont lus sur les fichiers start par lectba ..... |
---|
1203 | ! |
---|
1204 | |
---|
1205 | bp(llmp1) = 0. |
---|
1206 | |
---|
1207 | DO l = 1, llm |
---|
1208 | !c |
---|
1209 | !cc ap(l) = 0. |
---|
1210 | !cc bp(l) = sig(l) |
---|
1211 | |
---|
1212 | bp(l) = EXP( 1. -1./( sig(l)*sig(l)) ) |
---|
1213 | ap(l) = pa * ( sig(l) - bp(l) ) |
---|
1214 | ! |
---|
1215 | ENDDO |
---|
1216 | ap(llmp1) = pa * ( sig(llmp1) - bp(llmp1) ) |
---|
1217 | |
---|
1218 | PRINT *,' BP ' |
---|
1219 | PRINT *, bp |
---|
1220 | PRINT *,' AP ' |
---|
1221 | PRINT *, ap |
---|
1222 | |
---|
1223 | DO l = 1, llm |
---|
1224 | dpres(l) = bp(l) - bp(l+1) |
---|
1225 | presnivs(l) = 0.5 *( ap(l)+bp(l)*preff + ap(l+1)+bp(l+1)*preff ) |
---|
1226 | ENDDO |
---|
1227 | |
---|
1228 | PRINT *,' PRESNIVS ' |
---|
1229 | PRINT *,presnivs |
---|
1230 | |
---|
1231 | RETURN |
---|
1232 | END |
---|
1233 | |
---|
1234 | !====================================================================== |
---|
1235 | SUBROUTINE read_tsurf1d(knon,knindex,sst_out) |
---|
1236 | |
---|
1237 | ! This subroutine specifies the surface temperature to be used in 1D simulations |
---|
1238 | |
---|
1239 | USE dimphy, ONLY : klon |
---|
1240 | |
---|
1241 | INTEGER, INTENT(IN) :: knon ! nomber of points on compressed grid |
---|
1242 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex ! grid point number for compressed grid |
---|
1243 | REAL, DIMENSION(klon), INTENT(OUT) :: sst_out ! tsurf used to force the single-column model |
---|
1244 | |
---|
1245 | INTEGER :: i |
---|
1246 | ! COMMON defined in lmdz1d.F: |
---|
1247 | real ts_cur |
---|
1248 | common /sst_forcing/ts_cur |
---|
1249 | |
---|
1250 | DO i = 1, knon |
---|
1251 | sst_out(i) = ts_cur |
---|
1252 | ENDDO |
---|
1253 | |
---|
1254 | END SUBROUTINE read_tsurf1d |
---|
1255 | |
---|
1256 | !=============================================================== |
---|
1257 | subroutine advect_vert(llm,w,dt,q,plev) |
---|
1258 | !=============================================================== |
---|
1259 | ! Schema amont pour l'advection verticale en 1D |
---|
1260 | ! w est la vitesse verticale dp/dt en Pa/s |
---|
1261 | ! Traitement en volumes finis |
---|
1262 | ! d / dt ( zm q ) = delta_z ( omega q ) |
---|
1263 | ! d / dt ( zm ) = delta_z ( omega ) |
---|
1264 | ! avec zm = delta_z ( p ) |
---|
1265 | ! si * designe la valeur au pas de temps t+dt |
---|
1266 | ! zm*(l) q*(l) - zm(l) q(l) = w(l+1) q(l+1) - w(l) q(l) |
---|
1267 | ! zm*(l) -zm(l) = w(l+1) - w(l) |
---|
1268 | ! avec w=omega * dt |
---|
1269 | !--------------------------------------------------------------- |
---|
1270 | implicit none |
---|
1271 | ! arguments |
---|
1272 | integer llm |
---|
1273 | real w(llm+1),q(llm),plev(llm+1),dt |
---|
1274 | |
---|
1275 | ! local |
---|
1276 | integer l |
---|
1277 | real zwq(llm+1),zm(llm+1),zw(llm+1) |
---|
1278 | real qold |
---|
1279 | |
---|
1280 | !--------------------------------------------------------------- |
---|
1281 | |
---|
1282 | do l=1,llm |
---|
1283 | zw(l)=dt*w(l) |
---|
1284 | zm(l)=plev(l)-plev(l+1) |
---|
1285 | zwq(l)=q(l)*zw(l) |
---|
1286 | / enddo |
---|
1287 | zwq(llm+1)=0. |
---|
1288 | zw(llm+1)=0. |
---|
1289 | |
---|
1290 | do l=1,llm |
---|
1291 | qold=q(l) |
---|
1292 | q(l)=(q(l)*zm(l)+zwq(l+1)-zwq(l))/(zm(l)+zw(l+1)-zw(l)) |
---|
1293 | print*,'ADV Q ',zm(l),zw(l),zwq(l),qold,q(l) |
---|
1294 | enddo |
---|
1295 | |
---|
1296 | |
---|
1297 | return |
---|
1298 | end |
---|
1299 | |
---|
1300 | !=============================================================== |
---|
1301 | |
---|
1302 | |
---|
1303 | SUBROUTINE advect_va(llm,omega,d_t_va,d_q_va,d_u_va,d_v_va, |
---|
1304 | ! q,temp,u,v, |
---|
1305 | ! play,plev) |
---|
1306 | !itlmd |
---|
1307 | !---------------------------------------------------------------------- |
---|
1308 | ! Calcul de l'advection verticale (ascendance et subsidence) de |
---|
1309 | ! température et d'humidité. Hypothèse : ce qui rentre de l'extérieur |
---|
1310 | ! a les mêmes caractéristiques que l'air de la colonne 1D (WTG) ou |
---|
1311 | ! sans WTG rajouter une advection horizontale |
---|
1312 | !---------------------------------------------------------------------- |
---|
1313 | implicit none |
---|
1314 | #include "YOMCST.h" |
---|
1315 | ! argument |
---|
1316 | integer llm |
---|
1317 | real omega(llm+1),d_t_va(llm), d_q_va(llm,3) |
---|
1318 | real d_u_va(llm), d_v_va(llm) |
---|
1319 | real q(llm,3),temp(llm) |
---|
1320 | real u(llm),v(llm) |
---|
1321 | real play(llm),plev(llm+1) |
---|
1322 | ! interne |
---|
1323 | integer l |
---|
1324 | real alpha,omgdown,omgup |
---|
1325 | |
---|
1326 | do l= 1,llm |
---|
1327 | if(l.eq.1) then |
---|
1328 | !si omgup pour la couche 1, alors tendance nulle |
---|
1329 | omgdown=max(omega(2),0.0) |
---|
1330 | alpha = rkappa*temp(l)*(1.+q(l,1)*rv/rd)/(play(l)* |
---|
1331 | & (1.+q(l,1))) |
---|
1332 | d_t_va(l)= alpha*(omgdown)- |
---|
1333 | & omgdown*(temp(l)-temp(l+1)) |
---|
1334 | & /(play(l)-play(l+1)) |
---|
1335 | |
---|
1336 | d_q_va(l,:)= -omgdown*(q(l,:)-q(l+1,:)) |
---|
1337 | & /(play(l)-play(l+1)) |
---|
1338 | |
---|
1339 | d_u_va(l)= -omgdown*(u(l)-u(l+1)) |
---|
1340 | & /(play(l)-play(l+1)) |
---|
1341 | d_v_va(l)= -omgdown*(v(l)-v(l+1)) |
---|
1342 | & /(play(l)-play(l+1)) |
---|
1343 | |
---|
1344 | |
---|
1345 | elseif(l.eq.llm) then |
---|
1346 | omgup=min(omega(l),0.0) |
---|
1347 | alpha = rkappa*temp(l)*(1.+q(l,1)*rv/rd)/(play(l)* |
---|
1348 | & (1.+q(l,1))) |
---|
1349 | d_t_va(l)= alpha*(omgup)- |
---|
1350 | !bug? & omgup*(temp(l-1)-temp(l))/(play(l-1)-plev(l)) |
---|
1351 | & omgup*(temp(l-1)-temp(l))/(play(l-1)-play(l)) |
---|
1352 | d_q_va(l,:)= -omgup*(q(l-1,:)-q(l,:))/(play(l-1)-play(l)) |
---|
1353 | d_u_va(l)= -omgup*(u(l-1)-u(l))/(play(l-1)-play(l)) |
---|
1354 | d_v_va(l)= -omgup*(v(l-1)-v(l))/(play(l-1)-play(l)) |
---|
1355 | |
---|
1356 | else |
---|
1357 | omgup=min(omega(l),0.0) |
---|
1358 | omgdown=max(omega(l+1),0.0) |
---|
1359 | alpha = rkappa*temp(l)*(1.+q(l,1)*rv/rd)/(play(l)* |
---|
1360 | & (1.+q(l,1))) |
---|
1361 | d_t_va(l)= alpha*(omgup+omgdown)- |
---|
1362 | & omgdown*(temp(l)-temp(l+1)) |
---|
1363 | & /(play(l)-play(l+1))- |
---|
1364 | !bug? & omgup*(temp(l-1)-temp(l))/(play(l-1)-plev(l)) |
---|
1365 | & omgup*(temp(l-1)-temp(l))/(play(l-1)-play(l)) |
---|
1366 | ! print*, ' ??? ' |
---|
1367 | |
---|
1368 | d_q_va(l,:)= -omgdown*(q(l,:)-q(l+1,:)) |
---|
1369 | & /(play(l)-play(l+1))- |
---|
1370 | & omgup*(q(l-1,:)-q(l,:))/(play(l-1)-play(l)) |
---|
1371 | d_u_va(l)= -omgdown*(u(l)-u(l+1)) |
---|
1372 | & /(play(l)-play(l+1))- |
---|
1373 | & omgup*(u(l-1)-u(l))/(play(l-1)-play(l)) |
---|
1374 | d_v_va(l)= -omgdown*(v(l)-v(l+1)) |
---|
1375 | & /(play(l)-play(l+1))- |
---|
1376 | & omgup*(v(l-1)-v(l))/(play(l-1)-play(l)) |
---|
1377 | |
---|
1378 | endif |
---|
1379 | |
---|
1380 | enddo |
---|
1381 | !fin itlmd |
---|
1382 | return |
---|
1383 | end |
---|
1384 | ! SUBROUTINE lstendH(llm,omega,d_t_va,d_q_va,d_u_va,d_v_va, |
---|
1385 | SUBROUTINE lstendH(llm,nqtot,omega,d_t_va,d_q_va, |
---|
1386 | ! q,temp,u,v,play) |
---|
1387 | !itlmd |
---|
1388 | !---------------------------------------------------------------------- |
---|
1389 | ! Calcul de l'advection verticale (ascendance et subsidence) de |
---|
1390 | ! température et d'humidité. Hypothèse : ce qui rentre de l'extérieur |
---|
1391 | ! a les mêmes caractéristiques que l'air de la colonne 1D (WTG) ou |
---|
1392 | ! sans WTG rajouter une advection horizontale |
---|
1393 | !---------------------------------------------------------------------- |
---|
1394 | implicit none |
---|
1395 | #include "YOMCST.h" |
---|
1396 | ! argument |
---|
1397 | integer llm,nqtot |
---|
1398 | real omega(llm+1),d_t_va(llm), d_q_va(llm,nqtot) |
---|
1399 | ! real d_u_va(llm), d_v_va(llm) |
---|
1400 | real q(llm,nqtot),temp(llm) |
---|
1401 | real u(llm),v(llm) |
---|
1402 | real play(llm) |
---|
1403 | real cor(llm) |
---|
1404 | ! real dph(llm),dudp(llm),dvdp(llm),dqdp(llm),dtdp(llm) |
---|
1405 | real dph(llm),dqdp(llm),dtdp(llm) |
---|
1406 | ! interne |
---|
1407 | integer l,k |
---|
1408 | real alpha,omdn,omup |
---|
1409 | |
---|
1410 | ! dudp=0. |
---|
1411 | ! dvdp=0. |
---|
1412 | dqdp=0. |
---|
1413 | dtdp=0. |
---|
1414 | ! d_u_va=0. |
---|
1415 | ! d_v_va=0. |
---|
1416 | |
---|
1417 | cor(:) = rkappa*temp*(1.+q(:,1)*rv/rd)/(play*(1.+q(:,1))) |
---|
1418 | |
---|
1419 | |
---|
1420 | do k=2,llm-1 |
---|
1421 | |
---|
1422 | dph (k-1) = (play(k )- play(k-1 )) |
---|
1423 | ! dudp (k-1) = (u (k )- u (k-1 ))/dph(k-1) |
---|
1424 | ! dvdp (k-1) = (v (k )- v (k-1 ))/dph(k-1) |
---|
1425 | dqdp (k-1) = (q (k,1)- q (k-1,1))/dph(k-1) |
---|
1426 | dtdp (k-1) = (temp(k )- temp(k-1 ))/dph(k-1) |
---|
1427 | |
---|
1428 | enddo |
---|
1429 | |
---|
1430 | ! dudp ( llm ) = dudp ( llm-1 ) |
---|
1431 | ! dvdp ( llm ) = dvdp ( llm-1 ) |
---|
1432 | dqdp ( llm ) = dqdp ( llm-1 ) |
---|
1433 | dtdp ( llm ) = dtdp ( llm-1 ) |
---|
1434 | |
---|
1435 | do k=2,llm-1 |
---|
1436 | omdn=max(0.0,omega(k+1)) |
---|
1437 | omup=min(0.0,omega( k )) |
---|
1438 | |
---|
1439 | ! d_u_va(k) = -omdn*dudp(k)-omup*dudp(k-1) |
---|
1440 | ! d_v_va(k) = -omdn*dvdp(k)-omup*dvdp(k-1) |
---|
1441 | d_q_va(k,1)= -omdn*dqdp(k)-omup*dqdp(k-1) |
---|
1442 | d_t_va(k) = -omdn*dtdp(k)-omup*dtdp(k-1) |
---|
1443 | : +(omup+omdn)*cor(k) |
---|
1444 | enddo |
---|
1445 | |
---|
1446 | omdn=max(0.0,omega( 2 )) |
---|
1447 | omup=min(0.0,omega(llm)) |
---|
1448 | ! d_u_va( 1 ) = -omdn*dudp( 1 ) |
---|
1449 | ! d_u_va(llm) = -omup*dudp(llm) |
---|
1450 | ! d_v_va( 1 ) = -omdn*dvdp( 1 ) |
---|
1451 | ! d_v_va(llm) = -omup*dvdp(llm) |
---|
1452 | d_q_va( 1 ,1) = -omdn*dqdp( 1 ) |
---|
1453 | d_q_va(llm,1) = -omup*dqdp(llm) |
---|
1454 | d_t_va( 1 ) = -omdn*dtdp( 1 )+omdn*cor( 1 ) |
---|
1455 | d_t_va(llm) = -omup*dtdp(llm)!+omup*cor(llm) |
---|
1456 | |
---|
1457 | ! if(abs(rlat(1))>10.) then |
---|
1458 | ! Calculate the tendency due agestrophic motions |
---|
1459 | ! du_age = fcoriolis*(v-vg) |
---|
1460 | ! dv_age = fcoriolis*(ug-u) |
---|
1461 | ! endif |
---|
1462 | |
---|
1463 | ! call writefield_phy('d_t_va',d_t_va,llm) |
---|
1464 | |
---|
1465 | return |
---|
1466 | end |
---|
1467 | |
---|
1468 | !====================================================================== |
---|
1469 | SUBROUTINE read_togacoare(fich_toga,nlev_toga,nt_toga |
---|
1470 | : ,ts_toga,plev_toga,t_toga,q_toga,u_toga,v_toga,w_toga |
---|
1471 | : ,ht_toga,vt_toga,hq_toga,vq_toga) |
---|
1472 | implicit none |
---|
1473 | |
---|
1474 | c------------------------------------------------------------------------- |
---|
1475 | c Read TOGA-COARE forcing data |
---|
1476 | c------------------------------------------------------------------------- |
---|
1477 | |
---|
1478 | integer nlev_toga,nt_toga |
---|
1479 | real ts_toga(nt_toga),plev_toga(nlev_toga,nt_toga) |
---|
1480 | real t_toga(nlev_toga,nt_toga),q_toga(nlev_toga,nt_toga) |
---|
1481 | real u_toga(nlev_toga,nt_toga),v_toga(nlev_toga,nt_toga) |
---|
1482 | real w_toga(nlev_toga,nt_toga) |
---|
1483 | real ht_toga(nlev_toga,nt_toga),vt_toga(nlev_toga,nt_toga) |
---|
1484 | real hq_toga(nlev_toga,nt_toga),vq_toga(nlev_toga,nt_toga) |
---|
1485 | character*80 fich_toga |
---|
1486 | |
---|
1487 | integer no,l,k,ip |
---|
1488 | real riy,rim,rid,rih,bid |
---|
1489 | |
---|
1490 | integer iy,im,id,ih |
---|
1491 | |
---|
1492 | |
---|
1493 | real plev_min |
---|
1494 | |
---|
1495 | plev_min = 55. ! pas de tendance de vap. d eau au-dessus de 55 hPa |
---|
1496 | |
---|
1497 | open(21,file=trim(fich_toga),form='formatted') |
---|
1498 | read(21,'(a)') |
---|
1499 | do ip = 1, nt_toga |
---|
1500 | read(21,'(a)') |
---|
1501 | read(21,'(a)') |
---|
1502 | read(21,223) iy, im, id, ih, bid, ts_toga(ip), bid,bid,bid,bid |
---|
1503 | read(21,'(a)') |
---|
1504 | read(21,'(a)') |
---|
1505 | |
---|
1506 | do k = 1, nlev_toga |
---|
1507 | read(21,230) plev_toga(k,ip), t_toga(k,ip), q_toga(k,ip) |
---|
1508 | : ,u_toga(k,ip), v_toga(k,ip), w_toga(k,ip) |
---|
1509 | : ,ht_toga(k,ip), vt_toga(k,ip), hq_toga(k,ip), vq_toga(k,ip) |
---|
1510 | |
---|
1511 | ! conversion in SI units: |
---|
1512 | t_toga(k,ip)=t_toga(k,ip)+273.15 ! K |
---|
1513 | q_toga(k,ip)=q_toga(k,ip)*0.001 ! kg/kg |
---|
1514 | w_toga(k,ip)=w_toga(k,ip)*100./3600. ! Pa/s |
---|
1515 | ! no water vapour tendency above 55 hPa |
---|
1516 | if (plev_toga(k,ip) .lt. plev_min) then |
---|
1517 | q_toga(k,ip) = 0. |
---|
1518 | hq_toga(k,ip) = 0. |
---|
1519 | vq_toga(k,ip) =0. |
---|
1520 | endif |
---|
1521 | enddo |
---|
1522 | |
---|
1523 | ts_toga(ip)=ts_toga(ip)+273.15 ! K |
---|
1524 | enddo |
---|
1525 | close(21) |
---|
1526 | |
---|
1527 | 223 format(4i3,6f8.2) |
---|
1528 | 226 format(f7.1,1x,10f8.2) |
---|
1529 | 227 format(f7.1,1x,1p,4e11.3) |
---|
1530 | 230 format(6f9.3,4e11.3) |
---|
1531 | |
---|
1532 | return |
---|
1533 | end |
---|
1534 | end |
---|
1535 | |
---|
1536 | !===================================================================== |
---|
1537 | subroutine read_twpice(fich_twpice,nlevel,ntime |
---|
1538 | : ,T_srf,plev,T,q,u,v,omega |
---|
1539 | : ,T_adv_h,T_adv_v,q_adv_h,q_adv_v) |
---|
1540 | |
---|
1541 | !program reading forcings of the TWP-ICE experiment |
---|
1542 | |
---|
1543 | ! use netcdf |
---|
1544 | |
---|
1545 | implicit none |
---|
1546 | |
---|
1547 | #include "netcdf.inc" |
---|
1548 | |
---|
1549 | integer ntime,nlevel |
---|
1550 | integer l,k |
---|
1551 | character*80 :: fich_twpice |
---|
1552 | real*8 time(ntime) |
---|
1553 | real*8 lat, lon, alt, phis |
---|
1554 | real*8 lev(nlevel) |
---|
1555 | real*8 plev(nlevel,ntime) |
---|
1556 | |
---|
1557 | real*8 T(nlevel,ntime) |
---|
1558 | real*8 q(nlevel,ntime),u(nlevel,ntime) |
---|
1559 | real*8 v(nlevel,ntime) |
---|
1560 | real*8 omega(nlevel,ntime), div(nlevel,ntime) |
---|
1561 | real*8 T_adv_h(nlevel,ntime) |
---|
1562 | real*8 T_adv_v(nlevel,ntime), q_adv_h(nlevel,ntime) |
---|
1563 | real*8 q_adv_v(nlevel,ntime) |
---|
1564 | real*8 s(nlevel,ntime), s_adv_h(nlevel,ntime) |
---|
1565 | real*8 s_adv_v(nlevel,ntime) |
---|
1566 | real*8 p_srf_aver(ntime), p_srf_center(ntime) |
---|
1567 | real*8 T_srf(ntime) |
---|
1568 | |
---|
1569 | integer nid, ierr |
---|
1570 | integer nbvar3d |
---|
1571 | parameter(nbvar3d=20) |
---|
1572 | integer var3didin(nbvar3d) |
---|
1573 | |
---|
1574 | ierr = NF_OPEN(fich_twpice,NF_NOWRITE,nid) |
---|
1575 | if (ierr.NE.NF_NOERR) then |
---|
1576 | write(*,*) 'ERROR: Pb opening forcings cdf file ' |
---|
1577 | write(*,*) NF_STRERROR(ierr) |
---|
1578 | stop "" |
---|
1579 | endif |
---|
1580 | |
---|
1581 | ierr=NF_INQ_VARID(nid,"lat",var3didin(1)) |
---|
1582 | if(ierr/=NF_NOERR) then |
---|
1583 | write(*,*) NF_STRERROR(ierr) |
---|
1584 | stop 'lat' |
---|
1585 | endif |
---|
1586 | |
---|
1587 | ierr=NF_INQ_VARID(nid,"lon",var3didin(2)) |
---|
1588 | if(ierr/=NF_NOERR) then |
---|
1589 | write(*,*) NF_STRERROR(ierr) |
---|
1590 | stop 'lon' |
---|
1591 | endif |
---|
1592 | |
---|
1593 | ierr=NF_INQ_VARID(nid,"alt",var3didin(3)) |
---|
1594 | if(ierr/=NF_NOERR) then |
---|
1595 | write(*,*) NF_STRERROR(ierr) |
---|
1596 | stop 'alt' |
---|
1597 | endif |
---|
1598 | |
---|
1599 | ierr=NF_INQ_VARID(nid,"phis",var3didin(4)) |
---|
1600 | if(ierr/=NF_NOERR) then |
---|
1601 | write(*,*) NF_STRERROR(ierr) |
---|
1602 | stop 'phis' |
---|
1603 | endif |
---|
1604 | |
---|
1605 | ierr=NF_INQ_VARID(nid,"T",var3didin(5)) |
---|
1606 | if(ierr/=NF_NOERR) then |
---|
1607 | write(*,*) NF_STRERROR(ierr) |
---|
1608 | stop 'T' |
---|
1609 | endif |
---|
1610 | |
---|
1611 | ierr=NF_INQ_VARID(nid,"q",var3didin(6)) |
---|
1612 | if(ierr/=NF_NOERR) then |
---|
1613 | write(*,*) NF_STRERROR(ierr) |
---|
1614 | stop 'q' |
---|
1615 | endif |
---|
1616 | |
---|
1617 | ierr=NF_INQ_VARID(nid,"u",var3didin(7)) |
---|
1618 | if(ierr/=NF_NOERR) then |
---|
1619 | write(*,*) NF_STRERROR(ierr) |
---|
1620 | stop 'u' |
---|
1621 | endif |
---|
1622 | |
---|
1623 | ierr=NF_INQ_VARID(nid,"v",var3didin(8)) |
---|
1624 | if(ierr/=NF_NOERR) then |
---|
1625 | write(*,*) NF_STRERROR(ierr) |
---|
1626 | stop 'v' |
---|
1627 | endif |
---|
1628 | |
---|
1629 | ierr=NF_INQ_VARID(nid,"omega",var3didin(9)) |
---|
1630 | if(ierr/=NF_NOERR) then |
---|
1631 | write(*,*) NF_STRERROR(ierr) |
---|
1632 | stop 'omega' |
---|
1633 | endif |
---|
1634 | |
---|
1635 | ierr=NF_INQ_VARID(nid,"div",var3didin(10)) |
---|
1636 | if(ierr/=NF_NOERR) then |
---|
1637 | write(*,*) NF_STRERROR(ierr) |
---|
1638 | stop 'div' |
---|
1639 | endif |
---|
1640 | |
---|
1641 | ierr=NF_INQ_VARID(nid,"T_adv_h",var3didin(11)) |
---|
1642 | if(ierr/=NF_NOERR) then |
---|
1643 | write(*,*) NF_STRERROR(ierr) |
---|
1644 | stop 'T_adv_h' |
---|
1645 | endif |
---|
1646 | |
---|
1647 | ierr=NF_INQ_VARID(nid,"T_adv_v",var3didin(12)) |
---|
1648 | if(ierr/=NF_NOERR) then |
---|
1649 | write(*,*) NF_STRERROR(ierr) |
---|
1650 | stop 'T_adv_v' |
---|
1651 | endif |
---|
1652 | |
---|
1653 | ierr=NF_INQ_VARID(nid,"q_adv_h",var3didin(13)) |
---|
1654 | if(ierr/=NF_NOERR) then |
---|
1655 | write(*,*) NF_STRERROR(ierr) |
---|
1656 | stop 'q_adv_h' |
---|
1657 | endif |
---|
1658 | |
---|
1659 | ierr=NF_INQ_VARID(nid,"q_adv_v",var3didin(14)) |
---|
1660 | if(ierr/=NF_NOERR) then |
---|
1661 | write(*,*) NF_STRERROR(ierr) |
---|
1662 | stop 'q_adv_v' |
---|
1663 | endif |
---|
1664 | |
---|
1665 | ierr=NF_INQ_VARID(nid,"s",var3didin(15)) |
---|
1666 | if(ierr/=NF_NOERR) then |
---|
1667 | write(*,*) NF_STRERROR(ierr) |
---|
1668 | stop 's' |
---|
1669 | endif |
---|
1670 | |
---|
1671 | ierr=NF_INQ_VARID(nid,"s_adv_h",var3didin(16)) |
---|
1672 | if(ierr/=NF_NOERR) then |
---|
1673 | write(*,*) NF_STRERROR(ierr) |
---|
1674 | stop 's_adv_h' |
---|
1675 | endif |
---|
1676 | |
---|
1677 | ierr=NF_INQ_VARID(nid,"s_adv_v",var3didin(17)) |
---|
1678 | if(ierr/=NF_NOERR) then |
---|
1679 | write(*,*) NF_STRERROR(ierr) |
---|
1680 | stop 's_adv_v' |
---|
1681 | endif |
---|
1682 | |
---|
1683 | ierr=NF_INQ_VARID(nid,"p_srf_aver",var3didin(18)) |
---|
1684 | if(ierr/=NF_NOERR) then |
---|
1685 | write(*,*) NF_STRERROR(ierr) |
---|
1686 | stop 'p_srf_aver' |
---|
1687 | endif |
---|
1688 | |
---|
1689 | ierr=NF_INQ_VARID(nid,"p_srf_center",var3didin(19)) |
---|
1690 | if(ierr/=NF_NOERR) then |
---|
1691 | write(*,*) NF_STRERROR(ierr) |
---|
1692 | stop 'p_srf_center' |
---|
1693 | endif |
---|
1694 | |
---|
1695 | ierr=NF_INQ_VARID(nid,"T_srf",var3didin(20)) |
---|
1696 | if(ierr/=NF_NOERR) then |
---|
1697 | write(*,*) NF_STRERROR(ierr) |
---|
1698 | stop 'T_srf' |
---|
1699 | endif |
---|
1700 | |
---|
1701 | !dimensions lecture |
---|
1702 | call catchaxis(nid,ntime,nlevel,time,lev,ierr) |
---|
1703 | |
---|
1704 | !pressure |
---|
1705 | do l=1,ntime |
---|
1706 | do k=1,nlevel |
---|
1707 | plev(k,l)=lev(k) |
---|
1708 | enddo |
---|
1709 | enddo |
---|
1710 | |
---|
1711 | #ifdef NC_DOUBLE |
---|
1712 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),lat) |
---|
1713 | #else |
---|
1714 | ierr = NF_GET_VAR_REAL(nid,var3didin(1),lat) |
---|
1715 | #endif |
---|
1716 | if(ierr/=NF_NOERR) then |
---|
1717 | write(*,*) NF_STRERROR(ierr) |
---|
1718 | stop "getvarup" |
---|
1719 | endif |
---|
1720 | ! write(*,*)'lecture lat ok',lat |
---|
1721 | |
---|
1722 | #ifdef NC_DOUBLE |
---|
1723 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),lon) |
---|
1724 | #else |
---|
1725 | ierr = NF_GET_VAR_REAL(nid,var3didin(2),lon) |
---|
1726 | #endif |
---|
1727 | if(ierr/=NF_NOERR) then |
---|
1728 | write(*,*) NF_STRERROR(ierr) |
---|
1729 | stop "getvarup" |
---|
1730 | endif |
---|
1731 | ! write(*,*)'lecture lon ok',lon |
---|
1732 | |
---|
1733 | #ifdef NC_DOUBLE |
---|
1734 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),alt) |
---|
1735 | #else |
---|
1736 | ierr = NF_GET_VAR_REAL(nid,var3didin(3),alt) |
---|
1737 | #endif |
---|
1738 | if(ierr/=NF_NOERR) then |
---|
1739 | write(*,*) NF_STRERROR(ierr) |
---|
1740 | stop "getvarup" |
---|
1741 | endif |
---|
1742 | ! write(*,*)'lecture alt ok',alt |
---|
1743 | |
---|
1744 | #ifdef NC_DOUBLE |
---|
1745 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),phis) |
---|
1746 | #else |
---|
1747 | ierr = NF_GET_VAR_REAL(nid,var3didin(4),phis) |
---|
1748 | #endif |
---|
1749 | if(ierr/=NF_NOERR) then |
---|
1750 | write(*,*) NF_STRERROR(ierr) |
---|
1751 | stop "getvarup" |
---|
1752 | endif |
---|
1753 | ! write(*,*)'lecture phis ok',phis |
---|
1754 | |
---|
1755 | #ifdef NC_DOUBLE |
---|
1756 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),T) |
---|
1757 | #else |
---|
1758 | ierr = NF_GET_VAR_REAL(nid,var3didin(5),T) |
---|
1759 | #endif |
---|
1760 | if(ierr/=NF_NOERR) then |
---|
1761 | write(*,*) NF_STRERROR(ierr) |
---|
1762 | stop "getvarup" |
---|
1763 | endif |
---|
1764 | ! write(*,*)'lecture T ok' |
---|
1765 | |
---|
1766 | #ifdef NC_DOUBLE |
---|
1767 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),q) |
---|
1768 | #else |
---|
1769 | ierr = NF_GET_VAR_REAL(nid,var3didin(6),q) |
---|
1770 | #endif |
---|
1771 | if(ierr/=NF_NOERR) then |
---|
1772 | write(*,*) NF_STRERROR(ierr) |
---|
1773 | stop "getvarup" |
---|
1774 | endif |
---|
1775 | ! write(*,*)'lecture q ok' |
---|
1776 | !q in kg/kg |
---|
1777 | do l=1,ntime |
---|
1778 | do k=1,nlevel |
---|
1779 | q(k,l)=q(k,l)/1000. |
---|
1780 | enddo |
---|
1781 | enddo |
---|
1782 | #ifdef NC_DOUBLE |
---|
1783 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),u) |
---|
1784 | #else |
---|
1785 | ierr = NF_GET_VAR_REAL(nid,var3didin(7),u) |
---|
1786 | #endif |
---|
1787 | if(ierr/=NF_NOERR) then |
---|
1788 | write(*,*) NF_STRERROR(ierr) |
---|
1789 | stop "getvarup" |
---|
1790 | endif |
---|
1791 | ! write(*,*)'lecture u ok' |
---|
1792 | |
---|
1793 | #ifdef NC_DOUBLE |
---|
1794 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),v) |
---|
1795 | #else |
---|
1796 | ierr = NF_GET_VAR_REAL(nid,var3didin(8),v) |
---|
1797 | #endif |
---|
1798 | if(ierr/=NF_NOERR) then |
---|
1799 | write(*,*) NF_STRERROR(ierr) |
---|
1800 | stop "getvarup" |
---|
1801 | endif |
---|
1802 | ! write(*,*)'lecture v ok' |
---|
1803 | |
---|
1804 | #ifdef NC_DOUBLE |
---|
1805 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),omega) |
---|
1806 | #else |
---|
1807 | ierr = NF_GET_VAR_REAL(nid,var3didin(9),omega) |
---|
1808 | #endif |
---|
1809 | if(ierr/=NF_NOERR) then |
---|
1810 | write(*,*) NF_STRERROR(ierr) |
---|
1811 | stop "getvarup" |
---|
1812 | endif |
---|
1813 | ! write(*,*)'lecture omega ok' |
---|
1814 | !omega in mb/hour |
---|
1815 | do l=1,ntime |
---|
1816 | do k=1,nlevel |
---|
1817 | omega(k,l)=omega(k,l)*100./3600. |
---|
1818 | enddo |
---|
1819 | enddo |
---|
1820 | |
---|
1821 | #ifdef NC_DOUBLE |
---|
1822 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),div) |
---|
1823 | #else |
---|
1824 | ierr = NF_GET_VAR_REAL(nid,var3didin(10),div) |
---|
1825 | #endif |
---|
1826 | if(ierr/=NF_NOERR) then |
---|
1827 | write(*,*) NF_STRERROR(ierr) |
---|
1828 | stop "getvarup" |
---|
1829 | endif |
---|
1830 | ! write(*,*)'lecture div ok' |
---|
1831 | |
---|
1832 | #ifdef NC_DOUBLE |
---|
1833 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),T_adv_h) |
---|
1834 | #else |
---|
1835 | ierr = NF_GET_VAR_REAL(nid,var3didin(11),T_adv_h) |
---|
1836 | #endif |
---|
1837 | if(ierr/=NF_NOERR) then |
---|
1838 | write(*,*) NF_STRERROR(ierr) |
---|
1839 | stop "getvarup" |
---|
1840 | endif |
---|
1841 | ! write(*,*)'lecture T_adv_h ok' |
---|
1842 | !T adv in K/s |
---|
1843 | do l=1,ntime |
---|
1844 | do k=1,nlevel |
---|
1845 | T_adv_h(k,l)=T_adv_h(k,l)/3600. |
---|
1846 | enddo |
---|
1847 | enddo |
---|
1848 | |
---|
1849 | |
---|
1850 | #ifdef NC_DOUBLE |
---|
1851 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),T_adv_v) |
---|
1852 | #else |
---|
1853 | ierr = NF_GET_VAR_REAL(nid,var3didin(12),T_adv_v) |
---|
1854 | #endif |
---|
1855 | if(ierr/=NF_NOERR) then |
---|
1856 | write(*,*) NF_STRERROR(ierr) |
---|
1857 | stop "getvarup" |
---|
1858 | endif |
---|
1859 | ! write(*,*)'lecture T_adv_v ok' |
---|
1860 | !T adv in K/s |
---|
1861 | do l=1,ntime |
---|
1862 | do k=1,nlevel |
---|
1863 | T_adv_v(k,l)=T_adv_v(k,l)/3600. |
---|
1864 | enddo |
---|
1865 | enddo |
---|
1866 | |
---|
1867 | #ifdef NC_DOUBLE |
---|
1868 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),q_adv_h) |
---|
1869 | #else |
---|
1870 | ierr = NF_GET_VAR_REAL(nid,var3didin(13),q_adv_h) |
---|
1871 | #endif |
---|
1872 | if(ierr/=NF_NOERR) then |
---|
1873 | write(*,*) NF_STRERROR(ierr) |
---|
1874 | stop "getvarup" |
---|
1875 | endif |
---|
1876 | ! write(*,*)'lecture q_adv_h ok' |
---|
1877 | !q adv in kg/kg/s |
---|
1878 | do l=1,ntime |
---|
1879 | do k=1,nlevel |
---|
1880 | q_adv_h(k,l)=q_adv_h(k,l)/1000./3600. |
---|
1881 | enddo |
---|
1882 | enddo |
---|
1883 | |
---|
1884 | |
---|
1885 | #ifdef NC_DOUBLE |
---|
1886 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(14),q_adv_v) |
---|
1887 | #else |
---|
1888 | ierr = NF_GET_VAR_REAL(nid,var3didin(14),q_adv_v) |
---|
1889 | #endif |
---|
1890 | if(ierr/=NF_NOERR) then |
---|
1891 | write(*,*) NF_STRERROR(ierr) |
---|
1892 | stop "getvarup" |
---|
1893 | endif |
---|
1894 | ! write(*,*)'lecture q_adv_v ok' |
---|
1895 | !q adv in kg/kg/s |
---|
1896 | do l=1,ntime |
---|
1897 | do k=1,nlevel |
---|
1898 | q_adv_v(k,l)=q_adv_v(k,l)/1000./3600. |
---|
1899 | enddo |
---|
1900 | enddo |
---|
1901 | |
---|
1902 | |
---|
1903 | #ifdef NC_DOUBLE |
---|
1904 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(15),s) |
---|
1905 | #else |
---|
1906 | ierr = NF_GET_VAR_REAL(nid,var3didin(15),s) |
---|
1907 | #endif |
---|
1908 | if(ierr/=NF_NOERR) then |
---|
1909 | write(*,*) NF_STRERROR(ierr) |
---|
1910 | stop "getvarup" |
---|
1911 | endif |
---|
1912 | |
---|
1913 | #ifdef NC_DOUBLE |
---|
1914 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(16),s_adv_h) |
---|
1915 | #else |
---|
1916 | ierr = NF_GET_VAR_REAL(nid,var3didin(16),s_adv_h) |
---|
1917 | #endif |
---|
1918 | if(ierr/=NF_NOERR) then |
---|
1919 | write(*,*) NF_STRERROR(ierr) |
---|
1920 | stop "getvarup" |
---|
1921 | endif |
---|
1922 | |
---|
1923 | #ifdef NC_DOUBLE |
---|
1924 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(17),s_adv_v) |
---|
1925 | #else |
---|
1926 | ierr = NF_GET_VAR_REAL(nid,var3didin(17),s_adv_v) |
---|
1927 | #endif |
---|
1928 | if(ierr/=NF_NOERR) then |
---|
1929 | write(*,*) NF_STRERROR(ierr) |
---|
1930 | stop "getvarup" |
---|
1931 | endif |
---|
1932 | |
---|
1933 | #ifdef NC_DOUBLE |
---|
1934 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(18),p_srf_aver) |
---|
1935 | #else |
---|
1936 | ierr = NF_GET_VAR_REAL(nid,var3didin(18),p_srf_aver) |
---|
1937 | #endif |
---|
1938 | if(ierr/=NF_NOERR) then |
---|
1939 | write(*,*) NF_STRERROR(ierr) |
---|
1940 | stop "getvarup" |
---|
1941 | endif |
---|
1942 | |
---|
1943 | #ifdef NC_DOUBLE |
---|
1944 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(19),p_srf_center) |
---|
1945 | #else |
---|
1946 | ierr = NF_GET_VAR_REAL(nid,var3didin(19),p_srf_center) |
---|
1947 | #endif |
---|
1948 | if(ierr/=NF_NOERR) then |
---|
1949 | write(*,*) NF_STRERROR(ierr) |
---|
1950 | stop "getvarup" |
---|
1951 | endif |
---|
1952 | |
---|
1953 | #ifdef NC_DOUBLE |
---|
1954 | ierr = NF_GET_VAR_DOUBLE(nid,var3didin(20),T_srf) |
---|
1955 | #else |
---|
1956 | ierr = NF_GET_VAR_REAL(nid,var3didin(20),T_srf) |
---|
1957 | #endif |
---|
1958 | if(ierr/=NF_NOERR) then |
---|
1959 | write(*,*) NF_STRERROR(ierr) |
---|
1960 | stop "getvarup" |
---|
1961 | endif |
---|
1962 | ! write(*,*)'lecture T_srf ok', T_srf |
---|
1963 | |
---|
1964 | return |
---|
1965 | end subroutine read_twpice |
---|
1966 | !===================================================================== |
---|
1967 | subroutine catchaxis(nid,ttm,llm,time,lev,ierr) |
---|
1968 | |
---|
1969 | ! use netcdf |
---|
1970 | |
---|
1971 | implicit none |
---|
1972 | #include "netcdf.inc" |
---|
1973 | integer nid,ttm,llm |
---|
1974 | real*8 time(ttm) |
---|
1975 | real*8 lev(llm) |
---|
1976 | integer ierr |
---|
1977 | |
---|
1978 | integer i |
---|
1979 | integer timevar,levvar |
---|
1980 | integer timelen,levlen |
---|
1981 | integer timedimin,levdimin |
---|
1982 | |
---|
1983 | ! Control & lecture on dimensions |
---|
1984 | ! =============================== |
---|
1985 | ierr=NF_INQ_DIMID(nid,"time",timedimin) |
---|
1986 | ierr=NF_INQ_VARID(nid,"time",timevar) |
---|
1987 | if (ierr.NE.NF_NOERR) then |
---|
1988 | write(*,*) 'ERROR: Field <time> is missing' |
---|
1989 | stop "" |
---|
1990 | endif |
---|
1991 | ierr=NF_INQ_DIMLEN(nid,timedimin,timelen) |
---|
1992 | |
---|
1993 | ierr=NF_INQ_DIMID(nid,"lev",levdimin) |
---|
1994 | ierr=NF_INQ_VARID(nid,"lev",levvar) |
---|
1995 | if (ierr.NE.NF_NOERR) then |
---|
1996 | write(*,*) 'ERROR: Field <lev> is lacking' |
---|
1997 | stop "" |
---|
1998 | endif |
---|
1999 | ierr=NF_INQ_DIMLEN(nid,levdimin,levlen) |
---|
2000 | |
---|
2001 | if((timelen/=ttm).or.(levlen/=llm)) then |
---|
2002 | write(*,*) 'ERROR: Not the good lenght for axis' |
---|
2003 | write(*,*) 'longitude: ',timelen,ttm+1 |
---|
2004 | write(*,*) 'latitude: ',levlen,llm |
---|
2005 | stop "" |
---|
2006 | endif |
---|
2007 | |
---|
2008 | !#ifdef NC_DOUBLE |
---|
2009 | ierr = NF_GET_VAR_DOUBLE(nid,timevar,time) |
---|
2010 | ierr = NF_GET_VAR_DOUBLE(nid,levvar,lev) |
---|
2011 | !#else |
---|
2012 | ! ierr = NF_GET_VAR_REAL(nid,timevar,time) |
---|
2013 | ! ierr = NF_GET_VAR_REAL(nid,levvar,lev) |
---|
2014 | !#endif |
---|
2015 | |
---|
2016 | return |
---|
2017 | |
---|
2018 | !====================================================================== |
---|
2019 | SUBROUTINE read_rico(fich_rico,nlev_rico,ps_rico,play |
---|
2020 | : ,ts_rico,t_rico,q_rico,u_rico,v_rico,w_rico |
---|
2021 | : ,dth_dyn,dqh_dyn) |
---|
2022 | implicit none |
---|
2023 | |
---|
2024 | c------------------------------------------------------------------------- |
---|
2025 | c Read RICO forcing data |
---|
2026 | c------------------------------------------------------------------------- |
---|
2027 | #include "dimensions.h" |
---|
2028 | |
---|
2029 | |
---|
2030 | integer nlev_rico |
---|
2031 | real ts_rico,ps_rico |
---|
2032 | real t_rico(llm),q_rico(llm) |
---|
2033 | real u_rico(llm),v_rico(llm) |
---|
2034 | real w_rico(llm) |
---|
2035 | real dth_dyn(llm) |
---|
2036 | real dqh_dyn(llm) |
---|
2037 | |
---|
2038 | |
---|
2039 | real play(llm),zlay(llm) |
---|
2040 | |
---|
2041 | |
---|
2042 | real prico(nlev_rico),zrico(nlev_rico) |
---|
2043 | |
---|
2044 | character*80 fich_rico |
---|
2045 | |
---|
2046 | integer k,l |
---|
2047 | |
---|
2048 | |
---|
2049 | print*,fich_rico |
---|
2050 | open(21,file=trim(fich_rico),form='formatted') |
---|
2051 | do k=1,llm |
---|
2052 | zlay(k)=0. |
---|
2053 | enddo |
---|
2054 | |
---|
2055 | read(21,*) ps_rico,ts_rico |
---|
2056 | prico(1)=ps_rico |
---|
2057 | zrico(1)=0.0 |
---|
2058 | do l=2,nlev_rico |
---|
2059 | read(21,*) k,prico(l),zrico(l) |
---|
2060 | enddo |
---|
2061 | close(21) |
---|
2062 | |
---|
2063 | do k=1,llm |
---|
2064 | do l=1,80 |
---|
2065 | if(prico(l)>play(k)) then |
---|
2066 | if(play(k)>prico(l+1)) then |
---|
2067 | zlay(k)=zrico(l)+(play(k)-prico(l)) * |
---|
2068 | & (zrico(l+1)-zrico(l))/(prico(l+1)-prico(l)) |
---|
2069 | else |
---|
2070 | zlay(k)=zrico(l)+(play(k)-prico(80))* |
---|
2071 | & (zrico(81)-zrico(80))/(prico(81)-prico(80)) |
---|
2072 | endif |
---|
2073 | endif |
---|
2074 | enddo |
---|
2075 | print*,k,zlay(k) |
---|
2076 | ! U |
---|
2077 | if(0 < zlay(k) .and. zlay(k) < 4000) then |
---|
2078 | u_rico(k)=-9.9 + (-1.9 + 9.9)*zlay(k)/4000 |
---|
2079 | elseif(4000 < zlay(k) .and. zlay(k) < 12000) then |
---|
2080 | u_rico(k)= -1.9 + (30.0 + 1.9) / |
---|
2081 | : (12000 - 4000) * (zlay(k) - 4000) |
---|
2082 | elseif(12000 < zlay(k) .and. zlay(k) < 13000) then |
---|
2083 | u_rico(k)=30.0 |
---|
2084 | elseif(13000 < zlay(k) .and. zlay(k) < 20000) then |
---|
2085 | u_rico(k)=30.0 - (30.0) / |
---|
2086 | : (20000 - 13000) * (zlay(k) - 13000) |
---|
2087 | else |
---|
2088 | u_rico(k)=0.0 |
---|
2089 | endif |
---|
2090 | |
---|
2091 | !Q_v |
---|
2092 | if(0 < zlay(k) .and. zlay(k) < 740) then |
---|
2093 | q_rico(k)=16.0 + (13.8 - 16.0) / (740) * zlay(k) |
---|
2094 | elseif(740 < zlay(k) .and. zlay(k) < 3260) then |
---|
2095 | q_rico(k)=13.8 + (2.4 - 13.8) / |
---|
2096 | : (3260 - 740) * (zlay(k) - 740) |
---|
2097 | elseif(3260 < zlay(k) .and. zlay(k) < 4000) then |
---|
2098 | q_rico(k)=2.4 + (1.8 - 2.4) / |
---|
2099 | : (4000 - 3260) * (zlay(k) - 3260) |
---|
2100 | elseif(4000 < zlay(k) .and. zlay(k) < 9000) then |
---|
2101 | q_rico(k)=1.8 + (0 - 1.8) / |
---|
2102 | : (10000 - 4000) * (zlay(k) - 4000) |
---|
2103 | else |
---|
2104 | q_rico(k)=0.0 |
---|
2105 | endif |
---|
2106 | |
---|
2107 | !T |
---|
2108 | if(0 < zlay(k) .and. zlay(k) < 740) then |
---|
2109 | t_rico(k)=299.2 + (292.0 - 299.2) / (740) * zlay(k) |
---|
2110 | elseif(740 < zlay(k) .and. zlay(k) < 4000) then |
---|
2111 | t_rico(k)=292.0 + (278.0 - 292.0) / |
---|
2112 | : (4000 - 740) * (zlay(k) - 740) |
---|
2113 | elseif(4000 < zlay(k) .and. zlay(k) < 15000) then |
---|
2114 | t_rico(k)=278.0 + (203.0 - 278.0) / |
---|
2115 | : (15000 - 4000) * (zlay(k) - 4000) |
---|
2116 | elseif(15000 < zlay(k) .and. zlay(k) < 17500) then |
---|
2117 | t_rico(k)=203.0 + (194.0 - 203.0) / |
---|
2118 | : (17500 - 15000)* (zlay(k) - 15000) |
---|
2119 | elseif(17500 < zlay(k) .and. zlay(k) < 20000) then |
---|
2120 | t_rico(k)=194.0 + (206.0 - 194.0) / |
---|
2121 | : (20000 - 17500)* (zlay(k) - 17500) |
---|
2122 | elseif(20000 < zlay(k) .and. zlay(k) < 60000) then |
---|
2123 | t_rico(k)=206.0 + (270.0 - 206.0) / |
---|
2124 | : (60000 - 20000)* (zlay(k) - 20000) |
---|
2125 | endif |
---|
2126 | |
---|
2127 | ! W |
---|
2128 | if(0 < zlay(k) .and. zlay(k) < 2260 ) then |
---|
2129 | w_rico(k)=- (0.005/2260) * zlay(k) |
---|
2130 | elseif(2260 < zlay(k) .and. zlay(k) < 4000 ) then |
---|
2131 | w_rico(k)=- 0.005 |
---|
2132 | elseif(4000 < zlay(k) .and. zlay(k) < 5000 ) then |
---|
2133 | w_rico(k)=- 0.005 + (0.005/ (5000 - 4000)) * (zlay(k) - 4000) |
---|
2134 | else |
---|
2135 | w_rico(k)=0.0 |
---|
2136 | endif |
---|
2137 | |
---|
2138 | ! dThrz+dTsw0+dTlw0 |
---|
2139 | if(0 < zlay(k) .and. zlay(k) < 4000) then |
---|
2140 | dth_dyn(k)=- 2.51 / 86400 + (-2.18 + 2.51 )/ |
---|
2141 | : (86400*4000) * zlay(k) |
---|
2142 | elseif(4000 < zlay(k) .and. zlay(k) < 5000) then |
---|
2143 | dth_dyn(k)=- 2.18 / 86400 + ( 2.18 ) / |
---|
2144 | : (86400*(5000 - 4000)) * (zlay(k) - 4000) |
---|
2145 | else |
---|
2146 | dth_dyn(k)=0.0 |
---|
2147 | endif |
---|
2148 | ! dQhrz |
---|
2149 | if(0 < zlay(k) .and. zlay(k) < 3000) then |
---|
2150 | dqh_dyn(k)=-1.0 / 86400 + (0.345 + 1.0)/ |
---|
2151 | : (86400*3000) * (zlay(k)) |
---|
2152 | elseif(3000 < zlay(k) .and. zlay(k) < 4000) then |
---|
2153 | dqh_dyn(k)=0.345 / 86400 |
---|
2154 | elseif(4000 < zlay(k) .and. zlay(k) < 5000) then |
---|
2155 | dqh_dyn(k)=0.345 / 86400 + |
---|
2156 | + (-0.345)/(86400 * (5000 - 4000)) * (zlay(k)-4000) |
---|
2157 | else |
---|
2158 | dqh_dyn(k)=0.0 |
---|
2159 | endif |
---|
2160 | |
---|
2161 | !? if(play(k)>6e4) then |
---|
2162 | !? ratqs0(1,k)=ratqsbas*(plev(1)-play(k))/(plev(1)-6e4) |
---|
2163 | !? elseif((play(k)>3e4).and.(play(k)<6e4)) then |
---|
2164 | !? ratqs0(1,k)=ratqsbas+(ratqshaut-ratqsbas)& |
---|
2165 | !? *(6e4-play(k))/(6e4-3e4) |
---|
2166 | !? else |
---|
2167 | !? ratqs0(1,k)=ratqshaut |
---|
2168 | !? endif |
---|
2169 | |
---|
2170 | enddo |
---|
2171 | |
---|
2172 | do k=1,llm |
---|
2173 | q_rico(k)=q_rico(k)/1e3 |
---|
2174 | dqh_dyn(k)=dqh_dyn(k)/1e3 |
---|
2175 | v_rico(k)=-3.8 |
---|
2176 | enddo |
---|
2177 | |
---|
2178 | return |
---|
2179 | end |
---|
2180 | |
---|
2181 | !===================================================================== |
---|
2182 | c------------------------------------------------------------------------- |
---|
2183 | SUBROUTINE read_armcu(fich_armcu,nlev_armcu,nt_armcu, |
---|
2184 | : sens,flat,adv_theta,rad_theta,adv_qt) |
---|
2185 | implicit none |
---|
2186 | |
---|
2187 | c------------------------------------------------------------------------- |
---|
2188 | c Read ARM_CU case forcing data |
---|
2189 | c------------------------------------------------------------------------- |
---|
2190 | |
---|
2191 | integer nlev_armcu,nt_armcu |
---|
2192 | real sens(nt_armcu),flat(nt_armcu) |
---|
2193 | real adv_theta(nt_armcu),rad_theta(nt_armcu),adv_qt(nt_armcu) |
---|
2194 | character*80 fich_armcu |
---|
2195 | |
---|
2196 | integer no,l,k,ip |
---|
2197 | real riy,rim,rid,rih,bid |
---|
2198 | |
---|
2199 | integer iy,im,id,ih,in |
---|
2200 | |
---|
2201 | open(21,file=trim(fich_armcu),form='formatted') |
---|
2202 | read(21,'(a)') |
---|
2203 | do ip = 1, nt_armcu |
---|
2204 | read(21,'(a)') |
---|
2205 | read(21,'(a)') |
---|
2206 | read(21,223) iy, im, id, ih, in, sens(ip),flat(ip), |
---|
2207 | : adv_theta(ip),rad_theta(ip),adv_qt(ip) |
---|
2208 | print *,'forcages=',iy,im,id,ih,in, sens(ip),flat(ip), |
---|
2209 | : adv_theta(ip),rad_theta(ip),adv_qt(ip) |
---|
2210 | enddo |
---|
2211 | close(21) |
---|
2212 | |
---|
2213 | 223 format(5i3,5f8.3) |
---|
2214 | 226 format(f7.1,1x,10f8.2) |
---|
2215 | 227 format(f7.1,1x,1p,4e11.3) |
---|
2216 | 230 format(6f9.3,4e11.3) |
---|
2217 | |
---|
2218 | return |
---|
2219 | end |
---|
2220 | |
---|
2221 | !===================================================================== |
---|
2222 | SUBROUTINE interp_toga_vertical(play,nlev_toga,plev_prof |
---|
2223 | : ,t_prof,q_prof,u_prof,v_prof,w_prof |
---|
2224 | : ,ht_prof,vt_prof,hq_prof,vq_prof |
---|
2225 | : ,t_mod,q_mod,u_mod,v_mod,w_mod |
---|
2226 | : ,ht_mod,vt_mod,hq_mod,vq_mod,mxcalc) |
---|
2227 | |
---|
2228 | implicit none |
---|
2229 | |
---|
2230 | #include "dimensions.h" |
---|
2231 | |
---|
2232 | c------------------------------------------------------------------------- |
---|
2233 | c Vertical interpolation of TOGA-COARE forcing data onto model levels |
---|
2234 | c------------------------------------------------------------------------- |
---|
2235 | |
---|
2236 | integer nlevmax |
---|
2237 | parameter (nlevmax=41) |
---|
2238 | integer nlev_toga,mxcalc |
---|
2239 | ! real play(llm), plev_prof(nlevmax) |
---|
2240 | ! real t_prof(nlevmax),q_prof(nlevmax) |
---|
2241 | ! real u_prof(nlevmax),v_prof(nlevmax), w_prof(nlevmax) |
---|
2242 | ! real ht_prof(nlevmax),vt_prof(nlevmax) |
---|
2243 | ! real hq_prof(nlevmax),vq_prof(nlevmax) |
---|
2244 | |
---|
2245 | real play(llm), plev_prof(nlev_toga) |
---|
2246 | real t_prof(nlev_toga),q_prof(nlev_toga) |
---|
2247 | real u_prof(nlev_toga),v_prof(nlev_toga), w_prof(nlev_toga) |
---|
2248 | real ht_prof(nlev_toga),vt_prof(nlev_toga) |
---|
2249 | real hq_prof(nlev_toga),vq_prof(nlev_toga) |
---|
2250 | |
---|
2251 | real t_mod(llm),q_mod(llm) |
---|
2252 | real u_mod(llm),v_mod(llm), w_mod(llm) |
---|
2253 | real ht_mod(llm),vt_mod(llm) |
---|
2254 | real hq_mod(llm),vq_mod(llm) |
---|
2255 | |
---|
2256 | integer l,k,k1,k2,kp |
---|
2257 | real aa,frac,frac1,frac2,fact |
---|
2258 | |
---|
2259 | do l = 1, llm |
---|
2260 | |
---|
2261 | if (play(l).ge.plev_prof(nlev_toga)) then |
---|
2262 | |
---|
2263 | mxcalc=l |
---|
2264 | k1=0 |
---|
2265 | k2=0 |
---|
2266 | |
---|
2267 | if (play(l).le.plev_prof(1)) then |
---|
2268 | |
---|
2269 | do k = 1, nlev_toga-1 |
---|
2270 | if (play(l).le.plev_prof(k) |
---|
2271 | : .and. play(l).gt.plev_prof(k+1)) then |
---|
2272 | k1=k |
---|
2273 | k2=k+1 |
---|
2274 | endif |
---|
2275 | enddo |
---|
2276 | |
---|
2277 | if (k1.eq.0 .or. k2.eq.0) then |
---|
2278 | write(*,*) 'PB! k1, k2 = ',k1,k2 |
---|
2279 | write(*,*) 'l,play(l) = ',l,play(l)/100 |
---|
2280 | do k = 1, nlev_toga-1 |
---|
2281 | write(*,*) 'k,plev_prof(k) = ',k,plev_prof(k)/100 |
---|
2282 | enddo |
---|
2283 | endif |
---|
2284 | |
---|
2285 | frac = (plev_prof(k2)-play(l))/(plev_prof(k2)-plev_prof(k1)) |
---|
2286 | t_mod(l)= t_prof(k2) - frac*(t_prof(k2)-t_prof(k1)) |
---|
2287 | q_mod(l)= q_prof(k2) - frac*(q_prof(k2)-q_prof(k1)) |
---|
2288 | u_mod(l)= u_prof(k2) - frac*(u_prof(k2)-u_prof(k1)) |
---|
2289 | v_mod(l)= v_prof(k2) - frac*(v_prof(k2)-v_prof(k1)) |
---|
2290 | w_mod(l)= w_prof(k2) - frac*(w_prof(k2)-w_prof(k1)) |
---|
2291 | ht_mod(l)= ht_prof(k2) - frac*(ht_prof(k2)-ht_prof(k1)) |
---|
2292 | vt_mod(l)= vt_prof(k2) - frac*(vt_prof(k2)-vt_prof(k1)) |
---|
2293 | hq_mod(l)= hq_prof(k2) - frac*(hq_prof(k2)-hq_prof(k1)) |
---|
2294 | vq_mod(l)= vq_prof(k2) - frac*(vq_prof(k2)-vq_prof(k1)) |
---|
2295 | |
---|
2296 | else !play>plev_prof(1) |
---|
2297 | |
---|
2298 | k1=1 |
---|
2299 | k2=2 |
---|
2300 | frac1 = (play(l)-plev_prof(k2))/(plev_prof(k1)-plev_prof(k2)) |
---|
2301 | frac2 = (play(l)-plev_prof(k1))/(plev_prof(k1)-plev_prof(k2)) |
---|
2302 | t_mod(l)= frac1*t_prof(k1) - frac2*t_prof(k2) |
---|
2303 | q_mod(l)= frac1*q_prof(k1) - frac2*q_prof(k2) |
---|
2304 | u_mod(l)= frac1*u_prof(k1) - frac2*u_prof(k2) |
---|
2305 | v_mod(l)= frac1*v_prof(k1) - frac2*v_prof(k2) |
---|
2306 | w_mod(l)= frac1*w_prof(k1) - frac2*w_prof(k2) |
---|
2307 | ht_mod(l)= frac1*ht_prof(k1) - frac2*ht_prof(k2) |
---|
2308 | vt_mod(l)= frac1*vt_prof(k1) - frac2*vt_prof(k2) |
---|
2309 | hq_mod(l)= frac1*hq_prof(k1) - frac2*hq_prof(k2) |
---|
2310 | vq_mod(l)= frac1*vq_prof(k1) - frac2*vq_prof(k2) |
---|
2311 | |
---|
2312 | endif ! play.le.plev_prof(1) |
---|
2313 | |
---|
2314 | else ! above max altitude of forcing file |
---|
2315 | |
---|
2316 | cjyg |
---|
2317 | fact=20.*(plev_prof(nlev_toga)-play(l))/plev_prof(nlev_toga) !jyg |
---|
2318 | fact = max(fact,0.) !jyg |
---|
2319 | fact = exp(-fact) !jyg |
---|
2320 | t_mod(l)= t_prof(nlev_toga) !jyg |
---|
2321 | q_mod(l)= q_prof(nlev_toga)*fact !jyg |
---|
2322 | u_mod(l)= u_prof(nlev_toga)*fact !jyg |
---|
2323 | v_mod(l)= v_prof(nlev_toga)*fact !jyg |
---|
2324 | w_mod(l)= 0.0 !jyg |
---|
2325 | ht_mod(l)= ht_prof(nlev_toga) !jyg |
---|
2326 | vt_mod(l)= vt_prof(nlev_toga) !jyg |
---|
2327 | hq_mod(l)= hq_prof(nlev_toga)*fact !jyg |
---|
2328 | vq_mod(l)= vq_prof(nlev_toga)*fact !jyg |
---|
2329 | |
---|
2330 | endif ! play |
---|
2331 | |
---|
2332 | enddo ! l |
---|
2333 | |
---|
2334 | ! do l = 1,llm |
---|
2335 | ! print *,'t_mod(l),q_mod(l),ht_mod(l),hq_mod(l) ', |
---|
2336 | ! $ l,t_mod(l),q_mod(l),ht_mod(l),hq_mod(l) |
---|
2337 | ! enddo |
---|
2338 | |
---|
2339 | return |
---|
2340 | end |
---|
2341 | |
---|
2342 | !====================================================================== |
---|
2343 | SUBROUTINE interp_toga_time(day,day1,annee_ref |
---|
2344 | i ,year_ini_toga,day_ini_toga,nt_toga,dt_toga,nlev_toga |
---|
2345 | i ,ts_toga,plev_toga,t_toga,q_toga,u_toga,v_toga,w_toga |
---|
2346 | i ,ht_toga,vt_toga,hq_toga,vq_toga |
---|
2347 | o ,ts_prof,plev_prof,t_prof,q_prof,u_prof,v_prof,w_prof |
---|
2348 | o ,ht_prof,vt_prof,hq_prof,vq_prof) |
---|
2349 | implicit none |
---|
2350 | |
---|
2351 | !--------------------------------------------------------------------------------------- |
---|
2352 | ! Time interpolation of a 2D field to the timestep corresponding to day |
---|
2353 | ! |
---|
2354 | ! day: current julian day (e.g. 717538.2) |
---|
2355 | ! day1: first day of the simulation |
---|
2356 | ! nt_toga: total nb of data in the forcing (e.g. 480 for TOGA-COARE) |
---|
2357 | ! dt_toga: total time interval (in sec) between 2 forcing data (e.g. 6h for TOGA-COARE) |
---|
2358 | !--------------------------------------------------------------------------------------- |
---|
2359 | |
---|
2360 | #include "compar1d.h" |
---|
2361 | |
---|
2362 | ! inputs: |
---|
2363 | integer annee_ref |
---|
2364 | integer nt_toga,nlev_toga |
---|
2365 | integer year_ini_toga |
---|
2366 | real day, day1,day_ini_toga,dt_toga |
---|
2367 | real ts_toga(nt_toga) |
---|
2368 | real plev_toga(nlev_toga,nt_toga),t_toga(nlev_toga,nt_toga) |
---|
2369 | real q_toga(nlev_toga,nt_toga),u_toga(nlev_toga,nt_toga) |
---|
2370 | real v_toga(nlev_toga,nt_toga),w_toga(nlev_toga,nt_toga) |
---|
2371 | real ht_toga(nlev_toga,nt_toga),vt_toga(nlev_toga,nt_toga) |
---|
2372 | real hq_toga(nlev_toga,nt_toga),vq_toga(nlev_toga,nt_toga) |
---|
2373 | ! outputs: |
---|
2374 | real ts_prof |
---|
2375 | real plev_prof(nlev_toga),t_prof(nlev_toga) |
---|
2376 | real q_prof(nlev_toga),u_prof(nlev_toga) |
---|
2377 | real v_prof(nlev_toga),w_prof(nlev_toga) |
---|
2378 | real ht_prof(nlev_toga),vt_prof(nlev_toga) |
---|
2379 | real hq_prof(nlev_toga),vq_prof(nlev_toga) |
---|
2380 | ! local: |
---|
2381 | integer it_toga1, it_toga2,k |
---|
2382 | real timeit,time_toga1,time_toga2,frac |
---|
2383 | |
---|
2384 | |
---|
2385 | if (forcing_type.eq.2) then |
---|
2386 | ! Check that initial day of the simulation consistent with TOGA-COARE period: |
---|
2387 | if (annee_ref.ne.1992 .and. annee_ref.ne.1993) then |
---|
2388 | print*,'Pour TOGA-COARE, annee_ref doit etre 1992 ou 1993' |
---|
2389 | print*,'Changer annee_ref dans run.def' |
---|
2390 | stop |
---|
2391 | endif |
---|
2392 | if (annee_ref.eq.1992 .and. day1.lt.day_ini_toga) then |
---|
2393 | print*,'TOGA-COARE a débuté le 1er Nov 1992 (jour julien=306)' |
---|
2394 | print*,'Changer dayref dans run.def' |
---|
2395 | stop |
---|
2396 | endif |
---|
2397 | if (annee_ref.eq.1993 .and. day1.gt.day_ini_toga+119) then |
---|
2398 | print*,'TOGA-COARE a fini le 28 Feb 1993 (jour julien=59)' |
---|
2399 | print*,'Changer dayref ou nday dans run.def' |
---|
2400 | stop |
---|
2401 | endif |
---|
2402 | |
---|
2403 | else if (forcing_type.eq.4) then |
---|
2404 | |
---|
2405 | ! Check that initial day of the simulation consistent with TWP-ICE period: |
---|
2406 | if (annee_ref.ne.2006) then |
---|
2407 | print*,'Pour TWP-ICE, annee_ref doit etre 2006' |
---|
2408 | print*,'Changer annee_ref dans run.def' |
---|
2409 | stop |
---|
2410 | endif |
---|
2411 | if (annee_ref.eq.2006 .and. day1.lt.day_ini_toga) then |
---|
2412 | print*,'TWP-ICE a debute le 17 Jan 2006 (jour julien=17)' |
---|
2413 | print*,'Changer dayref dans run.def' |
---|
2414 | stop |
---|
2415 | endif |
---|
2416 | if (annee_ref.eq.2006 .and. day1.gt.day_ini_toga+26) then |
---|
2417 | print*,'TWP-ICE a fini le 12 Feb 2006 (jour julien=43)' |
---|
2418 | print*,'Changer dayref ou nday dans run.def' |
---|
2419 | stop |
---|
2420 | endif |
---|
2421 | |
---|
2422 | endif |
---|
2423 | |
---|
2424 | ! Determine timestep relative to the 1st day of TOGA-COARE: |
---|
2425 | ! timeit=(day-day1)*86400. |
---|
2426 | ! if (annee_ref.eq.1992) then |
---|
2427 | ! timeit=(day-day_ini_toga)*86400. |
---|
2428 | ! else |
---|
2429 | ! timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992 |
---|
2430 | ! endif |
---|
2431 | timeit=(day-day_ini_toga)*86400 |
---|
2432 | |
---|
2433 | ! Determine the closest observation times: |
---|
2434 | it_toga1=INT(timeit/dt_toga)+1 |
---|
2435 | it_toga2=it_toga1 + 1 |
---|
2436 | time_toga1=(it_toga1-1)*dt_toga |
---|
2437 | time_toga2=(it_toga2-1)*dt_toga |
---|
2438 | |
---|
2439 | if (it_toga1 .ge. nt_toga) then |
---|
2440 | write(*,*) 'PB-stop: day, it_toga1, it_toga2, timeit: ' |
---|
2441 | : ,day,it_toga1,it_toga2,timeit/86400. |
---|
2442 | stop |
---|
2443 | endif |
---|
2444 | |
---|
2445 | ! time interpolation: |
---|
2446 | frac=(time_toga2-timeit)/(time_toga2-time_toga1) |
---|
2447 | frac=max(frac,0.0) |
---|
2448 | |
---|
2449 | ts_prof = ts_toga(it_toga2) |
---|
2450 | : -frac*(ts_toga(it_toga2)-ts_toga(it_toga1)) |
---|
2451 | |
---|
2452 | ! print*, |
---|
2453 | ! :'day,annee_ref,day_ini_toga,timeit,it_toga1,it_toga2,SST:', |
---|
2454 | ! :day,annee_ref,day_ini_toga,timeit/86400.,it_toga1,it_toga2,ts_prof |
---|
2455 | |
---|
2456 | do k=1,nlev_toga |
---|
2457 | plev_prof(k) = 100.*(plev_toga(k,it_toga2) |
---|
2458 | : -frac*(plev_toga(k,it_toga2)-plev_toga(k,it_toga1))) |
---|
2459 | t_prof(k) = t_toga(k,it_toga2) |
---|
2460 | : -frac*(t_toga(k,it_toga2)-t_toga(k,it_toga1)) |
---|
2461 | q_prof(k) = q_toga(k,it_toga2) |
---|
2462 | : -frac*(q_toga(k,it_toga2)-q_toga(k,it_toga1)) |
---|
2463 | u_prof(k) = u_toga(k,it_toga2) |
---|
2464 | : -frac*(u_toga(k,it_toga2)-u_toga(k,it_toga1)) |
---|
2465 | v_prof(k) = v_toga(k,it_toga2) |
---|
2466 | : -frac*(v_toga(k,it_toga2)-v_toga(k,it_toga1)) |
---|
2467 | w_prof(k) = w_toga(k,it_toga2) |
---|
2468 | : -frac*(w_toga(k,it_toga2)-w_toga(k,it_toga1)) |
---|
2469 | ht_prof(k) = ht_toga(k,it_toga2) |
---|
2470 | : -frac*(ht_toga(k,it_toga2)-ht_toga(k,it_toga1)) |
---|
2471 | vt_prof(k) = vt_toga(k,it_toga2) |
---|
2472 | : -frac*(vt_toga(k,it_toga2)-vt_toga(k,it_toga1)) |
---|
2473 | hq_prof(k) = hq_toga(k,it_toga2) |
---|
2474 | : -frac*(hq_toga(k,it_toga2)-hq_toga(k,it_toga1)) |
---|
2475 | vq_prof(k) = vq_toga(k,it_toga2) |
---|
2476 | : -frac*(vq_toga(k,it_toga2)-vq_toga(k,it_toga1)) |
---|
2477 | enddo |
---|
2478 | |
---|
2479 | return |
---|
2480 | END |
---|
2481 | |
---|
2482 | !====================================================================== |
---|
2483 | SUBROUTINE interp_armcu_time(day,day1,annee_ref |
---|
2484 | i ,year_ini_armcu,day_ini_armcu,nt_armcu,dt_armcu |
---|
2485 | i ,nlev_armcu,fs_armcu,fl_armcu,at_armcu,rt_armcu |
---|
2486 | i ,aqt_armcu,fs_prof,fl_prof,at_prof,rt_prof,aqt_prof) |
---|
2487 | implicit none |
---|
2488 | |
---|
2489 | !--------------------------------------------------------------------------------------- |
---|
2490 | ! Time interpolation of a 2D field to the timestep corresponding to day |
---|
2491 | ! |
---|
2492 | ! day: current julian day (e.g. 717538.2) |
---|
2493 | ! day1: first day of the simulation |
---|
2494 | ! nt_armcu: total nb of data in the forcing (e.g. 31 for armcu) |
---|
2495 | ! dt_armcu: total time interval (in sec) between 2 forcing data (e.g. 1/2h for armcu) |
---|
2496 | ! fs= sensible flux |
---|
2497 | ! fl= latent flux |
---|
2498 | ! at,rt,aqt= advective and radiative tendencies |
---|
2499 | !--------------------------------------------------------------------------------------- |
---|
2500 | |
---|
2501 | ! inputs: |
---|
2502 | integer annee_ref |
---|
2503 | integer nt_armcu,nlev_armcu |
---|
2504 | integer year_ini_armcu |
---|
2505 | real day, day1,day_ini_armcu,dt_armcu |
---|
2506 | real fs_armcu(nt_armcu),fl_armcu(nt_armcu),at_armcu(nt_armcu) |
---|
2507 | real rt_armcu(nt_armcu),aqt_armcu(nt_armcu) |
---|
2508 | ! outputs: |
---|
2509 | real fs_prof,fl_prof,at_prof,rt_prof,aqt_prof |
---|
2510 | ! local: |
---|
2511 | integer it_armcu1, it_armcu2,k |
---|
2512 | real timeit,time_armcu1,time_armcu2,frac |
---|
2513 | |
---|
2514 | ! Check that initial day of the simulation consistent with ARMCU period: |
---|
2515 | if (annee_ref.ne.1997 ) then |
---|
2516 | print*,'Pour ARMCU, annee_ref doit etre 1997 ' |
---|
2517 | print*,'Changer annee_ref dans run.def' |
---|
2518 | stop |
---|
2519 | endif |
---|
2520 | |
---|
2521 | timeit=(day-day_ini_armcu)*86400 |
---|
2522 | |
---|
2523 | ! Determine the closest observation times: |
---|
2524 | it_armcu1=INT(timeit/dt_armcu)+1 |
---|
2525 | it_armcu2=it_armcu1 + 1 |
---|
2526 | time_armcu1=(it_armcu1-1)*dt_armcu |
---|
2527 | time_armcu2=(it_armcu2-1)*dt_armcu |
---|
2528 | print *,'timeit day day_ini_armcu',timeit,day,day_ini_armcu |
---|
2529 | print *,'it_armcu1,it_armcu2,time_armcu1,time_armcu2', |
---|
2530 | . it_armcu1,it_armcu2,time_armcu1,time_armcu2 |
---|
2531 | |
---|
2532 | if (it_armcu1 .ge. nt_armcu) then |
---|
2533 | write(*,*) 'PB-stop: day, it_armcu1, it_armcu2, timeit: ' |
---|
2534 | : ,day,it_armcu1,it_armcu2,timeit/86400. |
---|
2535 | stop |
---|
2536 | endif |
---|
2537 | |
---|
2538 | ! time interpolation: |
---|
2539 | frac=(time_armcu2-timeit)/(time_armcu2-time_armcu1) |
---|
2540 | frac=max(frac,0.0) |
---|
2541 | |
---|
2542 | fs_prof = fs_armcu(it_armcu2) |
---|
2543 | : -frac*(fs_armcu(it_armcu2)-fs_armcu(it_armcu1)) |
---|
2544 | fl_prof = fl_armcu(it_armcu2) |
---|
2545 | : -frac*(fl_armcu(it_armcu2)-fl_armcu(it_armcu1)) |
---|
2546 | at_prof = at_armcu(it_armcu2) |
---|
2547 | : -frac*(at_armcu(it_armcu2)-at_armcu(it_armcu1)) |
---|
2548 | rt_prof = rt_armcu(it_armcu2) |
---|
2549 | : -frac*(rt_armcu(it_armcu2)-rt_armcu(it_armcu1)) |
---|
2550 | aqt_prof = aqt_armcu(it_armcu2) |
---|
2551 | : -frac*(aqt_armcu(it_armcu2)-aqt_armcu(it_armcu1)) |
---|
2552 | |
---|
2553 | print*, |
---|
2554 | :'day,annee_ref,day_ini_armcu,timeit,it_armcu1,it_armcu2,SST:', |
---|
2555 | :day,annee_ref,day_ini_armcu,timeit/86400.,it_armcu1, |
---|
2556 | :it_armcu2,fs_prof,fl_prof,at_prof,rt_prof,aqt_prof |
---|
2557 | |
---|
2558 | return |
---|
2559 | END |
---|
2560 | |
---|
2561 | !===================================================================== |
---|
2562 | subroutine readprofiles(nlev_max,kmax,height, |
---|
2563 | . thlprof,qtprof,uprof, |
---|
2564 | . vprof,e12prof,ugprof,vgprof, |
---|
2565 | . wfls,dqtdxls,dqtdyls,dqtdtls, |
---|
2566 | . thlpcar) |
---|
2567 | implicit none |
---|
2568 | |
---|
2569 | integer nlev_max,kmax,kmax2 |
---|
2570 | logical :: llesread = .true. |
---|
2571 | |
---|
2572 | real height(nlev_max),thlprof(nlev_max),qtprof(nlev_max), |
---|
2573 | . uprof(nlev_max),vprof(nlev_max),e12prof(nlev_max), |
---|
2574 | . ugprof(nlev_max),vgprof(nlev_max),wfls(nlev_max), |
---|
2575 | . dqtdxls(nlev_max),dqtdyls(nlev_max),dqtdtls(nlev_max), |
---|
2576 | . thlpcar(nlev_max) |
---|
2577 | |
---|
2578 | integer, parameter :: ilesfile=1 |
---|
2579 | integer :: ierr,irad,imax,jtot,k |
---|
2580 | logical :: lmoist,lcoriol,ltimedep |
---|
2581 | real :: xsize,ysize |
---|
2582 | real :: ustin,wsvsurf,timerad |
---|
2583 | character(80) :: chmess |
---|
2584 | |
---|
2585 | if(.not.(llesread)) return |
---|
2586 | |
---|
2587 | open (ilesfile,file='prof.inp.001',status='old',iostat=ierr) |
---|
2588 | if (ierr /= 0) stop 'ERROR:Prof.inp does not exist' |
---|
2589 | read (ilesfile,*) kmax |
---|
2590 | do k=1,kmax |
---|
2591 | read (ilesfile,*) height(k),thlprof(k),qtprof (k), |
---|
2592 | . uprof (k),vprof (k),e12prof(k) |
---|
2593 | enddo |
---|
2594 | close(ilesfile) |
---|
2595 | |
---|
2596 | open(ilesfile,file='lscale.inp.001',status='old',iostat=ierr) |
---|
2597 | if (ierr /= 0) stop 'ERROR:Lscale.inp does not exist' |
---|
2598 | read (ilesfile,*) kmax2 |
---|
2599 | if (kmax .ne. kmax2) then |
---|
2600 | print *, 'fichiers prof.inp et lscale.inp incompatibles :' |
---|
2601 | print *, 'nbre de niveaux : ',kmax,' et ',kmax2 |
---|
2602 | stop 'lecture profiles' |
---|
2603 | endif |
---|
2604 | do k=1,kmax |
---|
2605 | read (ilesfile,*) height(k),ugprof(k),vgprof(k),wfls(k), |
---|
2606 | . dqtdxls(k),dqtdyls(k),dqtdtls(k),thlpcar(k) |
---|
2607 | end do |
---|
2608 | close(ilesfile) |
---|
2609 | |
---|
2610 | return |
---|
2611 | end |
---|
2612 | |
---|
2613 | !=============================================================== |
---|
2614 | function ismin(n,sx,incx) |
---|
2615 | |
---|
2616 | implicit none |
---|
2617 | integer n,i,incx,ismin,ix |
---|
2618 | real sx((n-1)*incx+1),sxmin |
---|
2619 | |
---|
2620 | ix=1 |
---|
2621 | ismin=1 |
---|
2622 | sxmin=sx(1) |
---|
2623 | do i=1,n-1 |
---|
2624 | ix=ix+incx |
---|
2625 | if(sx(ix).lt.sxmin) then |
---|
2626 | sxmin=sx(ix) |
---|
2627 | ismin=i+1 |
---|
2628 | endif |
---|
2629 | enddo |
---|
2630 | |
---|
2631 | return |
---|
2632 | end |
---|
2633 | |
---|
2634 | !=============================================================== |
---|
2635 | function ismax(n,sx,incx) |
---|
2636 | |
---|
2637 | implicit none |
---|
2638 | integer n,i,incx,ismax,ix |
---|
2639 | real sx((n-1)*incx+1),sxmax |
---|
2640 | |
---|
2641 | ix=1 |
---|
2642 | ismax=1 |
---|
2643 | sxmax=sx(1) |
---|
2644 | do i=1,n-1 |
---|
2645 | ix=ix+incx |
---|
2646 | if(sx(ix).gt.sxmax) then |
---|
2647 | sxmax=sx(ix) |
---|
2648 | ismax=i+1 |
---|
2649 | endif |
---|
2650 | enddo |
---|
2651 | |
---|
2652 | return |
---|
2653 | end |
---|
2654 | |
---|