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

Last change on this file since 832 was 787, checked in by aslmd, 12 years ago

LMDZ.GENERIC. (Sorry for long text but this is a quite major commit)

Paving the path for parallel computations. And moving towards a more flexible code.

Automatic allocation is used within all routines in phystd. No further mention to ngridmx and nqmx.

  1. ngridmx and nqmx are still used in LMDZ.GENERIC in the dyn3d part
  2. if the LMDZ4/LMDZ5 dynamical core is used, there is no more fixed dimensions ngridmx and nqmx --> a fully flexible parallel implementation is now possible (e.g. no need to recompile when changing numbers of processors)

The important stuff :

  • Compilation checked with ifort. OK with and without debug mode. No errors. Checked for: gcm, newstart, rcm1d, kcm1d
  • RUN GCM: Running an Earth test case. Comparison with previous revision --> debug mode : perfect match. bit by bit (diff command). checked with plots --> O1 mode : close match (checked with plots) --> O2 mode : sometimes up to 0.5 K departure.... BUT in this new version O2 and O1 are quite close while in previous version O1 and O2 differed by about, well, typically 0.5 K (pictures available on request)
  • RUN NEWSTART : perfect match (bit-by-bit) in either debug or normal mode.
  • RUN RCM1D : perfect match in normal mode.
  • RUN KCM1D : not tested (I don't know what is the use of kcm1d)

List of main changes :

  • Additional arguments to some subroutines (ngrid and nq)
  • F77 include strategy is obsolete and replaced by F90 module strategy In this new strategy arrays are allocatable and allocated once at first use This has to be done for all common featuring arrays defined with ngridmx or nqmx

surfdat.h >> surfdat_h.F90
tracer.h >> tracer_h.F90
comsaison.h >> comsaison_h.F90
comgeomfi.h >> comgeomfi_h.F90
comsoil.h >> comsoil_h.F90
comdiurn.h >> comdiurn_h.F90
fisice.h >> DELETED. was not used. probably a fossil.
watercap.h >> DELETED. variable put in surfdat_h.F90

  • F77 'save' strategy is obsolete and replaced by F90 'allocatable save' strategy (see previous point and e.g. new version of physiq.F90)
  • Suppressing any mention to advtrac.h which is a common in the dynamics and needs nqmx This was easily solved by adding an argument with tracer names, coming from the dynamics This is probably not a definitive solution, ... but this allows for generic physics to work easily with either LMDZ.GENERIC or LMDZ dynamical cores
  • Removing consistency tests between nq and nqmx ; and ngrid and ngridmx. No use now!
  • Adaptation of rcm1d, kcm1d, newstart given above-mentioned changes

A note on phyetat0 and soil_setting:

  • Now written so that a slice of horizontal size 'ngrid' starting at grid point 'cursor' is read in startfi.nc 'cursor' is defined in dimphys.h and initialized by inifis (or in newstart) this is useful for parallel computations. default behavior is the usual one : sequential runs, cursor is 1, size ngrid is the whole global domain

A note on an additional change :

  • nueffrad is now an argument to callcorrk as is the case for reffrad both are saved in physiq this is for consistency and lisibility (previously nueffrad was saved in callcorrk) ... but there is a call to a function which modifies nueffrad in physiq ... previously this was not modifying nueffrad (although it was quite cumbersome to detect this) ... to be conservative I kept this behaviour and highlighted it with an array nueffrad_dummy ... I added a comment because someone might want to change this
File size: 10.5 KB
Line 
1      SUBROUTINE iniwrite(nid,idayref,phis)
2
3      USE comsoil_h
4
5      IMPLICIT NONE
6
7c=======================================================================
8c
9c   Auteur:  L. Fairhead  ,  P. Le Van, Y. Wanherdrick, F. Forget
10c   -------
11c
12c   Objet:
13c   ------
14c
15c   'Initialize' the diagfi.nc file: write down dimensions as well
16c   as time-independent fields (e.g: geopotential, mesh area, ...)
17c
18c=======================================================================
19c-----------------------------------------------------------------------
20c   Declarations:
21c   -------------
22
23#include "dimensions.h"
24#include "paramet.h"
25!include "comconst.h"
26#include "comcstfi.h"
27#include "comvert.h"
28#include "comgeom.h"
29#include "temps.h"
30#include "ener.h"
31#include "logic.h"
32#include "netcdf.inc"
33#include "description.h"
34#include "serre.h"
35#include"dimphys.h"
36
37c   Arguments:
38c   ----------
39
40      integer nid        ! NetCDF file ID
41      INTEGER*4 idayref  ! date (initial date for this run)
42      REAL phis(ip1jmp1) ! surface geopotential
43
44c   Local:
45c   ------
46      INTEGER length,l
47      parameter (length = 100)
48      REAL tab_cntrl(length) ! run parameters are stored in this array
49      INTEGER ierr
50
51      integer :: nvarid,idim_index,idim_rlonu,idim_rlonv
52      integer :: idim_rlatu,idim_rlatv,idim_llmp1,idim_llm
53      integer :: idim_nsoilmx ! "subsurface_layers" dimension ID #
54      integer, dimension(2) :: id 
55c-----------------------------------------------------------------------
56
57      DO l=1,length
58         tab_cntrl(l)=0.
59      ENDDO
60      tab_cntrl(1)  = FLOAT(iim)
61      tab_cntrl(2)  = FLOAT(jjm)
62      tab_cntrl(3)  = FLOAT(llm)
63      tab_cntrl(4)  = FLOAT(idayref)
64      tab_cntrl(5)  = rad
65      tab_cntrl(6)  = omeg
66      tab_cntrl(7)  = g
67      tab_cntrl(8)  = mugaz
68      tab_cntrl(9)  = rcp
69      tab_cntrl(10) = daysec
70      tab_cntrl(11) = dtphys
71      tab_cntrl(12) = etot0
72      tab_cntrl(13) = ptot0
73      tab_cntrl(14) = ztot0
74      tab_cntrl(15) = stot0
75      tab_cntrl(16) = ang0
76c
77c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
78c         .....        parametres  pour le zoom          ......   
79      tab_cntrl(17)  = clon
80      tab_cntrl(18)  = clat
81      tab_cntrl(19)  = grossismx
82      tab_cntrl(20)  = grossismy
83c
84c     .....   ajout  le 6/05/97 et le 15/10/97  .......
85c
86      IF ( fxyhypb )   THEN
87        tab_cntrl(21) = 1.
88        tab_cntrl(22) = dzoomx
89        tab_cntrl(23) = dzoomy
90      ELSE
91        tab_cntrl(21) = 0.
92        tab_cntrl(22) = dzoomx
93        tab_cntrl(23) = dzoomy
94        tab_cntrl(24) = 0.
95        IF( ysinus )  tab_cntrl(24) = 1.
96      ENDIF
97
98c    .........................................................
99
100! Define dimensions
101   
102      ierr = NF_REDEF (nid)
103
104      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
105      ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu)
106      ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu)
107      ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv)
108      ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv)
109      ierr = NF_DEF_DIM (nid, "interlayer", (llm+1), idim_llmp1)
110      ierr = NF_DEF_DIM (nid, "altitude", llm, idim_llm)
111      ierr = NF_DEF_DIM (nid,"subsurface_layers",nsoilmx,idim_nsoilmx)
112c
113      ierr = NF_ENDDEF(nid)
114
115c  Contol parameters for this run
116      ierr = NF_REDEF (nid)
117#ifdef NC_DOUBLE
118      ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1,
119     .       idim_index,nvarid)
120#else
121      ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1,
122     .       idim_index,nvarid)
123#endif
124      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18,
125     .                       "Control parameters")
126      ierr = NF_ENDDEF(nid)
127#ifdef NC_DOUBLE
128      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
129#else
130      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
131#endif
132
133c --------------------------
134c  longitudes and latitudes
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
149c
150c --------------------------
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,rlatu/pi*180)
163#else
164      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180)
165#endif
166c
167c --------------------------
168      ierr = NF_REDEF (nid)
169#ifdef NC_DOUBLE
170      ierr =NF_DEF_VAR(nid,"longitude", NF_DOUBLE, 1, idim_rlonv,nvarid)
171#else
172      ierr = NF_DEF_VAR(nid,"longitude", NF_FLOAT, 1, idim_rlonv,nvarid)
173#endif
174      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
175     .      "East longitude")
176      ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east")
177      ierr = NF_ENDDEF(nid)
178#ifdef NC_DOUBLE
179      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180)
180#else
181      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180)
182#endif
183c
184c --------------------------
185      ierr = NF_REDEF (nid)
186#ifdef NC_DOUBLE
187      ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1,
188     .       idim_llm,nvarid)
189#else
190      ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1,
191     .       idim_llm,nvarid)
192#endif
193      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name",10,"pseudo-alt")
194      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km")
195      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up")
196
197      ierr = NF_ENDDEF(nid)
198#ifdef NC_DOUBLE
199      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pseudoalt)
200#else
201      ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt)
202#endif
203c
204c --------------------------
205      ierr = NF_REDEF (nid)
206#ifdef NC_DOUBLE
207      ierr = NF_DEF_VAR (nid, "rlatv", NF_DOUBLE, 1, idim_rlatv,nvarid)
208#else
209      ierr = NF_DEF_VAR (nid, "rlatv", NF_FLOAT, 1, idim_rlatv,nvarid)
210#endif
211      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 20,
212     .                       "Latitudes at v nodes")
213      ierr = NF_ENDDEF(nid)
214#ifdef NC_DOUBLE
215      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv/pi*180)
216#else
217      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv/pi*180)
218#endif
219c
220c --------------------------
221c  Vertical levels
222      call def_var(nid,"aps","hybrid pressure at midlayers ","Pa",
223     .            1,idim_llm,nvarid,ierr)
224#ifdef NC_DOUBLE
225      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps)
226#else
227      ierr = NF_PUT_VAR_REAL (nid,nvarid,aps)
228#endif
229
230      call def_var(nid,"bps","hybrid sigma at midlayers"," ",
231     .            1,idim_llm,nvarid,ierr)
232#ifdef NC_DOUBLE
233      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps)
234#else
235      ierr = NF_PUT_VAR_REAL (nid,nvarid,bps)
236#endif
237
238      call def_var(nid,"ap","hybrid pressure at interlayers","Pa",
239     .            1,idim_llmp1,nvarid,ierr)
240#ifdef NC_DOUBLE
241      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap)
242#else
243      ierr = NF_PUT_VAR_REAL (nid,nvarid,ap)
244#endif
245
246      call def_var(nid,"bp","hybrid sigma at interlayers"," ",
247     .            1,idim_llmp1,nvarid,ierr)
248#ifdef NC_DOUBLE
249      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp)
250#else
251      ierr = NF_PUT_VAR_REAL (nid,nvarid,bp)
252#endif
253
254!-------------------------------
255! (soil) depth variable mlayer() (known from comsoil.h)
256!-------------------------------
257      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
258      ! define variable
259#ifdef NC_DOUBLE
260      ierr=NF_DEF_VAR(nid,"soildepth",NF_DOUBLE,1,idim_nsoilmx,nvarid)
261#else
262      ierr=NF_DEF_VAR(nid,"soildepth",NF_FLOAT,1,idim_nsoilmx,nvarid)
263#endif
264      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 20,
265     .                        "Soil mid-layer depth")
266      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",1,"m")
267      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"positive",4,"down")
268      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
269      ! write variable
270#ifdef NC_DOUBLE
271      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,mlayer)
272#else
273      ierr=NF_PUT_VAR_REAL (nid,nvarid,mlayer)
274#endif
275
276c
277c --------------------------
278c  Mesh area and conversion coefficients cov. <-> contra. <--> natural
279
280      id(1)=idim_rlonu
281      id(2)=idim_rlatu
282c
283      ierr = NF_REDEF (nid)
284#ifdef NC_DOUBLE
285      ierr = NF_DEF_VAR (nid, "cu", NF_DOUBLE, 2, id,nvarid)
286#else
287      ierr = NF_DEF_VAR (nid, "cu", NF_FLOAT, 2, id,nvarid)
288#endif
289      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40,
290     .             "Conversion coefficients cov <--> natural")
291      ierr = NF_ENDDEF(nid)
292#ifdef NC_DOUBLE
293      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu)
294#else
295      ierr = NF_PUT_VAR_REAL (nid,nvarid,cu)
296#endif
297c
298      id(1)=idim_rlonv
299      id(2)=idim_rlatv
300c
301c --------------------------
302      ierr = NF_REDEF (nid)
303#ifdef NC_DOUBLE
304      ierr = NF_DEF_VAR (nid, "cv", NF_DOUBLE, 2, id,nvarid)
305#else
306      ierr = NF_DEF_VAR (nid, "cv", 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,cv)
313#else
314      ierr = NF_PUT_VAR_REAL (nid,nvarid,cv)
315#endif
316c
317      id(1)=idim_rlonv
318      id(2)=idim_rlatu
319c
320c --------------------------
321      ierr = NF_REDEF (nid)
322#ifdef NC_DOUBLE
323      ierr = NF_DEF_VAR (nid, "aire", NF_DOUBLE, 2, id,nvarid)
324#else
325      ierr = NF_DEF_VAR (nid, "aire", NF_FLOAT, 2, id,nvarid)
326#endif
327      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
328     .                       "Mesh area")
329      ierr = NF_ENDDEF(nid)
330#ifdef NC_DOUBLE
331      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire)
332#else
333      ierr = NF_PUT_VAR_REAL (nid,nvarid,aire)
334#endif
335c
336c  Surface geopotential
337      id(1)=idim_rlonv
338      id(2)=idim_rlatu
339c
340      ierr = NF_REDEF (nid)
341#ifdef NC_DOUBLE
342      ierr = NF_DEF_VAR (nid, "phisinit", NF_DOUBLE, 2, id,nvarid)
343#else
344      ierr = NF_DEF_VAR (nid, "phisinit", NF_FLOAT, 2, id,nvarid)
345#endif
346      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 27,
347     .                       "Geopotential at the surface")
348      ierr = NF_ENDDEF(nid)
349#ifdef NC_DOUBLE
350      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis)
351#else
352      ierr = NF_PUT_VAR_REAL (nid,nvarid,phis)
353#endif
354c
355
356      write(*,*)'iniwrite: iim,jjm,llm,idayref',iim,jjm,llm,idayref
357      write(*,*)'iniwrite: rad,omeg,g,mugaz,rcp',
358     s rad,omeg,g,mugaz,rcp
359      write(*,*)'iniwrite: daysec,dtphys',daysec,dtphys
360
361      END
Note: See TracBrowser for help on using the repository browser.