source: trunk/LMDZ.PLUTO.old/libf/phypluto/iniwrite.F @ 3436

Last change on this file since 3436 was 3175, checked in by emillour, 11 months ago

Pluto PCM:
Add the old Pluto LMDZ for reference (required prior step to making
an LMDZ.PLUTO using the same framework as the other physics packages).
TB+EM

File size: 10.6 KB
Line 
1      SUBROUTINE iniwrite(nid,idayref,phis)
2
3      use comsoil_h     
4      IMPLICIT NONE
5c=======================================================================
6c
7c   Auteur:  L. Fairhead  ,  P. Le Van, Y. Wanherdrick, F. Forget
8c   -------
9c
10c   Objet:
11c   ------
12c
13c   'Initialize' the diagfi.nc file: write down dimensions as well
14c   as time-independent fields (e.g: geopotential, mesh area, ...)
15c
16c=======================================================================
17c-----------------------------------------------------------------------
18c   Declarations:
19c   -------------
20
21#include "dimensions.h"
22#include "paramet.h"
23!include "comconst.h"
24#include "comcstfi.h"
25#include "comvert.h"
26#include "comgeom.h"
27#include "temps.h"
28#include "ener.h"
29#include "logic.h"
30#include "netcdf.inc"
31#include "description.h"
32#include "serre.h"
33#include"dimphys.h"
34!#include"comsoil.h"
35
36c   Arguments:
37c   ----------
38
39      integer nid        ! NetCDF file ID
40      INTEGER*4 idayref  ! date (initial date for this run)
41      REAL phis(iip1,jjp1) ! surface geopotential TB18c
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      write(*,*)'iniwrite: iim,jjm,llm,idayref',iim,jjm,llm,idayref
356      write(*,*)'iniwrite: rad,omeg,g,mugaz,rcp',
357     s rad,omeg,g,mugaz,rcp
358      write(*,*)'iniwrite: daysec,dtphys',daysec,dtphys
359
360      END
Note: See TracBrowser for help on using the repository browser.