source: trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specVI.F @ 486

Last change on this file since 486 was 305, checked in by rwordsworth, 13 years ago

Several new files added as part of the climate evolution model
(main program kcm.F90). Some general cleanup in physiq.F90 and
callcorrk.F90. Bugs in dust radiative transfer and H2 Rayleigh
scattering corrected.

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