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