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

Last change on this file since 190 was 38, checked in by emillour, 14 years ago

Ajout du modè Martien (mon LMDZ.MARS.BETA, du 28/01/2011) dans le rértoire mars, pour pouvoir suivre plus facilement les modifs.
EM

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