Ignore:
Timestamp:
Jul 21, 2020, 11:08:53 AM (4 years ago)
Author:
adurocher
Message:

Offload post-processing to XIOS

use expressions in .xml files to offload computations previously done in phys_output_write to XIOS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Optimisation_LMDZ/libf/phylmd/phys_output_write_xios_mod.f90

    r3754 r3768  
    353353    INTEGER :: flag_aerosol_strat
    354354    INTEGER :: flag_aerosol
    355     LOGICAL :: ok_cdnc
     355    LOGICAL :: ok_cdnc, var_is_set
    356356
    357357    ! Local
     
    374374    INTEGER ISW
    375375    CHARACTER*1 ch1
     376    CHARACTER(len=3) :: isrf_str
    376377    CHARACTER*20 varname
    377378
     
    381382    REAL, DIMENSION(klon, klev) :: z, dz
    382383    REAL, DIMENSION(klon)      :: zrho, zt
     384
     385    type(ctrl_out), SAVE :: o_wo_1 = ctrl_out(flag=0, name="wo_1", description = "Temporary", unit = "-", type_ecrit = "")
     386    type(ctrl_out), SAVE :: o_swradcorr = ctrl_out(flag=0, name="swradcorr", description = "Temporary", unit = "-", type_ecrit = "")
    383387
    384388    if( .not. CPP_XIOS_defined ) call abort_physic("phys_output_write_xios", "This io backend can only be used when LMDZ is compiled with XIOS support",1 )
     
    420424
    421425    !$omp MASTER
     426    IF (.not. vars_defined) THEN
     427      var_is_set = xios_setVar("pdtphys", pdtphys)
     428      var_is_set = xios_setVar("RG", RG)
     429      !wo_coeff = dobson_u*1e3/rmo3*rmd
     430      var_is_set = xios_setVar("dobson_u", dobson_u)
     431      var_is_set = xios_setVar("rmo3", rmo3)
     432      var_is_set = xios_setVar("rmd", rmd)
     433      var_is_set = xios_setVar("missing_val", missing_val)
     434    ENDIF
    422435    IF (.not. vars_defined .and. ok_strataer) THEN
    423436      !On ajoute les variables 3D traceurs par l interface fortran
     
    510523      CALL histwrite_phy(o_aire, zx_tmp_fi2d)
    511524
    512       DO i = 1, klon
    513         zx_tmp_fi2d(i) = pctsrf(i, is_ter) + pctsrf(i, is_lic)
    514       ENDDO
    515       CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
    516       CALL histwrite_phy(o_contfracOR, pctsrf(:, is_ter))
     525      ! DO i = 1, klon
     526      !   zx_tmp_fi2d(i) = pctsrf(i, is_ter) + pctsrf(i, is_lic)
     527      ! ENDDO
     528      ! CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
     529      !CALL histwrite_phy(o_contfracOR, pctsrf(:, is_ter))
    517530      CALL histwrite_phy("R_ecc", R_ecc)
    518531      CALL histwrite_phy("R_peri", R_peri)
     
    580593      CALL histwrite_phy(o_tsol, zxtsol)
    581594      CALL histwrite_phy(o_t2m, zt2m_cor)
    582       CALL histwrite_phy(o_t2m_min, zt2m_cor)
    583       CALL histwrite_phy(o_t2m_max, zt2m_cor)
     595      !CALL histwrite_phy(o_t2m_min, zt2m_cor)
     596      !CALL histwrite_phy(o_t2m_max, zt2m_cor)
    584597      CALL histwrite_phy(o_t2m_max_mon, t2m_max_mon)
    585598      CALL histwrite_phy(o_t2m_min_mon, t2m_min_mon)
    586       DO i = 1, klon
    587         zx_tmp_fi2d(i) = SQRT(zu10m_cor(i)*zu10m_cor(i) + zv10m_cor(i)*zv10m_cor(i))
    588       ENDDO
    589       CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
    590       DO i = 1, klon
    591         zx_tmp_fi2d(i) = SQRT(zu10m_cor(i)*zu10m_cor(i) + zv10m_cor(i)*zv10m_cor(i))
    592       ENDDO
    593       CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
     599      ! DO i = 1, klon
     600      !   zx_tmp_fi2d(i) = SQRT(zu10m_cor(i)*zu10m_cor(i) + zv10m_cor(i)*zv10m_cor(i))
     601      ! ENDDO
     602      ! CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
     603      ! DO i = 1, klon
     604      !   zx_tmp_fi2d(i) = SQRT(zu10m_cor(i)*zu10m_cor(i) + zv10m_cor(i)*zv10m_cor(i))
     605      ! ENDDO
     606      ! CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
    594607
    595608      CALL histwrite_phy(o_gusts, gustiness)
     
    615628        ENDDO
    616629      ENDDO
    617     CALL histwrite_phy(o_wind100m, zx_tmp_fi2d)
    618     IF (vars_defined) THEN
    619       DO i = 1, klon
    620         zx_tmp_fi2d(i) = pctsrf(i, is_sic)
    621       ENDDO
    622     ENDIF
    623       CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
     630      CALL histwrite_phy(o_wind100m, zx_tmp_fi2d)
     631      !CALL histwrite_phy(o_sicf, pctsrf(1:klon, is_sic))
    624632      CALL histwrite_phy(o_q2m, zq2m_cor)
    625633      CALL histwrite_phy(o_ustar, zustar)
    626634      CALL histwrite_phy(o_u10m, zu10m_cor)
    627635      CALL histwrite_phy(o_v10m, zv10m_cor)
    628       DO i = 1, klon
    629         zx_tmp_fi2d(i) = paprs(i, 1)
    630       ENDDO
    631 
    632       CALL histwrite_phy(o_psol, zx_tmp_fi2d)
     636      CALL histwrite_phy(o_psol, paprs(1:klon, 1))
    633637      CALL histwrite_phy(o_mass, zmasse)
    634638      CALL histwrite_phy(o_qsurf, zxqsurf)
     
    638642      ENDIF
    639643
    640       DO i = 1, klon
    641         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
    642       ENDDO
    643 
    644       CALL histwrite_phy(o_precip, zx_tmp_fi2d)
     644      ! DO i = 1, klon
     645      !   zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
     646      ! ENDDO
     647      ! CALL histwrite_phy(o_precip, zx_tmp_fi2d)
    645648      CALL histwrite_phy(o_rain_fall, rain_fall)
    646649      CALL histwrite_phy(o_ndayrain, nday_rain)
    647650      CALL histwrite_phy(o_ep, ep)
    648651     
    649       DO i = 1, klon
    650         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
    651       ENDDO
    652       CALL histwrite_phy(o_plul, zx_tmp_fi2d)
     652      ! DO i = 1, klon
     653      !   zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
     654      ! ENDDO
     655      ! CALL histwrite_phy(o_plul, zx_tmp_fi2d)
     656      CALL histwrite_phy(o_plul, rain_lsc)
    653657      CALL histwrite_phy(o_plun, rain_num)
    654658
    655       DO i = 1, klon
    656         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
    657       ENDDO
    658       CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
    659       CALL histwrite_phy(o_rain_con, rain_con)
     659      ! DO i = 1, klon
     660      !   zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
     661      ! ENDDO
     662      ! CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
     663      CALL histwrite_phy(o_pluc, snow_con)
     664      CALL histwrite_phy(o_rain_con, rain_con)     
    660665      CALL histwrite_phy(o_snow, snow_fall)
    661666      CALL histwrite_phy(o_msnow, zxsnow)
     
    663668      CALL histwrite_phy(o_evap, evap)
    664669
    665 
    666       zx_tmp_fi2d = topsw*swradcorr
    667       CALL histwrite_phy(o_tops, zx_tmp_fi2d)
    668       zx_tmp_fi2d = topsw0*swradcorr
    669       CALL histwrite_phy(o_tops0, zx_tmp_fi2d)
     670     
     671
    670672      CALL histwrite_phy(o_topl, toplw)
    671673      CALL histwrite_phy(o_topl0, toplw0)
    672       zx_tmp_fi2d(:) = swup(:, klevp1)*swradcorr(:)
    673       CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
    674       zx_tmp_fi2d(:) = swup0(:, klevp1)*swradcorr(:)
    675       CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
    676       zx_tmp_fi2d(:) = swupc0(:, klevp1)*swradcorr(:)
    677       CALL histwrite_phy(o_SWupTOAcleanclr, zx_tmp_fi2d)
    678       zx_tmp_fi2d(:) = swdn(:, klevp1)*swradcorr(:)
    679       CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
    680       zx_tmp_fi2d(:) = swdn0(:, klevp1)*swradcorr(:)
    681       CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
    682       zx_tmp_fi2d(:) = topsw(:)*swradcorr(:) - toplw(:)
    683       CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
    684       zx_tmp_fi2d = SWup200*swradcorr
    685       CALL histwrite_phy(o_SWup200, zx_tmp_fi2d)
    686       zx_tmp_fi2d = SWup200clr*swradcorr
    687       CALL histwrite_phy(o_SWup200clr, zx_tmp_fi2d)
    688       zx_tmp_fi2d = SWdn200*swradcorr
    689       CALL histwrite_phy(o_SWdn200, zx_tmp_fi2d)
    690       zx_tmp_fi2d = SWdn200clr*swradcorr
    691       CALL histwrite_phy(o_SWdn200clr, zx_tmp_fi2d)
     674
     675      ! zx_tmp_fi2d = topsw*swradcorr
     676      ! CALL histwrite_phy(o_tops, zx_tmp_fi2d)     
     677      ! zx_tmp_fi2d = topsw0*swradcorr
     678      ! CALL histwrite_phy(o_tops0, zx_tmp_fi2d)     
     679      ! zx_tmp_fi2d(:) = swup(:, klevp1)*swradcorr(:)
     680      ! CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
     681      ! zx_tmp_fi2d(:) = swup0(:, klevp1)*swradcorr(:)
     682      ! CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
     683      ! zx_tmp_fi2d(:) = swupc0(:, klevp1)*swradcorr(:)
     684      ! CALL histwrite_phy(o_SWupTOAcleanclr, zx_tmp_fi2d)
     685      ! zx_tmp_fi2d(:) = swdn(:, klevp1)*swradcorr(:)
     686      ! CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
     687      ! zx_tmp_fi2d(:) = swdn0(:, klevp1)*swradcorr(:)
     688      ! CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
     689      ! zx_tmp_fi2d(:) = topsw(:)*swradcorr(:) - toplw(:)
     690      ! CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
     691      ! zx_tmp_fi2d = SWup200*swradcorr
     692      ! CALL histwrite_phy(o_SWup200, zx_tmp_fi2d)
     693      ! zx_tmp_fi2d = SWup200clr*swradcorr
     694      ! CALL histwrite_phy(o_SWup200clr, zx_tmp_fi2d)
     695      ! zx_tmp_fi2d = SWdn200*swradcorr
     696      ! CALL histwrite_phy(o_SWdn200, zx_tmp_fi2d)
     697      ! zx_tmp_fi2d = SWdn200clr*swradcorr
     698      ! CALL histwrite_phy(o_SWdn200clr, zx_tmp_fi2d)
     699      ! zx_tmp_fi2d = solsw*swradcorr
     700      ! CALL histwrite_phy(o_sols, zx_tmp_fi2d)
     701      ! zx_tmp_fi2d = solsw0*swradcorr
     702      ! CALL histwrite_phy(o_sols0, zx_tmp_fi2d)
     703      ! zx_tmp_fi2d(:) = swup(:, 1)*swradcorr(:)
     704      ! CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
     705      ! zx_tmp_fi2d(:) = swup0(:, 1)*swradcorr(:)
     706      ! CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
     707      ! zx_tmp_fi2d(:) = swupc0(:, 1)*swradcorr(:)
     708      ! CALL histwrite_phy(o_SWupSFCcleanclr, zx_tmp_fi2d)
     709      ! zx_tmp_fi2d(:) = swdn(:, 1)*swradcorr(:)
     710      ! CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
     711      ! zx_tmp_fi2d(:) = swdn0(:, 1)*swradcorr(:)
     712      ! CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
     713      ! zx_tmp_fi2d(:) = swdnc0(:, 1)*swradcorr(:)
     714      ! CALL histwrite_phy(o_SWdnSFCcleanclr, zx_tmp_fi2d)
     715      CALL histwrite_phy(o_swradcorr, swradcorr)
     716      CALL histwrite_phy(o_tops, topsw)
     717      CALL histwrite_phy(o_tops0, topsw0)
     718      CALL histwrite_phy(o_SWupTOA, swup(:, klevp1))
     719      CALL histwrite_phy(o_SWupTOAclr, swup0(:, klevp1))
     720      CALL histwrite_phy(o_SWupTOAcleanclr, swupc0(:, klevp1))
     721      CALL histwrite_phy(o_SWdnTOA, swdn(:, klevp1))
     722      CALL histwrite_phy(o_SWdnTOAclr, swdn0(:, klevp1))
     723      CALL histwrite_phy(o_SWup200, SWup200)
     724      CALL histwrite_phy(o_SWup200clr, SWup200clr)
     725      CALL histwrite_phy(o_SWdn200, SWdn200)
     726      CALL histwrite_phy(o_SWdn200clr, SWdn200clr)
     727
     728      CALL histwrite_phy(o_SWupSFC, swup(:, 1))
     729      CALL histwrite_phy(o_SWupSFCclr, swup0(:, 1))
     730      CALL histwrite_phy(o_SWupSFCcleanclr, swupc0(:, 1))
     731      CALL histwrite_phy(o_SWdnSFC, swdn(:, 1))
     732      CALL histwrite_phy(o_SWdnSFCclr, swdn0(:, 1))
     733      CALL histwrite_phy(o_SWdnSFCcleanclr, swdnc0(:, 1))
     734
    692735      CALL histwrite_phy(o_LWup200, LWup200)
    693736      CALL histwrite_phy(o_LWup200clr, LWup200clr)
    694737      CALL histwrite_phy(o_LWdn200, LWdn200)
    695738      CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
    696       zx_tmp_fi2d = solsw*swradcorr
    697       CALL histwrite_phy(o_sols, zx_tmp_fi2d)
    698       zx_tmp_fi2d = solsw0*swradcorr
    699       CALL histwrite_phy(o_sols0, zx_tmp_fi2d)
     739     
     740      CALL histwrite_phy(o_sols, solsw)
     741      CALL histwrite_phy(o_sols0, solsw0)
    700742      CALL histwrite_phy(o_soll, sollw)
    701743      CALL histwrite_phy(o_soll0, sollw0)
    702744      CALL histwrite_phy(o_radsol, radsol)
    703       zx_tmp_fi2d(:) = swup(:, 1)*swradcorr(:)
    704       CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
    705       zx_tmp_fi2d(:) = swup0(:, 1)*swradcorr(:)
    706       CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
    707       zx_tmp_fi2d(:) = swupc0(:, 1)*swradcorr(:)
    708       CALL histwrite_phy(o_SWupSFCcleanclr, zx_tmp_fi2d)
    709       zx_tmp_fi2d(:) = swdn(:, 1)*swradcorr(:)
    710       CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
    711       zx_tmp_fi2d(:) = swdn0(:, 1)*swradcorr(:)
    712       CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
    713       zx_tmp_fi2d(:) = swdnc0(:, 1)*swradcorr(:)
    714       CALL histwrite_phy(o_SWdnSFCcleanclr, zx_tmp_fi2d)
    715       zx_tmp_fi2d(:) = sollwdown(:) - sollw(:)
    716       CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
     745
    717746      CALL histwrite_phy(o_LWdnSFC, sollwdown)
    718       sollwdownclr(1:klon) = -1.*lwdn0(1:klon, 1)
    719       zx_tmp_fi2d(1:klon) = sollwdownclr(1:klon) - sollw0(1:klon)
    720       CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
    721       CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
    722       zx_tmp_fi2d(:) = lwupc0(:, klevp1)
    723       CALL histwrite_phy(o_LWupTOAcleanclr, zx_tmp_fi2d)
    724       zx_tmp_fi2d(:) = -1.*lwdnc0(:, 1)
    725       CALL histwrite_phy(o_LWdnSFCcleanclr, zx_tmp_fi2d)
     747
     748      !sollwdownclr(1:klon) = -1.*lwdn0(1:klon, 1)
     749      !zx_tmp_fi2d(1:klon) = sollwdownclr(1:klon) - sollw0(1:klon)
     750      !CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
     751      !CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
     752      CALL histwrite_phy(o_LWdnSFCclr, lwdn0(1:klon, 1))
     753      CALL histwrite_phy(o_LWupTOAcleanclr, lwupc0(:, klevp1))
     754      ! zx_tmp_fi2d(:) = -1.*lwdnc0(:, 1)
     755      ! CALL histwrite_phy(o_LWdnSFCcleanclr, zx_tmp_fi2d)
     756      CALL histwrite_phy(o_LWdnSFCcleanclr, lwdnc0(:, 1))
    726757      CALL histwrite_phy(o_bils, bils)
    727758      CALL histwrite_phy(o_bils_diss, bils_diss)
     
    732763      CALL histwrite_phy(o_bils_latent, bils_latent)
    733764      CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
    734       zx_tmp_fi2d(1:klon) = -1*sens(1:klon)
    735       CALL histwrite_phy(o_sens, zx_tmp_fi2d)
     765      ! zx_tmp_fi2d(1:klon) = -1*sens(1:klon)
     766      ! CALL histwrite_phy(o_sens, zx_tmp_fi2d)
     767      CALL histwrite_phy(o_sens, sens(1:klon))
    736768      CALL histwrite_phy(o_fder, fder)
    737769      CALL histwrite_phy(o_ffonte, zxffonte)
    738770      CALL histwrite_phy(o_fqcalving, zxfqcalving)
    739771      CALL histwrite_phy(o_fqfonte, zxfqfonte)
    740       zx_tmp_fi2d(1:klon) = (zxfqfonte(1:klon) + rain_fall(1:klon))*pctsrf(1:klon, is_lic)
    741       CALL histwrite_phy(o_mrroli, zx_tmp_fi2d)
     772      ! zx_tmp_fi2d(1:klon) = (zxfqfonte(1:klon) + rain_fall(1:klon))*pctsrf(1:klon, is_lic)
     773      ! CALL histwrite_phy(o_mrroli, zx_tmp_fi2d)
    742774      CALL histwrite_phy(o_runofflic, zxrunofflic)
    743       zx_tmp_fi2d = 0.
    744       DO nsrf = 1, nbsrf
    745         zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + pctsrf(:, nsrf)*fluxu(:, 1, nsrf)
    746       ENDDO
    747       CALL histwrite_phy(o_taux, zx_tmp_fi2d)
    748 
    749       zx_tmp_fi2d = 0.
    750       DO nsrf = 1, nbsrf
    751         zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + pctsrf(:, nsrf)*fluxv(:, 1, nsrf)
    752       ENDDO
    753       CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
     775      ! zx_tmp_fi2d = 0.
     776      ! DO nsrf = 1, nbsrf
     777      !   zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + pctsrf(:, nsrf)*fluxu(:, 1, nsrf)
     778      ! ENDDO
     779      ! CALL histwrite_phy(o_taux, zx_tmp_fi2d)
     780      ! zx_tmp_fi2d = 0.
     781      ! DO nsrf = 1, nbsrf
     782      !   zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + pctsrf(:, nsrf)*fluxv(:, 1, nsrf)
     783      ! ENDDO
     784      ! CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
    754785
    755786      IF (ok_snow) THEN
     
    764795   
    765796      DO nsrf = 1, nbsrf
    766         zx_tmp_fi2d(1:klon) = pctsrf(1:klon, nsrf)*100.
    767         CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
    768         zx_tmp_fi2d(1:klon) = pctsrf(1:klon, nsrf)
    769         CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
    770         zx_tmp_fi2d(1:klon) = fluxu(1:klon, 1, nsrf)
    771         CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
    772         zx_tmp_fi2d(1:klon) = fluxv(1:klon, 1, nsrf)
    773         CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
    774         zx_tmp_fi2d(1:klon) = ftsol(1:klon, nsrf)
    775         CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
    776         zx_tmp_fi2d(1:klon) = evap_pot(1:klon, nsrf)
    777         CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
    778         zx_tmp_fi2d(1:klon) = ustar(1:klon, nsrf)
    779         CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
    780         zx_tmp_fi2d(1:klon) = u10m(1:klon, nsrf)
    781         CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
    782         zx_tmp_fi2d(1:klon) = v10m(1:klon, nsrf)
    783         CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
    784         zx_tmp_fi2d(1:klon) = t2m(1:klon, nsrf)
    785         CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
    786         zx_tmp_fi2d(1:klon) = fevap(1:klon, nsrf)
    787         CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
    788         zx_tmp_fi2d(1:klon) = fluxt(1:klon, 1, nsrf)
    789         CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
    790         zx_tmp_fi2d(1:klon) = fluxlat(1:klon, nsrf)
    791         CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
    792         zx_tmp_fi2d(1:klon) = fsollw(1:klon, nsrf)
    793         CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
    794         zx_tmp_fi2d(1:klon) = fsolsw(1:klon, nsrf)
    795         CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
    796         zx_tmp_fi2d(1:klon) = wfbils(1:klon, nsrf)
    797         CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
    798         zx_tmp_fi2d(1:klon) = wfbilo(1:klon, nsrf)
    799         CALL histwrite_phy(o_wbilo_srf(nsrf), zx_tmp_fi2d)
    800         zx_tmp_fi2d(1:klon) = wfevap(1:klon, nsrf)
    801         CALL histwrite_phy(o_wevap_srf(nsrf), zx_tmp_fi2d)
    802         zx_tmp_fi2d(1:klon) = wfrain(1:klon, nsrf)
    803         CALL histwrite_phy(o_wrain_srf(nsrf), zx_tmp_fi2d)
    804         zx_tmp_fi2d(1:klon) = wfsnow(1:klon, nsrf)
    805         CALL histwrite_phy(o_wsnow_srf(nsrf), zx_tmp_fi2d)
     797        ! zx_tmp_fi2d(1:klon) = pctsrf(1:klon, nsrf)*100.
     798        ! CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
     799        CALL histwrite_phy(o_fract_srf(nsrf), pctsrf(1:klon, nsrf))
     800        CALL histwrite_phy(o_taux_srf(nsrf), fluxu(1:klon, 1, nsrf))
     801        CALL histwrite_phy(o_tauy_srf(nsrf), fluxv(1:klon, 1, nsrf))
     802        CALL histwrite_phy(o_tsol_srf(nsrf), ftsol(1:klon, nsrf))
     803        CALL histwrite_phy(o_evappot_srf(nsrf), evap_pot(1:klon, nsrf))
     804        CALL histwrite_phy(o_ustar_srf(nsrf), ustar(1:klon, nsrf))
     805        CALL histwrite_phy(o_u10m_srf(nsrf), u10m(1:klon, nsrf))
     806        CALL histwrite_phy(o_v10m_srf(nsrf), v10m(1:klon, nsrf))
     807        CALL histwrite_phy(o_t2m_srf(nsrf), t2m(1:klon, nsrf))
     808        CALL histwrite_phy(o_evap_srf(nsrf), fevap(1:klon, nsrf))
     809        CALL histwrite_phy(o_sens_srf(nsrf), fluxt(1:klon, 1, nsrf))
     810        CALL histwrite_phy(o_lat_srf(nsrf), fluxlat(1:klon, nsrf))
     811        CALL histwrite_phy(o_flw_srf(nsrf), fsollw(1:klon, nsrf))
     812        CALL histwrite_phy(o_fsw_srf(nsrf), fsolsw(1:klon, nsrf))
     813        CALL histwrite_phy(o_wbils_srf(nsrf), wfbils(1:klon, nsrf))
     814        CALL histwrite_phy(o_wbilo_srf(nsrf), wfbilo(1:klon, nsrf))
     815        CALL histwrite_phy(o_wevap_srf(nsrf), wfevap(1:klon, nsrf))
     816        CALL histwrite_phy(o_wrain_srf(nsrf), wfrain(1:klon, nsrf))
     817        CALL histwrite_phy(o_wsnow_srf(nsrf), wfsnow(1:klon, nsrf))
    806818
    807819        IF (iflag_pbl > 1) THEN
    808820          CALL histwrite_phy(o_tke_srf(nsrf), pbl_tke(:, 1:klev, nsrf))
    809821          CALL histwrite_phy(o_l_mixmin(nsrf), l_mixmin(:, 1:klev, nsrf))
    810           CALL histwrite_phy(o_tke_max_srf(nsrf), pbl_tke(:, 1:klev, nsrf))
     822          !CALL histwrite_phy(o_tke_max_srf(nsrf), pbl_tke(:, 1:klev, nsrf))
    811823        ENDIF
    812824        IF (iflag_pbl > 1 .AND. iflag_wake >= 1 .AND. iflag_pbl_split >= 1) THEN
     
    815827      ENDDO
    816828
    817       zx_tmp_fi2d(1:klon) = sens_prec_liq_o(1:klon, 1)
    818       CALL histwrite_phy(o_sens_prec_liq_oce, zx_tmp_fi2d)
    819       zx_tmp_fi2d(1:klon) = sens_prec_liq_o(1:klon, 2)
    820       CALL histwrite_phy(o_sens_prec_liq_sic, zx_tmp_fi2d)
    821       zx_tmp_fi2d(1:klon) = sens_prec_sol_o(1:klon, 1)
    822       CALL histwrite_phy(o_sens_prec_sol_oce, zx_tmp_fi2d)
    823       zx_tmp_fi2d(1:klon) = sens_prec_sol_o(1:klon, 2)
    824       CALL histwrite_phy(o_sens_prec_sol_sic, zx_tmp_fi2d)
    825 
    826       zx_tmp_fi2d(1:klon) = lat_prec_liq_o(1:klon, 1)
    827       CALL histwrite_phy(o_lat_prec_liq_oce, zx_tmp_fi2d)
    828       zx_tmp_fi2d(1:klon) = lat_prec_liq_o(1:klon, 2)
    829       CALL histwrite_phy(o_lat_prec_liq_sic, zx_tmp_fi2d)
    830       zx_tmp_fi2d(1:klon) = lat_prec_sol_o(1:klon, 1)
    831       CALL histwrite_phy(o_lat_prec_sol_oce, zx_tmp_fi2d)
    832       zx_tmp_fi2d(1:klon) = lat_prec_sol_o(1:klon, 2)
    833       CALL histwrite_phy(o_lat_prec_sol_sic, zx_tmp_fi2d)
     829      CALL histwrite_phy(o_sens_prec_liq_oce, sens_prec_liq_o(1:klon, 1))
     830      CALL histwrite_phy(o_sens_prec_liq_sic, sens_prec_liq_o(1:klon, 2))
     831      CALL histwrite_phy(o_sens_prec_sol_oce, sens_prec_sol_o(1:klon, 1))
     832      CALL histwrite_phy(o_sens_prec_sol_sic, sens_prec_sol_o(1:klon, 2))
     833
     834      CALL histwrite_phy(o_lat_prec_liq_oce, lat_prec_liq_o(1:klon, 1))
     835      CALL histwrite_phy(o_lat_prec_liq_sic, lat_prec_liq_o(1:klon, 2))
     836      CALL histwrite_phy(o_lat_prec_sol_oce, lat_prec_sol_o(1:klon, 1))
     837      CALL histwrite_phy(o_lat_prec_sol_sic, lat_prec_sol_o(1:klon, 2))
    834838
    835839      DO nsrf = 1, nbsrf + 1
     
    845849      CALL histwrite_phy(o_JrNt, JrNt)
    846850
    847       zx_tmp_fi2d = cldl*JrNt
    848       CALL histwrite_phy(o_cldljn, zx_tmp_fi2d)
    849 
    850       zx_tmp_fi2d = cldm*JrNt
    851       CALL histwrite_phy(o_cldmjn, zx_tmp_fi2d)
    852 
    853       zx_tmp_fi2d = cldh*JrNt
    854       CALL histwrite_phy(o_cldhjn, zx_tmp_fi2d)
    855 
    856       zx_tmp_fi2d = cldt*JrNt
    857       CALL histwrite_phy(o_cldtjn, zx_tmp_fi2d)
     851      ! zx_tmp_fi2d = cldl*JrNt
     852      ! CALL histwrite_phy(o_cldljn, zx_tmp_fi2d)
     853      ! zx_tmp_fi2d = cldm*JrNt
     854      ! CALL histwrite_phy(o_cldmjn, zx_tmp_fi2d)
     855      ! zx_tmp_fi2d = cldh*JrNt
     856      ! CALL histwrite_phy(o_cldhjn, zx_tmp_fi2d)
     857      ! zx_tmp_fi2d = cldt*JrNt
     858      ! CALL histwrite_phy(o_cldtjn, zx_tmp_fi2d)
    858859
    859860      CALL histwrite_phy(o_cldq, cldq)
    860       zx_tmp_fi2d(1:klon) = flwp(1:klon)
    861       CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
    862       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
    863       CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
     861      CALL histwrite_phy(o_lwp, flwp(1:klon))
     862      CALL histwrite_phy(o_iwp, fiwp(1:klon))
    864863      CALL histwrite_phy(o_ue, ue)
    865864      CALL histwrite_phy(o_ve, ve)
     
    868867      CALL histwrite_phy(o_uwat, uwat)
    869868      CALL histwrite_phy(o_vwat, vwat)
    870    
     869
    871870      IF (iflag_con .GE. 3) THEN ! sb
    872871        CALL histwrite_phy(o_cape, cape)
     
    881880        ENDIF
    882881
    883         CALL histwrite_phy(o_cape_max, cape)
     882        !CALL histwrite_phy(o_cape_max, cape)
    884883
    885884        CALL histwrite_phy(o_upwd, upwd)
     
    891890            !! convection (output of the 3 fields: ftime_deepcv, ftime_th and
    892891            !!  ftime_con).
    893         IF (iflag_thermals >= 1) THEN
    894           zx_tmp_fi3d = -dnwd + dnwd0 + upwd + fm_therm(:, 1:klev)
    895         ELSE
    896           zx_tmp_fi3d = -dnwd + dnwd0 + upwd
    897         ENDIF
    898         CALL histwrite_phy(o_mc, zx_tmp_fi3d)
     892        ! IF (iflag_thermals >= 1) THEN
     893        !   zx_tmp_fi3d = -dnwd + dnwd0 + upwd + fm_therm(:, 1:klev)
     894        ! ELSE
     895        !   zx_tmp_fi3d = -dnwd + dnwd0 + upwd
     896        ! ENDIF
     897        ! CALL histwrite_phy(o_mc, zx_tmp_fi3d)
    899898      ENDIF !iflag_con .GE. 3
    900899      CALL histwrite_phy(o_prw, prw)
     
    922921        ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
    923922      ENDDO
    924       DO i = 1, klon
    925         IF (pctsrf(i, is_oce) .GT. epsfra .OR. &
    926             pctsrf(i, is_sic) .GT. epsfra) THEN
    927           zx_tmp_fi2d(i) = (ftsol(i, is_oce)*pctsrf(i, is_oce) + &
    928                             ftsol(i, is_sic)*pctsrf(i, is_sic))/ &
    929                            (pctsrf(i, is_oce) + pctsrf(i, is_sic))
    930         ELSE
    931           zx_tmp_fi2d(i) = 273.15
    932         ENDIF
    933       ENDDO
    934       CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
     923
     924      if( epsfra /= 1.0E-05 ) call abort_physic("phys_output_write_xios", "epsfra changed and is not synchronized with field_def_lmdz.xml", 1)
     925      ! DO i = 1, klon
     926      !   IF (pctsrf(i, is_oce) .GT. epsfra .OR. &
     927      !       pctsrf(i, is_sic) .GT. epsfra) THEN
     928      !     zx_tmp_fi2d(i) = (ftsol(i, is_oce)*pctsrf(i, is_oce) + &
     929      !                       ftsol(i, is_sic)*pctsrf(i, is_sic))/ &
     930      !                      (pctsrf(i, is_oce) + pctsrf(i, is_sic))
     931      !   ELSE
     932      !     zx_tmp_fi2d(i) = 273.15
     933      !   ENDIF
     934      ! ENDDO
     935      ! CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
    935936
    936937      ! Couplage convection-couche limite
     
    948949          CALL histwrite_phy(o_alp_wk, alp_wake)
    949950          IF (iflag_pbl_split >= 1) THEN
    950             zx_tmp_fi3d(1:klon, 1:klev) = d_t_vdf_x(1:klon, 1:klev)/pdtphys
    951             CALL histwrite_phy(o_dtvdf_x, zx_tmp_fi3d)
    952             zx_tmp_fi3d(1:klon, 1:klev) = d_t_vdf_w(1:klon, 1:klev)/pdtphys
    953             CALL histwrite_phy(o_dtvdf_w, zx_tmp_fi3d)
    954             zx_tmp_fi3d(1:klon, 1:klev) = d_q_vdf_x(1:klon, 1:klev)/pdtphys
    955             CALL histwrite_phy(o_dqvdf_x, zx_tmp_fi3d)
    956             zx_tmp_fi3d(1:klon, 1:klev) = d_q_vdf_w(1:klon, 1:klev)/pdtphys
    957             CALL histwrite_phy(o_dqvdf_w, zx_tmp_fi3d)
     951            ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_vdf_x(1:klon, 1:klev)/pdtphys
     952            ! CALL histwrite_phy(o_dtvdf_x, zx_tmp_fi3d)
     953            ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_vdf_w(1:klon, 1:klev)/pdtphys
     954            ! CALL histwrite_phy(o_dtvdf_w, zx_tmp_fi3d)
     955            ! zx_tmp_fi3d(1:klon, 1:klev) = d_q_vdf_x(1:klon, 1:klev)/pdtphys
     956            ! CALL histwrite_phy(o_dqvdf_x, zx_tmp_fi3d)
     957            ! zx_tmp_fi3d(1:klon, 1:klev) = d_q_vdf_w(1:klon, 1:klev)/pdtphys
     958            ! CALL histwrite_phy(o_dqvdf_w, zx_tmp_fi3d)
     959            CALL histwrite_phy(o_dtvdf_x, d_t_vdf_x(1:klon, 1:klev))
     960            CALL histwrite_phy(o_dtvdf_w, d_t_vdf_w(1:klon, 1:klev))
     961            CALL histwrite_phy(o_dqvdf_x, d_q_vdf_x(1:klon, 1:klev))
     962            CALL histwrite_phy(o_dqvdf_w, d_q_vdf_w(1:klon, 1:klev))
     963
    958964            CALL histwrite_phy(o_sens_x, sens_x)
    959965            CALL histwrite_phy(o_sens_w, sens_w)
     
    980986          CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
    981987          CALL histwrite_phy(o_wake_omg, wake_omg)
    982           zx_tmp_fi3d(1:klon, 1:klev) = d_t_wake(1:klon, 1:klev) &
    983                                                           /pdtphys
    984           CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
     988          ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_wake(1:klon, 1:klev) &
     989          !                                                 /pdtphys
     990          ! CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
     991          ! zx_tmp_fi3d(1:klon, 1:klev) = d_q_wake(1:klon, 1:klev)/pdtphys
     992          ! CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
     993          CALL histwrite_phy(o_dtwak, d_t_wake(1:klon, 1:klev))
     994          CALL histwrite_phy(o_dqwak, d_q_wake(1:klon, 1:klev))
    985995          zx_tmp_fi3d(1:klon, 1:klev) = d_q_wake(1:klon, 1:klev)/pdtphys
    986           CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
    987996          CALL water_int(klon, klev, zx_tmp_fi3d, zmasse, zx_tmp_fi2d)
    988997          CALL histwrite_phy(o_dqwak2d, zx_tmp_fi2d)
     
    10211030        CALL histwrite_phy(o_slab_bils, slab_wfbils)
    10221031        IF (nslay .EQ. 1) THEN
    1023           zx_tmp_fi2d(:) = tslab(:, 1)
    1024           CALL histwrite_phy(o_tslab, zx_tmp_fi2d)
    1025           zx_tmp_fi2d(:) = dt_qflux(:, 1)
    1026           CALL histwrite_phy(o_slab_qflux, zx_tmp_fi2d)
     1032          CALL histwrite_phy(o_tslab, tslab(:, 1))
     1033          CALL histwrite_phy(o_slab_qflux, dt_qflux(:, 1))
    10271034        ELSE
    10281035          CALL histwrite_phy(o_tslab, tslab(:, 1:nslay))
     
    10391046        IF (slab_hdiff) THEN
    10401047          IF (nslay .EQ. 1) THEN
    1041             zx_tmp_fi2d(:) = dt_hdiff(:, 1)
    1042             CALL histwrite_phy(o_slab_hdiff, zx_tmp_fi2d)
     1048            CALL histwrite_phy(o_slab_hdiff, dt_hdiff(:, 1))
    10431049          ELSE
    10441050            CALL histwrite_phy(o_slab_hdiff, dt_hdiff(:, 1:nslay))
     
    10471053        IF (slab_ekman .GT. 0) THEN
    10481054          IF (nslay .EQ. 1) THEN
    1049             zx_tmp_fi2d(:) = dt_ekman(:, 1)
    1050             CALL histwrite_phy(o_slab_ekman, zx_tmp_fi2d)
     1055            CALL histwrite_phy(o_slab_ekman, dt_ekman(:, 1))
    10511056          ELSE
    10521057            CALL histwrite_phy(o_slab_ekman, dt_ekman(:, 1:nslay))
     
    10641069      CALL histwrite_phy(o_re, re)
    10651070      CALL histwrite_phy(o_fl, fl)
    1066       DO i = 1, klon
    1067         zx_tmp_fi2d(i) = MIN(100., rh2m(i)*100.)
    1068       ENDDO
    1069       CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
     1071      ! DO i = 1, klon
     1072      !   zx_tmp_fi2d(i) = MIN(100., rh2m(i)*100.)
     1073      ! ENDDO
     1074      ! CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
     1075      CALL histwrite_phy(o_rh2m, rh2m)
    10701076      CALL histwrite_phy(o_qsat2m, zqsat2m_cor)
    10711077      CALL histwrite_phy(o_tpot, tpot)
    10721078      CALL histwrite_phy(o_tpote, tpote)
    1073       zx_tmp_fi2d(1:klon) = fsolsw(1:klon, is_ter)
    1074       CALL histwrite_phy(o_SWnetOR, zx_tmp_fi2d)
    1075       CALL histwrite_phy(o_LWdownOR, sollwdown)
     1079      !CALL histwrite_phy(o_SWnetOR, fsolsw(1:klon, is_ter))
     1080      !CALL histwrite_phy(o_LWdownOR, sollwdown)
    10761081      CALL histwrite_phy(o_snowl, snow_lsc)
    1077       CALL histwrite_phy(o_solldown, sollwdown)
     1082      !CALL histwrite_phy(o_solldown, sollwdown)
    10781083      CALL histwrite_phy(o_dtsvdfo, d_ts(:, is_oce))
    10791084      CALL histwrite_phy(o_dtsvdft, d_ts(:, is_ter))
     
    11411146      END DO
    11421147      CALL histwrite_phy(o_col_O3_tropo, zx_tmp_fi2d)   ! Added ThL
     1148      CALL histwrite_phy(o_wo_1, wo(:,:,1))
    11431149
    11441150      IF (ok_strataer .and. type_trac == 'coag') THEN
     
    11821188        ENDDO
    11831189        CALL histwrite_phy(o_heat_volc, zx_tmp_fi3d)
    1184         DO k = 1, klev
    1185           zx_tmp_fi3d(:, k) = cool_volc(:, k)
    1186         ENDDO
    1187         CALL histwrite_phy(o_cool_volc, zx_tmp_fi3d)
     1190        ! DO k = 1, klev
     1191        !   zx_tmp_fi3d(:, k) = cool_volc(:, k)
     1192        ! ENDDO
     1193        ! CALL histwrite_phy(o_cool_volc, zx_tmp_fi3d)
     1194        CALL histwrite_phy(o_cool_volc, cool_volc)
    11881195      ENDIF
    11891196      IF (ok_ade) THEN
    1190         zx_tmp_fi2d(:) = topswad_aero*swradcorr
    1191         CALL histwrite_phy(o_topswad, zx_tmp_fi2d)
    1192 
    1193         zx_tmp_fi2d(:) = topswad0_aero*swradcorr
    1194         CALL histwrite_phy(o_topswad0, zx_tmp_fi2d)
    1195 
    1196         zx_tmp_fi2d(:) = solswad_aero*swradcorr
    1197         CALL histwrite_phy(o_solswad, zx_tmp_fi2d)
    1198 
    1199         zx_tmp_fi2d(:) = solswad0_aero*swradcorr
    1200         CALL histwrite_phy(o_solswad0, zx_tmp_fi2d)
     1197        ! zx_tmp_fi2d(:) = topswad_aero*swradcorr
     1198        ! CALL histwrite_phy(o_topswad, zx_tmp_fi2d)
     1199
     1200        ! zx_tmp_fi2d(:) = topswad0_aero*swradcorr
     1201        ! CALL histwrite_phy(o_topswad0, zx_tmp_fi2d)
     1202
     1203        ! zx_tmp_fi2d(:) = solswad_aero*swradcorr
     1204        ! CALL histwrite_phy(o_solswad, zx_tmp_fi2d)
     1205
     1206        ! zx_tmp_fi2d(:) = solswad0_aero*swradcorr
     1207        ! CALL histwrite_phy(o_solswad0, zx_tmp_fi2d)
     1208
     1209        CALL histwrite_phy(o_topswad, topswad_aero)
     1210        CALL histwrite_phy(o_topswad0, topswad0_aero)
     1211        CALL histwrite_phy(o_solswad, solswad_aero)
     1212        CALL histwrite_phy(o_solswad0, solswad0_aero)
    12011213
    12021214        CALL histwrite_phy(o_toplwad, toplwad_aero)
     
    12081220        !ym => init to 0 in radlwsw_m.F90 ztopsw_aero, zsolsw_aero, ztopsw0_aero, zsolsw0_aero
    12091221
    1210         zx_tmp_fi2d(:) = topsw_aero(:, 1)*swradcorr(:)
    1211         CALL histwrite_phy(o_swtoaas_nat, zx_tmp_fi2d)
    1212         zx_tmp_fi2d(:) = solsw_aero(:, 1)*swradcorr(:)
    1213         CALL histwrite_phy(o_swsrfas_nat, zx_tmp_fi2d)
    1214         zx_tmp_fi2d(:) = topsw0_aero(:, 1)*swradcorr(:)
    1215         CALL histwrite_phy(o_swtoacs_nat, zx_tmp_fi2d)
    1216         zx_tmp_fi2d(:) = solsw0_aero(:, 1)*swradcorr(:)
    1217         CALL histwrite_phy(o_swsrfcs_nat, zx_tmp_fi2d)
     1222        ! zx_tmp_fi2d(:) = topsw_aero(:, 1)*swradcorr(:)
     1223        ! CALL histwrite_phy(o_swtoaas_nat, zx_tmp_fi2d)
     1224        ! zx_tmp_fi2d(:) = solsw_aero(:, 1)*swradcorr(:)
     1225        ! CALL histwrite_phy(o_swsrfas_nat, zx_tmp_fi2d)
     1226        ! zx_tmp_fi2d(:) = topsw0_aero(:, 1)*swradcorr(:)
     1227        ! CALL histwrite_phy(o_swtoacs_nat, zx_tmp_fi2d)
     1228        ! zx_tmp_fi2d(:) = solsw0_aero(:, 1)*swradcorr(:)
     1229        ! CALL histwrite_phy(o_swsrfcs_nat, zx_tmp_fi2d)
     1230        ! !ant
     1231        ! zx_tmp_fi2d(:) = topsw_aero(:, 2)*swradcorr(:)
     1232        ! CALL histwrite_phy(o_swtoaas_ant, zx_tmp_fi2d)
     1233        ! zx_tmp_fi2d(:) = solsw_aero(:, 2)*swradcorr(:)
     1234        ! CALL histwrite_phy(o_swsrfas_ant, zx_tmp_fi2d)
     1235        ! zx_tmp_fi2d(:) = topsw0_aero(:, 2)*swradcorr(:)
     1236        ! CALL histwrite_phy(o_swtoacs_ant, zx_tmp_fi2d)
     1237        ! zx_tmp_fi2d(:) = solsw0_aero(:, 2)*swradcorr(:)
     1238        ! CALL histwrite_phy(o_swsrfcs_ant, zx_tmp_fi2d)
     1239
     1240        CALL histwrite_phy(o_swtoaas_nat, topsw_aero(:, 1))
     1241        CALL histwrite_phy(o_swsrfas_nat, solsw_aero(:, 1))
     1242        CALL histwrite_phy(o_swtoacs_nat, topsw0_aero(:, 1))
     1243        CALL histwrite_phy(o_swsrfcs_nat, solsw0_aero(:, 1))
    12181244        !ant
    1219         zx_tmp_fi2d(:) = topsw_aero(:, 2)*swradcorr(:)
    1220         CALL histwrite_phy(o_swtoaas_ant, zx_tmp_fi2d)
    1221         zx_tmp_fi2d(:) = solsw_aero(:, 2)*swradcorr(:)
    1222         CALL histwrite_phy(o_swsrfas_ant, zx_tmp_fi2d)
    1223         zx_tmp_fi2d(:) = topsw0_aero(:, 2)*swradcorr(:)
    1224         CALL histwrite_phy(o_swtoacs_ant, zx_tmp_fi2d)
    1225         zx_tmp_fi2d(:) = solsw0_aero(:, 2)*swradcorr(:)
    1226         CALL histwrite_phy(o_swsrfcs_ant, zx_tmp_fi2d)
     1245        CALL histwrite_phy(o_swtoaas_ant, topsw_aero(:, 2))
     1246        CALL histwrite_phy(o_swsrfas_ant, solsw_aero(:, 2))
     1247        CALL histwrite_phy(o_swtoacs_ant, topsw0_aero(:, 2))
     1248        CALL histwrite_phy(o_swsrfcs_ant, solsw0_aero(:, 2))
    12271249        !cf
    12281250        IF (.not. aerosol_couple) THEN
    1229           zx_tmp_fi2d(:) = topswcf_aero(:, 1)*swradcorr(:)
    1230           CALL histwrite_phy(o_swtoacf_nat, zx_tmp_fi2d)
    1231           zx_tmp_fi2d(:) = solswcf_aero(:, 1)*swradcorr(:)
    1232           CALL histwrite_phy(o_swsrfcf_nat, zx_tmp_fi2d)
    1233           zx_tmp_fi2d(:) = topswcf_aero(:, 2)*swradcorr(:)
    1234           CALL histwrite_phy(o_swtoacf_ant, zx_tmp_fi2d)
    1235           zx_tmp_fi2d(:) = solswcf_aero(:, 2)*swradcorr(:)
    1236           CALL histwrite_phy(o_swsrfcf_ant, zx_tmp_fi2d)
    1237           zx_tmp_fi2d(:) = topswcf_aero(:, 3)*swradcorr(:)
    1238           CALL histwrite_phy(o_swtoacf_zero, zx_tmp_fi2d)
    1239           zx_tmp_fi2d(:) = solswcf_aero(:, 3)*swradcorr(:)
    1240           CALL histwrite_phy(o_swsrfcf_zero, zx_tmp_fi2d)
     1251          ! zx_tmp_fi2d(:) = topswcf_aero(:, 1)*swradcorr(:)
     1252          ! CALL histwrite_phy(o_swtoacf_nat, zx_tmp_fi2d)
     1253          ! zx_tmp_fi2d(:) = solswcf_aero(:, 1)*swradcorr(:)
     1254          ! CALL histwrite_phy(o_swsrfcf_nat, zx_tmp_fi2d)
     1255          ! zx_tmp_fi2d(:) = topswcf_aero(:, 2)*swradcorr(:)
     1256          ! CALL histwrite_phy(o_swtoacf_ant, zx_tmp_fi2d)
     1257          ! zx_tmp_fi2d(:) = solswcf_aero(:, 2)*swradcorr(:)
     1258          ! CALL histwrite_phy(o_swsrfcf_ant, zx_tmp_fi2d)
     1259          ! zx_tmp_fi2d(:) = topswcf_aero(:, 3)*swradcorr(:)
     1260          ! CALL histwrite_phy(o_swtoacf_zero, zx_tmp_fi2d)
     1261          ! zx_tmp_fi2d(:) = solswcf_aero(:, 3)*swradcorr(:)
     1262          ! CALL histwrite_phy(o_swsrfcf_zero, zx_tmp_fi2d)
     1263
     1264          CALL histwrite_phy(o_swtoacf_nat, topswcf_aero(:, 1))
     1265          CALL histwrite_phy(o_swsrfcf_nat, solswcf_aero(:, 1))
     1266          CALL histwrite_phy(o_swtoacf_ant, topswcf_aero(:, 2))
     1267          CALL histwrite_phy(o_swsrfcf_ant, solswcf_aero(:, 2))
     1268          CALL histwrite_phy(o_swtoacf_zero, topswcf_aero(:, 3))
     1269          CALL histwrite_phy(o_swsrfcf_zero, solswcf_aero(:, 3))
    12411270        ENDIF
    12421271        !====MS forcing diagnostics
    12431272      ENDIF
    12441273      IF (ok_aie) THEN
    1245         zx_tmp_fi2d(:) = topswai_aero*swradcorr
    1246         CALL histwrite_phy(o_topswai, zx_tmp_fi2d)
    1247 
    1248         zx_tmp_fi2d(:) = toplwai_aero*swradcorr
    1249         CALL histwrite_phy(o_toplwai, zx_tmp_fi2d)
    1250 
    1251         zx_tmp_fi2d(:) = solswai_aero*swradcorr
    1252         CALL histwrite_phy(o_solswai, zx_tmp_fi2d)
    1253 
    1254         zx_tmp_fi2d(:) = sollwai_aero*swradcorr
    1255         CALL histwrite_phy(o_sollwai, zx_tmp_fi2d)
     1274        CALL histwrite_phy(o_topswai, topswai_aero)
     1275        CALL histwrite_phy(o_toplwai, toplwai_aero)
     1276        CALL histwrite_phy(o_solswai, solswai_aero)
     1277        CALL histwrite_phy(o_sollwai, sollwai_aero)
    12561278      ENDIF
    12571279      IF (flag_aerosol .GT. 0 .AND. ok_cdnc) THEN
     
    12681290        CALL histwrite_phy(o_icc3dstra, icc3dstra)
    12691291        CALL histwrite_phy(o_cldicemxrat, zfice)
    1270         zx_tmp_fi3d(:, :) = 1 - zfice(:, :)
    1271         CALL histwrite_phy(o_cldwatmxrat, zx_tmp_fi3d)
     1292        ! zx_tmp_fi3d(:, :) = 1 - zfice(:, :)
     1293        ! CALL histwrite_phy(o_cldwatmxrat, zx_tmp_fi3d)
     1294        CALL histwrite_phy(o_cldwatmxrat, zfice)
    12721295        CALL histwrite_phy(o_reffclwtop, reffclwtop)
    12731296      ENDIF
     
    12841307      CALL histwrite_phy(o_oliq, ql_seri)
    12851308
    1286       zx_tmp_fi3d = ql_seri + qs_seri
    1287       CALL histwrite_phy(o_ocond, zx_tmp_fi3d)
     1309      ! zx_tmp_fi3d = ql_seri + qs_seri
     1310      ! CALL histwrite_phy(o_ocond, zx_tmp_fi3d)
     1311      CALL histwrite_phy(o_ocond, qs_seri)
    12881312
    12891313      CALL histwrite_phy(o_geop, zphi)
     
    12941318      CALL histwrite_phy(o_paprs, paprs(:, 1:klev))
    12951319
    1296       zx_tmp_fi3d = zphi/RG
    1297       CALL histwrite_phy(o_zfull, zx_tmp_fi3d)
     1320      ! zx_tmp_fi3d = zphi/RG
     1321      ! CALL histwrite_phy(o_zfull, zx_tmp_fi3d)
    12981322
    12991323      IF (ok_rrtm .and. iflag_rrtm .EQ. 1) THEN
     
    13041328      ENDIF
    13051329
    1306       IF (flag_aerosol_strat .EQ. 2) THEN
     1330      !IF (flag_aerosol_strat .EQ. 2) THEN
    13071331        CALL histwrite_phy(o_stratomask, stratomask)
    1308       ENDIF
     1332      !ENDIF
    13091333
    13101334      zx_tmp_fi3d(:, 1) = pphis(:)/RG
     
    13291353      CALL histwrite_phy(o_rhum, zx_rh)
    13301354
    1331       zx_tmp_fi3d = wo(:, :, 1)*dobson_u*1e3/zmasse/rmo3*rmd
    1332       CALL histwrite_phy(o_ozone, zx_tmp_fi3d)
     1355     
     1356      ! zx_tmp_fi3d = wo(:, :, 1)*dobson_u*1e3/zmasse/rmo3*rmd
     1357      ! CALL histwrite_phy(o_ozone, zx_tmp_fi3d) ! o_wo_1*dobson_u*1e3/o_mass/rmo3*rmd
    13331358
    13341359      IF (read_climoz == 2) THEN
    1335         zx_tmp_fi3d = wo(:, :, 2)*dobson_u*1e3/zmasse/rmo3*rmd
    1336         CALL histwrite_phy(o_ozone_light, zx_tmp_fi3d)
     1360        ! zx_tmp_fi3d = wo(:, :, 2)*dobson_u*1e3/zmasse/rmo3*rmd
     1361        ! CALL histwrite_phy(o_ozone_light, zx_tmp_fi3d)
     1362        CALL histwrite_phy(o_ozone_light, wo(:, :, 2))
    13371363      ENDIF
    13381364
     
    13611387
    13621388      DO nsrf = 1, nbsrf
    1363         zx_tmp_fi2d(1:klon) = falb1(1:klon, nsrf)
    1364         CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
    1365         zx_tmp_fi2d(1:klon) = z0m(1:klon, nsrf)
    1366         CALL histwrite_phy(o_z0m_srf(nsrf), zx_tmp_fi2d)
    1367         zx_tmp_fi2d(1:klon) = z0h(1:klon, nsrf)
    1368         CALL histwrite_phy(o_z0h_srf(nsrf), zx_tmp_fi2d)
    1369         zx_tmp_fi2d(1:klon) = agesno(1:klon, nsrf)
    1370         CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
    1371         zx_tmp_fi2d(1:klon) = snow(1:klon, nsrf)
    1372         CALL histwrite_phy(o_snow_srf(nsrf), zx_tmp_fi2d)
     1389        CALL histwrite_phy(o_albe_srf(nsrf), falb1(1:klon, nsrf))
     1390        CALL histwrite_phy(o_z0m_srf(nsrf), z0m(1:klon, nsrf))
     1391        CALL histwrite_phy(o_z0h_srf(nsrf), z0h(1:klon, nsrf))
     1392        CALL histwrite_phy(o_ages_srf(nsrf), agesno(1:klon, nsrf))
     1393        CALL histwrite_phy(o_snow_srf(nsrf), snow(1:klon, nsrf))
    13731394      ENDDO !nsrf=1, nbsrf
    13741395      CALL histwrite_phy(o_alb1, albsol1)
     
    13831404          ENDDO
    13841405        ENDDO
    1385         CALL histwrite_phy(o_tke, zx_tmp_fi3d)
    1386 
    1387         CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
     1406        ! reduce( sum(nsrf[1,4], o_fract_srf(nsrf)(:) * o_tke_srf(nsrf)(:,:))  )
     1407        ! == sum( o_fract_srf(nsrf)(:) * reduce(o_tke_srf(nsrf)(:,:)) )
     1408        CALL histwrite_phy(o_tke, zx_tmp_fi3d)
     1409        !CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
    13881410      ENDIF
    13891411
    13901412      CALL histwrite_phy(o_kz, coefh(:, :, is_ave))
    13911413
    1392       CALL histwrite_phy(o_kz_max, coefh(:, :, is_ave))
     1414      !CALL histwrite_phy(o_kz_max, coefh(:, :, is_ave))
    13931415
    13941416      CALL histwrite_phy(o_clwcon, clwcon0)
     
    14101432      CALL histwrite_phy(o_dvdyn, d_v_dyn)
    14111433
    1412       zx_tmp_fi3d(1:klon, 1:klev) = d_t_con(1:klon, 1:klev)/pdtphys
    1413       CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
     1434      ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_con(1:klon, 1:klev)/pdtphys
     1435      ! CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
     1436      CALL histwrite_phy(o_dtcon, d_t_con(:, 1:klev))
     1437
    14141438      IF (iflag_thermals .EQ. 0) THEN
    14151439        zx_tmp_fi3d(1:klon, 1:klev) = d_t_con(1:klon, 1:klev)/pdtphys + &
    14161440                                      d_t_ajsb(1:klon, 1:klev)/pdtphys
    1417         CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
     1441        CALL histwrite_phy(o_tntc, zx_tmp_fi3d) ! o_tntc = dtcon + o_dtthe
    14181442      ELSE IF (iflag_thermals .GE. 1 .AND. iflag_wake .EQ. 1) THEN
    14191443        zx_tmp_fi3d(1:klon, 1:klev) = d_t_con(1:klon, 1:klev)/pdtphys + &
    14201444                                      d_t_ajs(1:klon, 1:klev)/pdtphys + &
    14211445                                      d_t_wake(1:klon, 1:klev)/pdtphys
    1422         CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
    1423       ENDIF
    1424       zx_tmp_fi3d(1:klon, 1:klev) = d_u_con(1:klon, 1:klev)/pdtphys
    1425       CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
    1426       zx_tmp_fi3d(1:klon, 1:klev) = d_v_con(1:klon, 1:klev)/pdtphys
    1427       CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
     1446        CALL histwrite_phy(o_tntc, zx_tmp_fi3d) ! o_tntc = dtcon + ? + o_dtwak
     1447      ENDIF
     1448      ! zx_tmp_fi3d(1:klon, 1:klev) = d_u_con(1:klon, 1:klev)/pdtphys
     1449      ! CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
     1450      ! zx_tmp_fi3d(1:klon, 1:klev) = d_v_con(1:klon, 1:klev)/pdtphys
     1451      ! CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
     1452      ! zx_tmp_fi3d(1:klon, 1:klev) = d_q_con(1:klon, 1:klev)/pdtphys
     1453      ! CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)     
     1454      CALL histwrite_phy(o_ducon, d_u_con(1:klon, 1:klev))
     1455      CALL histwrite_phy(o_dvcon, d_v_con(1:klon, 1:klev))
     1456      CALL histwrite_phy(o_dqcon, d_q_con(1:klon, 1:klev))
     1457
    14281458      zx_tmp_fi3d(1:klon, 1:klev) = d_q_con(1:klon, 1:klev)/pdtphys
    1429       CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
    14301459      CALL water_int(klon, klev, zx_tmp_fi3d, zmasse, zx_tmp_fi2d)
    14311460      CALL histwrite_phy(o_dqcon2d, zx_tmp_fi2d)
    14321461
    14331462      IF (iflag_thermals .EQ. 0) THEN
    1434         zx_tmp_fi3d(1:klon, 1:klev) = d_q_con(1:klon, 1:klev)/pdtphys
    1435         CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
     1463        ! zx_tmp_fi3d(1:klon, 1:klev) = d_q_con(1:klon, 1:klev)/pdtphys
     1464        ! CALL histwrite_phy(o_tnhusc, d_q_con)
     1465        CALL histwrite_phy(o_tnhusc, d_q_con(1:klon, 1:klev))
    14361466      ELSE IF (iflag_thermals .GE. 1 .AND. iflag_wake .EQ. 1) THEN
    14371467        zx_tmp_fi3d(1:klon, 1:klev) = d_q_con(1:klon, 1:klev)/pdtphys + &
     
    14551485      ! Sorties specifiques a la separation thermiques/non thermiques
    14561486      IF (iflag_thermals >= 1) THEN
    1457         zx_tmp_fi3d(1:klon, 1:klev) = d_t_lscth(1:klon, 1:klev)/pdtphys
    1458         CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
    1459         zx_tmp_fi3d(1:klon, 1:klev) = d_t_lscst(1:klon, 1:klev)/pdtphys
    1460         CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
     1487        ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_lscth(1:klon, 1:klev)/pdtphys
     1488        ! CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
     1489        ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_lscst(1:klon, 1:klev)/pdtphys
     1490        ! CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
     1491        ! zx_tmp_fi3d(1:klon, 1:klev) = d_q_lscth(1:klon, 1:klev)/pdtphys
     1492        ! CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
     1493        ! zx_tmp_fi3d(1:klon, 1:klev) = d_q_lscst(1:klon, 1:klev)/pdtphys
     1494        ! CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
     1495
     1496        CALL histwrite_phy(o_dtlscth, d_t_lscth(1:klon, 1:klev))
     1497        CALL histwrite_phy(o_dtlscst, d_t_lscst(1:klon, 1:klev))
     1498        CALL histwrite_phy(o_dqlscth, d_q_lscth(1:klon, 1:klev))
     1499        CALL histwrite_phy(o_dqlscst, d_q_lscst(1:klon, 1:klev))
     1500
    14611501        zx_tmp_fi3d(1:klon, 1:klev) = d_q_lscth(1:klon, 1:klev)/pdtphys
    1462         CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
    14631502        CALL water_int(klon, klev, zx_tmp_fi3d, zmasse, zx_tmp_fi2d)
    1464         CALL histwrite_phy(o_dqlscth2d, zx_tmp_fi2d)
     1503        CALL histwrite_phy(o_dqlscth2d, zx_tmp_fi2d)       
    14651504        zx_tmp_fi3d(1:klon, 1:klev) = d_q_lscst(1:klon, 1:klev)/pdtphys
    1466         CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
    14671505        CALL water_int(klon, klev, zx_tmp_fi3d, zmasse, zx_tmp_fi2d)
    14681506        CALL histwrite_phy(o_dqlscst2d, zx_tmp_fi2d)
    14691507        CALL histwrite_phy(o_plulth, plul_th)
    14701508        CALL histwrite_phy(o_plulst, plul_st)
    1471         DO i = 1, klon
    1472           zx_tmp_fi2d(1:klon) = lmax_th(:)
    1473         ENDDO
     1509        zx_tmp_fi2d(:) = lmax_th(1:klon) ! Cast from int to real
    14741510        CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
    1475         DO k = 1, klev
    1476           DO i = 1, klon
    1477             IF (ptconvth(i, k)) THEN
    1478               zx_tmp_fi3d(i, k) = 1.
    1479             ELSE
    1480               zx_tmp_fi3d(i, k) = 0.
    1481             ENDIF
    1482           ENDDO
    1483         ENDDO
     1511        ! DO k = 1, klev
     1512        !   DO i = 1, klon
     1513        !     IF (ptconvth(i, k)) THEN
     1514        !       zx_tmp_fi3d(i, k) = 1.
     1515        !     ELSE
     1516        !       zx_tmp_fi3d(i, k) = 0.
     1517        !     ENDIF
     1518        !   ENDDO
     1519        ! ENDDO
     1520        ! CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
     1521        zx_tmp_fi3d(:,:) = MERGE(1., 0., ptconvth(:,:)) ! Cast from logical to real
    14841522        CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
    14851523      ENDIF ! iflag_thermals>=1
    14861524
    1487       zpt_conv = 0.
    1488       WHERE (ptconv) zpt_conv = 1.
     1525      zpt_conv(:,:) = MERGE(1., 0., ptconv(:,:))
    14891526      CALL histwrite_phy(o_ptconv, zpt_conv)
    14901527      zpt_conv2d(:) = 0.
     
    14981535      ENDDO
    14991536      CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
    1500       zx_tmp_fi2d(:) = max(zx_tmp_fi2d(:), zpt_conv2d(:))
    1501       CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
     1537      ! zx_tmp_fi2d(:) = max(zx_tmp_fi2d(:), zpt_conv2d(:))
     1538      ! CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
    15021539      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1503       zx_tmp_fi3d(1:klon, 1:klev) = d_t_vdf(1:klon, 1:klev)/pdtphys
    1504       CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
    1505       zx_tmp_fi3d(1:klon, 1:klev) = d_t_diss(1:klon, 1:klev)/pdtphys
    1506       CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
     1540      CALL histwrite_phy(o_dtvdf, d_t_vdf(1:klon, 1:klev))
     1541      CALL histwrite_phy(o_dtdis, d_t_diss(1:klon, 1:klev))
     1542      CALL histwrite_phy(o_dqvdf, d_q_vdf(1:klon, 1:klev))
     1543      CALL histwrite_phy(o_dteva, d_t_eva(1:klon, 1:klev))
     1544      CALL histwrite_phy(o_dqeva, d_q_eva(1:klon, 1:klev))
     1545      CALL histwrite_phy(o_duthe, d_u_ajs(1:klon, 1:klev))
     1546      CALL histwrite_phy(o_dvthe, d_v_ajs(1:klon, 1:klev))
     1547
    15071548      zx_tmp_fi3d(1:klon, 1:klev) = d_q_vdf(1:klon, 1:klev)/pdtphys
    1508       CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
    15091549      CALL water_int(klon, klev, zx_tmp_fi3d, zmasse, zx_tmp_fi2d)
    15101550      CALL histwrite_phy(o_dqvdf2d, zx_tmp_fi2d)
    1511       zx_tmp_fi3d(1:klon, 1:klev) = d_t_eva(1:klon, 1:klev)/pdtphys
    1512       CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
    15131551      zx_tmp_fi3d(1:klon, 1:klev) = d_q_eva(1:klon, 1:klev)/pdtphys
    1514       CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
    15151552      CALL water_int(klon, klev, zx_tmp_fi3d, zmasse, zx_tmp_fi2d)
    15161553      CALL histwrite_phy(o_dqeva2d, zx_tmp_fi2d)
     1554      ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_ajs(1:klon, 1:klev)/pdtphys - &
     1555      !                               d_t_ajsb(1:klon, 1:klev)/pdtphys
     1556      ! CALL histwrite_phy(o_dtthe, zx_tmp_fi3d) ! d_t_ajs(1:klon, 1:klev)/pdtphys + o_dtajs
     1557      CALL histwrite_phy(o_dtthe, d_t_ajs(1:klon, 1:klev))
    15171558      CALL histwrite_phy(o_ratqs, ratqs)
    1518         zx_tmp_fi3d(1:klon, 1:klev) = d_t_ajs(1:klon, 1:klev)/pdtphys - &
    1519                                       d_t_ajsb(1:klon, 1:klev)/pdtphys
    1520       CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
    1521         zx_tmp_fi3d(1:klon, 1:klev) = d_u_ajs(1:klon, 1:klev)/pdtphys
    1522       CALL histwrite_phy(o_duthe, zx_tmp_fi3d)
    1523         zx_tmp_fi3d(1:klon, 1:klev) = d_v_ajs(1:klon, 1:klev)/pdtphys
    1524       CALL histwrite_phy(o_dvthe, zx_tmp_fi3d)
     1559     
    15251560
    15261561      IF (iflag_thermals >= 1) THEN
     
    15461581        CALL water_int(klon, klev, zx_tmp_fi3d, zmasse, zx_tmp_fi2d)
    15471582        CALL histwrite_phy(o_dqthe2d, zx_tmp_fi2d)
     1583      ELSE
     1584        zx_tmp_fi2d(:) = 0
     1585        CALL histwrite_phy(o_f_th, zx_tmp_fi2d)
    15481586      ENDIF !iflag_thermals
    1549       zx_tmp_fi3d(1:klon, 1:klev) = d_t_ajsb(1:klon, 1:klev)/pdtphys
    1550       CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
    15511587      zx_tmp_fi3d(1:klon, 1:klev) = d_q_ajsb(1:klon, 1:klev)/pdtphys
    1552       CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
    15531588      CALL water_int(klon, klev, zx_tmp_fi3d, zmasse, zx_tmp_fi2d)
    15541589      CALL histwrite_phy(o_dqajs2d, zx_tmp_fi2d)
    1555       zx_tmp_fi3d(1:klon, 1:klev) = d_t_swr(1:klon, 1:klev)/pdtphys
    1556       CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
    1557       zx_tmp_fi3d(1:klon, 1:klev) = d_t_sw0(1:klon, 1:klev)/pdtphys
    1558       CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
    1559       zx_tmp_fi3d(1:klon, 1:klev) = d_t_lwr(1:klon, 1:klev)/pdtphys
    1560       CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
    1561       zx_tmp_fi3d(1:klon, 1:klev) = d_t_lw0(1:klon, 1:klev)/pdtphys
    1562       CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
    1563       zx_tmp_fi3d(1:klon, 1:klev) = d_t_ec(1:klon, 1:klev)/pdtphys
    1564       CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
    1565       zx_tmp_fi3d(1:klon, 1:klev) = d_u_vdf(1:klon, 1:klev)/pdtphys
    1566       CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
    1567       zx_tmp_fi3d(1:klon, 1:klev) = d_v_vdf(1:klon, 1:klev)/pdtphys
    1568       CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
     1590
     1591      CALL histwrite_phy(o_dtajs, d_t_ajsb(1:klon, 1:klev))
     1592      CALL histwrite_phy(o_dqajs, d_q_ajsb(1:klon, 1:klev))
     1593      CALL histwrite_phy(o_dtswr, d_t_swr(1:klon, 1:klev))
     1594      CALL histwrite_phy(o_dtsw0, d_t_sw0(1:klon, 1:klev))
     1595      CALL histwrite_phy(o_dtlwr, d_t_lwr(1:klon, 1:klev))
     1596      CALL histwrite_phy(o_dtlw0, d_t_lw0(1:klon, 1:klev))
     1597      CALL histwrite_phy(o_dtec, d_t_ec(1:klon, 1:klev))
     1598      CALL histwrite_phy(o_duvdf, d_u_vdf(1:klon, 1:klev))
     1599      CALL histwrite_phy(o_dvvdf, d_v_vdf(1:klon, 1:klev))
     1600
    15691601      IF (ok_orodr) THEN
    1570         zx_tmp_fi3d(1:klon, 1:klev) = d_u_oro(1:klon, 1:klev)/pdtphys
    1571         CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
    1572         zx_tmp_fi3d(1:klon, 1:klev) = d_v_oro(1:klon, 1:klev)/pdtphys
    1573         CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
    1574         zx_tmp_fi3d(1:klon, 1:klev) = d_t_oro(1:klon, 1:klev)/pdtphys
    1575         CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
     1602        ! zx_tmp_fi3d(1:klon, 1:klev) = d_u_oro(1:klon, 1:klev)/pdtphys
     1603        ! CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
     1604        ! zx_tmp_fi3d(1:klon, 1:klev) = d_v_oro(1:klon, 1:klev)/pdtphys
     1605        ! CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
     1606        ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_oro(1:klon, 1:klev)/pdtphys
     1607        ! CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
     1608
     1609        CALL histwrite_phy(o_duoro, d_u_oro(1:klon, 1:klev))
     1610        CALL histwrite_phy(o_dvoro, d_v_oro(1:klon, 1:klev))
     1611        CALL histwrite_phy(o_dtoro, d_t_oro(1:klon, 1:klev))
    15761612      ENDIF
    15771613      IF (ok_orolf) THEN
    1578         zx_tmp_fi3d(1:klon, 1:klev) = d_u_lif(1:klon, 1:klev)/pdtphys
    1579         CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
    1580 
    1581         zx_tmp_fi3d(1:klon, 1:klev) = d_v_lif(1:klon, 1:klev)/pdtphys
    1582         CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
    1583 
    1584         zx_tmp_fi3d(1:klon, 1:klev) = d_t_lif(1:klon, 1:klev)/pdtphys
    1585         CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
     1614        ! zx_tmp_fi3d(1:klon, 1:klev) = d_u_lif(1:klon, 1:klev)/pdtphys
     1615        ! CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
     1616        ! zx_tmp_fi3d(1:klon, 1:klev) = d_v_lif(1:klon, 1:klev)/pdtphys
     1617        ! CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
     1618        ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_lif(1:klon, 1:klev)/pdtphys
     1619        ! CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
     1620
     1621        CALL histwrite_phy(o_dulif, d_u_lif(1:klon, 1:klev))
     1622        CALL histwrite_phy(o_dvlif, d_v_lif(1:klon, 1:klev))
     1623        CALL histwrite_phy(o_dtlif, d_t_lif(1:klon, 1:klev))
    15861624      ENDIF
    15871625
    15881626      IF (ok_hines) THEN
    1589         zx_tmp_fi3d = du_gwd_hines/pdtphys
    1590         CALL histwrite_phy(o_du_gwd_hines, zx_tmp_fi3d)
    1591 
    1592         zx_tmp_fi3d = dv_gwd_hines/pdtphys
    1593         CALL histwrite_phy(o_dv_gwd_hines, zx_tmp_fi3d)
    1594 
    1595         zx_tmp_fi3d(1:klon, 1:klev) = d_t_hin(1:klon, 1:klev)/pdtphys
    1596         CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
     1627        ! zx_tmp_fi3d = du_gwd_hines/pdtphys
     1628        ! CALL histwrite_phy(o_du_gwd_hines, zx_tmp_fi3d)
     1629        ! zx_tmp_fi3d = dv_gwd_hines/pdtphys
     1630        ! CALL histwrite_phy(o_dv_gwd_hines, zx_tmp_fi3d)
     1631        ! zx_tmp_fi3d = d_t_hin(1:klon, 1:klev)/pdtphys
     1632
     1633        CALL histwrite_phy(o_du_gwd_hines, du_gwd_hines)
     1634        CALL histwrite_phy(o_dv_gwd_hines, dv_gwd_hines)
     1635        CALL histwrite_phy(o_dthin, d_t_hin)
     1636
    15971637        CALL histwrite_phy(o_ustr_gwd_hines, zustr_gwd_hines)
    15981638        CALL histwrite_phy(o_vstr_gwd_hines, zvstr_gwd_hines)
     
    16001640
    16011641      IF (.not. ok_hines .and. ok_gwd_rando) THEN
    1602         zx_tmp_fi3d = du_gwd_front/pdtphys
    1603         CALL histwrite_phy(o_du_gwd_front, zx_tmp_fi3d)
    1604 
    1605         zx_tmp_fi3d = dv_gwd_front/pdtphys
    1606         CALL histwrite_phy(o_dv_gwd_front, zx_tmp_fi3d)
     1642        ! zx_tmp_fi3d = du_gwd_front/pdtphys
     1643        ! CALL histwrite_phy(o_du_gwd_front, zx_tmp_fi3d)
     1644        ! zx_tmp_fi3d = dv_gwd_front/pdtphys
     1645        ! CALL histwrite_phy(o_dv_gwd_front, zx_tmp_fi3d)
     1646
     1647        CALL histwrite_phy(o_du_gwd_front, du_gwd_front)
     1648        CALL histwrite_phy(o_dv_gwd_front, dv_gwd_front)
    16071649
    16081650        CALL histwrite_phy(o_ustr_gwd_front, zustr_gwd_front)
     
    16111653
    16121654      IF (ok_gwd_rando) THEN
    1613         zx_tmp_fi3d = du_gwd_rando/pdtphys
    1614         CALL histwrite_phy(o_du_gwd_rando, zx_tmp_fi3d)
    1615 
    1616         zx_tmp_fi3d = dv_gwd_rando/pdtphys
    1617         CALL histwrite_phy(o_dv_gwd_rando, zx_tmp_fi3d)
     1655        ! zx_tmp_fi3d = du_gwd_rando/pdtphys
     1656        ! CALL histwrite_phy(o_du_gwd_rando, zx_tmp_fi3d)
     1657        ! zx_tmp_fi3d = dv_gwd_rando/pdtphys
     1658        ! CALL histwrite_phy(o_dv_gwd_rando, zx_tmp_fi3d)
     1659
     1660        CALL histwrite_phy(o_du_gwd_rando, du_gwd_rando)
     1661        CALL histwrite_phy(o_dv_gwd_rando, dv_gwd_rando)
     1662
    16181663        CALL histwrite_phy(o_ustr_gwd_rando, zustr_gwd_rando)
    16191664        CALL histwrite_phy(o_vstr_gwd_rando, zvstr_gwd_rando)
     
    16231668
    16241669      IF (ok_qch4) THEN
     1670        ! GLITCHY : not in field_def_lmdz.xml
    16251671        zx_tmp_fi3d = d_q_ch4/pdtphys
    16261672        CALL histwrite_phy(o_dqch4, zx_tmp_fi3d)
     
    16301676        zx_tmp_fi3d1(:, k) = swup(:, k)*swradcorr(:)
    16311677      ENDDO
    1632 
    16331678      CALL histwrite_phy(o_rsu, zx_tmp_fi3d1)
    16341679
     
    16361681        zx_tmp_fi3d1(:, k) = swdn(:, k)*swradcorr(:)
    16371682      ENDDO
    1638 
    1639 
    16401683      CALL histwrite_phy(o_rsd, zx_tmp_fi3d1)
     1684
    16411685      DO k = 1, klevp1
    16421686        zx_tmp_fi3d1(:, k) = swup0(:, k)*swradcorr(:)
    16431687      ENDDO
    1644 
    16451688      CALL histwrite_phy(o_rsucs, zx_tmp_fi3d1)
     1689
    16461690      DO k = 1, klevp1
    16471691        zx_tmp_fi3d1(:, k) = swupc0(:, k)*swradcorr(:)
     
    16641708      CALL histwrite_phy(o_rldcs, lwdn0)
    16651709
    1666       zx_tmp_fi3d(1:klon, 1:klev) = d_t(1:klon, 1:klev) + &
    1667                                     d_t_dyn(1:klon, 1:klev)
    1668       CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
    1669 
    1670       zx_tmp_fi3d(1:klon, 1:klev) = d_t_swr(1:klon, 1:klev)/pdtphys + &
    1671                                     d_t_lwr(1:klon, 1:klev)/pdtphys
    1672       CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
    1673       zx_tmp_fi3d(1:klon, 1:klev) = (d_t_lsc(1:klon, 1:klev) + &
    1674                                      d_t_eva(1:klon, 1:klev) + &
    1675                                      d_t_vdf(1:klon, 1:klev))/pdtphys
    1676       CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
    1677       zx_tmp_fi3d(1:klon, 1:klev) = d_qx(1:klon, 1:klev, ivap) + &
    1678                                     d_q_dyn(1:klon, 1:klev)
    1679       CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
    1680       zx_tmp_fi3d(1:klon, 1:klev) = d_q_lsc(1:klon, 1:klev)/pdtphys + &
    1681                                     d_q_eva(1:klon, 1:klev)/pdtphys
    1682       CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
    16831710      CALL histwrite_phy(o_evu, coefm(:, :, is_ave))
    1684       zx_tmp_fi3d(1:klon, 1:klev) = q_seri(1:klon, 1:klev) + &
    1685                                     ql_seri(1:klon, 1:klev)
    1686       CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
     1711
     1712      ! zx_tmp_fi3d(1:klon, 1:klev) = d_t(1:klon, 1:klev) + &
     1713      !                               d_t_dyn(1:klon, 1:klev)
     1714      ! CALL histwrite_phy(o_tnt, zx_tmp_fi3d) ! o_dtphy + o_dtdyn
     1715      ! zx_tmp_fi3d(1:klon, 1:klev) = d_t_swr(1:klon, 1:klev)/pdtphys + &
     1716      !                               d_t_lwr(1:klon, 1:klev)/pdtphys
     1717      ! CALL histwrite_phy(o_tntr, zx_tmp_fi3d)!o_dtswr + o_dtlwr
     1718      ! zx_tmp_fi3d(1:klon, 1:klev) = (d_t_lsc(1:klon, 1:klev) + &
     1719      !                                d_t_eva(1:klon, 1:klev) + &
     1720      !                                d_t_vdf(1:klon, 1:klev))/pdtphys
     1721      ! CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d) ! o_dtlsc + o_dteva + o_dtvdf
     1722      ! zx_tmp_fi3d(1:klon, 1:klev) = d_qx(1:klon, 1:klev, ivap) + &
     1723      !                               d_q_dyn(1:klon, 1:klev)
     1724      ! CALL histwrite_phy(o_tnhus, zx_tmp_fi3d) ! o_dqphy + o_dqdyn
     1725      ! zx_tmp_fi3d(1:klon, 1:klev) = d_q_lsc(1:klon, 1:klev)/pdtphys + &
     1726      !                               d_q_eva(1:klon, 1:klev)/pdtphys
     1727      ! CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d) ! o_dqlsc + o_dqeva
     1728      ! zx_tmp_fi3d(1:klon, 1:klev) = q_seri(1:klon, 1:klev) + &
     1729      !                               ql_seri(1:klon, 1:klev)
     1730      ! CALL histwrite_phy(o_h2o, zx_tmp_fi3d) ! o_ovap + o_oliq
    16871731      IF (iflag_con >= 3) THEN
    16881732        zx_tmp_fi3d(1:klon, 1:klev) = -1*(dnwd(1:klon, 1:klev) + &
    16891733                                            dnwd0(1:klon, 1:klev))
    1690         CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
     1734        CALL histwrite_phy(o_mcd, zx_tmp_fi3d) ! - (o_dnwd + dnwd0)
    16911735        zx_tmp_fi3d(1:klon, 1:klev) = upwd(1:klon, 1:klev) + &
    16921736                                        dnwd(1:klon, 1:klev) + dnwd0(1:klon, 1:klev)
    1693         CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
     1737        CALL histwrite_phy(o_dmc, zx_tmp_fi3d) ! o_upwd - o_mcd
    16941738      ELSE IF (iflag_con == 2) THEN
    16951739        CALL histwrite_phy(o_mcd, pmfd)
    16961740        zx_tmp_fi3d = pmfu + pmfd
    1697         CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
     1741        CALL histwrite_phy(o_dmc, zx_tmp_fi3d) ! pmfu + o_mcd
    16981742      ENDIF
    16991743      CALL histwrite_phy(o_ref_liq, ref_liq)
     
    17011745
    17021746      IF (ok_4xCO2atm) THEN
    1703         zx_tmp_fi2d(:) = swupp(:, klevp1)*swradcorr(:)
    1704         CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
    1705         zx_tmp_fi2d(:) = lwupp(:, klevp1)
    1706         CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
    1707         zx_tmp_fi2d(:) = swup0p(:, klevp1)*swradcorr(:)
    1708         CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
    1709         zx_tmp_fi2d(:) = lwup0p(:, klevp1)
    1710         CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
    1711         DO k = 1, klevp1
    1712           zx_tmp_fi3d1(:, k) = swupp(:, k)*swradcorr(:)
    1713         ENDDO
    1714         CALL histwrite_phy(o_rsu4co2, zx_tmp_fi3d1)
    1715         DO k = 1, klevp1
    1716           zx_tmp_fi3d1(:, k) = swup0p(:, k)*swradcorr(:)
    1717         ENDDO
    1718         CALL histwrite_phy(o_rsucs4co2, zx_tmp_fi3d1)
    1719         DO k = 1, klevp1
    1720           zx_tmp_fi3d1(:, k) = swdnp(:, k)*swradcorr(:)
    1721         ENDDO
    1722         CALL histwrite_phy(o_rsd4co2, zx_tmp_fi3d1)
    1723         DO k = 1, klevp1
    1724           zx_tmp_fi3d1(:, k) = swdn0p(:, k)*swradcorr(:)
    1725         ENDDO
    1726         CALL histwrite_phy(o_rsdcs4co2, zx_tmp_fi3d1)
     1747        ! zx_tmp_fi2d(:) = swupp(:, klevp1)*swradcorr(:)
     1748        ! CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
     1749        ! zx_tmp_fi2d(:) = lwupp(:, klevp1)
     1750        ! CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
     1751        ! zx_tmp_fi2d(:) = swup0p(:, klevp1)*swradcorr(:)
     1752        ! CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
     1753        ! zx_tmp_fi2d(:) = lwup0p(:, klevp1)
     1754        ! CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
     1755        CALL histwrite_phy(o_rsut4co2, swupp(:, klevp1))
     1756        CALL histwrite_phy(o_rlut4co2, lwupp(:, klevp1))
     1757        CALL histwrite_phy(o_rsutcs4co2, swup0p(:, klevp1))
     1758        CALL histwrite_phy(o_rlutcs4co2, lwup0p(:, klevp1))
     1759       
     1760        if( any(swradcorr(:) /= 1.0) ) then
     1761          DO k = 1, klevp1
     1762            zx_tmp_fi3d1(:, k) = swupp(:, k)*swradcorr(:)
     1763          ENDDO
     1764          CALL histwrite_phy(o_rsu4co2, zx_tmp_fi3d1)
     1765          DO k = 1, klevp1
     1766            zx_tmp_fi3d1(:, k) = swup0p(:, k)*swradcorr(:)
     1767          ENDDO
     1768          CALL histwrite_phy(o_rsucs4co2, zx_tmp_fi3d1)
     1769          DO k = 1, klevp1
     1770            zx_tmp_fi3d1(:, k) = swdnp(:, k)*swradcorr(:)
     1771          ENDDO
     1772          CALL histwrite_phy(o_rsd4co2, zx_tmp_fi3d1)
     1773          DO k = 1, klevp1
     1774            zx_tmp_fi3d1(:, k) = swdn0p(:, k)*swradcorr(:)
     1775          ENDDO
     1776          CALL histwrite_phy(o_rsdcs4co2, zx_tmp_fi3d1)
     1777        else
     1778          CALL histwrite_phy(o_rsu4co2, swupp)
     1779          CALL histwrite_phy(o_rsucs4co2, swup0p)
     1780          CALL histwrite_phy(o_rsd4co2, swdnp)
     1781          CALL histwrite_phy(o_rsdcs4co2, swdn0p)
     1782        endif
    17271783        CALL histwrite_phy(o_rlu4co2, lwupp)
    17281784        CALL histwrite_phy(o_rlucs4co2, lwup0p)
     
    17381794      CALL histwrite_phy(o_va, vlevSTD(:, :))
    17391795      CALL histwrite_phy(o_wap, wlevSTD(:, :))
    1740       DO k = 1, nlevSTD
    1741         DO i = 1, klon
    1742           IF (O3STD(i, k) .NE. missing_val) THEN
    1743             zx_tmp_fi3d_STD(i, k) = O3STD(i, k)*1.e+9
    1744           ELSE
    1745             zx_tmp_fi3d_STD(i, k) = missing_val
    1746           ENDIF
    1747         ENDDO
    1748       ENDDO !k=1, nlevSTD
    1749       CALL histwrite_phy(o_tro3, zx_tmp_fi3d_STD)
     1796      ! DO k = 1, nlevSTD
     1797      !   DO i = 1, klon
     1798      !     IF (O3STD(i, k) .NE. missing_val) THEN
     1799      !       zx_tmp_fi3d_STD(i, k) = O3STD(i, k)*1.e+9
     1800      !     ELSE
     1801      !       zx_tmp_fi3d_STD(i, k) = missing_val
     1802      !     ENDIF
     1803      !   ENDDO
     1804      ! ENDDO !k=1, nlevSTD
     1805      ! CALL histwrite_phy(o_tro3, zx_tmp_fi3d_STD)
     1806      ! !(this/=missing_val)?this*1.e+9:missing_val
     1807      CALL histwrite_phy(o_tro3, O3STD(1:klon, 1:nlevSTD))
     1808      ! IF (read_climoz == 2) THEN
     1809      !   DO k = 1, nlevSTD
     1810      !     DO i = 1, klon
     1811      !       IF (O3daySTD(i, k) .NE. missing_val) THEN
     1812      !         zx_tmp_fi3d_STD(i, k) = O3daySTD(i, k)*1.e+9
     1813      !       ELSE
     1814      !         zx_tmp_fi3d_STD(i, k) = missing_val
     1815      !       ENDIF
     1816      !     ENDDO
     1817      !   ENDDO !k=1, nlevSTD
     1818      ! ENDIF
     1819      ! CALL histwrite_phy(o_tro3_daylight, zx_tmp_fi3d_STD)
     1820      ! !(this/=missing_val)?this*1.e+9:missing_val
    17501821      IF (read_climoz == 2) THEN
    1751         DO k = 1, nlevSTD
    1752           DO i = 1, klon
    1753             IF (O3daySTD(i, k) .NE. missing_val) THEN
    1754               zx_tmp_fi3d_STD(i, k) = O3daySTD(i, k)*1.e+9
    1755             ELSE
    1756               zx_tmp_fi3d_STD(i, k) = missing_val
    1757             ENDIF
    1758           ENDDO
    1759         ENDDO !k=1, nlevSTD
    1760       ENDIF
    1761       CALL histwrite_phy(o_tro3_daylight, zx_tmp_fi3d_STD)
     1822        CALL histwrite_phy(o_tro3_daylight, O3daySTD(1:klon, 1:nlevSTD))
     1823      else
     1824        CALL histwrite_phy(o_tro3_daylight, O3STD(1:klon, 1:nlevSTD))
     1825      ENDIF
    17621826      CALL histwrite_phy(o_uxv, uvSTD(:, :))
    17631827      CALL histwrite_phy(o_vxq, vqSTD(:, :))
     
    17901854            !--2D fields
    17911855            CALL histwrite_phy(o_dtr_dry(iq - nqo), flux_tr_dry(:, iq - nqo))
    1792             zx_tmp_fi2d = 0.
    1793             DO k = 1, klev
    1794               zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + zmasse(:, k)*tr_seri(:, k, iq - nqo)
    1795             ENDDO
    17961856            if (.not. ok_reprobus) then
     1857              zx_tmp_fi2d = 0.
     1858              DO k = 1, klev
     1859                zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + zmasse(:, k)*tr_seri(:, k, iq - nqo)
     1860              ENDDO
    17971861              CALL histwrite_phy(o_trac_cum(iq - nqo), zx_tmp_fi2d)
    17981862            end if
Note: See TracChangeset for help on using the changeset viewer.