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