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 | write (*,*) 'istime=',istime |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | if (abs(float(nsteppd)-daysec/dtphys).gt.1.e-8*daysec) |
---|
33 | , stop'Dans Instat: 1jour .ne. n pas physiques' |
---|
34 | |
---|
35 | |
---|
36 | if(mod(nsteppd,istime).ne.0) |
---|
37 | , stop'Dans Instat: 1jour .ne. n*istime pas physiques' |
---|
38 | |
---|
39 | istats=nsteppd/istime |
---|
40 | write (*,*) 'istats=',istats |
---|
41 | write (*,*) 'Storing ',istime,'times per day' |
---|
42 | write (*,*) 'thus every ',istats,'physical timestep ' |
---|
43 | write (*,*) |
---|
44 | |
---|
45 | do l= 1, llm |
---|
46 | sig_s(l)=((ap(l)+ap(l+1))/preff+bp(l)+bp(l+1))/2. |
---|
47 | pseudoalt(l)=-15.*log(presnivs(l)/preff) |
---|
48 | enddo |
---|
49 | |
---|
50 | ierr = NF_CREATE("stats.nc",NF_CLOBBER,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(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(nid,"latitude","latitude","degrees_north",1, |
---|
69 | . 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(nid,"longitude","East longitude","degrees_east",1, |
---|
76 | . 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(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(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 | end |
---|