/[lmdze]/trunk/libf/dyn3d/gcm.f90
ViewVC logotype

Annotation of /trunk/libf/dyn3d/gcm.f90

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Wed Feb 27 13:16:39 2008 UTC (16 years, 2 months ago) by guez
File size: 6928 byte(s)
Initial import
1 guez 3 PROGRAM gcm
2    
3     ! General circulation model of LMD
4    
5     ! From "gcm.F", version 1.4, 2006/04/04 15:05:16
6    
7     ! Avec coordonnées verticales hybrides, avec nouveaux opérateurs de
8     ! dissipation * (gradiv2, divgrad2, nxgraro2)
9    
10     ! Authors: P. Le Van, L. Fairhead, F. Hourdin
11    
12     ! Possibilité de choisir le schéma pour l'advection de "q", en
13     ! modifiant "iadv" dans "traceur.def".
14    
15     ! Pour Van-Leer plus vapeur d'eau saturée : iadv(1)=4
16     ! Pour Van-Leer : iadv=10
17    
18     USE IOIPSL, only: ioconf_calendar
19     use dimens_m, only: iim, jjm, llm, nqmx
20     use dimphy, only: klon
21     use paramet_m, only: ip1jm, ip1jmp1
22     use comconst, only: daysec, cpp, dtvr, dtphys, g, rad, r, initialize
23    
24     use comdissnew, only: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
25     tetagrot, tetatemp
26    
27     use conf_gcm_m, only: day_step, iperiod, anneeref, dayref, iecri, iphysiq, &
28     nday, raz_date, periodav, conf_gcm
29    
30     use logic, only: iflag_phys
31     use comgeom, only: rlatu, aire_2d, cu_2d, cv_2d, rlonv
32     use temps, only: day_ref, annee_ref, day_ini, day_end, itau_phy, itau_dyn
33     use com_io_dyn, only: histid, histvid, histaveid
34     use tracstoke, only: istdyn, istphy
35     use abort_gcm_m, only: abort_gcm
36     use inithist_m, only: inithist
37     use initdynav_m, only: initdynav
38     use dynetat0_m, only: dynetat0
39     use grid_change, only: dyn_phy, init_dyn_phy
40     use advtrac_m, only: iniadvtrac
41     use leapfrog_m, only: leapfrog
42    
43     IMPLICIT NONE
44    
45     REAL clesphy0(20)
46     REAL zdtvr ! time step for dynamics, in s
47    
48     ! Variables dynamiques :
49     REAL vcov(ip1jm, llm), ucov(ip1jmp1, llm) ! vents covariants
50     REAL teta(ip1jmp1, llm) ! température potentielle
51     REAL q(ip1jmp1, llm, nqmx) ! champs advectés
52     REAL ps(ip1jmp1) ! pression au sol (Pa)
53    
54     REAL masse(ip1jmp1, llm) ! masse d'air
55     REAL phis(ip1jmp1) ! géopotentiel au sol
56    
57     ! Variables pour le fichier histoire :
58     REAL time_0
59    
60     !!INTEGER i
61    
62     ! Calendrier :
63     LOGICAL:: true_calendar = .false. ! default value
64    
65     ! Variables pour l'initialisation de la physique :
66     integer nq
67     REAL zcufi(klon), zcvfi(klon) ! "cu" and "cv" values on the scalar grid
68     REAL latfi(klon), lonfi(klon)
69     REAL airefi(klon)
70    
71     logical mask_v(iim + 1, jjm)
72     ! (mask for points in the "v" grid, first index is for longitude,
73     ! second index is for latitude)
74    
75     namelist /main_nml/true_calendar
76    
77     !------------------------------------------------------------
78    
79     print *, "Enter namelist 'main_nml'."
80     read (unit=*, nml=main_nml)
81     write(unit=*, nml=main_nml)
82    
83     ! Initialisations:
84     call initialize
85    
86     ! Choix du calendrier :
87     if (true_calendar) then
88     call ioconf_calendar('gregorian')
89     else
90     call ioconf_calendar('360d')
91     endif
92    
93     ! Lecture des fichiers "gcm.def" ou "run.def" :
94     CALL conf_gcm(clesphy0)
95    
96     ! Initialisation des traceurs
97     ! Choix du schéma pour l'advection dans le fichier "traceur.def" ou via INCA
98     call iniadvtrac(nq)
99    
100     ! Lecture du fichier "start.nc" :
101     CALL dynetat0(vcov, ucov, teta, q, masse, ps, phis, time_0)
102     ! Begin special experiment
103     !!$ print *, "This is a special experiment."
104     !!$ print *, "We are setting:"
105     !!$ print *, "ucov = vcov = 0, q = 0, ps = 101325"
106     !!$ print *, "We are averaging 'teta' horizontally."
107     !!$ ucov = 0.
108     !!$ vcov = 0.
109     !!$ q = 0.
110     !!$ ps = 101325.
111     ! Average teta over all longitudes and latitudes:
112     !!$ forall(i = 1:llm) teta(:,i) = sum(teta(:,i)) / ip1jmp1
113     ! (it would be better to weight each element with an associated
114     ! surface area)
115     ! End special experiment
116    
117     ! Lecture des paramètres de contrôle pour la simulation :
118     ! on recalcule éventuellement le pas de temps
119     IF (MOD(day_step, iperiod) /= 0) THEN
120     call abort_gcm(modname = "gcm", message = &
121     'Il faut choisir un nombre de pas par jour multiple de "iperiod".', &
122     ierr = 1)
123     ENDIF
124    
125     IF (MOD(day_step,iphysiq)/=0) THEN
126     call abort_gcm(modname = "gcm", message = &
127     'Il faut choisir un nombre de pas par jour multiple de "iphysiq".', &
128     ierr = 1)
129     ENDIF
130    
131     ! On remet le calendrier à zero si demandé:
132     if (annee_ref /= anneeref .or. day_ref /= dayref) then
133     print *, 'Attention : les dates initiales lues dans le fichier ' // &
134     '"start" ne correspondent pas à celles lues dans "gcm.def".'
135     if (raz_date /= 1) then
136     print *, 'On garde les dates du fichier "start".'
137     else
138     print *, 'On réinitialise à la date lue dans "gcm.def".'
139     annee_ref = anneeref
140     day_ref = dayref
141     day_ini = dayref
142     itau_dyn = 0
143     itau_phy = 0
144     time_0 = 0.
145     endif
146     ELSE
147     raz_date = 0
148     endif
149    
150     ! Initialisation des constantes dynamiques :
151     zdtvr = daysec / REAL(day_step)
152     IF (dtvr /= zdtvr) THEN
153     print *, 'Warning: the time steps in the ".def" file and in ' // &
154     '"start.nc" are different'
155     print *, 'dtvr (from "start.nc") = ', dtvr
156     print *, 'zdtvr (from ".def") = ', zdtvr
157     print *, 'Using the value from the ".def" file.'
158     dtvr = zdtvr
159     ENDIF
160     CALL iniconst
161    
162     ! Initialisation de la géometrie :
163     CALL inigeom
164    
165     ! Initialisation du filtre :
166     CALL inifilr
167    
168     ! Initialisation de la dissipation :
169     CALL inidissip(lstardis, nitergdiv, nitergrot, niterh, tetagdiv, tetagrot, &
170     tetatemp)
171    
172     call init_dyn_phy
173    
174     ! Initialisation de la physique :
175     IF (iflag_phys == 1) THEN
176     latfi(1)=rlatu(1)
177     latfi(2:klon-1) = pack(spread(rlatu(2:jjm), 1, iim), .true.)
178     latfi(klon)= rlatu(jjm + 1)
179    
180     lonfi(1)=0.
181     lonfi(2:klon-1) = pack(spread(rlonv(:iim), 2, jjm - 1), .true.)
182     lonfi(klon)= 0.
183    
184     zcufi = pack(cu_2d, dyn_phy)
185    
186     ! Construct a mask for points in the "v" grid:
187     mask_v = .true.
188     mask_v(2:, 1) = .false.
189     mask_v(iim + 1, 2:) = .false.
190    
191     zcvfi(:klon - 1) = pack(cv_2d, mask_v)
192     zcvfi(klon) = cv_2d(1, jjm)
193     ! (that value of "cv_2d" is used twice in "zcvfi")
194    
195     airefi = pack(aire_2d, dyn_phy)
196     print *, 'Attention : vitesse verticale nulle dans la physique.'
197     CALL iniphysiq(klon, llm, daysec, day_ini, dtphys, latfi, lonfi, airefi, &
198     zcufi, zcvfi, rad, g, r, cpp)
199     ENDIF
200    
201     ! Numéro de stockage pour les fichiers de redémarrage :
202     ! Initialisation des entrées-sorties :
203     day_end = day_ini + nday
204     print *, "day_ini = ", day_ini
205     print *, "day_end = ", day_end
206    
207     CALL dynredem0("restart.nc", day_end, phis, nqmx)
208     CALL inithist(day_ref, annee_ref, zdtvr, nqmx, histid, histvid, &
209     infile="dyn_hist.nc", t_ops = iecri * daysec, t_wrt = iecri * daysec)
210     CALL initdynav(day_ref, annee_ref, zdtvr, nqmx, histaveid, &
211     infile='dyn_hist_ave.nc', t_ops = iperiod * zdtvr, &
212     t_wrt = periodav * daysec)
213    
214     ! Choix des fréquences de stockage pour le hors-ligne :
215     istdyn = day_step / 4 ! stockage toutes les 6 h = 1 jour / 4
216     istphy = istdyn / iphysiq
217    
218     ! Intégration temporelle du modèle :
219     CALL leapfrog(ucov, vcov, teta, ps, masse, phis, nq, q, clesphy0, time_0)
220    
221     END PROGRAM gcm

  ViewVC Help
Powered by ViewVC 1.1.21