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