!
! $Header$
!
      ndex = 0
      ndex2d = 0
      ndex3d = 0
c
cIM itau_phy n'est pas defini dans phytrac   itau_w = itau_phy + nstep
      itau_w = nstep
c     print*,'write_histrac: itau_w itau_phy nstep',itau_w,itau_phy,
c    $ nstep
c      
      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
      CALL histwrite(nid_tra,"phis",itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
C
      CALL gr_fi_ecrit(1,klon,iim,jjm+1,airephy,zx_tmp_2d)      
      CALL histwrite(nid_tra,"aire",itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
#ifdef INCA
      CALL gr_fi_ecrit(1, klon,iim,jjm+1, ps,zx_tmp_2d)
      CALL histwrite(nid_tra,"ps",itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)

      CALL gr_fi_ecrit(1, klon,iim,jjm+1, ptrop,zx_tmp_2d)
      CALL histwrite(nid_tra,"ptrop",itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)

C   3d FIELDS

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,t_seri, zx_tmp_3d)
      CALL histwrite(nid_tra,"temp",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,u, zx_tmp_3d)
      CALL histwrite(nid_tra,"u",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,v, zx_tmp_3d)
      CALL histwrite(nid_tra,"v",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,sh, zx_tmp_3d)
      CALL histwrite(nid_tra,"h2o",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pdel, zx_tmp_3d)
      CALL histwrite(nid_tra,"pdel",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pplay, zx_tmp_3d)
      CALL histwrite(nid_tra,"pmid",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

! Ajout Anne
#ifdef INCA_AER
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,airm, zx_tmp_3d)
      CALL histwrite(nid_tra,"airm",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)
#endif

! Fin ajout Anne

#ifdef INCA
#ifdef INCAINFO
      DO it=1, phtcnt
      WRITE(str2,'(i2.2)') it
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,it),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"j"//str2,itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
      ENDDO

      DO it=1, hetcnt
      WRITE(str2,'(i2.2)') it
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hrates(1,1,it),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"w"//str2,itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
      ENDDO

      DO it=1, extcnt
      WRITE(str2,'(i2.2)') it
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,extflx(1,1,it),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"ext"//str2,itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
      ENDDO

      DO it=1, nfs
      WRITE(str2,'(i2.2)') it
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,invariants(1,1,it),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"INV"//str2,itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
      ENDDO
#else
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,2),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"jO3",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,4),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"jNO2",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,13),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"jH2O2",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hrates(1,1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"wHNO3",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,krates(1,1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"kN2O5",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,extflx(1,1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"LghtNO",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
#endif
      DO it=1, grpcnt

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,nas(1,1,it),zx_tmp_3d)
      zx_tmp_3d = zx_tmp_3d * dry_mass / nadv_mass(it)
      CALL histwrite(nid_tra,grpsym(it),itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
      ENDDO
#endif

#ifdef INCA_AER

      it = id_CIDUSTM
       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,scavcoef_st(1,1,it),
     .                  zx_tmp_3d)
       CALL histwrite(nid_tra2,"scavcoef_st",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)
       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,scavcoef_cv(1,1,it),
     .                  zx_tmp_3d)
       CALL histwrite(nid_tra2,"scavcoef_cv",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)

       CALL gr_fi_ecrit(1, klon,iim,jjm+1,angst(1),zx_tmp_2d)
       CALL histwrite(nid_tra2,"AngstroemComp",itau_w,zx_tmp_2d,
     .                     iim*(jjm+1),ndex2d)

       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,totaerh2o(1,1), zx_tmp_3d)
       CALL histwrite(nid_tra2,"TOTAERH2O",itau_w,zx_tmp_3d, 
     .                     iim*(jjm+1)*klev,ndex3d)

#endif
#endif

      DO it=1,nqmax
