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

Annotation of /trunk/dyn3d/gcm.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (hide 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 guez 3 PROGRAM gcm
2    
3 guez 36 ! Authors: P. Le Van, L. Fairhead, F. Hourdin
4     ! From "gcm.F", version 1.4, 2006/04/04 15:05:16
5 guez 3 ! General circulation model of LMD
6     ! Avec coordonnées verticales hybrides, avec nouveaux opérateurs de
7 guez 36 ! dissipation "*" (gradiv2, divgrad2, nxgraro2)
8 guez 3 ! 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 guez 26 use clesphys2, only: read_clesphys2
14     use com_io_dyn, only: histid, histvid, histaveid
15 guez 23 use comconst, only: daysec, cpp, dtvr, g, rad, r, initialize
16 guez 26 use comgeom, only: rlatu, aire_2d, cu_2d, cv_2d, rlonv
17 guez 3 use conf_gcm_m, only: day_step, iperiod, anneeref, dayref, iecri, iphysiq, &
18     nday, raz_date, periodav, conf_gcm
19 guez 26 use dimens_m, only: iim, jjm, llm, nqmx
20     use dimphy, only: klon
21 guez 25 use dynetat0_m, only: dynetat0, day_ini
22 guez 26 use dynredem0_m, only: dynredem0
23 guez 3 use grid_change, only: dyn_phy, init_dyn_phy
24 guez 18 use iniadvtrac_m, only: iniadvtrac
25 guez 26 use inidissip_m, only: inidissip
26     use inigeom_m, only: inigeom
27     use initdynav_m, only: initdynav
28     use inithist_m, only: inithist
29 guez 30 USE calendar, only: ioconf_calendar
30     use histcom, only: histclo
31 guez 3 use leapfrog_m, only: leapfrog
32 guez 26 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 guez 3
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 guez 7 REAL phis(iim + 1, jjm + 1) ! géopotentiel au sol
49 guez 3
50     ! Variables pour le fichier histoire :
51 guez 25 REAL time_0 ! time in day, as a fraction of day, in [0, 1[
52 guez 3
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 guez 13 call read_clesphys2
85     CALL conf_gcm
86 guez 3
87     ! Initialisation des traceurs
88     ! Choix du schéma pour l'advection dans le fichier "traceur.def" ou via INCA
89 guez 23 call iniadvtrac
90 guez 3
91     ! Lecture du fichier "start.nc" :
92     CALL dynetat0(vcov, ucov, teta, q, masse, ps, phis, time_0)
93    
94 guez 36 ! On remet le calendrier à zero si demandé :
95 guez 3 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 guez 15 if (raz_date) then
99 guez 3 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 guez 15 else
106     print *, 'On garde les dates du fichier "start".'
107 guez 3 endif
108     ELSE
109 guez 15 raz_date = .false.
110 guez 3 endif
111    
112 guez 36 ! On recalcule éventuellement le pas de temps :
113 guez 3 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 guez 33
123 guez 36 CALL iniconst
124     CALL inigeom ! initialisation de la géometrie
125     CALL inifilr ! initialisation du filtre
126 guez 27 CALL inidissip
127 guez 3 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 guez 36 CALL iniphysiq(klon, llm, latfi, lonfi, airefi, zcufi, zcvfi, rad, g, r, &
152     cpp)
153 guez 3 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 guez 5 CALL dynredem0("restart.nc", day_end, phis)
161 guez 3 CALL inithist(day_ref, annee_ref, zdtvr, nqmx, histid, histvid, &
162 guez 27 t_ops = iecri * daysec, t_wrt = iecri * daysec)
163 guez 3 CALL initdynav(day_ref, annee_ref, zdtvr, nqmx, histaveid, &
164 guez 27 t_ops = iperiod * zdtvr, t_wrt = periodav * daysec)
165 guez 3
166     ! Choix des fréquences de stockage pour le hors-ligne :
167 guez 36 istdyn = day_step / 4 ! stockage toutes les 6 h = 1 jour / 4
168 guez 3 istphy = istdyn / iphysiq
169    
170     ! Intégration temporelle du modèle :
171 guez 23 CALL leapfrog(ucov, vcov, teta, ps, masse, phis, q, time_0)
172 guez 3
173 guez 10 call histclo
174     print *, 'Simulation finished'
175     print *, 'Everything is cool'
176    
177 guez 3 END PROGRAM gcm

  ViewVC Help
Powered by ViewVC 1.1.21