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 | |
---|
11 | ! INTERFACE histwrite_cosp |
---|
12 | ! MODULE PROCEDURE histwrite2d_cosp,histwrite3d_cosp |
---|
13 | ! END INTERFACE |
---|
14 | |
---|
15 | CONTAINS |
---|
16 | |
---|
17 | SUBROUTINE cosp_output_write(Nlevlmdz, Npoints, Ncolumns, itap, dtime, freq_COSP, cfg, gbx, sglidar, stlidar, isccp) |
---|
18 | |
---|
19 | USE ioipsl |
---|
20 | USE control_mod |
---|
21 | |
---|
22 | #ifdef CPP_XIOS |
---|
23 | ! ug Pour les sorties XIOS |
---|
24 | USE wxios |
---|
25 | USE xios |
---|
26 | #endif |
---|
27 | |
---|
28 | !!! Variables d'entree |
---|
29 | integer :: itap, Nlevlmdz, Ncolumns, Npoints |
---|
30 | real :: freq_COSP, dtime |
---|
31 | type(cosp_config) :: cfg ! Control outputs |
---|
32 | type(cosp_gridbox) :: gbx ! Gridbox information. Input for COSP |
---|
33 | type(cosp_sglidar) :: sglidar ! Output from lidar simulator |
---|
34 | type(cosp_isccp) :: isccp ! Output from ISCCP simulator |
---|
35 | type(cosp_lidarstats) :: stlidar ! Summary statistics from lidar simulator |
---|
36 | |
---|
37 | !!! Variables locales |
---|
38 | integer :: icl, iinitend=1 |
---|
39 | logical :: ok_sync |
---|
40 | integer :: itau_wcosp |
---|
41 | real, dimension(Npoints,PARASOL_NREFL) :: parasolcrefl, Ncref |
---|
42 | |
---|
43 | include "temps.h" |
---|
44 | |
---|
45 | IF (MOD(itap,NINT(freq_COSP/dtime)).EQ.0) THEN |
---|
46 | |
---|
47 | ! A refaire |
---|
48 | itau_wcosp = itau_phy + itap + start_time * day_step / iphysiq |
---|
49 | |
---|
50 | ! On le donne a cosp_output_write_mod pour que les histwrite y aient acces: |
---|
51 | CALL set_itau_iocosp(itau_wcosp) |
---|
52 | |
---|
53 | ok_sync = .TRUE. |
---|
54 | |
---|
55 | IF(.NOT.cosp_varsdefined) THEN |
---|
56 | iinitend = 2 |
---|
57 | ELSE |
---|
58 | iinitend = 1 |
---|
59 | ENDIF |
---|
60 | |
---|
61 | ! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage: |
---|
62 | DO iinit=1, iinitend |
---|
63 | #ifdef CPP_XIOS |
---|
64 | IF (cosp_varsdefined) THEN |
---|
65 | CALL wxios_update_calendar(itau_iocosp) |
---|
66 | END IF |
---|
67 | #endif |
---|
68 | |
---|
69 | if (cfg%Llidar_sim) then |
---|
70 | |
---|
71 | ! Pb des valeurs indefinies, on les met a 0 |
---|
72 | ! A refaire proprement |
---|
73 | do k = 1,Nlevout |
---|
74 | do ip = 1,Npoints |
---|
75 | if(stlidar%lidarcld(ip,k).eq.R_UNDEF)then |
---|
76 | stlidar%lidarcld(ip,k)=0. |
---|
77 | endif |
---|
78 | enddo |
---|
79 | |
---|
80 | do ii= 1,SR_BINS |
---|
81 | do ip = 1,Npoints |
---|
82 | if(stlidar%cfad_sr(ip,ii,k).eq.R_UNDEF)then |
---|
83 | stlidar%cfad_sr(ip,ii,k)=0. |
---|
84 | endif |
---|
85 | enddo |
---|
86 | enddo |
---|
87 | enddo |
---|
88 | |
---|
89 | do ip = 1,Npoints |
---|
90 | do k = 1,Nlevlmdz |
---|
91 | if(sglidar%beta_mol(ip,k).eq.R_UNDEF)then |
---|
92 | sglidar%beta_mol(ip,k)=0. |
---|
93 | endif |
---|
94 | |
---|
95 | do ii= 1,Ncolumns |
---|
96 | if(sglidar%beta_tot(ip,ii,k).eq.R_UNDEF)then |
---|
97 | sglidar%beta_tot(ip,ii,k)=0. |
---|
98 | endif |
---|
99 | enddo |
---|
100 | |
---|
101 | enddo !k = 1,Nlevlmdz |
---|
102 | enddo !ip = 1,Npoints |
---|
103 | |
---|
104 | do k = 1,LIDAR_NCAT |
---|
105 | do ip = 1,Npoints |
---|
106 | if(stlidar%cldlayer(ip,k).eq.R_UNDEF)then |
---|
107 | stlidar%cldlayer(ip,k)=0. |
---|
108 | endif |
---|
109 | enddo |
---|
110 | enddo |
---|
111 | |
---|
112 | CALL histwrite2d_cosp(o_cllcalipso,stlidar%cldlayer(:,1)) |
---|
113 | CALL histwrite2d_cosp(o_clhcalipso,stlidar%cldlayer(:,3)) |
---|
114 | CALL histwrite2d_cosp(o_clmcalipso,stlidar%cldlayer(:,2)) |
---|
115 | CALL histwrite2d_cosp(o_cltcalipso,stlidar%cldlayer(:,4)) |
---|
116 | CALL histwrite3d_cosp(o_clcalipso,stlidar%lidarcld,nvert) |
---|
117 | |
---|
118 | do icl=1,SR_BINS |
---|
119 | CALL histwrite3d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr(:,icl,:),nvert,icl) |
---|
120 | enddo |
---|
121 | |
---|
122 | CALL histwrite3d_cosp(o_parasol_refl,stlidar%parasolrefl,nvertp) |
---|
123 | |
---|
124 | do k=1,PARASOL_NREFL |
---|
125 | do ip=1, Npoints |
---|
126 | if (stlidar%cldlayer(ip,4).gt.0.01) then |
---|
127 | parasolcrefl(ip,k)=(stlidar%parasolrefl(ip,k)-0.03*(1.-stlidar%cldlayer(ip,4)))/ & |
---|
128 | stlidar%cldlayer(ip,4) |
---|
129 | Ncref(ip,k) = 1. |
---|
130 | else |
---|
131 | parasolcrefl(ip,k)=0. |
---|
132 | Ncref(ip,k) = 0. |
---|
133 | endif |
---|
134 | enddo |
---|
135 | enddo |
---|
136 | CALL histwrite3d_cosp(o_parasol_crefl,parasolcrefl,nvertp) |
---|
137 | |
---|
138 | do icl=1,Ncolumns |
---|
139 | CALL histwrite3d_cosp(o_atb532,sglidar%beta_tot(:,icl,:),nvertmcosp,icl) |
---|
140 | enddo |
---|
141 | CALL histwrite3d_cosp(o_beta_mol532,sglidar%beta_mol,nvertmcosp) |
---|
142 | endif !Lidar |
---|
143 | |
---|
144 | if (cfg%Lisccp_sim) then |
---|
145 | |
---|
146 | ! Traitement des valeurs indefinies |
---|
147 | do ip = 1,Npoints |
---|
148 | if(isccp%totalcldarea(ip).eq.-1.E+30)then |
---|
149 | isccp%totalcldarea(ip)=0. |
---|
150 | endif |
---|
151 | if(isccp%meanptop(ip).eq.-1.E+30)then |
---|
152 | isccp%meanptop(ip)=0. |
---|
153 | endif |
---|
154 | if(isccp%meantaucld(ip).eq.-1.E+30)then |
---|
155 | isccp%meantaucld(ip)=0. |
---|
156 | endif |
---|
157 | if(isccp%meanalbedocld(ip).eq.-1.E+30)then |
---|
158 | isccp%meanalbedocld(ip)=0. |
---|
159 | endif |
---|
160 | if(isccp%meantb(ip).eq.-1.E+30)then |
---|
161 | isccp%meantb(ip)=0. |
---|
162 | endif |
---|
163 | if(isccp%meantbclr(ip).eq.-1.E+30)then |
---|
164 | isccp%meantbclr(ip)=0. |
---|
165 | endif |
---|
166 | |
---|
167 | do k=1,7 |
---|
168 | do ii=1,7 |
---|
169 | if(isccp%fq_isccp(ip,ii,k).eq.-1.E+30)then |
---|
170 | isccp%fq_isccp(ip,ii,k)=0. |
---|
171 | endif |
---|
172 | enddo |
---|
173 | enddo |
---|
174 | |
---|
175 | do ii=1,Ncolumns |
---|
176 | if(isccp%boxtau(ip,ii).eq.-1.E+30)then |
---|
177 | isccp%boxtau(ip,ii)=0. |
---|
178 | endif |
---|
179 | enddo |
---|
180 | |
---|
181 | do ii=1,Ncolumns |
---|
182 | if(isccp%boxptop(ip,ii).eq.-1.E+30)then |
---|
183 | isccp%boxptop(ip,ii)=0. |
---|
184 | endif |
---|
185 | enddo |
---|
186 | enddo |
---|
187 | |
---|
188 | CALL histwrite2d_cosp(o_sunlit,gbx%sunlit) |
---|
189 | do icl=1,7 |
---|
190 | CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl) |
---|
191 | enddo |
---|
192 | CALL histwrite3d_cosp(o_boxtauisccp,isccp%boxtau,nvertcol) |
---|
193 | CALL histwrite3d_cosp(o_boxptopisccp,isccp%boxptop,nvertcol) |
---|
194 | CALL histwrite2d_cosp(o_tclisccp,isccp%totalcldarea) |
---|
195 | CALL histwrite2d_cosp(o_ctpisccp,isccp%meanptop) |
---|
196 | CALL histwrite2d_cosp(o_tauisccp,isccp%meantaucld) |
---|
197 | CALL histwrite2d_cosp(o_albisccp,isccp%meanalbedocld) |
---|
198 | CALL histwrite2d_cosp(o_meantbisccp,isccp%meantb) |
---|
199 | CALL histwrite2d_cosp(o_meantbclrisccp,isccp%meantbclr) |
---|
200 | endif ! Isccp |
---|
201 | |
---|
202 | IF(.NOT.cosp_varsdefined) THEN |
---|
203 | !$OMP MASTER |
---|
204 | DO iff=1,3 |
---|
205 | IF (cosp_outfilekeys(iff)) THEN |
---|
206 | CALL histend(cosp_nidfiles(iff)) |
---|
207 | ENDIF ! cosp_outfilekeys |
---|
208 | ENDDO ! iff |
---|
209 | #ifdef CPP_XIOS |
---|
210 | !On finalise l'initialisation: |
---|
211 | CALL wxios_closedef() |
---|
212 | #endif |
---|
213 | !$OMP END MASTER |
---|
214 | !$OMP BARRIER |
---|
215 | cosp_varsdefined = .TRUE. |
---|
216 | END IF |
---|
217 | END DO !! iinit |
---|
218 | |
---|
219 | ! IF(cosp_varsdefined) THEN |
---|
220 | ! On synchronise les fichiers pour IOIPSL |
---|
221 | !$OMP MASTER |
---|
222 | DO iff=1,3 |
---|
223 | IF (ok_sync .AND. cosp_outfilekeys(iff)) THEN |
---|
224 | CALL histsync(cosp_nidfiles(iff)) |
---|
225 | ENDIF |
---|
226 | END DO |
---|
227 | !$OMP END MASTER |
---|
228 | |
---|
229 | ENDIF ! if freq_COSP |
---|
230 | |
---|
231 | END SUBROUTINE cosp_output_write |
---|
232 | |
---|
233 | ! ug Routine pour definir itau_iocosp depuis cosp_output_write_mod: |
---|
234 | SUBROUTINE set_itau_iocosp(ito) |
---|
235 | IMPLICIT NONE |
---|
236 | INTEGER, INTENT(IN) :: ito |
---|
237 | itau_iocosp = ito |
---|
238 | END SUBROUTINE |
---|
239 | |
---|
240 | SUBROUTINE histdef2d_cosp (iff,var) |
---|
241 | |
---|
242 | USE ioipsl |
---|
243 | USE dimphy |
---|
244 | use iophy |
---|
245 | USE mod_phys_lmdz_para |
---|
246 | |
---|
247 | IMPLICIT NONE |
---|
248 | |
---|
249 | INCLUDE "dimensions.h" |
---|
250 | INCLUDE "temps.h" |
---|
251 | |
---|
252 | INTEGER :: iff |
---|
253 | TYPE(ctrl_outcosp) :: var |
---|
254 | |
---|
255 | REAL zstophym |
---|
256 | CHARACTER(LEN=20) :: typeecrit |
---|
257 | |
---|
258 | ! ug On récupère le type écrit de la structure: |
---|
259 | ! Assez moche, Ã| refaire si meilleure méthode... |
---|
260 | IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN |
---|
261 | typeecrit = 'once' |
---|
262 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_min") > 0) THEN |
---|
263 | typeecrit = 't_min(X)' |
---|
264 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_max") > 0) THEN |
---|
265 | typeecrit = 't_max(X)' |
---|
266 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "inst") > 0) THEN |
---|
267 | typeecrit = 'inst(X)' |
---|
268 | ELSE |
---|
269 | typeecrit = cosp_outfiletypes(iff) |
---|
270 | ENDIF |
---|
271 | |
---|
272 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
---|
273 | zstophym=zoutm_cosp(iff) |
---|
274 | ELSE |
---|
275 | zstophym=zdtimemoy_cosp |
---|
276 | ENDIF |
---|
277 | |
---|
278 | #ifdef CPP_XIOS |
---|
279 | CALL wxios_add_field_to_file(var%name, 2, cosp_nidfiles(iff), |
---|
280 | cosp_outfilenames(iff), & |
---|
281 | var%description, var%unit, var%cles(iff), typeecrit) |
---|
282 | #endif |
---|
283 | IF ( var%cles(iff) ) THEN |
---|
284 | CALL histdef (cosp_nidfiles(iff), var%name, var%description, var%unit, & |
---|
285 | iim,jj_nb,nhoricosp(iff), 1,1,1, -99, 32, & |
---|
286 | typeecrit, zstophym,zoutm_cosp(iff)) |
---|
287 | ENDIF |
---|
288 | |
---|
289 | END SUBROUTINE histdef2d_cosp |
---|
290 | |
---|
291 | SUBROUTINE histdef3d_cosp (iff,var,nvertsave,ncols) |
---|
292 | USE ioipsl |
---|
293 | USE dimphy |
---|
294 | use iophy |
---|
295 | USE mod_phys_lmdz_para |
---|
296 | |
---|
297 | IMPLICIT NONE |
---|
298 | |
---|
299 | INCLUDE "dimensions.h" |
---|
300 | INCLUDE "temps.h" |
---|
301 | |
---|
302 | INTEGER :: iff, klevs |
---|
303 | INTEGER, INTENT(IN), OPTIONAL :: ncols ! ug RUSTINE POUR LES variables 4D |
---|
304 | INTEGER, INTENT(IN) :: nvertsave |
---|
305 | TYPE(ctrl_outcosp) :: var |
---|
306 | |
---|
307 | REAL zstophym |
---|
308 | CHARACTER(LEN=20) :: typeecrit, nomi |
---|
309 | CHARACTER(LEN=20) :: nom |
---|
310 | character(len=2) :: str2 |
---|
311 | |
---|
312 | ! Axe vertical |
---|
313 | IF (nvertsave.eq.nvertp(iff)) THEN |
---|
314 | klevs=PARASOL_NREFL |
---|
315 | ELSE IF (nvertsave.eq.nvertisccp(iff)) THEN |
---|
316 | klevs=7 |
---|
317 | ELSE IF (nvertsave.eq.nvertcol(iff)) THEN |
---|
318 | klevs=Ncolout |
---|
319 | ELSE |
---|
320 | klevs=Nlevout |
---|
321 | ENDIF |
---|
322 | |
---|
323 | |
---|
324 | ! ug RUSTINE POUR LES Champs 4D |
---|
325 | IF (PRESENT(ncols)) THEN |
---|
326 | write(str2,'(i2.2)')ncols |
---|
327 | nomi=var%name |
---|
328 | nom="c"//str2//"_"//nomi |
---|
329 | ELSE |
---|
330 | nom=var%name |
---|
331 | END IF |
---|
332 | |
---|
333 | ! ug On récupère le type écrit de la structure: |
---|
334 | ! Assez moche, Ã| refaire si meilleure méthode... |
---|
335 | IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN |
---|
336 | typeecrit = 'once' |
---|
337 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_min") > 0) THEN |
---|
338 | typeecrit = 't_min(X)' |
---|
339 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "t_max") > 0) THEN |
---|
340 | typeecrit = 't_max(X)' |
---|
341 | ELSE IF(INDEX(var%cosp_typeecrit(iff), "inst") > 0) THEN |
---|
342 | typeecrit = 'inst(X)' |
---|
343 | ELSE |
---|
344 | typeecrit = cosp_outfiletypes(iff) |
---|
345 | ENDIF |
---|
346 | |
---|
347 | IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN |
---|
348 | zstophym=zoutm_cosp(iff) |
---|
349 | ELSE |
---|
350 | zstophym=zdtimemoy_cosp |
---|
351 | ENDIF |
---|
352 | |
---|
353 | #ifdef CPP_XIOS |
---|
354 | CALL wxios_add_field_to_file(nom, 3, cosp_nidfiles(iff), |
---|
355 | cosp_outfilenames(iff), & |
---|
356 | var%description, var%unit, var%flag(iff), typeecrit) |
---|
357 | #endif |
---|
358 | IF ( var%cles(iff) ) THEN |
---|
359 | CALL histdef (cosp_nidfiles(iff), nom, var%description, var%unit, & |
---|
360 | iim, jj_nb, nhoricosp(iff), klevs, 1, & |
---|
361 | klevs, nvertsave, 32, typeecrit, & |
---|
362 | zstophym, zoutm_cosp(iff)) |
---|
363 | ENDIF |
---|
364 | END SUBROUTINE histdef3d_cosp |
---|
365 | |
---|
366 | SUBROUTINE histwrite2d_cosp(var,field) |
---|
367 | USE dimphy |
---|
368 | USE mod_phys_lmdz_para |
---|
369 | USE ioipsl |
---|
370 | use iophy |
---|
371 | |
---|
372 | #ifdef CPP_XIOS |
---|
373 | USE wxios |
---|
374 | #endif |
---|
375 | |
---|
376 | IMPLICIT NONE |
---|
377 | INCLUDE 'dimensions.h' |
---|
378 | INCLUDE 'iniprint.h' |
---|
379 | |
---|
380 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
---|
381 | REAL, DIMENSION(:), INTENT(IN) :: field |
---|
382 | |
---|
383 | INTEGER :: iff |
---|
384 | |
---|
385 | REAL,DIMENSION(klon_mpi) :: buffer_omp |
---|
386 | INTEGER, allocatable, DIMENSION(:) :: index2d |
---|
387 | REAL :: Field2d(iim,jj_nb) |
---|
388 | CHARACTER(LEN=20) :: nomi, nom |
---|
389 | character(len=2) :: str2 |
---|
390 | |
---|
391 | IF (prt_level >= 9) WRITE(lunout,*)'Begin histrwrite2d ',var%name |
---|
392 | |
---|
393 | ! On regarde si on est dans la phase de définition ou d'écriture: |
---|
394 | IF(.NOT.cosp_varsdefined) THEN |
---|
395 | !$OMP MASTER |
---|
396 | !Si phase de définition.... on définit |
---|
397 | CALL conf_cospoutputs(var%name,var%cles) |
---|
398 | DO iff=1, 3 |
---|
399 | IF (cosp_outfilekeys(iff)) THEN |
---|
400 | CALL histdef2d_cosp(iff, var) |
---|
401 | ENDIF |
---|
402 | ENDDO |
---|
403 | !$OMP END MASTER |
---|
404 | ELSE |
---|
405 | !Et sinon on.... écrit |
---|
406 | IF (SIZE(field)/=klon) & |
---|
407 | CALL abort_gcm('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1) |
---|
408 | |
---|
409 | CALL Gather_omp(field,buffer_omp) |
---|
410 | !$OMP MASTER |
---|
411 | CALL grid1Dto2D_mpi(buffer_omp,Field2d) |
---|
412 | |
---|
413 | ! La boucle sur les fichiers: |
---|
414 | DO iff=1, 3 |
---|
415 | IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN |
---|
416 | ALLOCATE(index2d(iim*jj_nb)) |
---|
417 | CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,iim*jj_nb,index2d) |
---|
418 | #ifdef CPP_XIOS |
---|
419 | IF (iff == 1) THEN |
---|
420 | CALL wxios_write_2D(var%name, Field2d) |
---|
421 | ENDIF |
---|
422 | #endif |
---|
423 | |
---|
424 | deallocate(index2d) |
---|
425 | ENDIF !levfiles |
---|
426 | ENDDO |
---|
427 | !$OMP END MASTER |
---|
428 | ENDIF ! vars_defined |
---|
429 | IF (prt_level >= 9) WRITE(lunout,*)'End histrwrite2d_cosp ',nom |
---|
430 | END SUBROUTINE histwrite2d_cosp |
---|
431 | |
---|
432 | ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE |
---|
433 | ! AI sept 2013 |
---|
434 | SUBROUTINE histwrite3d_cosp(var, field, nverts, ncols) |
---|
435 | USE dimphy |
---|
436 | USE mod_phys_lmdz_para |
---|
437 | USE ioipsl |
---|
438 | use iophy |
---|
439 | |
---|
440 | #ifdef CPP_XIOS |
---|
441 | ! USE WXIOS |
---|
442 | #endif |
---|
443 | |
---|
444 | |
---|
445 | IMPLICIT NONE |
---|
446 | INCLUDE 'dimensions.h' |
---|
447 | INCLUDE 'iniprint.h' |
---|
448 | |
---|
449 | TYPE(ctrl_outcosp), INTENT(IN) :: var |
---|
450 | REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:) |
---|
451 | INTEGER, INTENT(IN), OPTIONAL :: ncols ! ug RUSTINE POUR LES Champs 4D..... |
---|
452 | INTEGER, DIMENSION(3), INTENT(IN) :: nverts |
---|
453 | |
---|
454 | INTEGER :: iff, k |
---|
455 | |
---|
456 | REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp |
---|
457 | REAL :: Field3d(iim,jj_nb,SIZE(field,2)) |
---|
458 | INTEGER :: ip, n, nlev |
---|
459 | INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d |
---|
460 | CHARACTER(LEN=20) :: nomi, nom |
---|
461 | character(len=2) :: str2 |
---|
462 | |
---|
463 | IF (prt_level >= 9) write(lunout,*)'Begin histrwrite3d ',var%name |
---|
464 | |
---|
465 | ! ug RUSTINE POUR LES STD LEVS..... |
---|
466 | IF (PRESENT(ncols)) THEN |
---|
467 | write(str2,'(i2.2)')ncols |
---|
468 | nomi=var%name |
---|
469 | nom="c"//str2//"_"//nomi |
---|
470 | ELSE |
---|
471 | nom=var%name |
---|
472 | END IF |
---|
473 | ! On regarde si on est dans la phase de définition ou d'écriture: |
---|
474 | IF(.NOT.cosp_varsdefined) THEN |
---|
475 | !Si phase de définition.... on définit |
---|
476 | !$OMP MASTER |
---|
477 | CALL conf_cospoutputs(var%name,var%cles) |
---|
478 | DO iff=1, 3 |
---|
479 | IF (cosp_outfilekeys(iff)) THEN |
---|
480 | CALL histdef3d_cosp(iff, var, nverts(iff), ncols) |
---|
481 | ENDIF |
---|
482 | ENDDO |
---|
483 | !$OMP END MASTER |
---|
484 | ELSE |
---|
485 | !Et sinon on.... écrit |
---|
486 | IF (SIZE(field,1)/=klon) & |
---|
487 | CALL abort_gcm('iophy::histwrite3d','Field first DIMENSION not equal to klon',1) |
---|
488 | nlev=SIZE(field,2) |
---|
489 | |
---|
490 | |
---|
491 | CALL Gather_omp(field,buffer_omp) |
---|
492 | !$OMP MASTER |
---|
493 | CALL grid1Dto2D_mpi(buffer_omp,field3d) |
---|
494 | |
---|
495 | |
---|
496 | ! BOUCLE SUR LES FICHIERS |
---|
497 | DO iff=1, 3 |
---|
498 | IF (var%cles(iff) .AND. cosp_outfilekeys(iff)) THEN |
---|
499 | ALLOCATE(index3d(iim*jj_nb*nlev)) |
---|
500 | CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,iim*jj_nb*nlev,index3d) |
---|
501 | |
---|
502 | #ifdef CPP_XIOS |
---|
503 | IF (iff == 1) THEN |
---|
504 | CALL wxios_write_3D(nom, Field3d(:,:,1:klev)) |
---|
505 | ENDIF |
---|
506 | #endif |
---|
507 | deallocate(index3d) |
---|
508 | ENDIF |
---|
509 | ENDDO |
---|
510 | !$OMP END MASTER |
---|
511 | ENDIF ! vars_defined |
---|
512 | IF (prt_level >= 9) write(lunout,*)'End histrwrite3d_cosp ',nom |
---|
513 | END SUBROUTINE histwrite3d_cosp |
---|
514 | |
---|
515 | SUBROUTINE conf_cospoutputs(nam_var,cles_var) |
---|
516 | !!! Lecture des noms et cles de sortie des variables dans config.def |
---|
517 | ! en utilisant les routines getin de IOIPSL |
---|
518 | use ioipsl |
---|
519 | |
---|
520 | IMPLICIT NONE |
---|
521 | include 'iniprint.h' |
---|
522 | |
---|
523 | CHARACTER(LEN=20) :: nam_var, nnam_var |
---|
524 | LOGICAL, DIMENSION(3) :: cles_var |
---|
525 | |
---|
526 | ! Lecture dans config.def ou output.def de cles_var et name_var |
---|
527 | CALL getin('cles_'//nam_var,cles_var) |
---|
528 | CALL getin('name_'//nam_var,nam_var) |
---|
529 | IF(prt_level>10) WRITE(lunout,*)'nam_var cles_var ',nam_var,cles_var(:) |
---|
530 | |
---|
531 | END SUBROUTINE conf_cospoutputs |
---|
532 | |
---|
533 | END MODULE cosp_output_write_mod |
---|