1 | SUBROUTINE dynredem0_loc(fichnom, iday_end, phis) |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------- |
---|
4 | ! Write the NetCDF restart file (initialization). |
---|
5 | !------------------------------------------------------------------------------- |
---|
6 | USE IOIPSL |
---|
7 | USE parallel_lmdz |
---|
8 | USE mod_hallo |
---|
9 | USE lmdz_strings, ONLY: maxlen |
---|
10 | USE infotrac, ONLY: nqtot, tracers |
---|
11 | USE netcdf, ONLY: nf90_create, nf90_def_dim, nf90_inq_varid, nf90_global, & |
---|
12 | nf90_close, nf90_put_att, nf90_unlimited, nf90_clobber, & |
---|
13 | nf90_64bit_offset |
---|
14 | USE dynredem_mod, ONLY: cre_var, put_var, err, modname, fil |
---|
15 | USE comvert_mod, ONLY: ap, bp, presnivs, pa, preff, nivsig, nivsigs, & |
---|
16 | aps, bps, pseudoalt |
---|
17 | USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad |
---|
18 | USE logic_mod, ONLY: fxyhypb, ysinus |
---|
19 | USE serre_mod, ONLY: clon, clat, grossismx, grossismy, dzoomx, dzoomy, & |
---|
20 | taux, tauy |
---|
21 | USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itaufin, start_time |
---|
22 | USE ener_mod, ONLY: etot0, ptot0, ztot0, stot0, ang0 |
---|
23 | USE lmdz_description, ONLY: descript |
---|
24 | USE lmdz_iniprint, ONLY: lunout, prt_level |
---|
25 | USE lmdz_comgeom |
---|
26 | |
---|
27 | IMPLICIT NONE |
---|
28 | INCLUDE "dimensions.h" |
---|
29 | INCLUDE "paramet.h" |
---|
30 | !=============================================================================== |
---|
31 | ! Arguments: |
---|
32 | CHARACTER(LEN = *), INTENT(IN) :: fichnom !--- FILE NAME |
---|
33 | INTEGER, INTENT(IN) :: iday_end !--- |
---|
34 | REAL, INTENT(IN) :: phis(ijb_u:ije_u)!--- GROUND GEOPOTENTIAL |
---|
35 | !=============================================================================== |
---|
36 | ! Local variables: |
---|
37 | INTEGER :: iq |
---|
38 | INTEGER, PARAMETER :: length = 100 |
---|
39 | REAL :: tab_cntrl(length) !--- RUN PARAMETERS TABLE |
---|
40 | REAL :: phis_glo(ip1jmp1) |
---|
41 | ! For NetCDF: |
---|
42 | CHARACTER(LEN = maxlen) :: unites |
---|
43 | INTEGER :: indexID |
---|
44 | INTEGER :: rlonuID, rlonvID, rlatuID, rlatvID |
---|
45 | INTEGER :: sID, sigID, nID, timID |
---|
46 | INTEGER :: yyears0, jjour0, mmois0 |
---|
47 | REAL :: zjulian, hours |
---|
48 | !=============================================================================== |
---|
49 | modname = 'dynredem0'; fil = fichnom |
---|
50 | CALL Gather_field_u(phis, phis_glo, 1) |
---|
51 | IF(mpi_rank/=0) RETURN |
---|
52 | |
---|
53 | CALL ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian) |
---|
54 | CALL ju2ymds(zjulian, yyears0, mmois0, jjour0, hours) |
---|
55 | |
---|
56 | tab_cntrl(:) = 0. |
---|
57 | tab_cntrl(1) = REAL(iim) |
---|
58 | tab_cntrl(2) = REAL(jjm) |
---|
59 | tab_cntrl(3) = REAL(llm) |
---|
60 | tab_cntrl(4) = REAL(day_ref) |
---|
61 | tab_cntrl(5) = REAL(annee_ref) |
---|
62 | tab_cntrl(6) = rad |
---|
63 | tab_cntrl(7) = omeg |
---|
64 | tab_cntrl(8) = g |
---|
65 | tab_cntrl(9) = cpp |
---|
66 | tab_cntrl(10) = kappa |
---|
67 | tab_cntrl(11) = daysec |
---|
68 | tab_cntrl(12) = dtvr |
---|
69 | tab_cntrl(13) = etot0 |
---|
70 | tab_cntrl(14) = ptot0 |
---|
71 | tab_cntrl(15) = ztot0 |
---|
72 | tab_cntrl(16) = stot0 |
---|
73 | tab_cntrl(17) = ang0 |
---|
74 | tab_cntrl(18) = pa |
---|
75 | tab_cntrl(19) = preff |
---|
76 | |
---|
77 | ! ..... parameters for zoom ...... |
---|
78 | tab_cntrl(20) = clon |
---|
79 | tab_cntrl(21) = clat |
---|
80 | tab_cntrl(22) = grossismx |
---|
81 | tab_cntrl(23) = grossismy |
---|
82 | |
---|
83 | IF (fxyhypb) THEN |
---|
84 | tab_cntrl(24) = 1. |
---|
85 | tab_cntrl(25) = dzoomx |
---|
86 | tab_cntrl(26) = dzoomy |
---|
87 | tab_cntrl(27) = 0. |
---|
88 | tab_cntrl(28) = taux |
---|
89 | tab_cntrl(29) = tauy |
---|
90 | ELSE |
---|
91 | tab_cntrl(24) = 0. |
---|
92 | tab_cntrl(25) = dzoomx |
---|
93 | tab_cntrl(26) = dzoomy |
---|
94 | tab_cntrl(27) = 0. |
---|
95 | tab_cntrl(28) = 0. |
---|
96 | tab_cntrl(29) = 0. |
---|
97 | IF(ysinus) tab_cntrl(27) = 1. |
---|
98 | END IF |
---|
99 | tab_cntrl(30) = REAL(iday_end) |
---|
100 | tab_cntrl(31) = REAL(itau_dyn + itaufin) |
---|
101 | ! start_time: start_time of simulation (not necessarily 0.) |
---|
102 | tab_cntrl(32) = start_time |
---|
103 | |
---|
104 | !--- File creation |
---|
105 | CALL err(nf90_create(fichnom, IOR(nf90_clobber, nf90_64bit_offset), nid)) |
---|
106 | |
---|
107 | !--- Some global attributes |
---|
108 | CALL err(nf90_put_att(nid, nf90_global, "title", "Fichier demarrage dynamique")) |
---|
109 | |
---|
110 | !--- Dimensions |
---|
111 | CALL err(nf90_def_dim(nid, "index", length, indexID)) |
---|
112 | CALL err(nf90_def_dim(nid, "rlonu", iip1, rlonuID)) |
---|
113 | CALL err(nf90_def_dim(nid, "rlatu", jjp1, rlatuID)) |
---|
114 | CALL err(nf90_def_dim(nid, "rlonv", iip1, rlonvID)) |
---|
115 | CALL err(nf90_def_dim(nid, "rlatv", jjm, rlatvID)) |
---|
116 | CALL err(nf90_def_dim(nid, "sigs", llm, sID)) |
---|
117 | CALL err(nf90_def_dim(nid, "sig", llmp1, sigID)) |
---|
118 | CALL err(nf90_def_dim(nid, "temps", nf90_unlimited, timID)) |
---|
119 | |
---|
120 | !--- Define and save invariant fields |
---|
121 | CALL put_var(nid, "controle", "Parametres de controle", [indexID], tab_cntrl) |
---|
122 | CALL put_var(nid, "rlonu", "Longitudes des points U", [rlonuID], rlonu) |
---|
123 | CALL put_var(nid, "rlatu", "Latitudes des points U", [rlatuID], rlatu) |
---|
124 | CALL put_var(nid, "rlonv", "Longitudes des points V", [rlonvID], rlonv) |
---|
125 | CALL put_var(nid, "rlatv", "Latitudes des points V", [rlatvID], rlatv) |
---|
126 | CALL put_var(nid, "nivsigs", "Numero naturel des couches s", [sID], nivsigs) |
---|
127 | CALL put_var(nid, "nivsig", "Numero naturel des couches sigma", [sigID], nivsig) |
---|
128 | CALL put_var(nid, "ap", "Coefficient A pour hybride", [sigID], ap) |
---|
129 | CALL put_var(nid, "bp", "Coefficient B pour hybride", [sigID], bp) |
---|
130 | CALL put_var(nid, "presnivs", "", [sID], presnivs) |
---|
131 | ! covariant <-> contravariant <-> natural conversion coefficients |
---|
132 | CALL put_var(nid, "cu", "Coefficient de passage pour U", [rlonuID, rlatuID], cu) |
---|
133 | CALL put_var(nid, "cv", "Coefficient de passage pour V", [rlonvID, rlatvID], cv) |
---|
134 | CALL put_var(nid, "aire", "Aires de chaque maille", [rlonvID, rlatuID], aire) |
---|
135 | CALL put_var(nid, "phisinit", "Geopotentiel au sol", [rlonvID, rlatuID], phis_glo) |
---|
136 | |
---|
137 | !--- Define fields saved later |
---|
138 | WRITE(unites, "('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')") & |
---|
139 | yyears0, mmois0, jjour0 |
---|
140 | CALL cre_var(nid, "temps", "Temps de simulation", [timID], unites) |
---|
141 | CALL cre_var(nid, "ucov", "Vitesse U", [rlonuID, rlatuID, sID, timID]) |
---|
142 | CALL cre_var(nid, "vcov", "Vitesse V", [rlonvID, rlatvID, sID, timID]) |
---|
143 | CALL cre_var(nid, "teta", "Temperature", [rlonvID, rlatuID, sID, timID]) |
---|
144 | DO iq = 1, nqtot |
---|
145 | CALL cre_var(nid, tracers(iq)%name, tracers(iq)%longName, [rlonvID, rlatuID, sID, timID]) |
---|
146 | END DO |
---|
147 | CALL cre_var(nid, "masse", "Masse d air", [rlonvID, rlatuID, sID, timID]) |
---|
148 | CALL cre_var(nid, "ps", "Pression au sol", [rlonvID, rlatuID, timID]) |
---|
149 | CALL err(nf90_close (nid)) |
---|
150 | |
---|
151 | WRITE(lunout, *)TRIM(modname) // ': iim,jjm,llm,iday_end', iim, jjm, llm, iday_end |
---|
152 | WRITE(lunout, *)TRIM(modname) // ': rad,omeg,g,cpp,kappa', rad, omeg, g, cpp, kappa |
---|
153 | |
---|
154 | END SUBROUTINE dynredem0_loc |
---|
155 | |
---|
156 | !------------------------------------------------------------------------------- |
---|
157 | |
---|
158 | |
---|
159 | !------------------------------------------------------------------------------- |
---|
160 | |
---|
161 | SUBROUTINE dynredem1_loc(fichnom, time, vcov, ucov, teta, q, masse, ps) |
---|
162 | |
---|
163 | !------------------------------------------------------------------------------- |
---|
164 | ! Purpose: Write the NetCDF restart file (append). |
---|
165 | !------------------------------------------------------------------------------- |
---|
166 | USE parallel_lmdz |
---|
167 | USE mod_hallo |
---|
168 | USE lmdz_strings, ONLY: maxlen |
---|
169 | USE infotrac, ONLY: nqtot, tracers, type_trac |
---|
170 | USE control_mod |
---|
171 | USE netcdf, ONLY: nf90_open, nf90_nowrite, nf90_get_var, nf90_inq_varid, & |
---|
172 | nf90_close, nf90_write, nf90_put_var, nf90_noerr |
---|
173 | USE dynredem_mod, ONLY: dynredem_write_u, dynredem_write_v, dynredem_read_u, & |
---|
174 | err, modname, fil, msg |
---|
175 | USE temps_mod, ONLY: itau_dyn, itaufin |
---|
176 | USE lmdz_description, ONLY: descript |
---|
177 | USE lmdz_iniprint, ONLY: lunout, prt_level |
---|
178 | USE lmdz_comgeom |
---|
179 | |
---|
180 | IMPLICIT NONE |
---|
181 | INCLUDE "dimensions.h" |
---|
182 | INCLUDE "paramet.h" |
---|
183 | !=============================================================================== |
---|
184 | ! Arguments: |
---|
185 | CHARACTER(LEN = *), INTENT(IN) :: fichnom !-- FILE NAME |
---|
186 | REAL, INTENT(IN) :: time !-- TIME |
---|
187 | REAL, INTENT(IN) :: vcov(ijb_v:ije_v, llm) !-- V COVARIANT WIND |
---|
188 | REAL, INTENT(IN) :: ucov(ijb_u:ije_u, llm) !-- U COVARIANT WIND |
---|
189 | REAL, INTENT(IN) :: teta(ijb_u:ije_u, llm) !-- POTENTIAL TEMPERATURE |
---|
190 | REAL, INTENT(INOUT) :: q(ijb_u:ije_u, llm, nqtot) !-- TRACERS |
---|
191 | REAL, INTENT(IN) :: masse(ijb_u:ije_u, llm) !-- MASS PER CELL |
---|
192 | REAL, INTENT(IN) :: ps(ijb_u:ije_u) !-- GROUND PRESSURE |
---|
193 | !=============================================================================== |
---|
194 | ! Local variables: |
---|
195 | INTEGER :: iq, nid, vID, ierr, nid_trac, vID_trac |
---|
196 | INTEGER, SAVE :: nb = 0 |
---|
197 | INTEGER, PARAMETER :: length = 100 |
---|
198 | REAL :: tab_cntrl(length) ! tableau des parametres du run |
---|
199 | CHARACTER(LEN = maxlen) :: var, dum |
---|
200 | LOGICAL :: lread_inca |
---|
201 | !=============================================================================== |
---|
202 | |
---|
203 | !$OMP MASTER |
---|
204 | IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
205 | modname = 'dynredem1_loc'; fil = fichnom |
---|
206 | CALL err(nf90_open(fil, nf90_write, nid), "open", fil) |
---|
207 | |
---|
208 | !--- Write/extend time coordinate |
---|
209 | nb = nb + 1 |
---|
210 | var = "temps" |
---|
211 | CALL err(nf90_inq_varid(nid, var, vID), "inq", var) |
---|
212 | CALL err(nf90_put_var(nid, vID, [time]), "put", var) |
---|
213 | WRITE(lunout, *)TRIM(modname) // ": Saving for ", nb, time |
---|
214 | |
---|
215 | !--- Rewrite control table (itaufin undefined in dynredem0) |
---|
216 | var = "controle" |
---|
217 | CALL err(nf90_inq_varid(nid, var, vID), "inq", var) |
---|
218 | CALL err(nf90_get_var(nid, vID, tab_cntrl), "get", var) |
---|
219 | tab_cntrl(31) = DBLE(itau_dyn + itaufin) |
---|
220 | CALL err(nf90_inq_varid(nid, var, vID), "inq", var) |
---|
221 | CALL err(nf90_put_var(nid, vID, tab_cntrl), "put", var) |
---|
222 | END IF !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
223 | !$OMP END MASTER |
---|
224 | |
---|
225 | !--- Save fields |
---|
226 | CALL dynredem_write_u(nid, "ucov", ucov, llm) |
---|
227 | CALL dynredem_write_v(nid, "vcov", vcov, llm) |
---|
228 | CALL dynredem_write_u(nid, "teta", teta, llm) |
---|
229 | CALL dynredem_write_u(nid, "masse", masse, llm) |
---|
230 | CALL dynredem_write_u(nid, "ps", ps, 1) |
---|
231 | |
---|
232 | !--- Tracers in file "start_trac.nc" (added by Anne) |
---|
233 | lread_inca = .FALSE. |
---|
234 | !$OMP MASTER |
---|
235 | fil = "start_trac.nc" |
---|
236 | IF(ANY(type_trac == ['inca', 'inco'])) INQUIRE(FILE = fil, EXIST = lread_inca) |
---|
237 | IF(lread_inca) CALL err(nf90_open(fil, nf90_nowrite, nid_trac), "open") |
---|
238 | !$OMP END MASTER |
---|
239 | !$OMP BARRIER |
---|
240 | |
---|
241 | !--- Save tracers |
---|
242 | DO iq = 1, nqtot; var = TRIM(tracers(iq)%name); ierr = -1 |
---|
243 | IF(lread_inca) THEN !--- Possibly read from "start_trac.nc" |
---|
244 | !$OMP MASTER |
---|
245 | fil = "start_trac.nc" |
---|
246 | ierr = nf90_inq_varid(nid_trac, var, vID_trac) |
---|
247 | dum = 'inq'; IF(ierr==nf90_noerr) dum = 'fnd' |
---|
248 | WRITE(lunout, *)msg(dum, var) |
---|
249 | !$OMP END MASTER |
---|
250 | !$OMP BARRIER |
---|
251 | IF(ierr==nf90_noerr) CALL dynredem_read_u(nid_trac, var, q(:, :, iq), llm) |
---|
252 | END IF |
---|
253 | fil = fichnom |
---|
254 | CALL dynredem_write_u(nid, var, q(:, :, iq), llm) |
---|
255 | END DO |
---|
256 | |
---|
257 | !$OMP MASTER |
---|
258 | IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
259 | CALL err(nf90_close(nid), "close") |
---|
260 | fil = "start_trac.nc" |
---|
261 | IF(lread_inca) CALL err(nf90_close(nid_trac), "close") |
---|
262 | END IF !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
263 | !$OMP END MASTER |
---|
264 | |
---|
265 | END SUBROUTINE dynredem1_loc |
---|
266 | |
---|