source: trunk/LMDZ.PLUTO.old/libf/phypluto/physdem1pal.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: 18.1 KB
Line 
1      subroutine physdem1pal(filename,lonfi,latfi,nsoil,nq,
2     .          phystep,day_ini,
3     .          time,tsurf,tsoil,emis,q2,qsurf,
4     .          airefi,alb,ith,pzmea,pzstd,pzsig,pzgam,pzthe,
5     .          oblipal,eccpal,tpalnew,adjustnew,phisfipal,peri_daypal)
6
7
8
9      use planet_h         
10      use comgeomfi_h
11      use comsoil_h
12      implicit none
13c-------------------------------------------------------------
14c
15c create physics (re-)start data file "restartfi.nc"
16c
17c
18c
19#include "dimensions.h"
20#include "paramet.h"
21c-----------------------------------------------------------------------
22#include "comvert.h"
23#include "comgeom2.h"
24#include "control.h"
25#include "comdissnew.h"
26#include "logic.h"
27#include "ener.h"
28#include "netcdf.inc"
29#include "dimphys.h"
30#include"advtrac.h"
31#include"callkeys.h"
32
33      INTEGER nid,iq
34      INTEGER, parameter :: ivap=1
35      REAL, parameter :: qsolmax= 150.0
36      character (len=*) :: filename
37      character (len=7) :: str7
38
39      REAL day_ini
40      REAL oblipal,peri_daypal,eccpal   !TB16 : change of obliquity/periday/eccentricity for paleo run
41      REAL peripal,aphepal   !TB16 : change of perihelion/aphelion from eccentricity
42      REAL tpalnew   !TB16 : change of obliquity for paleo run
43      REAL adjustnew   !TB21 : change in N2 ice albedo
44      REAL phisfipal(ngridmx)   !TB16 : change of phisfi for paleo run
45      INTEGER nsoil,nq
46      integer ierr,idim1,idim2,idim3,idim4,idim5,nvarid
47
48c
49      REAL phystep,time
50      REAL latfi(ngridmx), lonfi(ngridmx)
51!      REAL champhys(ngridmx)
52      REAL tsurf(ngridmx)
53      INTEGER length
54      PARAMETER (length=100)
55      REAL tab_cntrl(length)
56
57c
58
59!      EXTERNAL defrun_new,iniconst,geopot,inigeom,massdair,pression
60!      EXTERNAL exner_hyb , SSUM
61c
62#include "serre.h"
63#include "clesph0.h"
64#include "fxyprim.h"
65#include "surfdat.h"
66!#include "comsoil.h"
67!#include "planete.h"
68#include "comcstfi.h"
69
70      real tsoil(ngridmx,nsoil),emis(ngridmx)
71      real q2(ngridmx, llm+1),qsurf(ngridmx,nq)
72      real airefi(ngridmx)
73      real alb(ngridmx),ith(ngridmx,nsoil)
74      real pzmea(ngridmx),pzstd(ngridmx)
75      real pzsig(ngridmx),pzgam(ngridmx),pzthe(ngridmx)
76      integer ig
77      INTEGER lnblnk
78      EXTERNAL lnblnk
79
80! flag which identifies if we are using old tracer names (qsurf01,...)
81      integer :: count
82      character(len=30) :: txt ! to store some text
83c-----------------------------------------------------------------------
84
85      ! copy airefi(:) to area(:)
86      CALL SCOPY(ngridmx,airefi,1,area,1)
87      ! note: area() is defined in comgeomfi.h
88
89      DO ig=1,ngridmx
90         albedodat(ig)=alb(ig) ! note: albedodat() is defined in surfdat.h
91         zmea(ig)=pzmea(ig) ! note: zmea() is defined in surfdat.h
92         zstd(ig)=pzstd(ig) ! note: zstd() is defined in surfdat.h
93         zsig(ig)=pzsig(ig) ! note: zsig() is defined in surfdat.h
94         zgam(ig)=pzgam(ig) ! note: zgam() is defined in surfdat.h
95         zthe(ig)=pzthe(ig) ! note: zthe() is defined in surfdat.h
96         inertiedat(ig,:)=ith(ig,:) ! note inertiedat() is defined in comsoil.h
97      ENDDO
98
99c
100c  things to store in the physics start file:
101c
102      ierr = NF_CREATE(adjustl(filename),NF_CLOBBER, nid)
103      IF (ierr.NE.NF_NOERR) THEN
104        WRITE(6,*)'physdem1: Problem creating file ',adjustl(filename)
105        write(6,*) NF_STRERROR(ierr)
106        CALL ABORT
107      ENDIF
108c
109      print*,'physdem1d creating restart'
110
111      ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 18,
112     .                       "Physics start file")
113c
114      ierr = NF_DEF_DIM (nid,"index",length,idim1)
115      if (ierr.ne.NF_NOERR) then
116        WRITE(6,*)'physdem1: Problem defining index dimension'
117        write(6,*) NF_STRERROR(ierr)
118        call abort
119      endif
120c
121      ierr = NF_DEF_DIM (nid,"physical_points",ngridmx,idim2)
122      if (ierr.ne.NF_NOERR) then
123        WRITE(6,*)'physdem1: Problem defining physical_points dimension'
124        write(6,*) NF_STRERROR(ierr)
125        call abort
126      endif
127c
128      ierr = NF_DEF_DIM (nid,"subsurface_layers",nsoil,idim3)
129      if (ierr.ne.NF_NOERR) then
130      WRITE(6,*)'physdem1: Problem defining subsurface_layers dimension'
131        write(6,*) NF_STRERROR(ierr)
132        call abort
133      endif
134c
135!      ierr = NF_DEF_DIM (nid,"nlayer+1",llm+1,idim4)
136      ierr = NF_DEF_DIM (nid,"nlayer_plus_1",llm+1,idim4)
137      if (ierr.ne.NF_NOERR) then
138        WRITE(6,*)'physdem1: Problem defining nlayer+1 dimension'
139        write(6,*) NF_STRERROR(ierr)
140        call abort
141      endif
142c
143      ierr = NF_DEF_DIM (nid,"number_of_advected_fields",nq,idim5)
144      if (ierr.ne.NF_NOERR) then
145        WRITE(6,*)'physdem1: Problem defining advected fields dimension'
146        WRITE(6,*)' nq = ',nq,' and ierr = ', ierr
147        write(6,*) NF_STRERROR(ierr)
148      endif
149
150      ierr = NF_ENDDEF(nid) ! exit NetCDF define mode
151
152c clear tab_cntrl(:) array
153      DO ierr = 1, length
154         tab_cntrl(ierr) = 0.0
155      ENDDO
156
157      write(*,*) "physdem1: ngridmx: ",ngridmx
158      write(*,*) "change of eccentricity, ecc=",eccpal
159      peripal=(periheli+aphelie)/2.*(1-eccpal)
160      aphepal=(periheli+aphelie)/2.*(1+eccpal)
161      write(*,*) "check peri old/new=",periheli,peripal
162      write(*,*) "check aphe old/new=",aphelie,aphepal
163      write(*,*) "check a old/new=",aphelie+periheli,aphepal+peripal
164
165ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
166c Fill control array tab_cntrl(:) with paramleters for this run
167ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
168c Informations on the physics grid
169      tab_cntrl(1) = float(ngridmx)  ! number of nodes on physics grid
170      tab_cntrl(2) = float(nlayermx) ! number of atmospheric layers
171      tab_cntrl(3) = day_ini + int(time)         ! initial day
172      tab_cntrl(4) = time -int(time)            ! initiale time of day
173
174c Informations about Pluto, used by dynamics and physics
175      tab_cntrl(5) = rad      ! radius (m)
176      tab_cntrl(6) = omeg     ! rotation rate (rad.s-1)
177      tab_cntrl(7) = g        ! gravity (m.s-2)
178      tab_cntrl(8) = mugaz    ! Molar mass of the atmosphere (g.mol-1)
179      tab_cntrl(9) = rcp      !  = r/cp (=kappa dans dynamique)
180      tab_cntrl(10) = daysec  ! length of a sol (s)
181
182      tab_cntrl(11) = phystep  ! time step in the physics
183      tab_cntrl(12) = 0.
184      tab_cntrl(13) = 0.
185
186c Informations about Pluto, only for physics
187      tab_cntrl(14) = year_day  ! length of year (sols)
188      tab_cntrl(15) = peripal  ! min. Sun-Pluto distance (Mkm)
189      tab_cntrl(16) = aphepal   ! max. SUn-Pluto distance (Mkm)
190      tab_cntrl(17) = peri_daypal  ! date of perihelion (sols since N. spring)
191      tab_cntrl(18) = oblipal  ! Obliquity of the dwarf planet (deg)
192
193c Boundary layer and turbulence
194      tab_cntrl(19) = z0        ! surface roughness (m)
195
196c Paleoclimate run
197      tab_cntrl(20) = tpalnew  ! Time to start paleoclimate run (e.g -10)
198      tab_cntrl(21) = adjustnew  ! Change in N2 ice albedo
199c aerosol properties
200
201      tab_cntrl(28) = 0.
202      tab_cntrl(29) = 0.
203      tab_cntrl(30) = 0.
204
205! Soil properties:
206      tab_cntrl(35) = volcapa ! soil volumetric heat capacity
207     
208
209!      write(*,*) "physdem1: tab_cntrl():",tab_cntrl
210     
211      ierr = NF_REDEF (nid) ! Enter NetCDF (re-)define mode
212      IF (ierr.NE.NF_NOERR) THEN
213         PRINT*, 'physdem1: Failed to swich to NetCDF define mode'
214         CALL abort
215      ENDIF
216      ! define variable
217#ifdef NC_DOUBLE
218      ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, idim1,nvarid)
219#else
220      ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, idim1,nvarid)
221#endif
222      IF (ierr.NE.NF_NOERR) THEN
223         PRINT*, 'physdem1: Failed to define controle'
224         CALL abort
225      ENDIF
226      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18,
227     .                        "Control parameters")
228      IF (ierr.NE.NF_NOERR) THEN
229         PRINT*, 'physdem1: Failed to define controle title attribute'
230         CALL abort
231      ENDIF
232      ierr = NF_ENDDEF(nid) ! Leave NetCDF define mode
233      IF (ierr.NE.NF_NOERR) THEN
234         PRINT*, 'physdem1: Failed to swich out of NetCDF define mode'
235         CALL abort
236      ENDIF
237      ! write variable
238#ifdef NC_DOUBLE
239      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
240#else
241      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
242#endif
243      IF (ierr.NE.NF_NOERR) THEN
244         PRINT*, 'physdem1: Failed to write controle data'
245         CALL abort
246      ENDIF
247
248! write mid-layer depths mlayer() !known from comsoil.h
249
250      ierr = NF_REDEF (nid) ! Enter NetCDF (re-)define mode
251      ! define variable
252#ifdef NC_DOUBLE
253      ierr = NF_DEF_VAR (nid,"soildepth",NF_DOUBLE,1,idim3,nvarid)
254#else
255      ierr = NF_DEF_VAR (nid,"soildepth",NF_FLOAT,1,idim3,nvarid)
256#endif
257      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 20,
258     .                        "Soil mid-layer depth")
259      ierr = NF_ENDDEF(nid) ! Leave NetCDF define mode
260      ! write variable
261#ifdef NC_DOUBLE
262      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,mlayer)
263#else
264      ierr = NF_PUT_VAR_REAL (nid,nvarid,mlayer)
265#endif
266
267c
268
269      ierr = NF_REDEF (nid)
270#ifdef NC_DOUBLE
271      ierr = NF_DEF_VAR (nid, "longitude", NF_DOUBLE, 1, idim2,nvarid)
272#else
273      ierr = NF_DEF_VAR (nid, "longitude", NF_FLOAT, 1, idim2,nvarid)
274#endif
275      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 26,
276     .                        "Longitudes of physics grid")
277      ierr = NF_ENDDEF(nid)
278
279#ifdef NC_DOUBLE
280      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lonfi)
281#else
282      ierr = NF_PUT_VAR_REAL (nid,nvarid,lonfi)
283#endif
284
285c
286
287      ierr = NF_REDEF (nid)
288#ifdef NC_DOUBLE
289      ierr = NF_DEF_VAR (nid, "latitude", NF_DOUBLE, 1, idim2,nvarid)
290#else
291      ierr = NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim2,nvarid)
292#endif
293      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 25,
294     .                        "Latitudes of physics grid")
295      ierr = NF_ENDDEF(nid)
296#ifdef NC_DOUBLE
297      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,latfi)
298#else
299      ierr = NF_PUT_VAR_REAL (nid,nvarid,latfi)
300#endif
301
302c
303
304      ierr = NF_REDEF (nid)
305#ifdef NC_DOUBLE
306      ierr = NF_DEF_VAR (nid, "area", NF_DOUBLE, 1, idim2,nvarid)
307#else
308      ierr = NF_DEF_VAR (nid, "area", NF_FLOAT, 1, idim2,nvarid)
309#endif
310      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
311     .                        "Mesh area")
312      ierr = NF_ENDDEF(nid)
313#ifdef NC_DOUBLE
314      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area)
315#else
316      ierr = NF_PUT_VAR_REAL (nid,nvarid,area)
317#endif
318
319c
320
321      ierr = NF_REDEF (nid)
322#ifdef NC_DOUBLE
323      ierr = NF_DEF_VAR (nid, "phisfi", NF_DOUBLE, 1, idim2,nvarid)
324#else
325      ierr = NF_DEF_VAR (nid, "phisfi", NF_FLOAT, 1, idim2,nvarid)
326#endif
327      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 27,
328     .                        "Geopotential at the surface")
329      ierr = NF_ENDDEF(nid)
330#ifdef NC_DOUBLE
331      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phisfipal)
332#else
333      ierr = NF_PUT_VAR_REAL (nid,nvarid,phisfipal)
334#endif
335
336c
337
338      ierr = NF_REDEF (nid)
339#ifdef NC_DOUBLE
340      ierr = NF_DEF_VAR (nid, "albedodat", NF_DOUBLE, 1, idim2,nvarid)
341#else
342      ierr = NF_DEF_VAR (nid, "albedodat", NF_FLOAT, 1, idim2,nvarid)
343#endif
344      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 21,
345     .                        "Albedo of bare ground")
346      ierr = NF_ENDDEF(nid)
347#ifdef NC_DOUBLE
348      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,albedodat)
349#else
350      ierr = NF_PUT_VAR_REAL (nid,nvarid,albedodat)
351#endif
352
353c
354c   some data for Francois Lott programs
355c
356
357      ierr = NF_REDEF (nid)
358#ifdef NC_DOUBLE
359      ierr = NF_DEF_VAR (nid, "ZMEA", NF_DOUBLE, 1, idim2,nvarid)
360#else
361      ierr = NF_DEF_VAR (nid, "ZMEA", NF_FLOAT, 1, idim2,nvarid)
362#endif
363      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19,
364     .                        "Relief: mean relief")
365      ierr = NF_ENDDEF(nid)
366#ifdef NC_DOUBLE
367      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zmea)
368#else
369      ierr = NF_PUT_VAR_REAL (nid,nvarid,zmea)
370#endif
371c
372      ierr = NF_REDEF (nid)
373#ifdef NC_DOUBLE
374      ierr = NF_DEF_VAR (nid, "ZSTD", NF_DOUBLE, 1, idim2,nvarid)
375#else
376      ierr = NF_DEF_VAR (nid, "ZSTD", NF_FLOAT, 1, idim2,nvarid)
377#endif
378      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 26,
379     .                        "Relief: standard deviation")
380      ierr = NF_ENDDEF(nid)
381#ifdef NC_DOUBLE
382      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zstd)
383#else
384      ierr = NF_PUT_VAR_REAL (nid,nvarid,zstd)
385#endif
386c
387      ierr = NF_REDEF (nid)
388#ifdef NC_DOUBLE
389      ierr = NF_DEF_VAR (nid, "ZSIG", NF_DOUBLE, 1, idim2,nvarid)
390#else
391      ierr = NF_DEF_VAR (nid, "ZSIG", NF_FLOAT, 1, idim2,nvarid)
392#endif
393      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
394     .                        "Relief: sigma parameter")
395      ierr = NF_ENDDEF(nid)
396#ifdef NC_DOUBLE
397      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zsig)
398#else
399      ierr = NF_PUT_VAR_REAL (nid,nvarid,zsig)
400#endif
401c
402      ierr = NF_REDEF (nid)
403#ifdef NC_DOUBLE
404      ierr = NF_DEF_VAR (nid, "ZGAM", NF_DOUBLE, 1, idim2,nvarid)
405#else
406      ierr = NF_DEF_VAR (nid, "ZGAM", NF_FLOAT, 1, idim2,nvarid)
407#endif
408      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
409     .                        "Relief: gamma parameter")
410      ierr = NF_ENDDEF(nid)
411#ifdef NC_DOUBLE
412      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zgam)
413#else
414      ierr = NF_PUT_VAR_REAL (nid,nvarid,zgam)
415#endif
416c
417      ierr = NF_REDEF (nid)
418#ifdef NC_DOUBLE
419      ierr = NF_DEF_VAR (nid, "ZTHE", NF_DOUBLE, 1, idim2,nvarid)
420#else
421      ierr = NF_DEF_VAR (nid, "ZTHE", NF_FLOAT, 1, idim2,nvarid)
422#endif
423      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
424     .                        "Relief: theta parameter")
425      ierr = NF_ENDDEF(nid)
426#ifdef NC_DOUBLE
427      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zthe)
428#else
429      ierr = NF_PUT_VAR_REAL (nid,nvarid,zthe)
430#endif
431
432c Write the physical fields
433
434! Soil Thermal inertia
435
436      ierr = NF_REDEF (nid)
437#ifdef NC_DOUBLE
438      ierr = NF_DEF_VAR (nid,"inertiedat",NF_DOUBLE,
439     &                   2,(/idim2,idim3/),nvarid)
440#else
441      ierr = NF_DEF_VAR (nid,"inertiedat",NF_FLOAT,
442     &                   2,(/idim2,idim3/),nvarid)
443#endif
444      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 20,
445     .                        "Soil thermal inertia")
446      ierr = NF_ENDDEF(nid)
447#ifdef NC_DOUBLE
448      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,inertiedat)
449#else
450      ierr = NF_PUT_VAR_REAL (nid,nvarid,inertiedat)
451#endif
452
453!  Surface temperature
454
455      ierr = NF_REDEF (nid)
456#ifdef NC_DOUBLE
457      ierr = NF_DEF_VAR (nid, "tsurf", NF_DOUBLE, 1, idim2,nvarid)
458#else
459      ierr = NF_DEF_VAR (nid, "tsurf", NF_FLOAT, 1, idim2,nvarid)
460#endif
461      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19,
462     .                        "Surface temperature")
463      ierr = NF_ENDDEF(nid)
464#ifdef NC_DOUBLE
465      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tsurf)
466#else
467      ierr = NF_PUT_VAR_REAL (nid,nvarid,tsurf)
468#endif
469
470! Soil temperature
471
472      ierr = NF_REDEF (nid)
473#ifdef NC_DOUBLE
474      ierr = NF_DEF_VAR (nid,"tsoil",NF_DOUBLE,2,(/idim2,idim3/),nvarid)
475#else
476!      ierr = NF_DEF_VAR (nid, "tsoil", NF_FLOAT, 2, idim2,nvarid)
477      ierr = NF_DEF_VAR (nid,"tsoil",NF_FLOAT,2,(/idim2,idim3/),nvarid)
478#endif
479      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 16,
480     .                        "Soil temperature")
481      ierr = NF_ENDDEF(nid)
482#ifdef NC_DOUBLE
483      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tsoil)
484#else
485      ierr = NF_PUT_VAR_REAL (nid,nvarid,tsoil)
486#endif
487
488c emissivity
489
490      ierr = NF_REDEF (nid)
491#ifdef NC_DOUBLE
492      ierr = NF_DEF_VAR (nid, "emis", NF_DOUBLE, 1, idim2,nvarid)
493#else
494      ierr = NF_DEF_VAR (nid, "emis", NF_FLOAT, 1, idim2,nvarid)
495#endif
496      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 18,
497     .                        "Surface emissivity")
498      ierr = NF_ENDDEF(nid)
499#ifdef NC_DOUBLE
500      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,emis)
501#else
502      ierr = NF_PUT_VAR_REAL (nid,nvarid,emis)
503#endif
504
505c planetary boundary layer
506
507      ierr = NF_REDEF (nid)
508#ifdef NC_DOUBLE
509      ierr = NF_DEF_VAR(nid,"q2",NF_DOUBLE, 2,(/idim2,idim4/),nvarid)
510#else
511      ierr = NF_DEF_VAR (nid, "q2", NF_FLOAT, 2,(/idim2,idim4/),nvarid)
512#endif
513      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 17,
514     .                        "pbl wind variance")
515      ierr = NF_ENDDEF(nid)
516#ifdef NC_DOUBLE
517      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,q2)
518#else
519      ierr = NF_PUT_VAR_REAL (nid,nvarid,q2)
520#endif
521      IF (ierr.NE.NF_NOERR) THEN
522        PRINT*, 'physdem1: Failed to write q2'
523        CALL abort
524      ENDIF
525
526c tracers
527
528! Preliminary stuff: check if tracers follow old naming convention (qsurf01,
529!                    qsurf02, ...)
530      count=0
531      do iq=1,nqmx
532        txt= " "
533        write(txt,'(a1,i2.2)')'q',iq
534        if (txt.ne.tnom(iq)) then ! use tracer names stored in dynamics
535          ! did not find old tracer name
536          exit ! might as well stop here
537        else
538          ! found old tracer name
539          count=count+1
540        endif
541      enddo
542      if (count.eq.nqmx) then
543        write(*,*) "physdem1:tracers seem to follow old naming ",
544     &             "convention (qsurf01,qsurf02,...)"
545
546        call abort
547      endif ! of if (count.eq.nqmx)
548
549      IF(nq.GE.1) THEN
550         DO iq=1,nq
551           txt=tnom(iq)
552
553           ierr=NF_REDEF(nid)
554           IF (ierr.NE.NF_NOERR) THEN
555             PRINT*, 'physdem1: Failed to swich to NetCDF define mode'
556             CALL abort
557           ENDIF
558#ifdef NC_DOUBLE
559           ierr=NF_DEF_VAR(nid,txt,NF_DOUBLE,1,idim2,nvarid)
560#else
561           ierr=NF_DEF_VAR(nid,txt,NF_FLOAT,1,idim2,nvarid)
562#endif
563           IF (ierr.NE.NF_NOERR) THEN
564             PRINT*, 'physdem1: Failed to define ',trim(txt)
565             CALL abort
566           ENDIF
567           ierr=NF_PUT_ATT_TEXT (nid, nvarid, "title", 17,
568     &                        "tracer on surface")
569           IF (ierr.NE.NF_NOERR) THEN
570             PRINT*, 'physdem1: Failed to define ',trim(txt),
571     &               ' title attribute'
572             CALL abort
573           ENDIF
574           ierr=NF_ENDDEF(nid)
575           IF (ierr.NE.NF_NOERR) THEN
576             PRINT*, 'physdem1: Failed to swich out of define mode'
577             CALL abort
578           ENDIF
579           
580#ifdef NC_DOUBLE
581            ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,qsurf(1,iq))
582#else
583            ierr=NF_PUT_VAR_REAL (nid,nvarid,qsurf(1,iq))
584#endif
585           IF (ierr.NE.NF_NOERR) THEN
586             PRINT*, 'physdem1: Failed to write ',trim(txt)
587             CALL abort
588           ENDIF
589         ENDDO ! of DO iq=1,nq
590      ENDIF ! of IF(nq.GE.1)
591
592c close file
593      ierr = NF_CLOSE(nid)
594
595      RETURN
596
597      END
Note: See TracBrowser for help on using the repository browser.