source: trunk/LMDZ.GENERIC/libf/phystd/iniwrite.F @ 2987

Last change on this file since 2987 was 1621, checked in by emillour, 8 years ago

Further work on full dynamics/physics separation.

LMDZ.COMMON:

  • added phy_common/vertical_layers_mod.F90 to store information on vertical grid. This is where routines in the physics should get the information.
  • The contents of vertical_layers_mod intialized via dynphy_lonlat/inigeomphy_mod.F90.

LMDZ.MARS:

  • physics now completely decoupled from dynamics; the physics package may now be compiled as a library (-libphy option of makelmdz_fcm).
  • created an "ini_tracer_mod" routine in module "tracer_mod" for a cleaner initialization of the later.
  • removed some purely dynamics-related outputs (etot0, zoom parameters, etc.) from diagfi.nc and stats.nc outputs as these informations are not available in the physics.

LMDZ.GENERIC:

  • physics now completely decoupled from dynamics; the physics package may now be compiled as a library (-libphy option of makelmdz_fcm).
  • added nqtot to tracer_h.F90.
  • removed some purely dynamics-related outputs (etot0, zoom parameters, etc.) from diagfi.nc and stats.nc outputs as these informations are not available in the physics.

LMDZ.VENUS:

  • physics now completely decoupled from dynamics; the physics package may now be compiled as a library (-libphy option of makelmdz_fcm).
  • added infotrac_phy.F90 to store information on tracers in the physics. Initialized via iniphysiq.
  • added cpdet_phy_mod.F90 to store t2tpot etc. functions to be used in the physics. Initialized via iniphysiq. IMPORTANT: there are some hard-coded constants! These should match what is in cpdet_mod.F90 in the dynamics.
  • got rid of references to moyzon_mod module within the physics. The required variables (tmoy, plevmoy) are passed to the physics as arguments to physiq.

LMDZ.TITAN:

  • added infotrac_phy.F90 to store information on tracers in the physics. Initialized via iniphysiq.
  • added cpdet_phy_mod.F90 to store t2tpot etc. functions to be used in the physics.
  • Extra work required to completely decouple physics and dynamics: moyzon_mod should be cleaned up and information passed from dynamics to physics as as arguments. Likewise moyzon_ch and moyzon_mu should not be queried from logic_mod (which is in the dynamics).

EM

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