C champs 2D
#ifdef INCA
      IF ( prt_flag_ts(it) == 0 ) CYCLE
      CALL gr_fi_ecrit(1, klon,iim,jjm+1, eflux(1,it),zx_tmp_2d)
      CALL histwrite(nid_tra,"Emi_"//solsym(it),itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)

      CALL gr_fi_ecrit(1, klon,iim,jjm+1, dvel(1,it),zx_tmp_2d)
      CALL histwrite(nid_tra,"Dep_"//solsym(it),itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)
#ifdef INCA_AER
      call diag(airephy,tr_seri,.false.)

      CALL gr_fi_ecrit(1, klon,iim,jjm+1,dflux(1,it),zx_tmp_2d)
      CALL histwrite(nid_tra2,"Dry_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)

      IF  ((it .ge. trmx) .and. (it .le. trnx)) then
        CALL gr_fi_ecrit(1, klon,iim,jjm+1,sflux(1,it),zx_tmp_2d)
        CALL histwrite(nid_tra2,"Sed_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
        
        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wflux(1,it),zx_tmp_2d)
        CALL histwrite(nid_tra2,"Wet_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wsflux(1,it),zx_tmp_2d)
        CALL histwrite(nid_tra2,"WetST_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wcflux(1,it),zx_tmp_2d)
        CALL histwrite(nid_tra2,"WetCV_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
        
        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,eflux_alt(1,1,it),zx_tmp_3d)
        CALL histwrite(nid_tra2,"Emi_alt_"//solsym(it),itau_w,zx_tmp_3d,iim*(jjm+1)*klev,ndex3d)
        
        CALL gr_fi_ecrit(1, klon,iim,jjm+1,aload(1,it),zx_tmp_2d)
        CALL histwrite(nid_tra2,"Load_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
        CALL histwrite(nid_tra3,"Inst_Load_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)

        CALL gr_fi_ecrit(1, klon,iim,jjm+1,sconc(1,it),zx_tmp_2d)
        CALL histwrite(nid_tra2,"SConc_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)

        do la=1,las
          CALL gr_fi_ecrit(1, klon,iim,jjm+1,tausum(1,la,it),zx_tmp_2d)
          CALL histwrite(nid_tra2,"OD"//cla(la)//"_"//solsym(it),itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
          CALL gr_fi_ecrit(klev, klon,iim,jjm+1,tau(1,1,la,it),zx_tmp_3d)
          CALL histwrite(nid_tra2,"OD3D"//cla(la)//"_"//solsym(it),itau_w,zx_tmp_3d,iim*(jjm+1)*klev,ndex3d)
        enddo

        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,md(1,1,it),zx_tmp_3d)
        CALL histwrite(nid_tra2,"MD_"//solsym(it),itau_w,zx_tmp_3d,iim*(jjm+1)*klev,ndex3d)

        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,mdw(1,1,it),zx_tmp_3d)
        CALL histwrite(nid_tra2,"MDW_"//solsym(it),itau_w,zx_tmp_3d,iim*(jjm+1)*klev,ndex3d)

        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,cload(1,1,it),zx_tmp_3d)
        CALL histwrite(nid_tra2,"CLOAD_"//solsym(it),itau_w,zx_tmp_3d,iim*(jjm+1)*klev,ndex3d)


      endif


#endif
C champs 3D
       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,tr_seri(1,1,it),zx_tmp_3d)

       !Prefer vmr to mmr for transported species
       if( adv_mass(it) /= 0. ) then
#ifdef INCA_AER
         if (it .lt. trmx) then
#endif
       zx_tmp_3d = zx_tmp_3d * dry_mass / adv_mass(it)
#ifdef INCA_AER
         endif
#endif
       else
#ifdef INCA
       if ( solsym(it) == 'OX' ) then
       zx_tmp_3d = zx_tmp_3d * dry_mass / nadv_mass(id_o3)
       end if
#endif
       end if

       CALL histwrite(nid_tra,solsym(it),itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
#else

       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,tr_seri(1,1,it),zx_tmp_3d)
       CALL histwrite(nid_tra,tnom(it+2),itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
       if (lessivage) THEN
       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,flestottr(1,1,it),zx_tmp_3d)
       CALL histwrite(nid_tra,"fl"//tnom(it+2),itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
      endif
      
c----Olivia
       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_th(1,1,it),zx_tmp_3d)
       CALL histwrite(nid_tra,"d_tr_th_"//tnom(it+2),itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_cv(1,1,it),zx_tmp_3d)
       CALL histwrite(nid_tra,"d_tr_cv_"//tnom(it+2),itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_cl(1,1,it),zx_tmp_3d)
       CALL histwrite(nid_tra,"d_tr_cl_"//tnom(it+2),itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
c---fin Olivia      
      
#endif
      ENDDO

#ifdef INCA
!#ifdef INCA_CH4
      CALL gr_fi_ecrit(1, klon,iim,jjm+1, o3_col(1), zx_tmp_2d)
      CALL histwrite(nid_tra,"O3_column",itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)

      CALL gr_fi_ecrit(1, klon,iim,jjm+1, co_col(1), zx_tmp_2d)
      CALL histwrite(nid_tra,"CO_column",itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)

      CALL gr_fi_ecrit(1, klon,iim,jjm+1, ch4_col(1), zx_tmp_2d)
      CALL histwrite(nid_tra,"CH4_column",itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)

      CALL gr_fi_ecrit(1, klon,iim,jjm+1, no2_col(1), zx_tmp_2d)
      CALL histwrite(nid_tra,"NO2_column",itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)

      CALL gr_fi_ecrit(1, klon,iim,jjm+1, o3_st_flx(1), zx_tmp_2d)
      CALL histwrite(nid_tra,"O3_ste",itau_w,zx_tmp_2d,
     .     iim*(jjm+1),ndex2d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,o3_prod(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"O3_prod",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,o3_loss(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"O3_loss",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex3d)
! Ajout Anne
#ifdef INCA_AER
! for sulfur cycle

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,SO2_p_dmsoh(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"SO2_p_dmsoh",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,SO2_p_dmsno3(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"SO2_p_dmsno3",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,SO2_p_h2soh(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"SO2_p_h2soh",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,SO2_p_dmsooh(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"SO2_p_dmsooh",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,DMSO_p_dmsoh(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"DMSO_p_dmsoh",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,ASMSAM_p_dmsooh(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"ASMSAM_p_dmsooh",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,ASSO4M_p_so2oh(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"ASSO4M_p_so2oh",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,ASSO4M_p_so2h2o2(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"ASSO4M_p_so2h2o2",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,ASSO4M_p_so2o3(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"ASSO4M_p_so2o3",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

c closing the sulfur budget
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, wet3d_so2(1,1), zx_tmp_3d)
      CALL histwrite(nid_tra,"Wet3D_SO2",itau_w,zx_tmp_3d,
     .     iim*(jjm+1)*klev,ndex)
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, wet3d_dms(1,1), zx_tmp_3d)
      CALL histwrite(nid_tra,"Wet3D_DMS",itau_w,zx_tmp_3d,
     .     iim*(jjm+1)*klev,ndex)
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, wet3d_hno3(1,1), zx_tmp_3d)
      CALL histwrite(nid_tra,"Wet3D_HNO3",itau_w,zx_tmp_3d,
     .     iim*(jjm+1)*klev,ndex)
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, wet3d_h2o2(1,1), zx_tmp_3d)
      CALL histwrite(nid_tra,"Wet3D_H2O2",itau_w,zx_tmp_3d,
     .     iim*(jjm+1)*klev,ndex)


      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,PH_HIST(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"PH_HIST",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)
#endif

#ifdef INCA_NMHC
      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,CO2_basprod(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"CO2_basprod",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,CO2_nmhcprod(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"CO2_nmhcprod",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,CO2_radicalprod(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"CO2_radicalprod",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hno3_prod(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"HNO3_prod",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hno3_loss(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"HNO3_loss",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,co_prod(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"CO_prod",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,co_loss(1,1),
     .     zx_tmp_3d)
      CALL histwrite(nid_tra,"CO_loss",itau_w,zx_tmp_3d,
     .                                   iim*(jjm+1)*klev,ndex)

#endif

! Fin ajout Anne

!     ... Special section for daytime averaging
!       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,day_cnt(1,1),
!    .       zx_tmp_3d)
!       CALL histwrite(nid_tra,"day_cnt",itau_w,zx_tmp_3d,
!    .                                  iim*(jjm+1)*klev,ndex3d)
!       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,no_daytime(1,1),
!    .       zx_tmp_3d)
!       CALL histwrite(nid_tra,"NO_day",itau_w,zx_tmp_3d,
!    .                                  iim*(jjm+1)*klev,ndex3d)

!#endif
#else

C abder
         CALL gr_fi_ecrit(1,klon,iim,jjm+1,yu1,zx_tmp_2d)
         CALL histwrite(nid_tra,"pyu1",itau_w,zx_tmp_2d,
     s                                  iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,yv1,zx_tmp_2d)
         CALL histwrite(nid_tra,"pyv1",itau_w,zx_tmp_2d,
     s                                  iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol1,zx_tmp_2d)
         CALL histwrite(nid_tra,"ftsol1",itau_w,zx_tmp_2d,
     s                                       iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol2,zx_tmp_2d)
         CALL histwrite(nid_tra,"ftsol2",itau_w,zx_tmp_2d,
     s                                       iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol3,zx_tmp_2d)
         CALL histwrite(nid_tra,"ftsol3",itau_w,zx_tmp_2d,
     s                                      iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol4,zx_tmp_2d)
         CALL histwrite(nid_tra,"ftsol4",itau_w,zx_tmp_2d,
     s                                      iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf1,zx_tmp_2d)
         CALL histwrite(nid_tra,"psrf1",itau_w,zx_tmp_2d,
     s                                     iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf2,zx_tmp_2d)
         CALL histwrite(nid_tra,"psrf2",itau_w,zx_tmp_2d,
     s                                     iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf3,zx_tmp_2d)
         CALL histwrite(nid_tra,"psrf3",itau_w,zx_tmp_2d,
     s                                     iim*(jjm+1),ndex2d)

         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf4,zx_tmp_2d)
         CALL histwrite(nid_tra,"psrf4",itau_w,zx_tmp_2d,
     s                                     iim*(jjm+1),ndex2d)
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pplay,zx_tmp_3d)
        CALL histwrite(nid_tra,"pplay",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)

        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,t_seri,zx_tmp_3d)
        CALL histwrite(nid_tra,"t",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pmfu,zx_tmp_3d)
        CALL histwrite(nid_tra,"mfu",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pmfd,zx_tmp_3d)
        CALL histwrite(nid_tra,"mfd",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pen_u,zx_tmp_3d)
        CALL histwrite(nid_tra,"en_u",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pen_d,zx_tmp_3d)
        CALL histwrite(nid_tra,"en_d",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pde_d,zx_tmp_3d)
        CALL histwrite(nid_tra,"de_d",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pde_u,zx_tmp_3d)
        CALL histwrite(nid_tra,"de_u",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)
        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,coefh,zx_tmp_3d)
        CALL histwrite(nid_tra,"coefh",itau_w,zx_tmp_3d,
     .                  iim*(jjm+1)*klev,ndex3d)


c abder
#endif

      if (ok_sync) then
         call histsync(nid_tra)
#ifdef INCA_AER
         call histsync(nid_tra2)
         call histsync(nid_tra3)
#endif
       endif


