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

Contents of /trunk/dyn3d/gcm.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations)
Thu Dec 2 17:11:04 2010 UTC (13 years, 5 months ago) by guez
Original Path: trunk/libf/dyn3d/gcm.f90
File size: 5635 byte(s)
Now using the library "NR_util".

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

  ViewVC Help
Powered by ViewVC 1.1.21