source: trunk/LMDZ.GENERIC/libf/phystd/inistats.F @ 1157

Last change on this file since 1157 was 965, checked in by emillour, 12 years ago

Common dynamics and generic/universal GCM:

  • LMDZ.COMMON: minor bug fix on the computation of physics mesh area in gcm.F
  • LMDZ.UNIVERSAL: missing clean initialization of tab_cntrl(:) array in phyredem.F90
  • LMDZ.GENERIC: minor bug fix in hydrol.F90, only output runoff if it is used. Update output routines so that all outputs files (stats, diagfi.nc, diagsoil.nc, diagspecIR.nc and diagspecVI.nc) can be generated when running LMDZ.UNIVERSAL in MPI mode.

EM

File size: 3.7 KB
Line 
1      subroutine inistats(ierr)
2
3#ifdef CPP_PARA
4      use mod_phys_lmdz_para, only : is_master
5#endif
6      implicit none
7
8#include "dimensions.h"
9#include "paramet.h"
10#include "comgeom.h"
11#include "comvert.h"
12#include "comconst.h"
13#include "statto.h"
14#include "netcdf.inc"
15
16#ifndef CPP_PARA
17      logical,parameter :: is_master=.true.
18#endif
19      integer,intent(out) :: ierr
20      integer :: nid
21      integer :: l,nsteppd
22      real, dimension(llm) ::  sig_s
23      integer :: idim_lat,idim_lon,idim_llm,idim_llmp1,idim_time
24      real, dimension(istime) :: lt
25      integer :: nvarid
26
27      write (*,*)
28      write (*,*) '                        || STATS ||'
29      write (*,*)
30      write (*,*) 'daysec',daysec
31      write (*,*) 'dtphys',dtphys
32      nsteppd=nint(daysec/dtphys)
33      write (*,*) 'nsteppd=',nsteppd
34      write (*,*) 'istime=',istime
35
36
37
38      if (abs(float(nsteppd)-daysec/dtphys).gt.1.e-8*daysec)
39     ,   stop'Dans Instat:  1jour .ne. n pas physiques'
40
41
42      if(mod(nsteppd,istime).ne.0)
43     ,   stop'Dans Instat:  1jour .ne. n*istime pas physiques'
44
45      istats=nsteppd/istime
46      write (*,*) 'istats=',istats
47      write (*,*) 'Storing ',istime,'times per day'
48      write (*,*) 'thus every ',istats,'physical timestep '
49      write (*,*)
50
51      do l= 1, llm
52         sig_s(l)=((ap(l)+ap(l+1))/preff+bp(l)+bp(l+1))/2.
53         pseudoalt(l)=-10.*log(presnivs(l)/preff)   
54      enddo
55
56      if (is_master) then
57      ! only the master needs do this
58
59      ierr = NF_CREATE("stats.nc",NF_CLOBBER,nid)
60      if (ierr.ne.NF_NOERR) then
61         write (*,*) NF_STRERROR(ierr)
62         stop ""
63      endif
64
65      ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_lat)
66      ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_lon)
67      ierr = NF_DEF_DIM (nid, "altitude", llm, idim_llm)
68      ierr = NF_DEF_DIM (nid, "llmp1", llm+1, idim_llmp1)
69      ierr = NF_DEF_DIM (nid, "Time", NF_UNLIMITED, idim_time)
70
71      ierr = NF_ENDDEF(nid)
72      call def_var(nid,"Time","Time",
73     .            "days since 0000-00-0 00:00:00",1,
74     .            idim_time,nvarid,ierr)
75! Time is initialised later by mkstats subroutine
76
77      call def_var(nid,"latitude","latitude","degrees_north",1,
78     .            idim_lat,nvarid,ierr)
79#ifdef NC_DOUBLE
80      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180)
81#else
82      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180)
83#endif
84      call def_var(nid,"longitude","East longitude","degrees_east",1,
85     .            idim_lon,nvarid,ierr)
86#ifdef NC_DOUBLE
87      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180)
88#else
89      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180)
90#endif
91
92! Niveaux verticaux, aps et bps
93      ierr = NF_REDEF (nid)
94#ifdef NC_DOUBLE
95      ierr = NF_DEF_VAR (nid,"altitude", NF_DOUBLE, 1,idim_llm,nvarid)
96#else
97      ierr = NF_DEF_VAR (nid,"altitude", NF_FLOAT, 1,idim_llm,nvarid)
98#endif
99      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name",8,"altitude")
100      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km")
101      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up")
102      ierr = NF_ENDDEF(nid)
103#ifdef NC_DOUBLE
104      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pseudoalt)
105#else
106      ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt)
107#endif
108      call def_var(nid,"aps","hybrid pressure at midlayers"," ",
109     .            1,idim_llm,nvarid,ierr)
110#ifdef NC_DOUBLE
111      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps)
112#else
113      ierr = NF_PUT_VAR_REAL (nid,nvarid,aps)
114#endif
115
116      call def_var(nid,"bps","hybrid sigma at midlayers"," ",
117     .            1,idim_llm,nvarid,ierr)
118#ifdef NC_DOUBLE
119      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps)
120#else
121      ierr = NF_PUT_VAR_REAL (nid,nvarid,bps)
122#endif
123
124      ierr=NF_CLOSE(nid)
125
126      endif ! of if (is_master)
127      end
Note: See TracBrowser for help on using the repository browser.