source: trunk/LMDZ.MARS/libf/phymars/inistats.F @ 1524

Last change on this file since 1524 was 1524, checked in by emillour, 9 years ago

All GCMS:
More updates to enforce dynamics/physics separation:

get rid of references to "temps_mod" from physics packages;
make a "time_phylmdz_mod.F90" module to store that
information and fill it via "iniphysiq".

EM

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