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

Annotation of /trunk/Sources/dyn3d/gcm.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33 - (hide annotations)
Fri Apr 9 10:56:14 2010 UTC (14 years, 1 month ago) by guez
Original Path: trunk/libf/dyn3d/gcm.f90
File size: 5718 byte(s)
Test namelist input in procedure "conf_gcm" rather than program unit
"gcm".

Compute "time" in procedure "sortvarc" rather than "leapfrog".

Rewrote "leapfrog" with a single loop on "itau" instead of two nested
loops on number of periodic matsuno-leapfrog cycles and leapfrog
iterations.

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

  ViewVC Help
Powered by ViewVC 1.1.21