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