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

Annotation of /trunk/dyn3d/gcm.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (hide annotations)
Thu Apr 1 09:07:28 2010 UTC (14 years, 1 month ago) by guez
Original Path: trunk/libf/dyn3d/gcm.f90
File size: 6253 byte(s)
Imported Source files of the external library "IOIPSL_Lionel" into
"libf/IOIPSL".

Split "cray.f90" into "scopy.f90" and "ssum.f90".

Rewrote "leapfrog" in order to have a clearer algorithmic structure.

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

  ViewVC Help
Powered by ViewVC 1.1.21