c
      ndex2d = 0
      itau_w=itau_dyn+itau
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(prt_level) 
      CALL histwrite(nid_ctesGCM, "prt_level", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(dayref)
      CALL histwrite(nid_ctesGCM, "dayref", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(anneeref)
      CALL histwrite(nid_ctesGCM, "anneeref", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(raz_date)
      CALL histwrite(nid_ctesGCM, "raz_date", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(nday)
      CALL histwrite(nid_ctesGCM, "nday", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(day_step)
      CALL histwrite(nid_ctesGCM, "day_step", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(iperiod)
      CALL histwrite(nid_ctesGCM, "iperiod", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(iapp_tracvl)
      CALL histwrite(nid_ctesGCM, "iapp_tracvl", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(iconser)
      CALL histwrite(nid_ctesGCM, "iconser", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(iecri)
      CALL histwrite(nid_ctesGCM, "iecri", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=periodav
      CALL histwrite(nid_ctesGCM, "periodav", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(idissip)
      CALL histwrite(nid_ctesGCM, "idissip", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(lstardis) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "lstardis", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(nitergdiv)
      CALL histwrite(nid_ctesGCM, "nitergdiv", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(nitergrot)
      CALL histwrite(nid_ctesGCM, "nitergrot", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(niterh) 
      CALL histwrite(nid_ctesGCM, "niterh", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=tetagdiv
      CALL histwrite(nid_ctesGCM, "tetagdiv", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=tetagrot
      CALL histwrite(nid_ctesGCM, "tetagrot", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=tetatemp
      CALL histwrite(nid_ctesGCM, "tetatemp", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=coefdis
      CALL histwrite(nid_ctesGCM, "coefdis", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(purmats) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "purmats", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(ok_guide) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "ok_guide", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(true_calendar) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "true_calendar", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(iflag_phys)
      CALL histwrite(nid_ctesGCM, "iflag_phys", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=FLOAT(iphysiq)
      CALL histwrite(nid_ctesGCM, "iphysiq", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=ecritphy
      CALL histwrite(nid_ctesGCM, "ecritphy", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(cycle_diurne) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "cycle_diurne", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(soil_model) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "soil_model", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(new_oliq) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "new_oliq", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(ok_orodr) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "ok_orodr", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(ok_orolf) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "ok_orolf", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(ok_limitvrai) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "ok_limitvrai", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=nbapp_rad
      CALL histwrite(nid_ctesGCM, "nbapp_rad", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=iflag_con
      CALL histwrite(nid_ctesGCM, "iflag_con", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=clon
      CALL histwrite(nid_ctesGCM, "clon", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=clat
      CALL histwrite(nid_ctesGCM, "clat", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=grossismx
      CALL histwrite(nid_ctesGCM, "grossismx", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=grossismy
      CALL histwrite(nid_ctesGCM, "grossismy", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(fxyhypb) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "fxyhypb", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=dzoomx
      CALL histwrite(nid_ctesGCM, "dzoomx", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=dzoomy
      CALL histwrite(nid_ctesGCM, "dzoomy", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=taux
      CALL histwrite(nid_ctesGCM, "taux", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=tauy
      CALL histwrite(nid_ctesGCM, "tauy", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      IF(ysinus) THEN
       zx_tmp_2d(1:iip1,1:jjp1)=1.
      ELSE
       zx_tmp_2d(1:iip1,1:jjp1)=0.
      ENDIF
      CALL histwrite(nid_ctesGCM, "ysinus", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
      zx_tmp_2d(1:iip1,1:jjp1)=ip_ebil_dyn
      CALL histwrite(nid_ctesGCM, "ip_ebil_dyn", itau_w,
     .               zx_tmp_2d,iip1*jjp1,ndex2d)
c
c=================================================================
c
      if (ok_sync) then
        call histsync(nid_ctesGCM)
      endif
c
c=================================================================
