1 | ! |
---|
2 | ! $Header$ |
---|
3 | ! |
---|
4 | ! This subroutine creates the file grilles_gcm.nc containg longitudes and |
---|
5 | ! latitudes in degrees for grid u and v. This subroutine is called from |
---|
6 | ! ce0l if grilles_gcm_netcdf=TRUE. This subroutine corresponds to the first |
---|
7 | ! part in the program create_fausse_var. |
---|
8 | ! |
---|
9 | SUBROUTINE grilles_gcm_netcdf_sub(masque,phis) |
---|
10 | |
---|
11 | USE comvert_mod, ONLY: pa,preff,presnivs |
---|
12 | USE comconst_mod, ONLY: daysec,rad,omeg,g,kappa,cpp,pi |
---|
13 | |
---|
14 | IMPLICIT NONE |
---|
15 | |
---|
16 | INCLUDE "dimensions.h" |
---|
17 | INCLUDE "paramet.h" |
---|
18 | INCLUDE "comgeom.h" |
---|
19 | INCLUDE "netcdf.inc" |
---|
20 | |
---|
21 | |
---|
22 | REAL,DIMENSION(iip1,jjp1),INTENT(IN) :: masque ! masque terre/mer |
---|
23 | REAL,DIMENSION(iip1,jjp1),INTENT(IN) :: phis ! geopotentiel au sol |
---|
24 | |
---|
25 | REAL temp(iim+1,jjm+1) |
---|
26 | ! Attributs netcdf sortie |
---|
27 | INTEGER ncid_out,rcode_out |
---|
28 | INTEGER out_lonuid,out_lonvid,out_latuid,out_latvid,out_levid |
---|
29 | INTEGER out_varid |
---|
30 | INTEGER out_lonudim,out_lonvdim |
---|
31 | INTEGER out_latudim,out_latvdim,out_dim(3) |
---|
32 | INTEGER out_levdim |
---|
33 | |
---|
34 | INTEGER start(4),COUNT(4) |
---|
35 | |
---|
36 | INTEGER status,i,j |
---|
37 | REAL rlatudeg(jjp1),rlatvdeg(jjm),rlevdeg(llm) |
---|
38 | REAL rlonudeg(iip1),rlonvdeg(iip1) |
---|
39 | |
---|
40 | REAL dlon1(iip1),dlon2(iip1),dlat1(jjp1),dlat2(jjp1) |
---|
41 | REAL acoslat,dxkm,dykm,resol(iip1,jjp1) |
---|
42 | REAL,DIMENSION(iip1,jjp1) :: phis_loc |
---|
43 | INTEGER masque_int(iip1,jjp1) |
---|
44 | INTEGER :: phis_id |
---|
45 | INTEGER :: area_id |
---|
46 | INTEGER :: mask_id |
---|
47 | |
---|
48 | rad = 6400000 |
---|
49 | omeg = 7.272205e-05 |
---|
50 | g = 9.8 |
---|
51 | kappa = 0.285716 |
---|
52 | daysec = 86400 |
---|
53 | cpp = 1004.70885 |
---|
54 | |
---|
55 | preff = 101325. |
---|
56 | pa= 50000. |
---|
57 | |
---|
58 | CALL conf_gcm( 99, .TRUE. ) |
---|
59 | CALL iniconst |
---|
60 | CALL inigeom |
---|
61 | |
---|
62 | DO j=1,jjp1 |
---|
63 | rlatudeg(j)=rlatu(j)*180./pi |
---|
64 | ENDDO |
---|
65 | DO j=1,jjm |
---|
66 | rlatvdeg(j)=rlatv(j)*180./pi |
---|
67 | ENDDO |
---|
68 | |
---|
69 | DO i=1,iip1 |
---|
70 | rlonudeg(i)=rlonu(i)*180./pi + 360. |
---|
71 | rlonvdeg(i)=rlonv(i)*180./pi + 360. |
---|
72 | ENDDO |
---|
73 | |
---|
74 | |
---|
75 | ! 2 ----- OUVERTURE DE LA SORTIE NETCDF |
---|
76 | ! --------------------------------------------------- |
---|
77 | ! CREATION OUTPUT |
---|
78 | ! ouverture fichier netcdf de sortie out |
---|
79 | status=NF_CREATE('grilles_gcm.nc',NF_NOCLOBBER,ncid_out) |
---|
80 | status=NF_DEF_DIM(ncid_out,'lonu',iim+1,out_lonudim) |
---|
81 | status=NF_DEF_DIM(ncid_out,'lonv',iim+1,out_lonvdim) |
---|
82 | status=NF_DEF_DIM(ncid_out,'latu',jjm+1,out_latudim) |
---|
83 | status=NF_DEF_DIM(ncid_out,'latv',jjm,out_latvdim) |
---|
84 | |
---|
85 | |
---|
86 | ! Longitudes en u |
---|
87 | status=NF_DEF_VAR(ncid_out,'lonu',NF_FLOAT,1,[out_lonudim], out_lonuid) |
---|
88 | CALL handle_err(status) |
---|
89 | status=NF_PUT_ATT_TEXT(ncid_out,out_lonuid,'units', 12,'degrees_east') |
---|
90 | status=NF_PUT_ATT_TEXT(ncid_out,out_lonuid,'long_name',9,'Longitude en u') |
---|
91 | |
---|
92 | ! Longitudes en v |
---|
93 | status=NF_DEF_VAR(ncid_out,'lonv',NF_FLOAT,1,[out_lonvdim], out_lonvid) |
---|
94 | CALL handle_err(status) |
---|
95 | status=NF_PUT_ATT_TEXT(ncid_out,out_lonvid,'units', 12,'degrees_east') |
---|
96 | status=NF_PUT_ATT_TEXT(ncid_out,out_lonvid,'long_name', 9,'Longitude en v') |
---|
97 | |
---|
98 | ! Latitude en u |
---|
99 | status=NF_DEF_VAR(ncid_out,'latu',NF_FLOAT,1,[out_latudim], out_latuid) |
---|
100 | CALL handle_err(status) |
---|
101 | status=NF_PUT_ATT_TEXT(ncid_out,out_latuid,'units', 13,'degrees_north') |
---|
102 | status=NF_PUT_ATT_TEXT(ncid_out,out_latuid,'long_name', 8,'Latitude en u') |
---|
103 | |
---|
104 | ! Latitude en v |
---|
105 | status=NF_DEF_VAR(ncid_out,'latv',NF_FLOAT,1,[out_latvdim], out_latvid) |
---|
106 | CALL handle_err(status) |
---|
107 | status=NF_PUT_ATT_TEXT(ncid_out,out_latvid,'units', 13,'degrees_north') |
---|
108 | status=NF_PUT_ATT_TEXT(ncid_out,out_latvid,'long_name', 8,'Latitude en v') |
---|
109 | |
---|
110 | ! ecriture de la grille u |
---|
111 | out_dim(1)=out_lonudim |
---|
112 | out_dim(2)=out_latudim |
---|
113 | status=NF_DEF_VAR(ncid_out,'grille_u',NF_FLOAT,2,out_dim, out_varid) |
---|
114 | CALL handle_err(status) |
---|
115 | status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'units', 6,'Kelvin') |
---|
116 | status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'long_name', 16,'Grille aux point u') |
---|
117 | |
---|
118 | ! ecriture de la grille v |
---|
119 | out_dim(1)=out_lonvdim |
---|
120 | out_dim(2)=out_latvdim |
---|
121 | status=NF_DEF_VAR(ncid_out,'grille_v',NF_FLOAT,2,out_dim, out_varid) |
---|
122 | CALL handle_err(status) |
---|
123 | status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'units', 6,'Kelvin') |
---|
124 | status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'long_name', 16,'Grille aux point v') |
---|
125 | |
---|
126 | ! ecriture de la grille u |
---|
127 | out_dim(1)=out_lonvdim |
---|
128 | out_dim(2)=out_latudim |
---|
129 | status=NF_DEF_VAR(ncid_out,'grille_s',NF_FLOAT,2,out_dim, out_varid) |
---|
130 | CALL handle_err(status) |
---|
131 | status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'units', 6,'Kelvin') |
---|
132 | status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'long_name',16,'Grille aux point u') |
---|
133 | |
---|
134 | status=NF_ENDDEF(ncid_out) |
---|
135 | ! 5) ----- FERMETURE DES FICHIERS NETCDF------------------ |
---|
136 | ! -------------------------------------------------------- |
---|
137 | ! 3-b- Ecriture de la grille pour la sortie |
---|
138 | ! rajoute l'ecriture de la grille |
---|
139 | |
---|
140 | #ifdef NC_DOUBLE |
---|
141 | status=NF_PUT_VARA_DOUBLE(ncid_out,out_lonuid,[1],[iim+1],rlonudeg) |
---|
142 | status=NF_PUT_VARA_DOUBLE(ncid_out,out_lonvid,[1],[iim+1],rlonvdeg) |
---|
143 | status=NF_PUT_VARA_DOUBLE(ncid_out,out_latuid,[1],[jjm+1],rlatudeg) |
---|
144 | status=NF_PUT_VARA_DOUBLE(ncid_out,out_latvid,[1],[jjm],rlatvdeg) |
---|
145 | #else |
---|
146 | status=NF_PUT_VARA_REAL(ncid_out,out_lonuid,[1],[iim+1],rlonudeg) |
---|
147 | status=NF_PUT_VARA_REAL(ncid_out,out_lonvid,[1],[iim+1],rlonvdeg) |
---|
148 | status=NF_PUT_VARA_REAL(ncid_out,out_latuid,[1],[jjm+1],rlatudeg) |
---|
149 | status=NF_PUT_VARA_REAL(ncid_out,out_latvid,[1],[jjm],rlatvdeg) |
---|
150 | #endif |
---|
151 | |
---|
152 | start(1)=1 |
---|
153 | start(2)=1 |
---|
154 | start(3)=1 |
---|
155 | start(4)=1 |
---|
156 | |
---|
157 | COUNT(1)=iim+1 |
---|
158 | COUNT(2)=jjm+1 |
---|
159 | COUNT(3)=1 |
---|
160 | COUNT(4)=1 |
---|
161 | |
---|
162 | DO j=1,jjm+1 |
---|
163 | DO i=1,iim+1 |
---|
164 | temp(i,j)=MOD(i,2)+MOD(j,2) |
---|
165 | ENDDO |
---|
166 | ENDDO |
---|
167 | |
---|
168 | #ifdef NC_DOUBLE |
---|
169 | status=NF_PUT_VARA_DOUBLE(ncid_out,out_varid,start, count,temp) |
---|
170 | #else |
---|
171 | status=NF_PUT_VARA_REAL(ncid_out,out_varid,start, count,temp) |
---|
172 | #endif |
---|
173 | |
---|
174 | ! On re-ouvre le fichier pour rajouter 4 nouvelles variables necessaire pour INCA |
---|
175 | ! lev - phis - aire - mask |
---|
176 | rlevdeg(:) = presnivs |
---|
177 | phis_loc(:,:) = phis(:,:)/g |
---|
178 | |
---|
179 | ! niveaux de pression verticaux |
---|
180 | status = NF_REDEF (ncid_out) |
---|
181 | status=NF_DEF_DIM(ncid_out,'lev',llm,out_levdim) |
---|
182 | |
---|
183 | ! fields |
---|
184 | out_dim(1)=out_lonvdim |
---|
185 | out_dim(2)=out_latudim |
---|
186 | |
---|
187 | status = nf_def_var(ncid_out,'phis',NF_FLOAT,2,out_dim,phis_id) |
---|
188 | CALL handle_err(status) |
---|
189 | status = nf_def_var(ncid_out,'aire',NF_FLOAT,2,out_dim,area_id) |
---|
190 | CALL handle_err(status) |
---|
191 | status = nf_def_var(ncid_out,'mask',NF_INT ,2,out_dim,mask_id) |
---|
192 | CALL handle_err(status) |
---|
193 | |
---|
194 | status=NF_ENDDEF(ncid_out) |
---|
195 | |
---|
196 | ! ecriture des variables |
---|
197 | #ifdef NC_DOUBLE |
---|
198 | status=NF_PUT_VARA_DOUBLE(ncid_out,out_levid,[1],[llm],rlevdeg) |
---|
199 | #else |
---|
200 | status=NF_PUT_VARA_REAL(ncid_out,out_levid,[1],[llm],rlevdeg) |
---|
201 | #endif |
---|
202 | |
---|
203 | start(1)=1 |
---|
204 | start(2)=1 |
---|
205 | start(3)=1 |
---|
206 | start(4)=0 |
---|
207 | COUNT(1)=iip1 |
---|
208 | COUNT(2)=jjp1 |
---|
209 | COUNT(3)=1 |
---|
210 | COUNT(4)=0 |
---|
211 | |
---|
212 | status = nf_put_vara_double(ncid_out, phis_id,start,count, phis_loc) |
---|
213 | status = nf_put_vara_double(ncid_out, area_id,start,count, aire) |
---|
214 | masque_int(:,:) = nINT(masque(:,:)) |
---|
215 | status = nf_put_vara_int(ncid_out, mask_id,start,count,masque_int) |
---|
216 | CALL handle_err(status) |
---|
217 | |
---|
218 | ! fermeture du fichier netcdf |
---|
219 | CALL ncclos(ncid_out,rcode_out) |
---|
220 | |
---|
221 | END SUBROUTINE grilles_gcm_netcdf_sub |
---|
222 | |
---|
223 | |
---|
224 | |
---|
225 | SUBROUTINE handle_err(status) |
---|
226 | INCLUDE "netcdf.inc" |
---|
227 | |
---|
228 | INTEGER status |
---|
229 | IF (status.NE.nf_noerr) THEN |
---|
230 | PRINT *,NF_STRERROR(status) |
---|
231 | CALL abort_gcm('grilles_gcm_netcdf','netcdf error',1) |
---|
232 | ENDIF |
---|
233 | END SUBROUTINE handle_err |
---|
234 | |
---|