1 | !!!! Abderrahmane Idelkadi aout 2013 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
2 | ! Module pour definir (au 1er appel) et ecrire les variables dans les fichiers de sortie cosp |
---|
3 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
4 | MODULE cosp_output_write_mod |
---|
5 | |
---|
6 | USE cosp_output_mod |
---|
7 | |
---|
8 | INTEGER, SAVE :: itau_iocosp |
---|
9 | !$OMP THREADPRIVATE(itau_iocosp) |
---|
10 | INTEGER, save :: Nlevout, Ncolout |
---|
11 | !$OMP THREADPRIVATE(Nlevout, Ncolout) |
---|
12 | |
---|
13 | ! INTERFACE histwrite_cosp |
---|
14 | ! MODULE PROCEDURE histwrite2d_cosp,histwrite3d_cosp |
---|
15 | ! END INTERFACE |
---|
16 | |
---|
17 | CONTAINS |
---|
18 | |
---|
19 | SUBROUTINE cosp_output_write(Nlevlmdz, Npoints, Ncolumns, itap, dtime, freq_COSP, & |
---|
20 | cfg, gbx, vgrid, sglidar, sgradar, stlidar, stradar, & |
---|
21 | isccp, misr, modis) |
---|
22 | |
---|
23 | USE ioipsl |
---|
24 | USE time_phylmdz_mod, ONLY: itau_phy, start_time, day_step_phy |
---|
25 | USE print_control_mod, ONLY: lunout,prt_level |
---|
26 | |
---|
27 | #ifdef CPP_XIOS |
---|
28 | USE wxios, only: wxios_closedef |
---|
29 | USE xios, only: xios_update_calendar |
---|
30 | #endif |
---|
31 | |
---|
32 | !!! Variables d'entree |
---|
33 | integer :: itap, Nlevlmdz, Ncolumns, Npoints |
---|
34 | real :: freq_COSP, dtime |
---|
35 | type(cosp_config) :: cfg ! Control outputs |
---|
36 | type(cosp_gridbox) :: gbx ! Gridbox information. Input for COSP |
---|
37 | type(cosp_sglidar) :: sglidar ! Output from lidar simulator |
---|
38 | type(cosp_sgradar) :: sgradar ! Output from radar simulator |
---|
39 | type(cosp_isccp) :: isccp ! Output from ISCCP simulator |
---|
40 | type(cosp_lidarstats) :: stlidar ! Summary statistics from lidar simulator |
---|
41 | type(cosp_radarstats) :: stradar |
---|
42 | type(cosp_misr) :: misr ! Output from MISR |
---|
43 | type(cosp_modis) :: modis ! Outputs from Modis |
---|
44 | type(cosp_vgrid) :: vgrid ! Information on vertical grid of stats |
---|
45 | |
---|
46 | !!! Variables locales |
---|
47 | integer :: icl |
---|
48 | logical :: ok_sync |
---|
49 | integer :: itau_wcosp |
---|
50 | real, dimension(Npoints,PARASOL_NREFL) :: parasolcrefl, Ncref |
---|
51 | |
---|
52 | Nlevout = vgrid%Nlvgrid |
---|
53 | Ncolout = Ncolumns |
---|
54 | |
---|
55 | ! A refaire |
---|
56 | itau_wcosp = itau_phy + itap + start_time * day_step_phy |
---|
57 | if (prt_level >= 10) then |
---|
58 | WRITE(lunout,*)'itau_wcosp, itap, start_time, day_step_phy =', & |
---|
59 | itau_wcosp, itap, start_time, day_step_phy |
---|
60 | endif |
---|
61 | |
---|
62 | ! On le donne a cosp_output_write_mod pour que les histwrite y aient acces: |
---|
63 | CALL set_itau_iocosp(itau_wcosp) |
---|
64 | if (prt_level >= 10) then |
---|
65 | WRITE(lunout,*)'itau_iocosp =',itau_iocosp |
---|
66 | endif |
---|
67 | |
---|
68 | ok_sync = .TRUE. |
---|
69 | |
---|
70 | !DO iinit=1, iinitend |
---|
71 | ! AI sept 2014 cette boucle supprimee |
---|
72 | ! On n'ecrit pas quand itap=1 (cosp) |
---|
73 | |
---|
74 | if (prt_level >= 10) then |
---|
75 | WRITE(lunout,*)'DO iinit=1, iinitend ',iinitend |
---|
76 | endif |
---|
77 | |
---|
78 | !#ifdef CPP_XIOS |
---|
79 | ! !$OMP MASTER |
---|
80 | !IF (cosp_varsdefined) THEN |
---|
81 | ! if (prt_level >= 10) then |
---|
82 | ! WRITE(lunout,*)'Apell xios_update_calendar cosp_varsdefined iinitend ', & |
---|
83 | ! cosp_varsdefined,iinitend |
---|
84 | ! endif |
---|
85 | ! CALL xios_update_calendar(itau_wcosp) |
---|
86 | !ENDIF |
---|
87 | ! !$OMP END MASTER |
---|
88 | ! !$OMP BARRIER |
---|
89 | !#endif |
---|
90 | |
---|
91 | if (cfg%Llidar_sim) then |
---|
92 | ! Pb des valeurs indefinies, on les met a 0 |
---|
93 | ! A refaire proprement |
---|
94 | do k = 1,Nlevout |
---|
95 | do ip = 1,Npoints |
---|
96 | if(stlidar%lidarcld(ip,k).eq.R_UNDEF)then |
---|
97 | stlidar%lidarcld(ip,k)=Cosp_fill_value |
---|
98 | endif |
---|
99 | enddo |
---|
100 | |
---|
101 | do ii= 1,SR_BINS |
---|
102 | do ip = 1,Npoints |
---|
103 | if(stlidar%cfad_sr(ip,ii,k).eq.R_UNDEF)then |
---|
104 | stlidar%cfad_sr(ip,ii,k)=Cosp_fill_value |
---|
105 | endif |
---|
106 | enddo |
---|
107 | enddo |
---|
108 | enddo |
---|
109 | |
---|
110 | do ip = 1,Npoints |
---|
111 | do k = 1,Nlevlmdz |
---|
112 | if(sglidar%beta_mol(ip,k).eq.R_UNDEF)then |
---|
113 | sglidar%beta_mol(ip,k)=Cosp_fill_value |
---|
114 | endif |
---|
115 | |
---|
116 | do ii= 1,Ncolumns |
---|
117 | if(sglidar%beta_tot(ip,ii,k).eq.R_UNDEF)then |
---|
118 | sglidar%beta_tot(ip,ii,k)=Cosp_fill_value |
---|
119 | endif |
---|
120 | enddo |
---|
121 | |
---|
122 | enddo !k = 1,Nlevlmdz |
---|
123 | enddo !ip = 1,Npoints |
---|
124 | |
---|
125 | do k = 1,LIDAR_NCAT |
---|
126 | do ip = 1,Npoints |
---|
127 | if(stlidar%cldlayer(ip,k).eq.R_UNDEF)then |
---|
128 | stlidar%cldlayer(ip,k)=Cosp_fill_value |
---|
129 | endif |
---|
130 | enddo |
---|
131 | enddo |
---|
132 | |
---|
133 | ! AI 11 / 2015 |
---|
134 | |
---|
135 | where(stlidar%parasolrefl == R_UNDEF) stlidar%parasolrefl = 0.0 |
---|
136 | where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = 0.0 |
---|
137 | where(stlidar%cldlayerphase == R_UNDEF) stlidar%cldlayerphase = 0.0 |
---|
138 | where(stlidar%lidarcldphase == R_UNDEF) stlidar%lidarcldphase = 0.0 |
---|
139 | where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = 0.0 |
---|
140 | |
---|
141 | |
---|
142 | print*,'Appel histwrite2d_cosp' |
---|
143 | CALL histwrite2d_cosp(o_cllcalipso,stlidar%cldlayer(:,1)) |
---|
144 | CALL histwrite2d_cosp(o_clhcalipso,stlidar%cldlayer(:,3)) |
---|
145 | CALL histwrite2d_cosp(o_clmcalipso,stlidar%cldlayer(:,2)) |
---|
146 | CALL histwrite2d_cosp(o_cltcalipso,stlidar%cldlayer(:,4)) |
---|
147 | CALL histwrite3d_cosp(o_clcalipso,stlidar%lidarcld,nvert) |
---|
148 | CALL histwrite3d_cosp(o_clcalipsotmp,stlidar%lidarcldtmp(:,:,1),nverttemp) |
---|
149 | |
---|
150 | CALL histwrite2d_cosp(o_cllcalipsoice,stlidar%cldlayerphase(:,1,1)) |
---|
151 | CALL histwrite2d_cosp(o_clhcalipsoice,stlidar%cldlayerphase(:,3,1)) |
---|
152 | CALL histwrite2d_cosp(o_clmcalipsoice,stlidar%cldlayerphase(:,2,1)) |
---|
153 | CALL histwrite2d_cosp(o_cltcalipsoice,stlidar%cldlayerphase(:,4,1)) |
---|
154 | CALL histwrite3d_cosp(o_clcalipsoice,stlidar%lidarcldphase(:,:,1),nvert) |
---|
155 | CALL histwrite3d_cosp(o_clcalipsotmpice,stlidar%lidarcldtmp(:,:,2),nverttemp) |
---|
156 | |
---|
157 | CALL histwrite2d_cosp(o_cllcalipsoliq,stlidar%cldlayerphase(:,1,2)) |
---|
158 | CALL histwrite2d_cosp(o_clhcalipsoliq,stlidar%cldlayerphase(:,3,2)) |
---|
159 | CALL histwrite2d_cosp(o_clmcalipsoliq,stlidar%cldlayerphase(:,2,2)) |
---|
160 | CALL histwrite2d_cosp(o_cltcalipsoliq,stlidar%cldlayerphase(:,4,2)) |
---|
161 | CALL histwrite3d_cosp(o_clcalipsoliq,stlidar%lidarcldphase(:,:,2),nvert) |
---|
162 | CALL histwrite3d_cosp(o_clcalipsotmpliq,stlidar%lidarcldtmp(:,:,3),nverttemp) |
---|
163 | |
---|
164 | CALL histwrite2d_cosp(o_cllcalipsoun,stlidar%cldlayerphase(:,1,3)) |
---|
165 | CALL histwrite2d_cosp(o_clhcalipsoun,stlidar%cldlayerphase(:,3,3)) |
---|
166 | CALL histwrite2d_cosp(o_clmcalipsoun,stlidar%cldlayerphase(:,2,3)) |
---|
167 | CALL histwrite2d_cosp(o_cltcalipsoun,stlidar%cldlayerphase(:,4,3)) |
---|
168 | CALL histwrite3d_cosp(o_clcalipsoun,stlidar%lidarcldphase(:,:,3),nvert) |
---|
169 | CALL histwrite3d_cosp(o_clcalipsotmpun,stlidar%lidarcldtmp(:,:,4),nverttemp) |
---|
170 | |
---|
171 | do icl=1,SR_BINS |
---|
172 | CALL histwrite3d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr(:,icl,:),nvert,icl) |
---|
173 | enddo |
---|
174 | |
---|
175 | CALL histwrite3d_cosp(o_parasol_refl,stlidar%parasolrefl,nvertp) |
---|
176 | |
---|
177 | do k=1,PARASOL_NREFL |
---|
178 | do ip=1, Npoints |
---|
179 | if (stlidar%cldlayer(ip,4).gt.0.01) then |
---|
180 | parasolcrefl(ip,k)=(stlidar%parasolrefl(ip,k)-0.03*(1.-stlidar%cldlayer(ip,4)))/ & |
---|
181 | stlidar%cldlayer(ip,4) |
---|
182 | Ncref(ip,k) = 1. |
---|
183 | else |
---|
184 | parasolcrefl(ip,k)=0. |
---|
185 | Ncref(ip,k) = 0. |
---|
186 | endif |
---|
187 | enddo |
---|
188 | enddo |
---|
189 | CALL histwrite3d_cosp(o_Ncrefl,Ncref,nvertp) |
---|
190 | CALL histwrite3d_cosp(o_parasol_crefl,parasolcrefl,nvertp) |
---|
191 | |
---|
192 | do icl=1,Ncolumns |
---|
193 | CALL histwrite3d_cosp(o_atb532,sglidar%beta_tot(:,icl,:),nvertmcosp,icl) |
---|
194 | enddo |
---|
195 | CALL histwrite3d_cosp(o_beta_mol532,sglidar%beta_mol,nvertmcosp) |
---|
196 | endif !Lidar |
---|
197 | |
---|
198 | if (cfg%Lradar_sim) then |
---|
199 | do icl=1,Ncolumns |
---|
200 | CALL histwrite3d_cosp(o_dbze94,sgradar%Ze_tot(:,icl,:),nvertmcosp,icl) |
---|
201 | enddo |
---|
202 | do icl=1,DBZE_BINS |
---|
203 | CALL histwrite3d_cosp(o_cfadDbze94,stradar%cfad_ze(:,icl,:),nvert,icl) |
---|
204 | enddo |
---|
205 | endif |
---|
206 | |
---|
207 | if (cfg%Llidar_sim .and. cfg%Lradar_sim) then |
---|
208 | where(stradar%lidar_only_freq_cloud == R_UNDEF) & |
---|
209 | stradar%lidar_only_freq_cloud = 0.0 |
---|
210 | CALL histwrite3d_cosp(o_clcalipso2,stradar%lidar_only_freq_cloud,nvert) |
---|
211 | where(stradar%radar_lidar_tcc == R_UNDEF) & |
---|
212 | stradar%radar_lidar_tcc = 0.0 |
---|
213 | CALL histwrite2d_cosp(o_cltlidarradar,stradar%radar_lidar_tcc) |
---|
214 | endif |
---|
215 | |
---|
216 | if (cfg%Lisccp_sim) then |
---|
217 | |
---|
218 | ! Traitement des valeurs indefinies |
---|
219 | do ip = 1,Npoints |
---|
220 | if(isccp%totalcldarea(ip).eq.R_UNDEF)then |
---|
221 | isccp%totalcldarea(ip)=Cosp_fill_value |
---|
222 | endif |
---|
223 | if(isccp%meanptop(ip).eq.R_UNDEF)then |
---|
224 | isccp%meanptop(ip)=Cosp_fill_value |
---|
225 | endif |
---|
226 | if(isccp%meantaucld(ip).eq.R_UNDEF)then |
---|
227 | isccp%meantaucld(ip)=Cosp_fill_value |
---|
228 | endif |
---|
229 | if(isccp%meanalbedocld(ip).eq.R_UNDEF)then |
---|
230 | isccp%meanalbedocld(ip)=Cosp_fill_value |
---|
231 | endif |
---|
232 | if(isccp%meantb(ip).eq.R_UNDEF)then |
---|
233 | isccp%meantb(ip)=Cosp_fill_value |
---|
234 | endif |
---|
235 | if(isccp%meantbclr(ip).eq.R_UNDEF)then |
---|
236 | isccp%meantbclr(ip)=Cosp_fill_value |
---|
237 | endif |
---|
238 | |
---|
239 | do k=1,7 |
---|
240 | do ii=1,7 |
---|
241 | if(isccp%fq_isccp(ip,ii,k).eq.R_UNDEF)then |
---|
242 | isccp%fq_isccp(ip,ii,k)=Cosp_fill_value |
---|
243 | endif |
---|
244 | enddo |
---|
245 | enddo |
---|
246 | |
---|
247 | do ii=1,Ncolumns |
---|
248 | if(isccp%boxtau(ip,ii).eq.R_UNDEF)then |
---|
249 | isccp%boxtau(ip,ii)=Cosp_fill_value |
---|
250 | endif |
---|
251 | enddo |
---|
252 | |
---|
253 | do ii=1,Ncolumns |
---|
254 | if(isccp%boxptop(ip,ii).eq.R_UNDEF)then |
---|
255 | isccp%boxptop(ip,ii)=Cosp_fill_value |
---|
256 | endif |
---|
257 | enddo |
---|
258 | enddo |
---|
259 | |
---|
260 | CALL histwrite2d_cosp(o_sunlit,gbx%sunlit) |
---|
261 | do icl=1,7 |
---|
262 | CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl) |
---|
263 | enddo |
---|
264 | CALL histwrite3d_cosp(o_boxtauisccp,isccp%boxtau,nvertcol) |
---|
265 | CALL histwrite3d_cosp(o_boxptopisccp,isccp%boxptop,nvertcol) |
---|
266 | CALL histwrite2d_cosp(o_tclisccp,isccp%totalcldarea) |
---|
267 | CALL histwrite2d_cosp(o_ctpisccp,isccp%meanptop) |
---|
268 | CALL histwrite2d_cosp(o_tauisccp,isccp%meantaucld) |
---|
269 | CALL histwrite2d_cosp(o_albisccp,isccp%meanalbedocld) |
---|
270 | CALL histwrite2d_cosp(o_meantbisccp,isccp%meantb) |
---|
271 | CALL histwrite2d_cosp(o_meantbclrisccp,isccp%meantbclr) |
---|
272 | endif ! Isccp |
---|
273 | |
---|
274 | ! MISR simulator |
---|
275 | if (cfg%Lmisr_sim) then |
---|
276 | do ip=1,Npoints |
---|
277 | do ii=1,7 |
---|
278 | do k=1,MISR_N_CTH |
---|
279 | if(misr%fq_MISR(ip,ii,k).eq.R_UNDEF)then |
---|
280 | misr%fq_MISR(ip,ii,k)=Cosp_fill_value |
---|
281 | endif |
---|
282 | enddo |
---|
283 | enddo |
---|
284 | enddo |
---|
285 | |
---|
286 | do icl=1,7 |
---|
287 | CALL histwrite3d_cosp(o_clMISR,misr%fq_MISR(:,icl,:),nvertmisr,icl) |
---|
288 | enddo |
---|
289 | endif |
---|
290 | |
---|
291 | ! Modis simulator |
---|
292 | if (cfg%Lmodis_sim) then |
---|
293 | |
---|
294 | do ip=1,Npoints |
---|
295 | if(modis%Cloud_Fraction_Low_Mean(ip).eq.R_UNDEF)then |
---|
296 | modis%Cloud_Fraction_Low_Mean(ip)=Cosp_fill_value |
---|
297 | endif |
---|
298 | if(modis%Cloud_Fraction_High_Mean(ip).eq.R_UNDEF)then |
---|
299 | modis%Cloud_Fraction_High_Mean(ip)=Cosp_fill_value |
---|
300 | endif |
---|
301 | if(modis%Cloud_Fraction_Mid_Mean(ip).eq.R_UNDEF)then |
---|
302 | modis%Cloud_Fraction_Mid_Mean(ip)=Cosp_fill_value |
---|
303 | endif |
---|
304 | if(modis%Cloud_Fraction_Total_Mean(ip).eq.R_UNDEF)then |
---|
305 | modis%Cloud_Fraction_Total_Mean(ip)=Cosp_fill_value |
---|
306 | endif |
---|
307 | if(modis%Cloud_Fraction_Water_Mean(ip).eq.R_UNDEF)then |
---|
308 | modis%Cloud_Fraction_Water_Mean(ip)=Cosp_fill_value |
---|
309 | endif |
---|
310 | if(modis%Cloud_Fraction_Ice_Mean(ip).eq.R_UNDEF)then |
---|
311 | modis%Cloud_Fraction_Ice_Mean(ip)=Cosp_fill_value |
---|
312 | endif |
---|
313 | if(modis%Optical_Thickness_Total_Mean(ip).eq.R_UNDEF)then |
---|
314 | modis%Optical_Thickness_Total_Mean(ip)=Cosp_fill_value |
---|
315 | endif |
---|
316 | if(modis%Optical_Thickness_Water_Mean(ip).eq.R_UNDEF)then |
---|
317 | modis%Optical_Thickness_Water_Mean(ip)=Cosp_fill_value |
---|
318 | endif |
---|
319 | if(modis%Optical_Thickness_Ice_Mean(ip).eq.R_UNDEF)then |
---|
320 | modis%Optical_Thickness_Ice_Mean(ip)=Cosp_fill_value |
---|
321 | endif |
---|
322 | if(modis%Cloud_Particle_Size_Water_Mean(ip).eq.R_UNDEF)then |
---|
323 | modis%Cloud_Particle_Size_Water_Mean(ip)=Cosp_fill_value |
---|
324 | endif |
---|
325 | if(modis%Cloud_Particle_Size_Ice_Mean(ip).eq.R_UNDEF)then |
---|
326 | modis%Cloud_Particle_Size_Ice_Mean(ip)=Cosp_fill_value |
---|
327 | endif |
---|
328 | if(modis%Cloud_Top_Pressure_Total_Mean(ip).eq.R_UNDEF)then |
---|
329 | modis%Cloud_Top_Pressure_Total_Mean(ip)=Cosp_fill_value |
---|
330 | endif |
---|
331 | if(modis%Liquid_Water_Path_Mean(ip).eq.R_UNDEF)then |
---|
332 | modis%Liquid_Water_Path_Mean(ip)=Cosp_fill_value |
---|
333 | endif |
---|
334 | if(modis%Ice_Water_Path_Mean(ip).eq.R_UNDEF)then |
---|
335 | modis%Ice_Water_Path_Mean(ip)=Cosp_fill_value |
---|
336 | endif |
---|
337 | |
---|
338 | enddo |
---|
339 | |
---|
340 | CALL histwrite2d_cosp(o_cllmodis,modis%Cloud_Fraction_Low_Mean) |
---|
341 | CALL histwrite2d_cosp(o_clhmodis,modis%Cloud_Fraction_High_Mean) |
---|
342 | CALL histwrite2d_cosp(o_clmmodis,modis%Cloud_Fraction_Mid_Mean) |
---|
343 | CALL histwrite2d_cosp(o_cltmodis,modis%Cloud_Fraction_Total_Mean) |
---|
344 | CALL histwrite2d_cosp(o_clwmodis,modis%Cloud_Fraction_Water_Mean) |
---|
345 | CALL histwrite2d_cosp(o_climodis,modis%Cloud_Fraction_Ice_Mean) |
---|
346 | CALL histwrite2d_cosp(o_tautmodis,modis%Optical_Thickness_Total_Mean) |
---|
347 | CALL histwrite2d_cosp(o_tauwmodis,modis%Optical_Thickness_Water_Mean) |
---|
348 | CALL histwrite2d_cosp(o_tauimodis,modis%Optical_Thickness_Ice_Mean) |
---|
349 | CALL histwrite2d_cosp(o_tautlogmodis,modis%Optical_Thickness_Total_LogMean) |
---|
350 | CALL histwrite2d_cosp(o_tauwlogmodis,modis%Optical_Thickness_Water_LogMean) |
---|
351 | CALL histwrite2d_cosp(o_tauilogmodis,modis%Optical_Thickness_Ice_LogMean) |
---|
352 | CALL histwrite2d_cosp(o_reffclwmodis,modis%Cloud_Particle_Size_Water_Mean) |
---|
353 | CALL histwrite2d_cosp(o_reffclimodis,modis%Cloud_Particle_Size_Ice_Mean) |
---|
354 | CALL histwrite2d_cosp(o_pctmodis,modis%Cloud_Top_Pressure_Total_Mean) |
---|
355 | CALL histwrite2d_cosp(o_lwpmodis,modis%Liquid_Water_Path_Mean) |
---|
356 | CALL histwrite2d_cosp(o_iwpmodis,modis%Ice_Water_Path_Mean) |
---|
357 | |
---|
358 | do ip=1,Npoints |
---|
359 | do ii=1,7 |
---|
360 | do k=1,7 |
---|
361 | if(modis%Optical_Thickness_vs_Cloud_Top_Pressure(ip,ii,k).eq.R_UNDEF)then |
---|
362 | modis%Optical_Thickness_vs_Cloud_Top_Pressure(ip,ii,k)=0. |
---|
363 | endif |
---|
364 | enddo |
---|
365 | enddo |
---|
366 | enddo |
---|
367 | |
---|
368 | do icl=1,7 |
---|
369 | CALL histwrite3d_cosp(o_clmodis, & |
---|
370 | modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl) |
---|
371 | enddo |
---|
372 | endif |
---|
373 | |
---|
374 | IF(.NOT.cosp_varsdefined) THEN |
---|
375 | !$OMP MASTER |
---|
376 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
377 | DO iff=1,3 |
---|
378 | IF (cosp_outfilekeys(iff)) THEN |
---|
379 | CALL histend(cosp_nidfiles(iff)) |
---|
380 | ENDIF ! cosp_outfilekeys |
---|
381 | ENDDO ! iff |
---|
382 | #endif |
---|
383 | ! Fermeture dans phys_output_write |
---|
384 | !#ifdef CPP_XIOS |
---|
385 | !On finalise l'initialisation: |
---|
386 | !CALL wxios_closedef() |
---|
387 | !#endif |
---|
388 | |
---|
389 | !$OMP END MASTER |
---|
390 | !$OMP BARRIER |
---|
391 | cosp_varsdefined = .TRUE. |
---|
392 | END IF |
---|
393 | |
---|
394 | IF(cosp_varsdefined) THEN |
---|
395 | ! On synchronise les fichiers pour IOIPSL |
---|
396 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
397 | !$OMP MASTER |
---|
398 | DO iff=1,3 |
---|
399 | IF (ok_sync .AND. cosp_outfilekeys(iff)) THEN |
---|
400 | CALL histsync(cosp_nidfiles(iff)) |
---|
401 | ENDIF |
---|
402 | END DO |
---|
403 | !$OMP END MASTER |
---|
404 | #endif |
---|
405 | ENDIF !cosp_varsdefined |
---|
406 | |
---|
407 | END SUBROUTINE cosp_output_write |
---|
408 | |
---|
409 | ! ug Routine pour definir itau_iocosp depuis cosp_output_write_mod: |
---|
410 | SUBROUTINE set_itau_iocosp(ito) |
---|
411 | IMPLICIT NONE |
---|
412 | INTEGER, INTENT(IN) :: ito |
---|
413 | itau_iocosp = ito |
---|
414 | END SUBROUTINE |
---|
415 | |
---|
416 | SUBROUTINE histdef2d_cosp (iff,var) |
---|
417 | |
---|
418 | USE ioipsl |
---|
419 | USE dimphy |
---|
420 | use iophy |
---|
421 | USE mod_phys_lmdz_para |
---|
422 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
---|
423 | USE print_control_mod, ONLY: lunout,prt_level |
---|
424 | #ifdef CPP_XIOS |
---|
425 | USE wxios |
---|
426 | #endif |
---|
427 | |
---|
428 | IMPLICIT NONE |
---|
429 | |
---|
430 | INCLUDE "clesphys.h" |
---|
431 | |
---|
432 | INTEGER :: iff |
---|
433 | TYPE(ctrl_outcosp) :: var |
---|
434 | |
---|
435 | REAL zstophym |
---|
436 | CHARACTER(LEN=20) :: typeecrit |
---|
437 | |
---|
438 | ! ug On récupère le type écrit de la structure: |
---|
439 | ! Assez moche, Ã| refaire si meilleure méthode... |
---|
440 | IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN |
---|
441 | typeecrit = 'once' |
---|
442 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_min") > 0) THEN |
---|
443 | typeecrit = 't_min(X)' |
---|
444 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_max") > 0) THEN |
---|
445 | typeecrit = 't_max(X)' |
---|
446 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "inst") > 0) THEN |
---|
447 | typeecrit = 'inst(X)' |
---|
448 | ELSE |
---|
449 | typeecrit = cosp_outfiletypes(iff) |
---|
450 | ENDIF |
---|
451 | |
---|
452 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
---|
453 | zstophym=zoutm_cosp(iff) |
---|
454 | ELSE |
---|
455 | zstophym=zdtimemoy_cosp |
---|
456 | ENDIF |
---|
457 | |
---|
458 | #ifdef CPP_XIOS |
---|
459 | IF (.not. ok_all_xml) then |
---|
460 | IF ( var%cles(iff) ) THEN |
---|
461 | if (prt_level >= 10) then |
---|
462 | WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name |
---|
463 | endif |
---|
464 | CALL wxios_add_field_to_file(var%name, 2, cosp_nidfiles(iff), cosp_outfilenames(iff), & |
---|
465 | var%description, var%unit, 1, typeecrit) |
---|
466 | ENDIF |
---|
467 | ENDIF |
---|
468 | #endif |
---|
469 | |
---|
470 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
471 | IF ( var%cles(iff) ) THEN |
---|
472 | CALL histdef (cosp_nidfiles(iff), var%name, var%description, var%unit, & |
---|
473 | nbp_lon,jj_nb,nhoricosp(iff), 1,1,1, -99, 32, & |
---|
474 | typeecrit, zstophym,zoutm_cosp(iff)) |
---|
475 | ENDIF |
---|
476 | #endif |
---|
477 | |
---|
478 | END SUBROUTINE histdef2d_cosp |
---|
479 | |
---|
480 | SUBROUTINE histdef3d_cosp (iff,var,nvertsave,ncols) |
---|
481 | USE ioipsl |
---|
482 | USE dimphy |
---|
483 | use iophy |
---|
484 | USE mod_phys_lmdz_para |
---|
485 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
---|
486 | USE print_control_mod, ONLY: lunout,prt_level |
---|
487 | |
---|
488 | #ifdef CPP_XIOS |
---|
489 | USE wxios |
---|
490 | #endif |
---|
491 | |
---|
492 | |
---|
493 | IMPLICIT NONE |
---|
494 | |
---|
495 | INCLUDE "clesphys.h" |
---|
496 | |
---|
497 | INTEGER :: iff, klevs |
---|
498 | INTEGER, INTENT(IN), OPTIONAL :: ncols ! ug RUSTINE POUR LES variables 4D |
---|
499 | INTEGER, INTENT(IN) :: nvertsave |
---|
500 | TYPE(ctrl_outcosp) :: var |
---|
501 | |
---|
502 | REAL zstophym |
---|
503 | CHARACTER(LEN=20) :: typeecrit, nomi |
---|
504 | CHARACTER(LEN=20) :: nom |
---|
505 | character(len=2) :: str2 |
---|
506 | CHARACTER(len=20) :: nam_axvert |
---|
507 | |
---|
508 | ! Axe vertical |
---|
509 | IF (nvertsave.eq.nvertp(iff)) THEN |
---|
510 | klevs=PARASOL_NREFL |
---|
511 | nam_axvert="sza" |
---|
512 | ELSE IF (nvertsave.eq.nvertisccp(iff)) THEN |
---|
513 | klevs=7 |
---|
514 | nam_axvert="pressure2" |
---|
515 | ELSE IF (nvertsave.eq.nvertcol(iff)) THEN |
---|
516 | klevs=Ncolout |
---|
517 | nam_axvert="column" |
---|
518 | ELSE IF (nvertsave.eq.nverttemp(iff)) THEN |
---|
519 | klevs=LIDAR_NTEMP |
---|
520 | nam_axvert="temp" |
---|
521 | ELSE IF (nvertsave.eq.nvertmisr(iff)) THEN |
---|
522 | klevs=MISR_N_CTH |
---|
523 | nam_axvert="cth16" |
---|
524 | ELSE |
---|
525 | klevs=Nlevout |
---|
526 | nam_axvert="presnivs" |
---|
527 | ENDIF |
---|
528 | |
---|
529 | ! ug RUSTINE POUR LES Champs 4D |
---|
530 | IF (PRESENT(ncols)) THEN |
---|
531 | write(str2,'(i2.2)')ncols |
---|
532 | nomi=var%name |
---|
533 | nom="c"//str2//"_"//nomi |
---|
534 | ELSE |
---|
535 | nom=var%name |
---|
536 | END IF |
---|
537 | |
---|
538 | ! ug On récupère le type écrit de la structure: |
---|
539 | ! Assez moche, Ã| refaire si meilleure méthode... |
---|
540 | IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN |
---|
541 | typeecrit = 'once' |
---|
542 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_min") > 0) THEN |
---|
543 | typeecrit = 't_min(X)' |
---|
544 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_max") > 0) THEN |
---|
545 | typeecrit = 't_max(X)' |
---|
546 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "inst") > 0) THEN |
---|
547 | typeecrit = 'inst(X)' |
---|
548 | ELSE |
---|
549 | typeecrit = cosp_outfiletypes(iff) |
---|
550 | ENDIF |
---|
551 | |
---|
552 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
---|
553 | zstophym=zoutm_cosp(iff) |
---|
554 | ELSE |
---|
555 | zstophym=zdtimemoy_cosp |
---|
556 | ENDIF |
---|
557 | |
---|
558 | #ifdef CPP_XIOS |
---|
559 | IF (.not. ok_all_xml) then |
---|
560 | IF ( var%cles(iff) ) THEN |
---|
561 | if (prt_level >= 10) then |
---|
562 | WRITE(lunout,*)'Appel wxios_add_field_to_file 3d nom variable nam_axvert = ',nom, nam_axvert |
---|
563 | endif |
---|
564 | CALL wxios_add_field_to_file(nom, 3, cosp_nidfiles(iff), cosp_outfilenames(iff), & |
---|
565 | var%description, var%unit, 1, typeecrit, nam_axvert) |
---|
566 | ENDIF |
---|
567 | ENDIF |
---|
568 | #endif |
---|
569 | |
---|
570 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
571 | IF ( var%cles(iff) ) THEN |
---|
572 | CALL histdef (cosp_nidfiles(iff), nom, var%description, var%unit, & |
---|
573 | nbp_lon, jj_nb, nhoricosp(iff), klevs, 1, & |
---|
574 | klevs, nvertsave, 32, typeecrit, & |
---|
575 | zstophym, zoutm_cosp(iff)) |
---|
576 | ENDIF |
---|
577 | #endif |
---|
578 | |
---|
579 | END SUBROUTINE histdef3d_cosp |
---|
580 | |
---|
581 | SUBROUTINE histwrite2d_cosp(var,field) |
---|
582 | USE dimphy |
---|
583 | USE mod_phys_lmdz_para |
---|
584 | USE ioipsl |
---|
585 | use iophy |
---|
586 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
---|
587 | USE print_control_mod, ONLY: lunout,prt_level |
---|
588 | |
---|
589 | #ifdef CPP_XIOS |
---|
590 | USE xios, only: xios_send_field |
---|
591 | #endif |
---|
592 | |
---|
593 | IMPLICIT NONE |
---|
594 | INCLUDE 'clesphys.h' |
---|
595 | |
---|
596 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
---|
597 | REAL, DIMENSION(:), INTENT(IN) :: field |
---|
598 | |
---|
599 | INTEGER :: iff |
---|
600 | |
---|
601 | REAL,DIMENSION(klon_mpi) :: buffer_omp |
---|
602 | INTEGER, allocatable, DIMENSION(:) :: index2d |
---|
603 | REAL :: Field2d(nbp_lon,jj_nb) |
---|
604 | CHARACTER(LEN=20) :: nomi, nom |
---|
605 | character(len=2) :: str2 |
---|
606 | LOGICAL, SAVE :: firstx |
---|
607 | !$OMP THREADPRIVATE(firstx) |
---|
608 | |
---|
609 | IF (prt_level >= 9) WRITE(lunout,*)'Begin histrwrite2d ',var%name |
---|
610 | |
---|
611 | ! On regarde si on est dans la phase de définition ou d'écriture: |
---|
612 | IF(.NOT.cosp_varsdefined) THEN |
---|
613 | !$OMP MASTER |
---|
614 | !Si phase de définition.... on définit |
---|
615 | CALL conf_cospoutputs(var%name,var%cles) |
---|
616 | DO iff=1, 3 |
---|
617 | IF (cosp_outfilekeys(iff)) THEN |
---|
618 | CALL histdef2d_cosp(iff, var) |
---|
619 | ENDIF |
---|
620 | ENDDO |
---|
621 | !$OMP END MASTER |
---|
622 | ELSE |
---|
623 | !Et sinon on.... écrit |
---|
624 | IF (SIZE(field)/=klon) & |
---|
625 | CALL abort_physic('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1) |
---|
626 | |
---|
627 | CALL Gather_omp(field,buffer_omp) |
---|
628 | !$OMP MASTER |
---|
629 | CALL grid1Dto2D_mpi(buffer_omp,Field2d) |
---|
630 | |
---|
631 | ! La boucle sur les fichiers: |
---|
632 | firstx=.true. |
---|
633 | DO iff=1, 3 |
---|
634 | IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN |
---|
635 | ALLOCATE(index2d(nbp_lon*jj_nb)) |
---|
636 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
637 | CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d) |
---|
638 | #endif |
---|
639 | deallocate(index2d) |
---|
640 | #ifdef CPP_XIOS |
---|
641 | IF (.not. ok_all_xml) then |
---|
642 | if (firstx) then |
---|
643 | if (prt_level >= 10) then |
---|
644 | WRITE(lunout,*)'xios_send_field variable ',var%name |
---|
645 | endif |
---|
646 | CALL xios_send_field(var%name, Field2d) |
---|
647 | firstx=.false. |
---|
648 | endif |
---|
649 | ENDIF |
---|
650 | #endif |
---|
651 | ENDIF |
---|
652 | ENDDO |
---|
653 | |
---|
654 | #ifdef CPP_XIOS |
---|
655 | IF (ok_all_xml) THEN |
---|
656 | if (prt_level >= 1) then |
---|
657 | WRITE(lunout,*)'xios_send_field variable ',var%name |
---|
658 | endif |
---|
659 | CALL xios_send_field(var%name, Field2d) |
---|
660 | ENDIF |
---|
661 | #endif |
---|
662 | |
---|
663 | !$OMP END MASTER |
---|
664 | ENDIF ! vars_defined |
---|
665 | IF (prt_level >= 9) WRITE(lunout,*)'End histrwrite2d_cosp ',var%name |
---|
666 | END SUBROUTINE histwrite2d_cosp |
---|
667 | |
---|
668 | ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE |
---|
669 | ! AI sept 2013 |
---|
670 | SUBROUTINE histwrite3d_cosp(var, field, nverts, ncols) |
---|
671 | USE dimphy |
---|
672 | USE mod_phys_lmdz_para |
---|
673 | USE ioipsl |
---|
674 | use iophy |
---|
675 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
---|
676 | USE print_control_mod, ONLY: lunout,prt_level |
---|
677 | |
---|
678 | #ifdef CPP_XIOS |
---|
679 | USE xios, only: xios_send_field |
---|
680 | #endif |
---|
681 | |
---|
682 | |
---|
683 | IMPLICIT NONE |
---|
684 | INCLUDE 'clesphys.h' |
---|
685 | |
---|
686 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
---|
687 | REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:) |
---|
688 | INTEGER, INTENT(IN), OPTIONAL :: ncols ! ug RUSTINE POUR LES Champs 4D..... |
---|
689 | INTEGER, DIMENSION(3), INTENT(IN) :: nverts |
---|
690 | |
---|
691 | INTEGER :: iff, k |
---|
692 | |
---|
693 | REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp |
---|
694 | REAL :: Field3d(nbp_lon,jj_nb,SIZE(field,2)) |
---|
695 | INTEGER :: ip, n, nlev |
---|
696 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d |
---|
697 | CHARACTER(LEN=20) :: nomi, nom |
---|
698 | character(len=2) :: str2 |
---|
699 | LOGICAL, SAVE :: firstx |
---|
700 | !$OMP THREADPRIVATE(firstx) |
---|
701 | |
---|
702 | IF (prt_level >= 9) write(lunout,*)'Begin histrwrite3d ',var%name |
---|
703 | |
---|
704 | ! ug RUSTINE POUR LES STD LEVS..... |
---|
705 | IF (PRESENT(ncols)) THEN |
---|
706 | write(str2,'(i2.2)')ncols |
---|
707 | nomi=var%name |
---|
708 | nom="c"//str2//"_"//nomi |
---|
709 | ELSE |
---|
710 | nom=var%name |
---|
711 | END IF |
---|
712 | ! On regarde si on est dans la phase de définition ou d'écriture: |
---|
713 | IF(.NOT.cosp_varsdefined) THEN |
---|
714 | !Si phase de définition.... on définit |
---|
715 | !$OMP MASTER |
---|
716 | CALL conf_cospoutputs(var%name,var%cles) |
---|
717 | DO iff=1, 3 |
---|
718 | IF (cosp_outfilekeys(iff)) THEN |
---|
719 | CALL histdef3d_cosp(iff, var, nverts(iff), ncols) |
---|
720 | ENDIF |
---|
721 | ENDDO |
---|
722 | !$OMP END MASTER |
---|
723 | ELSE |
---|
724 | !Et sinon on.... écrit |
---|
725 | IF (SIZE(field,1)/=klon) & |
---|
726 | CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1) |
---|
727 | nlev=SIZE(field,2) |
---|
728 | |
---|
729 | |
---|
730 | CALL Gather_omp(field,buffer_omp) |
---|
731 | !$OMP MASTER |
---|
732 | CALL grid1Dto2D_mpi(buffer_omp,field3d) |
---|
733 | |
---|
734 | ! BOUCLE SUR LES FICHIERS |
---|
735 | firstx=.true. |
---|
736 | DO iff=1, 3 |
---|
737 | IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN |
---|
738 | ALLOCATE(index3d(nbp_lon*jj_nb*nlev)) |
---|
739 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
740 | CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,nbp_lon*jj_nb*nlev,index3d) |
---|
741 | #endif |
---|
742 | |
---|
743 | #ifdef CPP_XIOS |
---|
744 | IF (.not. ok_all_xml) then |
---|
745 | IF (firstx) THEN |
---|
746 | CALL xios_send_field(nom, Field3d(:,:,1:nlev)) |
---|
747 | IF (prt_level >= 9) WRITE(lunout,*)'xios_send_field ',var%name |
---|
748 | firstx=.FALSE. |
---|
749 | ENDIF |
---|
750 | ENDIF |
---|
751 | #endif |
---|
752 | deallocate(index3d) |
---|
753 | ENDIF |
---|
754 | ENDDO |
---|
755 | #ifdef CPP_XIOS |
---|
756 | IF (ok_all_xml) THEN |
---|
757 | CALL xios_send_field(nom, Field3d(:,:,1:nlev)) |
---|
758 | IF (prt_level >= 1) WRITE(lunout,*)'xios_send_field ',var%name |
---|
759 | ENDIF |
---|
760 | #endif |
---|
761 | |
---|
762 | !$OMP END MASTER |
---|
763 | ENDIF ! vars_defined |
---|
764 | IF (prt_level >= 9) write(lunout,*)'End histrwrite3d_cosp ',nom |
---|
765 | END SUBROUTINE histwrite3d_cosp |
---|
766 | |
---|
767 | SUBROUTINE conf_cospoutputs(nam_var,cles_var) |
---|
768 | !!! Lecture des noms et cles de sortie des variables dans config.def |
---|
769 | ! en utilisant les routines getin de IOIPSL |
---|
770 | use ioipsl |
---|
771 | USE print_control_mod, ONLY: lunout,prt_level |
---|
772 | |
---|
773 | IMPLICIT NONE |
---|
774 | |
---|
775 | CHARACTER(LEN=20) :: nam_var, nnam_var |
---|
776 | LOGICAL, DIMENSION(3) :: cles_var |
---|
777 | |
---|
778 | ! Lecture dans config.def ou output.def de cles_var et name_var |
---|
779 | CALL getin('cles_'//nam_var,cles_var) |
---|
780 | CALL getin('name_'//nam_var,nam_var) |
---|
781 | IF(prt_level>10) WRITE(lunout,*)'nam_var cles_var ',nam_var,cles_var(:) |
---|
782 | |
---|
783 | END SUBROUTINE conf_cospoutputs |
---|
784 | |
---|
785 | END MODULE cosp_output_write_mod |
---|