/[lmdze]/trunk/dyn3d/gcm.f
ViewVC logotype

Contents of /trunk/dyn3d/gcm.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (show annotations)
Tue Jan 10 19:02:02 2012 UTC (12 years, 4 months ago) by guez
Original Path: trunk/libf/dyn3d/gcm.f90
File size: 5343 byte(s)
Imported "writehist.f" from LMDZ.

Moved module variable "histaveid" from "com_io_dyn" to "initdynav_m".

In "inithist", access directly module variables from "com_io_dyn"
instead of going through the arguments. Copying from LMDZ, write "u"
and scalar variables to separate files. Create a new variable for the
new file in "com_io_dyn". Copying from LMDZ, change the vertical axes
of the three files.

Removed some useless initializations in "dissip".

In "bilan_dyn", removed useless variable "time". Avoiding the
approximate test on "dt_cum" being a multiple of "dt_app", just
compute "ncum" from known usage of "bilan_dyn" and compute "dt_cum"
from "ncum". Change "periodav" from real to integer in
"conf_gcm_m". Since "day_step" is required to be a multiple of
"iperiod", so is "ncum".

1 PROGRAM gcm
2
3 ! Authors: P. Le Van, L. Fairhead, F. Hourdin
4 ! From "gcm.F", version 1.4, 2006/04/04 15:05:16
5
6 ! 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 use clesphys2, only: read_clesphys2
12 use comconst, only: daysec, cpp, dtvr, g, rad, r
13 use comgeom, only: rlatu, aire_2d, cu_2d, cv_2d, rlonv
14 use comgeomphy, only: airephy, cuphy, cvphy, rlatd, rlond
15 use conf_gcm_m, only: day_step, iperiod, anneeref, dayref, iecri, iphysiq, &
16 nday, raz_date, periodav, conf_gcm
17 use dimens_m, only: iim, jjm, llm, nqmx
18 use dimphy, only: klon
19 use dynetat0_m, only: dynetat0, day_ini
20 use dynredem0_m, only: dynredem0
21 use grid_change, only: dyn_phy, init_dyn_phy
22 use iniadvtrac_m, only: iniadvtrac
23 use inidissip_m, only: inidissip
24 use inifilr_m, only: inifilr
25 use inigeom_m, only: inigeom
26 use initdynav_m, only: initdynav
27 use inithist_m, only: inithist
28 USE calendar, only: ioconf_calendar
29 use histcom, only: histclo
30 use leapfrog_m, only: leapfrog
31 use logic, only: iflag_phys
32 use suphec_m, only: suphec
33 use temps, only: day_ref, annee_ref, day_end, itau_dyn
34 use tracstoke, only: istdyn, istphy
35 use yoethf_m, only: yoethf
36
37 IMPLICIT NONE
38
39 REAL zdtvr ! time step for dynamics, in s
40
41 ! Variables dynamiques :
42 REAL ucov(iim + 1, jjm + 1, llm), vcov(iim + 1, jjm, llm) ! vent covariant
43 REAL teta(iim + 1, jjm + 1, llm) ! température potentielle
44 REAL q(iim + 1, jjm + 1, llm, nqmx) ! champs advectés
45 REAL ps(iim + 1, jjm + 1) ! pression au sol (Pa)
46 REAL masse(iim + 1, jjm + 1, llm) ! masse d'air
47 REAL phis(iim + 1, jjm + 1) ! géopotentiel au sol
48
49 ! Variables pour le fichier histoire :
50 REAL time_0 ! time in day, as a fraction of day, in [0, 1[
51
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 call read_clesphys2
76 CALL conf_gcm
77
78 ! Initialisation des traceurs
79 ! Choix du schéma pour l'advection dans le fichier "traceur.def" ou via INCA
80 call iniadvtrac
81
82 ! Lecture du fichier "start.nc" :
83 CALL dynetat0(vcov, ucov, teta, q, masse, ps, phis, time_0)
84
85 ! On remet le calendrier à zero si demandé :
86 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 if (raz_date) then
90 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 else
97 print *, 'On garde les dates du fichier "start".'
98 endif
99 ELSE
100 raz_date = .false.
101 endif
102
103 ! On recalcule éventuellement le pas de temps :
104 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
114 CALL iniconst
115 CALL inigeom ! initialisation de la géometrie
116 CALL inifilr ! initialisation du filtre
117 CALL inidissip
118 call init_dyn_phy
119
120 ! Initialisation de la physique :
121 IF (iflag_phys == 1) THEN
122 rlatd(1)=rlatu(1)
123 rlatd(2:klon-1) = pack(spread(rlatu(2:jjm), 1, iim), .true.)
124 rlatd(klon)= rlatu(jjm + 1)
125
126 rlond(1)=0.
127 rlond(2:klon-1) = pack(spread(rlonv(:iim), 2, jjm - 1), .true.)
128 rlond(klon)= 0.
129
130 cuphy = pack(cu_2d, dyn_phy)
131
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 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
141 airephy = pack(aire_2d, dyn_phy)
142 CALL suphec
143 call yoethf
144 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 CALL dynredem0("restart.nc", day_end, phis)
152 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
157 ! Choix des fréquences de stockage pour le hors-ligne :
158 istdyn = day_step / 4 ! stockage toutes les 6 h = 1 jour / 4
159 istphy = istdyn / iphysiq
160
161 ! Intégration temporelle du modèle :
162 CALL leapfrog(ucov, vcov, teta, ps, masse, phis, q, time_0)
163
164 call histclo
165 print *, 'Simulation finished'
166 print *, 'Everything is cool'
167
168 END PROGRAM gcm

  ViewVC Help
Powered by ViewVC 1.1.21