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, missing_val, & |
---|
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, missing_val |
---|
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)=missing_val |
---|
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)=missing_val |
---|
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)=missing_val |
---|
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)=missing_val |
---|
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)=missing_val |
---|
129 | endif |
---|
130 | enddo |
---|
131 | enddo |
---|
132 | |
---|
133 | ! AI 11 / 2015 |
---|
134 | |
---|
135 | where(stlidar%parasolrefl == R_UNDEF) stlidar%parasolrefl = missing_val |
---|
136 | where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = missing_val |
---|
137 | where(stlidar%cldlayerphase == R_UNDEF) stlidar%cldlayerphase = missing_val |
---|
138 | where(stlidar%lidarcldphase == R_UNDEF) stlidar%lidarcldphase = missing_val |
---|
139 | where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = missing_val |
---|
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 = missing_val |
---|
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 = missing_val |
---|
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)=missing_val |
---|
222 | endif |
---|
223 | if(isccp%meanptop(ip).eq.R_UNDEF)then |
---|
224 | isccp%meanptop(ip)=missing_val |
---|
225 | endif |
---|
226 | if(isccp%meantaucld(ip).eq.R_UNDEF)then |
---|
227 | isccp%meantaucld(ip)=missing_val |
---|
228 | endif |
---|
229 | if(isccp%meanalbedocld(ip).eq.R_UNDEF)then |
---|
230 | isccp%meanalbedocld(ip)=missing_val |
---|
231 | endif |
---|
232 | if(isccp%meantb(ip).eq.R_UNDEF)then |
---|
233 | isccp%meantb(ip)=missing_val |
---|
234 | endif |
---|
235 | if(isccp%meantbclr(ip).eq.R_UNDEF)then |
---|
236 | isccp%meantbclr(ip)=missing_val |
---|
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)=missing_val |
---|
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)=missing_val |
---|
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)=missing_val |
---|
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)=missing_val |
---|
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)=missing_val |
---|
297 | endif |
---|
298 | if(modis%Cloud_Fraction_High_Mean(ip).eq.R_UNDEF)then |
---|
299 | modis%Cloud_Fraction_High_Mean(ip)=missing_val |
---|
300 | endif |
---|
301 | if(modis%Cloud_Fraction_Mid_Mean(ip).eq.R_UNDEF)then |
---|
302 | modis%Cloud_Fraction_Mid_Mean(ip)=missing_val |
---|
303 | endif |
---|
304 | if(modis%Cloud_Fraction_Total_Mean(ip).eq.R_UNDEF)then |
---|
305 | modis%Cloud_Fraction_Total_Mean(ip)=missing_val |
---|
306 | endif |
---|
307 | if(modis%Cloud_Fraction_Water_Mean(ip).eq.R_UNDEF)then |
---|
308 | modis%Cloud_Fraction_Water_Mean(ip)=missing_val |
---|
309 | endif |
---|
310 | if(modis%Cloud_Fraction_Ice_Mean(ip).eq.R_UNDEF)then |
---|
311 | modis%Cloud_Fraction_Ice_Mean(ip)=missing_val |
---|
312 | endif |
---|
313 | if(modis%Optical_Thickness_Total_Mean(ip).eq.R_UNDEF)then |
---|
314 | modis%Optical_Thickness_Total_Mean(ip)=missing_val |
---|
315 | endif |
---|
316 | if(modis%Optical_Thickness_Water_Mean(ip).eq.R_UNDEF)then |
---|
317 | modis%Optical_Thickness_Water_Mean(ip)=missing_val |
---|
318 | endif |
---|
319 | if(modis%Optical_Thickness_Ice_Mean(ip).eq.R_UNDEF)then |
---|
320 | modis%Optical_Thickness_Ice_Mean(ip)=missing_val |
---|
321 | endif |
---|
322 | if(modis%Cloud_Particle_Size_Water_Mean(ip).eq.R_UNDEF)then |
---|
323 | modis%Cloud_Particle_Size_Water_Mean(ip)=missing_val |
---|
324 | endif |
---|
325 | if(modis%Cloud_Particle_Size_Ice_Mean(ip).eq.R_UNDEF)then |
---|
326 | modis%Cloud_Particle_Size_Ice_Mean(ip)=missing_val |
---|
327 | endif |
---|
328 | if(modis%Cloud_Top_Pressure_Total_Mean(ip).eq.R_UNDEF)then |
---|
329 | modis%Cloud_Top_Pressure_Total_Mean(ip)=missing_val |
---|
330 | endif |
---|
331 | if(modis%Liquid_Water_Path_Mean(ip).eq.R_UNDEF)then |
---|
332 | modis%Liquid_Water_Path_Mean(ip)=missing_val |
---|
333 | endif |
---|
334 | if(modis%Ice_Water_Path_Mean(ip).eq.R_UNDEF)then |
---|
335 | modis%Ice_Water_Path_Mean(ip)=missing_val |
---|
336 | endif |
---|
337 | |
---|
338 | enddo |
---|
339 | |
---|
340 | where(modis%Optical_Thickness_Total_LogMean == R_UNDEF) & |
---|
341 | modis%Optical_Thickness_Total_LogMean = missing_val |
---|
342 | |
---|
343 | |
---|
344 | where(modis%Optical_Thickness_Water_LogMean == R_UNDEF) & |
---|
345 | modis%Optical_Thickness_Water_LogMean = missing_val |
---|
346 | |
---|
347 | where(modis%Optical_Thickness_Ice_LogMean == R_UNDEF) & |
---|
348 | modis%Optical_Thickness_Ice_LogMean = missing_val |
---|
349 | |
---|
350 | CALL histwrite2d_cosp(o_cllmodis,modis%Cloud_Fraction_Low_Mean) |
---|
351 | CALL histwrite2d_cosp(o_clhmodis,modis%Cloud_Fraction_High_Mean) |
---|
352 | CALL histwrite2d_cosp(o_clmmodis,modis%Cloud_Fraction_Mid_Mean) |
---|
353 | CALL histwrite2d_cosp(o_cltmodis,modis%Cloud_Fraction_Total_Mean) |
---|
354 | CALL histwrite2d_cosp(o_clwmodis,modis%Cloud_Fraction_Water_Mean) |
---|
355 | CALL histwrite2d_cosp(o_climodis,modis%Cloud_Fraction_Ice_Mean) |
---|
356 | CALL histwrite2d_cosp(o_tautmodis,modis%Optical_Thickness_Total_Mean) |
---|
357 | CALL histwrite2d_cosp(o_tauwmodis,modis%Optical_Thickness_Water_Mean) |
---|
358 | CALL histwrite2d_cosp(o_tauimodis,modis%Optical_Thickness_Ice_Mean) |
---|
359 | CALL histwrite2d_cosp(o_tautlogmodis,modis%Optical_Thickness_Total_LogMean) |
---|
360 | CALL histwrite2d_cosp(o_tauwlogmodis,modis%Optical_Thickness_Water_LogMean) |
---|
361 | CALL histwrite2d_cosp(o_tauilogmodis,modis%Optical_Thickness_Ice_LogMean) |
---|
362 | CALL histwrite2d_cosp(o_reffclwmodis,modis%Cloud_Particle_Size_Water_Mean) |
---|
363 | CALL histwrite2d_cosp(o_reffclimodis,modis%Cloud_Particle_Size_Ice_Mean) |
---|
364 | CALL histwrite2d_cosp(o_pctmodis,modis%Cloud_Top_Pressure_Total_Mean) |
---|
365 | CALL histwrite2d_cosp(o_lwpmodis,modis%Liquid_Water_Path_Mean) |
---|
366 | CALL histwrite2d_cosp(o_iwpmodis,modis%Ice_Water_Path_Mean) |
---|
367 | |
---|
368 | do ip=1,Npoints |
---|
369 | do ii=1,7 |
---|
370 | do k=1,7 |
---|
371 | if(modis%Optical_Thickness_vs_Cloud_Top_Pressure(ip,ii,k).eq.R_UNDEF)then |
---|
372 | modis%Optical_Thickness_vs_Cloud_Top_Pressure(ip,ii,k)=missing_val |
---|
373 | endif |
---|
374 | enddo |
---|
375 | enddo |
---|
376 | enddo |
---|
377 | |
---|
378 | do icl=1,7 |
---|
379 | CALL histwrite3d_cosp(o_clmodis, & |
---|
380 | modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl) |
---|
381 | enddo |
---|
382 | |
---|
383 | where(modis%Optical_Thickness_vs_ReffIce == R_UNDEF) & |
---|
384 | modis%Optical_Thickness_vs_ReffIce = missing_val |
---|
385 | |
---|
386 | where(modis%Optical_Thickness_vs_ReffLiq == R_UNDEF) & |
---|
387 | modis%Optical_Thickness_vs_ReffLiq = missing_val |
---|
388 | |
---|
389 | do icl=1,7 |
---|
390 | CALL histwrite3d_cosp(o_crimodis, & |
---|
391 | modis%Optical_Thickness_vs_ReffIce(:,icl,:),nvertReffIce,icl) |
---|
392 | CALL histwrite3d_cosp(o_crlmodis, & |
---|
393 | modis%Optical_Thickness_vs_ReffLiq(:,icl,:),nvertReffLiq,icl) |
---|
394 | enddo |
---|
395 | endif |
---|
396 | |
---|
397 | IF(.NOT.cosp_varsdefined) THEN |
---|
398 | !$OMP MASTER |
---|
399 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
400 | DO iff=1,3 |
---|
401 | IF (cosp_outfilekeys(iff)) THEN |
---|
402 | CALL histend(cosp_nidfiles(iff)) |
---|
403 | ENDIF ! cosp_outfilekeys |
---|
404 | ENDDO ! iff |
---|
405 | #endif |
---|
406 | ! Fermeture dans phys_output_write |
---|
407 | !#ifdef CPP_XIOS |
---|
408 | !On finalise l'initialisation: |
---|
409 | !CALL wxios_closedef() |
---|
410 | !#endif |
---|
411 | |
---|
412 | !$OMP END MASTER |
---|
413 | !$OMP BARRIER |
---|
414 | cosp_varsdefined = .TRUE. |
---|
415 | END IF |
---|
416 | |
---|
417 | IF(cosp_varsdefined) THEN |
---|
418 | ! On synchronise les fichiers pour IOIPSL |
---|
419 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
420 | !$OMP MASTER |
---|
421 | DO iff=1,3 |
---|
422 | IF (ok_sync .AND. cosp_outfilekeys(iff)) THEN |
---|
423 | CALL histsync(cosp_nidfiles(iff)) |
---|
424 | ENDIF |
---|
425 | END DO |
---|
426 | !$OMP END MASTER |
---|
427 | #endif |
---|
428 | ENDIF !cosp_varsdefined |
---|
429 | |
---|
430 | END SUBROUTINE cosp_output_write |
---|
431 | |
---|
432 | ! ug Routine pour definir itau_iocosp depuis cosp_output_write_mod: |
---|
433 | SUBROUTINE set_itau_iocosp(ito) |
---|
434 | IMPLICIT NONE |
---|
435 | INTEGER, INTENT(IN) :: ito |
---|
436 | itau_iocosp = ito |
---|
437 | END SUBROUTINE |
---|
438 | |
---|
439 | SUBROUTINE histdef2d_cosp (iff,var) |
---|
440 | |
---|
441 | USE ioipsl |
---|
442 | USE dimphy |
---|
443 | use iophy |
---|
444 | USE mod_phys_lmdz_para |
---|
445 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
---|
446 | USE print_control_mod, ONLY: lunout,prt_level |
---|
447 | #ifdef CPP_XIOS |
---|
448 | USE wxios |
---|
449 | #endif |
---|
450 | |
---|
451 | IMPLICIT NONE |
---|
452 | |
---|
453 | INCLUDE "clesphys.h" |
---|
454 | |
---|
455 | INTEGER :: iff |
---|
456 | TYPE(ctrl_outcosp) :: var |
---|
457 | |
---|
458 | REAL zstophym |
---|
459 | CHARACTER(LEN=20) :: typeecrit |
---|
460 | |
---|
461 | ! ug On récupère le type écrit de la structure: |
---|
462 | ! Assez moche, Ã| refaire si meilleure méthode... |
---|
463 | IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN |
---|
464 | typeecrit = 'once' |
---|
465 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_min") > 0) THEN |
---|
466 | typeecrit = 't_min(X)' |
---|
467 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_max") > 0) THEN |
---|
468 | typeecrit = 't_max(X)' |
---|
469 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "inst") > 0) THEN |
---|
470 | typeecrit = 'inst(X)' |
---|
471 | ELSE |
---|
472 | typeecrit = cosp_outfiletypes(iff) |
---|
473 | ENDIF |
---|
474 | |
---|
475 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
---|
476 | zstophym=zoutm_cosp(iff) |
---|
477 | ELSE |
---|
478 | zstophym=zdtimemoy_cosp |
---|
479 | ENDIF |
---|
480 | |
---|
481 | #ifdef CPP_XIOS |
---|
482 | IF (.not. ok_all_xml) then |
---|
483 | IF ( var%cles(iff) ) THEN |
---|
484 | if (prt_level >= 10) then |
---|
485 | WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name |
---|
486 | endif |
---|
487 | CALL wxios_add_field_to_file(var%name, 2, cosp_nidfiles(iff), cosp_outfilenames(iff), & |
---|
488 | var%description, var%unit, 1, typeecrit) |
---|
489 | ENDIF |
---|
490 | ENDIF |
---|
491 | #endif |
---|
492 | |
---|
493 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
494 | IF ( var%cles(iff) ) THEN |
---|
495 | CALL histdef (cosp_nidfiles(iff), var%name, var%description, var%unit, & |
---|
496 | nbp_lon,jj_nb,nhoricosp(iff), 1,1,1, -99, 32, & |
---|
497 | typeecrit, zstophym,zoutm_cosp(iff)) |
---|
498 | ENDIF |
---|
499 | #endif |
---|
500 | |
---|
501 | END SUBROUTINE histdef2d_cosp |
---|
502 | |
---|
503 | SUBROUTINE histdef3d_cosp (iff,var,nvertsave,ncols) |
---|
504 | USE ioipsl |
---|
505 | USE dimphy |
---|
506 | use iophy |
---|
507 | USE mod_phys_lmdz_para |
---|
508 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
---|
509 | USE print_control_mod, ONLY: lunout,prt_level |
---|
510 | |
---|
511 | #ifdef CPP_XIOS |
---|
512 | USE wxios |
---|
513 | #endif |
---|
514 | |
---|
515 | |
---|
516 | IMPLICIT NONE |
---|
517 | |
---|
518 | INCLUDE "clesphys.h" |
---|
519 | |
---|
520 | INTEGER :: iff, klevs |
---|
521 | INTEGER, INTENT(IN), OPTIONAL :: ncols ! ug RUSTINE POUR LES variables 4D |
---|
522 | INTEGER, INTENT(IN) :: nvertsave |
---|
523 | TYPE(ctrl_outcosp) :: var |
---|
524 | |
---|
525 | REAL zstophym |
---|
526 | CHARACTER(LEN=20) :: typeecrit, nomi |
---|
527 | CHARACTER(LEN=20) :: nom |
---|
528 | character(len=2) :: str2 |
---|
529 | CHARACTER(len=20) :: nam_axvert |
---|
530 | |
---|
531 | ! Axe vertical |
---|
532 | IF (nvertsave.eq.nvertp(iff)) THEN |
---|
533 | klevs=PARASOL_NREFL |
---|
534 | nam_axvert="sza" |
---|
535 | ELSE IF (nvertsave.eq.nvertisccp(iff)) THEN |
---|
536 | klevs=7 |
---|
537 | nam_axvert="pressure2" |
---|
538 | ELSE IF (nvertsave.eq.nvertcol(iff)) THEN |
---|
539 | klevs=Ncolout |
---|
540 | nam_axvert="column" |
---|
541 | ELSE IF (nvertsave.eq.nverttemp(iff)) THEN |
---|
542 | klevs=LIDAR_NTEMP |
---|
543 | nam_axvert="temp" |
---|
544 | ELSE IF (nvertsave.eq.nvertmisr(iff)) THEN |
---|
545 | klevs=MISR_N_CTH |
---|
546 | nam_axvert="cth16" |
---|
547 | ELSE IF (nvertsave.eq.nvertReffIce(iff)) THEN |
---|
548 | klevs= numMODISReffIceBins |
---|
549 | nam_axvert="ReffIce" |
---|
550 | ELSE IF (nvertsave.eq.nvertReffLiq(iff)) THEN |
---|
551 | klevs= numMODISReffLiqBins |
---|
552 | nam_axvert="ReffLiq" |
---|
553 | ELSE |
---|
554 | klevs=Nlevout |
---|
555 | nam_axvert="presnivs" |
---|
556 | ENDIF |
---|
557 | |
---|
558 | ! ug RUSTINE POUR LES Champs 4D |
---|
559 | IF (PRESENT(ncols)) THEN |
---|
560 | write(str2,'(i2.2)')ncols |
---|
561 | nomi=var%name |
---|
562 | nom="c"//str2//"_"//nomi |
---|
563 | ELSE |
---|
564 | nom=var%name |
---|
565 | END IF |
---|
566 | |
---|
567 | ! ug On récupère le type écrit de la structure: |
---|
568 | ! Assez moche, Ã| refaire si meilleure méthode... |
---|
569 | IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN |
---|
570 | typeecrit = 'once' |
---|
571 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_min") > 0) THEN |
---|
572 | typeecrit = 't_min(X)' |
---|
573 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_max") > 0) THEN |
---|
574 | typeecrit = 't_max(X)' |
---|
575 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "inst") > 0) THEN |
---|
576 | typeecrit = 'inst(X)' |
---|
577 | ELSE |
---|
578 | typeecrit = cosp_outfiletypes(iff) |
---|
579 | ENDIF |
---|
580 | |
---|
581 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
---|
582 | zstophym=zoutm_cosp(iff) |
---|
583 | ELSE |
---|
584 | zstophym=zdtimemoy_cosp |
---|
585 | ENDIF |
---|
586 | |
---|
587 | #ifdef CPP_XIOS |
---|
588 | IF (.not. ok_all_xml) then |
---|
589 | IF ( var%cles(iff) ) THEN |
---|
590 | if (prt_level >= 10) then |
---|
591 | WRITE(lunout,*)'Appel wxios_add_field_to_file 3d nom variable nam_axvert = ',nom, nam_axvert |
---|
592 | endif |
---|
593 | CALL wxios_add_field_to_file(nom, 3, cosp_nidfiles(iff), cosp_outfilenames(iff), & |
---|
594 | var%description, var%unit, 1, typeecrit, nam_axvert) |
---|
595 | ENDIF |
---|
596 | ENDIF |
---|
597 | #endif |
---|
598 | |
---|
599 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
600 | IF ( var%cles(iff) ) THEN |
---|
601 | CALL histdef (cosp_nidfiles(iff), nom, var%description, var%unit, & |
---|
602 | nbp_lon, jj_nb, nhoricosp(iff), klevs, 1, & |
---|
603 | klevs, nvertsave, 32, typeecrit, & |
---|
604 | zstophym, zoutm_cosp(iff)) |
---|
605 | ENDIF |
---|
606 | #endif |
---|
607 | |
---|
608 | END SUBROUTINE histdef3d_cosp |
---|
609 | |
---|
610 | SUBROUTINE histwrite2d_cosp(var,field) |
---|
611 | USE dimphy |
---|
612 | USE mod_phys_lmdz_para |
---|
613 | USE ioipsl |
---|
614 | use iophy |
---|
615 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
---|
616 | USE print_control_mod, ONLY: lunout,prt_level |
---|
617 | |
---|
618 | #ifdef CPP_XIOS |
---|
619 | USE xios, only: xios_send_field |
---|
620 | #endif |
---|
621 | |
---|
622 | IMPLICIT NONE |
---|
623 | INCLUDE 'clesphys.h' |
---|
624 | |
---|
625 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
---|
626 | REAL, DIMENSION(:), INTENT(IN) :: field |
---|
627 | |
---|
628 | INTEGER :: iff |
---|
629 | |
---|
630 | REAL,DIMENSION(klon_mpi) :: buffer_omp |
---|
631 | INTEGER, allocatable, DIMENSION(:) :: index2d |
---|
632 | REAL :: Field2d(nbp_lon,jj_nb) |
---|
633 | CHARACTER(LEN=20) :: nomi, nom |
---|
634 | character(len=2) :: str2 |
---|
635 | LOGICAL, SAVE :: firstx |
---|
636 | !$OMP THREADPRIVATE(firstx) |
---|
637 | |
---|
638 | IF (prt_level >= 9) WRITE(lunout,*)'Begin histrwrite2d ',var%name |
---|
639 | |
---|
640 | ! On regarde si on est dans la phase de définition ou d'écriture: |
---|
641 | IF(.NOT.cosp_varsdefined) THEN |
---|
642 | !$OMP MASTER |
---|
643 | !Si phase de définition.... on définit |
---|
644 | CALL conf_cospoutputs(var%name,var%cles) |
---|
645 | DO iff=1, 3 |
---|
646 | IF (cosp_outfilekeys(iff)) THEN |
---|
647 | CALL histdef2d_cosp(iff, var) |
---|
648 | ENDIF |
---|
649 | ENDDO |
---|
650 | !$OMP END MASTER |
---|
651 | ELSE |
---|
652 | !Et sinon on.... écrit |
---|
653 | IF (SIZE(field)/=klon) & |
---|
654 | CALL abort_physic('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1) |
---|
655 | |
---|
656 | CALL Gather_omp(field,buffer_omp) |
---|
657 | !$OMP MASTER |
---|
658 | CALL grid1Dto2D_mpi(buffer_omp,Field2d) |
---|
659 | |
---|
660 | ! La boucle sur les fichiers: |
---|
661 | firstx=.true. |
---|
662 | DO iff=1, 3 |
---|
663 | IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN |
---|
664 | ALLOCATE(index2d(nbp_lon*jj_nb)) |
---|
665 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
666 | CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d) |
---|
667 | #endif |
---|
668 | deallocate(index2d) |
---|
669 | #ifdef CPP_XIOS |
---|
670 | IF (.not. ok_all_xml) then |
---|
671 | if (firstx) then |
---|
672 | if (prt_level >= 10) then |
---|
673 | WRITE(lunout,*)'xios_send_field variable ',var%name |
---|
674 | endif |
---|
675 | CALL xios_send_field(var%name, Field2d) |
---|
676 | firstx=.false. |
---|
677 | endif |
---|
678 | ENDIF |
---|
679 | #endif |
---|
680 | ENDIF |
---|
681 | ENDDO |
---|
682 | |
---|
683 | #ifdef CPP_XIOS |
---|
684 | IF (ok_all_xml) THEN |
---|
685 | if (prt_level >= 1) then |
---|
686 | WRITE(lunout,*)'xios_send_field variable ',var%name |
---|
687 | endif |
---|
688 | CALL xios_send_field(var%name, Field2d) |
---|
689 | ENDIF |
---|
690 | #endif |
---|
691 | |
---|
692 | !$OMP END MASTER |
---|
693 | ENDIF ! vars_defined |
---|
694 | IF (prt_level >= 9) WRITE(lunout,*)'End histrwrite2d_cosp ',var%name |
---|
695 | END SUBROUTINE histwrite2d_cosp |
---|
696 | |
---|
697 | ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE |
---|
698 | ! AI sept 2013 |
---|
699 | SUBROUTINE histwrite3d_cosp(var, field, nverts, ncols) |
---|
700 | USE dimphy |
---|
701 | USE mod_phys_lmdz_para |
---|
702 | USE ioipsl |
---|
703 | use iophy |
---|
704 | USE mod_grid_phy_lmdz, ONLY: nbp_lon |
---|
705 | USE print_control_mod, ONLY: lunout,prt_level |
---|
706 | |
---|
707 | #ifdef CPP_XIOS |
---|
708 | USE xios, only: xios_send_field |
---|
709 | #endif |
---|
710 | |
---|
711 | |
---|
712 | IMPLICIT NONE |
---|
713 | INCLUDE 'clesphys.h' |
---|
714 | |
---|
715 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
---|
716 | REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:) |
---|
717 | INTEGER, INTENT(IN), OPTIONAL :: ncols ! ug RUSTINE POUR LES Champs 4D..... |
---|
718 | INTEGER, DIMENSION(3), INTENT(IN) :: nverts |
---|
719 | |
---|
720 | INTEGER :: iff, k |
---|
721 | |
---|
722 | REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp |
---|
723 | REAL :: Field3d(nbp_lon,jj_nb,SIZE(field,2)) |
---|
724 | INTEGER :: ip, n, nlev |
---|
725 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d |
---|
726 | CHARACTER(LEN=20) :: nomi, nom |
---|
727 | character(len=2) :: str2 |
---|
728 | LOGICAL, SAVE :: firstx |
---|
729 | !$OMP THREADPRIVATE(firstx) |
---|
730 | |
---|
731 | IF (prt_level >= 9) write(lunout,*)'Begin histrwrite3d ',var%name |
---|
732 | |
---|
733 | ! ug RUSTINE POUR LES STD LEVS..... |
---|
734 | IF (PRESENT(ncols)) THEN |
---|
735 | write(str2,'(i2.2)')ncols |
---|
736 | nomi=var%name |
---|
737 | nom="c"//str2//"_"//nomi |
---|
738 | ELSE |
---|
739 | nom=var%name |
---|
740 | END IF |
---|
741 | ! On regarde si on est dans la phase de définition ou d'écriture: |
---|
742 | IF(.NOT.cosp_varsdefined) THEN |
---|
743 | !Si phase de définition.... on définit |
---|
744 | !$OMP MASTER |
---|
745 | CALL conf_cospoutputs(var%name,var%cles) |
---|
746 | DO iff=1, 3 |
---|
747 | IF (cosp_outfilekeys(iff)) THEN |
---|
748 | CALL histdef3d_cosp(iff, var, nverts(iff), ncols) |
---|
749 | ENDIF |
---|
750 | ENDDO |
---|
751 | !$OMP END MASTER |
---|
752 | ELSE |
---|
753 | !Et sinon on.... écrit |
---|
754 | IF (SIZE(field,1)/=klon) & |
---|
755 | CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1) |
---|
756 | nlev=SIZE(field,2) |
---|
757 | |
---|
758 | |
---|
759 | CALL Gather_omp(field,buffer_omp) |
---|
760 | !$OMP MASTER |
---|
761 | CALL grid1Dto2D_mpi(buffer_omp,field3d) |
---|
762 | |
---|
763 | ! BOUCLE SUR LES FICHIERS |
---|
764 | firstx=.true. |
---|
765 | DO iff=1, 3 |
---|
766 | IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN |
---|
767 | ALLOCATE(index3d(nbp_lon*jj_nb*nlev)) |
---|
768 | #ifndef CPP_IOIPSL_NO_OUTPUT |
---|
769 | CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,nbp_lon*jj_nb*nlev,index3d) |
---|
770 | #endif |
---|
771 | |
---|
772 | #ifdef CPP_XIOS |
---|
773 | IF (.not. ok_all_xml) then |
---|
774 | IF (firstx) THEN |
---|
775 | CALL xios_send_field(nom, Field3d(:,:,1:nlev)) |
---|
776 | IF (prt_level >= 9) WRITE(lunout,*)'xios_send_field ',var%name |
---|
777 | firstx=.FALSE. |
---|
778 | ENDIF |
---|
779 | ENDIF |
---|
780 | #endif |
---|
781 | deallocate(index3d) |
---|
782 | ENDIF |
---|
783 | ENDDO |
---|
784 | #ifdef CPP_XIOS |
---|
785 | IF (ok_all_xml) THEN |
---|
786 | CALL xios_send_field(nom, Field3d(:,:,1:nlev)) |
---|
787 | IF (prt_level >= 1) WRITE(lunout,*)'xios_send_field ',var%name |
---|
788 | ENDIF |
---|
789 | #endif |
---|
790 | |
---|
791 | !$OMP END MASTER |
---|
792 | ENDIF ! vars_defined |
---|
793 | IF (prt_level >= 9) write(lunout,*)'End histrwrite3d_cosp ',nom |
---|
794 | END SUBROUTINE histwrite3d_cosp |
---|
795 | |
---|
796 | SUBROUTINE conf_cospoutputs(nam_var,cles_var) |
---|
797 | !!! Lecture des noms et cles de sortie des variables dans config.def |
---|
798 | ! en utilisant les routines getin de IOIPSL |
---|
799 | use ioipsl |
---|
800 | USE print_control_mod, ONLY: lunout,prt_level |
---|
801 | |
---|
802 | IMPLICIT NONE |
---|
803 | |
---|
804 | CHARACTER(LEN=20) :: nam_var, nnam_var |
---|
805 | LOGICAL, DIMENSION(3) :: cles_var |
---|
806 | |
---|
807 | ! Lecture dans config.def ou output.def de cles_var et name_var |
---|
808 | CALL getin('cles_'//nam_var,cles_var) |
---|
809 | CALL getin('name_'//nam_var,nam_var) |
---|
810 | IF(prt_level>10) WRITE(lunout,*)'nam_var cles_var ',nam_var,cles_var(:) |
---|
811 | |
---|
812 | END SUBROUTINE conf_cospoutputs |
---|
813 | |
---|
814 | END MODULE cosp_output_write_mod |
---|