1 |
guez |
3 |
PROGRAM gcm |
2 |
|
|
|
3 |
guez |
36 |
! Authors: P. Le Van, L. Fairhead, F. Hourdin |
4 |
|
|
! From "gcm.F", version 1.4, 2006/04/04 15:05:16 |
5 |
guez |
3 |
|
6 |
guez |
38 |
! General circulation model of LMD. Avec coordonnée verticale |
7 |
|
|
! hybride, avec nouveaux opérateurs de dissipation "*" ("gradiv2", |
8 |
|
|
! "divgrad2", "nxgraro2"). Possibilité de choisir le schéma pour |
9 |
|
|
! l'advection de "q", en modifiant "iadv" dans "traceur.def". |
10 |
|
|
|
11 |
guez |
26 |
use clesphys2, only: read_clesphys2 |
12 |
guez |
39 |
use comconst, only: daysec, cpp, dtvr, g, rad, r |
13 |
guez |
26 |
use comgeom, only: rlatu, aire_2d, cu_2d, cv_2d, rlonv |
14 |
guez |
37 |
use comgeomphy, only: airephy, cuphy, cvphy, rlatd, rlond |
15 |
guez |
3 |
use conf_gcm_m, only: day_step, iperiod, anneeref, dayref, iecri, iphysiq, & |
16 |
|
|
nday, raz_date, periodav, conf_gcm |
17 |
guez |
26 |
use dimens_m, only: iim, jjm, llm, nqmx |
18 |
|
|
use dimphy, only: klon |
19 |
guez |
25 |
use dynetat0_m, only: dynetat0, day_ini |
20 |
guez |
26 |
use dynredem0_m, only: dynredem0 |
21 |
guez |
3 |
use grid_change, only: dyn_phy, init_dyn_phy |
22 |
guez |
18 |
use iniadvtrac_m, only: iniadvtrac |
23 |
guez |
26 |
use inidissip_m, only: inidissip |
24 |
guez |
54 |
use inifilr_m, only: inifilr |
25 |
guez |
26 |
use inigeom_m, only: inigeom |
26 |
|
|
use initdynav_m, only: initdynav |
27 |
|
|
use inithist_m, only: inithist |
28 |
guez |
30 |
USE calendar, only: ioconf_calendar |
29 |
|
|
use histcom, only: histclo |
30 |
guez |
3 |
use leapfrog_m, only: leapfrog |
31 |
guez |
26 |
use logic, only: iflag_phys |
32 |
guez |
37 |
use suphec_m, only: suphec |
33 |
guez |
26 |
use temps, only: day_ref, annee_ref, day_end, itau_dyn |
34 |
|
|
use tracstoke, only: istdyn, istphy |
35 |
guez |
38 |
use yoethf_m, only: yoethf |
36 |
guez |
3 |
|
37 |
|
|
IMPLICIT NONE |
38 |
|
|
|
39 |
|
|
REAL zdtvr ! time step for dynamics, in s |
40 |
|
|
|
41 |
|
|
! Variables dynamiques : |
42 |
guez |
55 |
REAL ucov(iim + 1, jjm + 1, llm), vcov(iim + 1, jjm, llm) ! vent covariant |
43 |
guez |
43 |
REAL teta(iim + 1, jjm + 1, llm) ! température potentielle |
44 |
guez |
40 |
REAL q(iim + 1, jjm + 1, llm, nqmx) ! champs advectés |
45 |
guez |
39 |
REAL ps(iim + 1, jjm + 1) ! pression au sol (Pa) |
46 |
guez |
55 |
REAL masse(iim + 1, jjm + 1, llm) ! masse d'air |
47 |
guez |
7 |
REAL phis(iim + 1, jjm + 1) ! géopotentiel au sol |
48 |
guez |
3 |
|
49 |
|
|
! Variables pour le fichier histoire : |
50 |
guez |
25 |
REAL time_0 ! time in day, as a fraction of day, in [0, 1[ |
51 |
guez |
3 |
|
52 |
|
|
! Calendrier : |
53 |
|
|
LOGICAL:: true_calendar = .false. ! default value |
54 |
|
|
|
55 |
|
|
logical mask_v(iim + 1, jjm) |
56 |
|
|
! (mask for points in the "v" grid, first index is for longitude, |
57 |
|
|
! second index is for latitude) |
58 |
|
|
|
59 |
|
|
namelist /main_nml/true_calendar |
60 |
|
|
|
61 |
|
|
!------------------------------------------------------------ |
62 |
|
|
|
63 |
|
|
print *, "Enter namelist 'main_nml'." |
64 |
|
|
read (unit=*, nml=main_nml) |
65 |
|
|
write(unit=*, nml=main_nml) |
66 |
|
|
|
67 |
|
|
! Choix du calendrier : |
68 |
|
|
if (true_calendar) then |
69 |
|
|
call ioconf_calendar('gregorian') |
70 |
|
|
else |
71 |
|
|
call ioconf_calendar('360d') |
72 |
|
|
endif |
73 |
|
|
|
74 |
|
|
! Lecture des fichiers "gcm.def" ou "run.def" : |
75 |
guez |
13 |
call read_clesphys2 |
76 |
|
|
CALL conf_gcm |
77 |
guez |
3 |
|
78 |
|
|
! Initialisation des traceurs |
79 |
|
|
! Choix du schéma pour l'advection dans le fichier "traceur.def" ou via INCA |
80 |
guez |
23 |
call iniadvtrac |
81 |
guez |
3 |
|
82 |
|
|
! Lecture du fichier "start.nc" : |
83 |
|
|
CALL dynetat0(vcov, ucov, teta, q, masse, ps, phis, time_0) |
84 |
|
|
|
85 |
guez |
36 |
! On remet le calendrier à zero si demandé : |
86 |
guez |
3 |
if (annee_ref /= anneeref .or. day_ref /= dayref) then |
87 |
|
|
print *, 'Attention : les dates initiales lues dans le fichier ' // & |
88 |
|
|
'"start" ne correspondent pas à celles lues dans "gcm.def".' |
89 |
guez |
15 |
if (raz_date) then |
90 |
guez |
3 |
print *, 'On réinitialise à la date lue dans "gcm.def".' |
91 |
|
|
annee_ref = anneeref |
92 |
|
|
day_ref = dayref |
93 |
|
|
day_ini = dayref |
94 |
|
|
itau_dyn = 0 |
95 |
|
|
time_0 = 0. |
96 |
guez |
15 |
else |
97 |
|
|
print *, 'On garde les dates du fichier "start".' |
98 |
guez |
3 |
endif |
99 |
|
|
ELSE |
100 |
guez |
15 |
raz_date = .false. |
101 |
guez |
3 |
endif |
102 |
|
|
|
103 |
guez |
36 |
! On recalcule éventuellement le pas de temps : |
104 |
guez |
3 |
zdtvr = daysec / REAL(day_step) |
105 |
|
|
IF (dtvr /= zdtvr) THEN |
106 |
|
|
print *, 'Warning: the time steps in the ".def" file and in ' // & |
107 |
|
|
'"start.nc" are different' |
108 |
|
|
print *, 'dtvr (from "start.nc") = ', dtvr |
109 |
|
|
print *, 'zdtvr (from ".def") = ', zdtvr |
110 |
|
|
print *, 'Using the value from the ".def" file.' |
111 |
|
|
dtvr = zdtvr |
112 |
|
|
ENDIF |
113 |
guez |
33 |
|
114 |
guez |
36 |
CALL iniconst |
115 |
|
|
CALL inigeom ! initialisation de la géometrie |
116 |
|
|
CALL inifilr ! initialisation du filtre |
117 |
guez |
27 |
CALL inidissip |
118 |
guez |
3 |
call init_dyn_phy |
119 |
|
|
|
120 |
|
|
! Initialisation de la physique : |
121 |
|
|
IF (iflag_phys == 1) THEN |
122 |
guez |
37 |
rlatd(1)=rlatu(1) |
123 |
|
|
rlatd(2:klon-1) = pack(spread(rlatu(2:jjm), 1, iim), .true.) |
124 |
|
|
rlatd(klon)= rlatu(jjm + 1) |
125 |
guez |
3 |
|
126 |
guez |
37 |
rlond(1)=0. |
127 |
|
|
rlond(2:klon-1) = pack(spread(rlonv(:iim), 2, jjm - 1), .true.) |
128 |
|
|
rlond(klon)= 0. |
129 |
guez |
3 |
|
130 |
guez |
37 |
cuphy = pack(cu_2d, dyn_phy) |
131 |
guez |
3 |
|
132 |
|
|
! Construct a mask for points in the "v" grid: |
133 |
|
|
mask_v = .true. |
134 |
|
|
mask_v(2:, 1) = .false. |
135 |
|
|
mask_v(iim + 1, 2:) = .false. |
136 |
|
|
|
137 |
guez |
37 |
cvphy(:klon - 1) = pack(cv_2d, mask_v) |
138 |
|
|
cvphy(klon) = cv_2d(1, jjm) |
139 |
|
|
! (that value of "cv_2d" is used twice in "cvphy") |
140 |
guez |
3 |
|
141 |
guez |
37 |
airephy = pack(aire_2d, dyn_phy) |
142 |
|
|
CALL suphec |
143 |
guez |
38 |
call yoethf |
144 |
guez |
3 |
ENDIF |
145 |
|
|
|
146 |
|
|
! Initialisation des entrées-sorties : |
147 |
|
|
day_end = day_ini + nday |
148 |
|
|
print *, "day_ini = ", day_ini |
149 |
|
|
print *, "day_end = ", day_end |
150 |
|
|
|
151 |
guez |
5 |
CALL dynredem0("restart.nc", day_end, phis) |
152 |
guez |
56 |
CALL inithist(day_ref, annee_ref, zdtvr, nqmx, t_ops = iecri * daysec, & |
153 |
|
|
t_wrt = iecri * daysec) |
154 |
|
|
CALL initdynav(day_ref, annee_ref, zdtvr, nqmx, t_ops = iperiod * zdtvr, & |
155 |
|
|
t_wrt = periodav * daysec) |
156 |
guez |
3 |
|
157 |
|
|
! Choix des fréquences de stockage pour le hors-ligne : |
158 |
guez |
36 |
istdyn = day_step / 4 ! stockage toutes les 6 h = 1 jour / 4 |
159 |
guez |
3 |
istphy = istdyn / iphysiq |
160 |
|
|
|
161 |
|
|
! Intégration temporelle du modèle : |
162 |
guez |
23 |
CALL leapfrog(ucov, vcov, teta, ps, masse, phis, q, time_0) |
163 |
guez |
3 |
|
164 |
guez |
10 |
call histclo |
165 |
|
|
print *, 'Simulation finished' |
166 |
|
|
print *, 'Everything is cool' |
167 |
|
|
|
168 |
guez |
3 |
END PROGRAM gcm |