1 | SUBROUTINE iniav(fichnom,pday0,pyear0,pfrac0,pperiod,phis,nq) |
---|
2 | |
---|
3 | USE comvert_mod, ONLY: ap,bp,nivsigs,nivsig,presnivs |
---|
4 | |
---|
5 | IMPLICIT NONE |
---|
6 | |
---|
7 | c======================================================================= |
---|
8 | c |
---|
9 | c pday0 jour de reference pour le stockage |
---|
10 | c pfrac0 decalage du debut du stockage par rapport a pday0 (en jour) |
---|
11 | c pperiod period de stockage en secondes |
---|
12 | c phis geopotentiel au sol |
---|
13 | c |
---|
14 | c initialisation de l'ecriture des moyennes temporelles. |
---|
15 | c |
---|
16 | c======================================================================= |
---|
17 | |
---|
18 | #include "dimensions.h" |
---|
19 | #include "paramet.h" |
---|
20 | #include "comav.h" |
---|
21 | #include "netcdf.inc" |
---|
22 | #include "comgeom.h" |
---|
23 | |
---|
24 | REAL pperiod |
---|
25 | |
---|
26 | INTEGER*4 pday0,pyear0 |
---|
27 | REAL pfrac0 |
---|
28 | CHARACTER*(*) fichnom |
---|
29 | REAL phis(ip1jmp1) |
---|
30 | c |
---|
31 | CHARACTER str3*3 |
---|
32 | c |
---|
33 | INTEGER nq |
---|
34 | INTEGER ierr, nid, nvarid, iq |
---|
35 | INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv |
---|
36 | INTEGER idim_s, idim_sig |
---|
37 | INTEGER idim_tim |
---|
38 | INTEGER dims2(2), dims3(3), dims4(4) |
---|
39 | |
---|
40 | period_av=pperiod |
---|
41 | time0_av=pfrac0 |
---|
42 | c |
---|
43 | ierr = NF_CREATE(fichnom, NF_CLOBBER, nid) |
---|
44 | IF (ierr.NE.NF_NOERR) THEN |
---|
45 | WRITE(6,*)" Pb d ouverture du fichier "//fichnom |
---|
46 | WRITE(6,*)' ierr = ', ierr |
---|
47 | CALL ABORT |
---|
48 | ENDIF |
---|
49 | c |
---|
50 | c Preciser quelques attributs globaux: |
---|
51 | c |
---|
52 | ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 32, |
---|
53 | . "Fichier moyen histoire dynamique") |
---|
54 | c |
---|
55 | c Definir les dimensions du fichiers: |
---|
56 | c |
---|
57 | ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) |
---|
58 | ierr = NF_DEF_DIM (nid, "rlatu", jjp1, idim_rlatu) |
---|
59 | ierr = NF_DEF_DIM (nid, "rlonv", iip1, idim_rlonv) |
---|
60 | ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) |
---|
61 | ierr = NF_DEF_DIM (nid, "sigs", llm, idim_s) |
---|
62 | ierr = NF_DEF_DIM (nid, "sig", llmp1, idim_sig) |
---|
63 | ierr = NF_DEF_DIM (nid, "temps", NF_UNLIMITED, idim_tim) |
---|
64 | c |
---|
65 | ierr = NF_ENDDEF(nid) ! sortir du mode de definition |
---|
66 | c |
---|
67 | c Definir et enregistrer certains champs invariants: |
---|
68 | c |
---|
69 | c |
---|
70 | ierr = NF_REDEF (nid) |
---|
71 | ccc ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid) |
---|
72 | ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid) |
---|
73 | ierr = NF_ENDDEF(nid) |
---|
74 | #ifdef NC_DOUBLE |
---|
75 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu) |
---|
76 | #else |
---|
77 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu) |
---|
78 | #endif |
---|
79 | c |
---|
80 | ierr = NF_REDEF (nid) |
---|
81 | ccc ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid) |
---|
82 | ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid) |
---|
83 | ierr = NF_ENDDEF(nid) |
---|
84 | #ifdef NC_DOUBLE |
---|
85 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu) |
---|
86 | #else |
---|
87 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu) |
---|
88 | #endif |
---|
89 | c |
---|
90 | ierr = NF_REDEF (nid) |
---|
91 | ccc ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid) |
---|
92 | ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid) |
---|
93 | ierr = NF_ENDDEF(nid) |
---|
94 | #ifdef NC_DOUBLE |
---|
95 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv) |
---|
96 | #else |
---|
97 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv) |
---|
98 | #endif |
---|
99 | c |
---|
100 | ierr = NF_REDEF (nid) |
---|
101 | ccc ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid) |
---|
102 | ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid) |
---|
103 | ierr = NF_ENDDEF(nid) |
---|
104 | #ifdef NC_DOUBLE |
---|
105 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv) |
---|
106 | #else |
---|
107 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv) |
---|
108 | #endif |
---|
109 | c |
---|
110 | ierr = NF_REDEF (nid) |
---|
111 | ccc ierr = NF_DEF_VAR (nid,"nivsigs",NF_DOUBLE,1,idim_s,nvarid) |
---|
112 | ierr = NF_DEF_VAR (nid,"nivsigs",NF_FLOAT,1,idim_s,nvarid) |
---|
113 | ierr = NF_ENDDEF(nid) |
---|
114 | #ifdef NC_DOUBLE |
---|
115 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsigs) |
---|
116 | #else |
---|
117 | ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsigs) |
---|
118 | #endif |
---|
119 | c |
---|
120 | ierr = NF_REDEF (nid) |
---|
121 | ccc ierr = NF_DEF_VAR (nid,"nivsig",NF_DOUBLE,1,idim_sig,nvarid) |
---|
122 | ierr = NF_DEF_VAR (nid,"nivsig",NF_FLOAT,1,idim_sig,nvarid) |
---|
123 | ierr = NF_ENDDEF(nid) |
---|
124 | #ifdef NC_DOUBLE |
---|
125 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsig) |
---|
126 | #else |
---|
127 | ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsig) |
---|
128 | #endif |
---|
129 | c |
---|
130 | ierr = NF_REDEF (nid) |
---|
131 | ccc ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_sig,nvarid) |
---|
132 | ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_sig,nvarid) |
---|
133 | ierr = NF_ENDDEF(nid) |
---|
134 | #ifdef NC_DOUBLE |
---|
135 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap) |
---|
136 | #else |
---|
137 | ierr = NF_PUT_VAR_REAL (nid,nvarid,ap) |
---|
138 | #endif |
---|
139 | c |
---|
140 | ierr = NF_REDEF (nid) |
---|
141 | ccc ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_sig,nvarid) |
---|
142 | ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_sig,nvarid) |
---|
143 | ierr = NF_ENDDEF(nid) |
---|
144 | #ifdef NC_DOUBLE |
---|
145 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp) |
---|
146 | #else |
---|
147 | ierr = NF_PUT_VAR_REAL (nid,nvarid,bp) |
---|
148 | #endif |
---|
149 | c |
---|
150 | ierr = NF_REDEF (nid) |
---|
151 | ccc ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_s,nvarid) |
---|
152 | ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_s,nvarid) |
---|
153 | ierr = NF_ENDDEF(nid) |
---|
154 | #ifdef NC_DOUBLE |
---|
155 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,presnivs) |
---|
156 | #else |
---|
157 | ierr = NF_PUT_VAR_REAL (nid,nvarid,presnivs) |
---|
158 | #endif |
---|
159 | c |
---|
160 | c Geopentiel au sol: |
---|
161 | c |
---|
162 | ierr = NF_REDEF (nid) |
---|
163 | dims2(1) = idim_rlonv |
---|
164 | dims2(2) = idim_rlatu |
---|
165 | ccc ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid) |
---|
166 | ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid) |
---|
167 | ierr = NF_ENDDEF(nid) |
---|
168 | #ifdef NC_DOUBLE |
---|
169 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis) |
---|
170 | #else |
---|
171 | ierr = NF_PUT_VAR_REAL (nid,nvarid,phis) |
---|
172 | #endif |
---|
173 | c |
---|
174 | c Definir les variables pour pouvoir les enregistrer plus tard: |
---|
175 | c |
---|
176 | ierr = NF_REDEF (nid) ! entrer dans le mode de definition |
---|
177 | c |
---|
178 | ccc ierr = NF_DEF_VAR (nid,"temps",NF_DOUBLE,1,idim_tim,nvarid) |
---|
179 | ierr = NF_DEF_VAR (nid,"temps",NF_FLOAT,1,idim_tim,nvarid) |
---|
180 | IF (ierr .NE. NF_NOERR) THEN |
---|
181 | PRINT*, "iniav: Erreur pour definir <temps>" |
---|
182 | CALL abort |
---|
183 | ENDIF |
---|
184 | c |
---|
185 | dims4(1) = idim_rlonu |
---|
186 | dims4(2) = idim_rlatu |
---|
187 | dims4(3) = idim_s |
---|
188 | dims4(4) = idim_tim |
---|
189 | ccc ierr = NF_DEF_VAR (nid,"vitu",NF_DOUBLE,4,dims4,nvarid) |
---|
190 | ierr = NF_DEF_VAR (nid,"vitu",NF_FLOAT,4,dims4,nvarid) |
---|
191 | c |
---|
192 | dims4(1) = idim_rlonv |
---|
193 | dims4(2) = idim_rlatv |
---|
194 | dims4(3) = idim_s |
---|
195 | dims4(4) = idim_tim |
---|
196 | ccc ierr = NF_DEF_VAR (nid,"vitv",NF_DOUBLE,4,dims4,nvarid) |
---|
197 | ierr = NF_DEF_VAR (nid,"vitv",NF_FLOAT,4,dims4,nvarid) |
---|
198 | c |
---|
199 | dims4(1) = idim_rlonv |
---|
200 | dims4(2) = idim_rlatu |
---|
201 | dims4(3) = idim_s |
---|
202 | dims4(4) = idim_tim |
---|
203 | ccc ierr = NF_DEF_VAR (nid,"temp",NF_DOUBLE,4,dims4,nvarid) |
---|
204 | ierr = NF_DEF_VAR (nid,"temp",NF_FLOAT,4,dims4,nvarid) |
---|
205 | c |
---|
206 | dims4(1) = idim_rlonv |
---|
207 | dims4(2) = idim_rlatu |
---|
208 | dims4(3) = idim_s |
---|
209 | dims4(4) = idim_tim |
---|
210 | IF(nq.GE.1) THEN |
---|
211 | DO iq=1,nq |
---|
212 | IF (iq.GT.99) THEN |
---|
213 | PRINT*, "Trop de traceurs" |
---|
214 | CALL abort |
---|
215 | ELSE |
---|
216 | str3(1:1)='q' |
---|
217 | WRITE(str3(2:3),'(i2.2)') iq |
---|
218 | ccc ierr = NF_DEF_VAR (nid,str3,NF_DOUBLE,4,dims4,nvarid) |
---|
219 | ierr = NF_DEF_VAR (nid,str3,NF_FLOAT,4,dims4,nvarid) |
---|
220 | ENDIF |
---|
221 | ENDDO |
---|
222 | ENDIF |
---|
223 | c |
---|
224 | dims3(1) = idim_rlonv |
---|
225 | dims3(2) = idim_rlatu |
---|
226 | dims3(3) = idim_tim |
---|
227 | ccc ierr = NF_DEF_VAR (nid,"ps",NF_DOUBLE,3,dims3,nvarid) |
---|
228 | ierr = NF_DEF_VAR (nid,"ps",NF_FLOAT,3,dims3,nvarid) |
---|
229 | c |
---|
230 | ierr = NF_ENDDEF(nid) ! sortir du mode de definition |
---|
231 | ierr = NF_CLOSE(nid) ! fermer le fichier |
---|
232 | |
---|
233 | PRINT*,'le fichier hist.moy stoke les variables toutes' |
---|
234 | PRINT*,'les ',period_av,'s' |
---|
235 | PRINT*,'A partir du jour de reference day0' |
---|
236 | RETURN |
---|
237 | END |
---|