1 | SUBROUTINE iniwrite(nid,idayref,phis,area) |
---|
2 | |
---|
3 | use comsoil_h, only: mlayer, nsoilmx |
---|
4 | USE comcstfi_h, only: g, mugaz, omeg, rad, rcp, pi |
---|
5 | USE comvert_mod, ONLY: ap,bp,aps,bps,pseudoalt |
---|
6 | USE logic_mod, ONLY: fxyhypb,ysinus |
---|
7 | USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy |
---|
8 | USE time_phylmdz_mod, ONLY: hour_ini, daysec, dtphys |
---|
9 | USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0 |
---|
10 | USE regular_lonlat_mod, ONLY: lon_reg, lat_reg |
---|
11 | USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev |
---|
12 | IMPLICIT NONE |
---|
13 | |
---|
14 | c======================================================================= |
---|
15 | c |
---|
16 | c Auteur: L. Fairhead , P. Le Van, Y. Wanherdrick, F. Forget |
---|
17 | c ------- |
---|
18 | c |
---|
19 | c Objet: |
---|
20 | c ------ |
---|
21 | c |
---|
22 | c 'Initialize' the diagfi.nc file: write down dimensions as well |
---|
23 | c as time-independent fields (e.g: geopotential, mesh area, ...) |
---|
24 | c |
---|
25 | c======================================================================= |
---|
26 | c----------------------------------------------------------------------- |
---|
27 | c Declarations: |
---|
28 | c ------------- |
---|
29 | |
---|
30 | include "netcdf.inc" |
---|
31 | |
---|
32 | c Arguments: |
---|
33 | c ---------- |
---|
34 | |
---|
35 | integer,intent(in) :: nid ! NetCDF file ID |
---|
36 | INTEGER*4,intent(in) :: idayref ! date (initial date for this run) |
---|
37 | real,intent(in) :: phis(nbp_lon+1,nbp_lat) ! surface geopotential |
---|
38 | real,intent(in) :: area(nbp_lon+1,nbp_lat) ! mesh area (m2) |
---|
39 | |
---|
40 | c Local: |
---|
41 | c ------ |
---|
42 | INTEGER length,l |
---|
43 | parameter (length = 100) |
---|
44 | REAL tab_cntrl(length) ! run parameters are stored in this array |
---|
45 | INTEGER ierr |
---|
46 | REAl :: lon_reg_ext(nbp_lon+1) ! extended longitudes |
---|
47 | |
---|
48 | integer :: nvarid,idim_index,idim_rlonv |
---|
49 | integer :: idim_rlatu,idim_llmp1,idim_llm |
---|
50 | integer :: idim_nsoilmx ! "subsurface_layers" dimension ID # |
---|
51 | integer, dimension(2) :: id |
---|
52 | c----------------------------------------------------------------------- |
---|
53 | |
---|
54 | DO l=1,length |
---|
55 | tab_cntrl(l)=0. |
---|
56 | ENDDO |
---|
57 | tab_cntrl(1) = real(nbp_lon) |
---|
58 | tab_cntrl(2) = real(nbp_lat-1) |
---|
59 | tab_cntrl(3) = real(nbp_lev) |
---|
60 | tab_cntrl(4) = real(idayref) |
---|
61 | tab_cntrl(5) = rad |
---|
62 | tab_cntrl(6) = omeg |
---|
63 | tab_cntrl(7) = g |
---|
64 | tab_cntrl(8) = mugaz |
---|
65 | tab_cntrl(9) = rcp |
---|
66 | tab_cntrl(10) = daysec |
---|
67 | tab_cntrl(11) = dtphys |
---|
68 | tab_cntrl(12) = etot0 |
---|
69 | tab_cntrl(13) = ptot0 |
---|
70 | tab_cntrl(14) = ztot0 |
---|
71 | tab_cntrl(15) = stot0 |
---|
72 | tab_cntrl(16) = ang0 |
---|
73 | |
---|
74 | tab_cntrl(27) = hour_ini |
---|
75 | c |
---|
76 | c .......... P.Le Van ( ajout le 8/04/96 ) ......... |
---|
77 | c ..... parametres pour le zoom ...... |
---|
78 | tab_cntrl(17) = clon |
---|
79 | tab_cntrl(18) = clat |
---|
80 | tab_cntrl(19) = grossismx |
---|
81 | tab_cntrl(20) = grossismy |
---|
82 | c |
---|
83 | c ..... ajout le 6/05/97 et le 15/10/97 ....... |
---|
84 | c |
---|
85 | IF ( fxyhypb ) THEN |
---|
86 | tab_cntrl(21) = 1. |
---|
87 | tab_cntrl(22) = dzoomx |
---|
88 | tab_cntrl(23) = dzoomy |
---|
89 | ELSE |
---|
90 | tab_cntrl(21) = 0. |
---|
91 | tab_cntrl(22) = dzoomx |
---|
92 | tab_cntrl(23) = dzoomy |
---|
93 | tab_cntrl(24) = 0. |
---|
94 | IF( ysinus ) tab_cntrl(24) = 1. |
---|
95 | ENDIF |
---|
96 | |
---|
97 | c ......................................................... |
---|
98 | |
---|
99 | ! Define dimensions |
---|
100 | |
---|
101 | ierr = NF_REDEF (nid) |
---|
102 | |
---|
103 | ierr = NF_DEF_DIM (nid, "index", length, idim_index) |
---|
104 | ! ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) |
---|
105 | ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu) |
---|
106 | ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv) |
---|
107 | ! ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) |
---|
108 | ierr = NF_DEF_DIM (nid, "interlayer", (nbp_lev+1), idim_llmp1) |
---|
109 | ierr = NF_DEF_DIM (nid, "altitude", nbp_lev, idim_llm) |
---|
110 | ierr = NF_DEF_DIM (nid,"subsurface_layers",nsoilmx,idim_nsoilmx) |
---|
111 | c |
---|
112 | ierr = NF_ENDDEF(nid) |
---|
113 | |
---|
114 | c Contol parameters for this run |
---|
115 | ierr = NF_REDEF (nid) |
---|
116 | #ifdef NC_DOUBLE |
---|
117 | ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, |
---|
118 | . idim_index,nvarid) |
---|
119 | #else |
---|
120 | ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, |
---|
121 | . idim_index,nvarid) |
---|
122 | #endif |
---|
123 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18, |
---|
124 | . "Control parameters") |
---|
125 | ierr = NF_ENDDEF(nid) |
---|
126 | #ifdef NC_DOUBLE |
---|
127 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl) |
---|
128 | #else |
---|
129 | ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl) |
---|
130 | #endif |
---|
131 | |
---|
132 | c -------------------------- |
---|
133 | c longitudes and latitudes |
---|
134 | ! |
---|
135 | ! ierr = NF_REDEF (nid) |
---|
136 | !#ifdef NC_DOUBLE |
---|
137 | ! ierr = NF_DEF_VAR (nid, "rlonu", NF_DOUBLE, 1, idim_rlonu,nvarid) |
---|
138 | !#else |
---|
139 | ! ierr = NF_DEF_VAR (nid, "rlonu", NF_FLOAT, 1, idim_rlonu,nvarid) |
---|
140 | !#endif |
---|
141 | ! ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 21, |
---|
142 | ! . "Longitudes at u nodes") |
---|
143 | ! ierr = NF_ENDDEF(nid) |
---|
144 | !#ifdef NC_DOUBLE |
---|
145 | ! ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu/pi*180) |
---|
146 | !#else |
---|
147 | ! ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu/pi*180) |
---|
148 | !#endif |
---|
149 | c |
---|
150 | c -------------------------- |
---|
151 | ierr = NF_REDEF (nid) |
---|
152 | #ifdef NC_DOUBLE |
---|
153 | ierr =NF_DEF_VAR(nid, "latitude", NF_DOUBLE, 1, idim_rlatu,nvarid) |
---|
154 | #else |
---|
155 | ierr =NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim_rlatu,nvarid) |
---|
156 | #endif |
---|
157 | ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north") |
---|
158 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14, |
---|
159 | . "North latitude") |
---|
160 | ierr = NF_ENDDEF(nid) |
---|
161 | #ifdef NC_DOUBLE |
---|
162 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180) |
---|
163 | #else |
---|
164 | ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180) |
---|
165 | #endif |
---|
166 | c |
---|
167 | c -------------------------- |
---|
168 | lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon) |
---|
169 | !add extra redundant point (180 degrees, since lon_reg starts at -180 |
---|
170 | lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1) |
---|
171 | |
---|
172 | ierr = NF_REDEF (nid) |
---|
173 | #ifdef NC_DOUBLE |
---|
174 | ierr =NF_DEF_VAR(nid,"longitude", NF_DOUBLE, 1, idim_rlonv,nvarid) |
---|
175 | #else |
---|
176 | ierr = NF_DEF_VAR(nid,"longitude", NF_FLOAT, 1, idim_rlonv,nvarid) |
---|
177 | #endif |
---|
178 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14, |
---|
179 | . "East longitude") |
---|
180 | ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east") |
---|
181 | ierr = NF_ENDDEF(nid) |
---|
182 | #ifdef NC_DOUBLE |
---|
183 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180) |
---|
184 | #else |
---|
185 | ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180) |
---|
186 | #endif |
---|
187 | c |
---|
188 | c -------------------------- |
---|
189 | ierr = NF_REDEF (nid) |
---|
190 | #ifdef NC_DOUBLE |
---|
191 | ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1, |
---|
192 | . idim_llm,nvarid) |
---|
193 | #else |
---|
194 | ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1, |
---|
195 | . idim_llm,nvarid) |
---|
196 | #endif |
---|
197 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name",10,"pseudo-alt") |
---|
198 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km") |
---|
199 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up") |
---|
200 | |
---|
201 | ierr = NF_ENDDEF(nid) |
---|
202 | #ifdef NC_DOUBLE |
---|
203 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pseudoalt) |
---|
204 | #else |
---|
205 | ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt) |
---|
206 | #endif |
---|
207 | c |
---|
208 | c -------------------------- |
---|
209 | ! ierr = NF_REDEF (nid) |
---|
210 | !#ifdef NC_DOUBLE |
---|
211 | ! ierr = NF_DEF_VAR (nid, "rlatv", NF_DOUBLE, 1, idim_rlatv,nvarid) |
---|
212 | !#else |
---|
213 | ! ierr = NF_DEF_VAR (nid, "rlatv", NF_FLOAT, 1, idim_rlatv,nvarid) |
---|
214 | !#endif |
---|
215 | ! ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 20, |
---|
216 | ! . "Latitudes at v nodes") |
---|
217 | ! ierr = NF_ENDDEF(nid) |
---|
218 | !#ifdef NC_DOUBLE |
---|
219 | ! ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv/pi*180) |
---|
220 | !#else |
---|
221 | ! ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv/pi*180) |
---|
222 | !#endif |
---|
223 | c |
---|
224 | c -------------------------- |
---|
225 | c Vertical levels |
---|
226 | call def_var(nid,"aps","hybrid pressure at midlayers ","Pa", |
---|
227 | . 1,idim_llm,nvarid,ierr) |
---|
228 | #ifdef NC_DOUBLE |
---|
229 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps) |
---|
230 | #else |
---|
231 | ierr = NF_PUT_VAR_REAL (nid,nvarid,aps) |
---|
232 | #endif |
---|
233 | |
---|
234 | call def_var(nid,"bps","hybrid sigma at midlayers"," ", |
---|
235 | . 1,idim_llm,nvarid,ierr) |
---|
236 | #ifdef NC_DOUBLE |
---|
237 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps) |
---|
238 | #else |
---|
239 | ierr = NF_PUT_VAR_REAL (nid,nvarid,bps) |
---|
240 | #endif |
---|
241 | |
---|
242 | call def_var(nid,"ap","hybrid pressure at interlayers","Pa", |
---|
243 | . 1,idim_llmp1,nvarid,ierr) |
---|
244 | #ifdef NC_DOUBLE |
---|
245 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap) |
---|
246 | #else |
---|
247 | ierr = NF_PUT_VAR_REAL (nid,nvarid,ap) |
---|
248 | #endif |
---|
249 | |
---|
250 | call def_var(nid,"bp","hybrid sigma at interlayers"," ", |
---|
251 | . 1,idim_llmp1,nvarid,ierr) |
---|
252 | #ifdef NC_DOUBLE |
---|
253 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp) |
---|
254 | #else |
---|
255 | ierr = NF_PUT_VAR_REAL (nid,nvarid,bp) |
---|
256 | #endif |
---|
257 | |
---|
258 | !------------------------------- |
---|
259 | ! (soil) depth variable mlayer() (known from comsoil_h) |
---|
260 | !------------------------------- |
---|
261 | ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode |
---|
262 | ! define variable |
---|
263 | #ifdef NC_DOUBLE |
---|
264 | ierr=NF_DEF_VAR(nid,"soildepth",NF_DOUBLE,1,idim_nsoilmx,nvarid) |
---|
265 | #else |
---|
266 | ierr=NF_DEF_VAR(nid,"soildepth",NF_FLOAT,1,idim_nsoilmx,nvarid) |
---|
267 | #endif |
---|
268 | ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 20, |
---|
269 | . "Soil mid-layer depth") |
---|
270 | ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",1,"m") |
---|
271 | ierr=NF_PUT_ATT_TEXT (nid,nvarid,"positive",4,"down") |
---|
272 | ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode |
---|
273 | ! write variable |
---|
274 | #ifdef NC_DOUBLE |
---|
275 | ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,mlayer) |
---|
276 | #else |
---|
277 | ierr=NF_PUT_VAR_REAL (nid,nvarid,mlayer) |
---|
278 | #endif |
---|
279 | |
---|
280 | c |
---|
281 | c -------------------------- |
---|
282 | c Mesh area and conversion coefficients cov. <-> contra. <--> natural |
---|
283 | |
---|
284 | ! id(1)=idim_rlonu |
---|
285 | ! id(2)=idim_rlatu |
---|
286 | c |
---|
287 | ! ierr = NF_REDEF (nid) |
---|
288 | !#ifdef NC_DOUBLE |
---|
289 | ! ierr = NF_DEF_VAR (nid, "cu", NF_DOUBLE, 2, id,nvarid) |
---|
290 | !#else |
---|
291 | ! ierr = NF_DEF_VAR (nid, "cu", NF_FLOAT, 2, id,nvarid) |
---|
292 | !#endif |
---|
293 | ! ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40, |
---|
294 | ! . "Conversion coefficients cov <--> natural") |
---|
295 | ! ierr = NF_ENDDEF(nid) |
---|
296 | !#ifdef NC_DOUBLE |
---|
297 | ! ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu) |
---|
298 | !#else |
---|
299 | ! ierr = NF_PUT_VAR_REAL (nid,nvarid,cu) |
---|
300 | !#endif |
---|
301 | c |
---|
302 | ! id(1)=idim_rlonv |
---|
303 | ! id(2)=idim_rlatv |
---|
304 | c |
---|
305 | c -------------------------- |
---|
306 | ! ierr = NF_REDEF (nid) |
---|
307 | !#ifdef NC_DOUBLE |
---|
308 | ! ierr = NF_DEF_VAR (nid, "cv", NF_DOUBLE, 2, id,nvarid) |
---|
309 | !#else |
---|
310 | ! ierr = NF_DEF_VAR (nid, "cv", NF_FLOAT, 2, id,nvarid) |
---|
311 | !#endif |
---|
312 | ! ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40, |
---|
313 | ! . "Conversion coefficients cov <--> natural") |
---|
314 | ! ierr = NF_ENDDEF(nid) |
---|
315 | !#ifdef NC_DOUBLE |
---|
316 | ! ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv) |
---|
317 | !#else |
---|
318 | ! ierr = NF_PUT_VAR_REAL (nid,nvarid,cv) |
---|
319 | !#endif |
---|
320 | c |
---|
321 | id(1)=idim_rlonv |
---|
322 | id(2)=idim_rlatu |
---|
323 | c |
---|
324 | c -------------------------- |
---|
325 | ierr = NF_REDEF (nid) |
---|
326 | #ifdef NC_DOUBLE |
---|
327 | ierr = NF_DEF_VAR (nid, "aire", NF_DOUBLE, 2, id,nvarid) |
---|
328 | #else |
---|
329 | ierr = NF_DEF_VAR (nid, "aire", NF_FLOAT, 2, id,nvarid) |
---|
330 | #endif |
---|
331 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9, |
---|
332 | . "Mesh area") |
---|
333 | ierr = NF_ENDDEF(nid) |
---|
334 | #ifdef NC_DOUBLE |
---|
335 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area) |
---|
336 | #else |
---|
337 | ierr = NF_PUT_VAR_REAL (nid,nvarid,area) |
---|
338 | #endif |
---|
339 | c |
---|
340 | c Surface geopotential |
---|
341 | id(1)=idim_rlonv |
---|
342 | id(2)=idim_rlatu |
---|
343 | c |
---|
344 | ierr = NF_REDEF (nid) |
---|
345 | #ifdef NC_DOUBLE |
---|
346 | ierr = NF_DEF_VAR (nid, "phisinit", NF_DOUBLE, 2, id,nvarid) |
---|
347 | #else |
---|
348 | ierr = NF_DEF_VAR (nid, "phisinit", NF_FLOAT, 2, id,nvarid) |
---|
349 | #endif |
---|
350 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 27, |
---|
351 | . "Geopotential at the surface") |
---|
352 | ierr = NF_ENDDEF(nid) |
---|
353 | #ifdef NC_DOUBLE |
---|
354 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis) |
---|
355 | #else |
---|
356 | ierr = NF_PUT_VAR_REAL (nid,nvarid,phis) |
---|
357 | #endif |
---|
358 | c |
---|
359 | |
---|
360 | write(*,*)'iniwrite: nbp_lon,nbp_lat,nbp_lev,idayref', |
---|
361 | & nbp_lon,nbp_lat,nbp_lev,idayref |
---|
362 | write(*,*)'iniwrite: rad,omeg,g,mugaz,rcp', |
---|
363 | & rad,omeg,g,mugaz,rcp |
---|
364 | write(*,*)'iniwrite: daysec,dtphys',daysec,dtphys |
---|
365 | |
---|
366 | END |
---|