!
! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ini_histins.h,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $
!
      IF (ok_instan) THEN

         zsto = dtime * ecrit_ins
         zout = dtime * ecrit_ins

         idayref = day_ref
         CALL ymds2ju(annee_ref, 1, idayref, zero, zjulian)

         call histbeg_phy("histins.nc",itau_phy,
     .                    zjulian,dtime,nhori,nid_ins)

!$OMP MASTER
         CALL histvert(nid_ins, "presnivs", "Vertical levels", "Pa",
     .                 klev, presnivs, nvert)

c-------------------------------------------------------
      IF(lev_histday.GE.1) THEN
c
ccccccccccccc 2D fields, basics
c
         CALL histdef(nid_ins, "phis", "Surface geop. height", "-",
     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
     .                "once",  zsto,zout)
c
         CALL histdef(nid_ins, "aire", "Grid area", "-",
     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
     .                "once",  zsto,zout)
c
         CALL histdef(nid_ins, "tsol", "Surface Temperature", "K",
     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "psol", "Surface Pressure", "Pa",
     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
     .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "ue", "Zonal energy transport", "-",
c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
c    .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "ve", "Merid energy transport", "-",
c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
c    .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "cdragh", "Drag coef on T", "-",
c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
c    .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "cdragm", "Drag coef on U", "-",
c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
c    .                "ins(X)", zsto,zout)
c
      ENDIF !lev_histday.GE.1
c
c-------------------------------------------------------
      IF(lev_histday.GE.2) THEN
c
ccccccccccccc 3D fields, basics
c
         CALL histdef(nid_ins, "temp", "Air temperature", "K",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "pres", "Air pressure", "Pa",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "geop", "Geopotential height", "m",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "vitu", "Zonal wind", "m/s",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "vitv", "Meridional wind", "m/s",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "vitw", "Vertical wind", "Pa/s",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "dudyn", "Dynamics dU", "m/s2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "duvdf", "Boundary-layer dU", "m/s2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "mang", "Angular momentum", "kg m2/s",
c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
c    .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "Kz", "vertical diffusion coef", "m2/s",
c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
c    .                "ins(X)", zsto,zout)
c
c plusieurs traceurs
          if (iflag_trac.eq.1) THEN
            DO iq=1,nqmax
             IF (iq.LE.99) THEN
          WRITE(str2,'(i2.2)') iq
          CALL histdef(nid_ins, tname(iq), ttext(iq), "ppm",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
             ELSE
          PRINT*, "Trop de traceurs"
          CALL abort
             ENDIF 
            ENDDO
          endif
c
         CALL histdef(nid_ins, "tops", "Solar rad. at TOA", "W/m2",
     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
     .                "ins(X)", zsto,zout)
c
      ENDIF !lev_histday.GE.2
c
c-------------------------------------------------------
      IF(lev_histday.GE.3) THEN
c
cccccccccccccccccc  Radiative transfer
c
c 2D
c
         CALL histdef(nid_ins, "topl", "IR rad. at TOA", "W/m2",
     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "sols", "Solar rad. at surf.", "W/m2",
     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "soll", "IR rad. at surface", "W/m2",
     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
     .                "ins(X)", zsto,zout)
c
c 3D
c
         CALL histdef(nid_ins, "SWnet", "Net SW flux","W/m2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert,
     .                32, "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "LWnet", "Net LW flux","W/m2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert,
     .                32, "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "fluxvdf", "PBL net flux","W/m2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert,
     .                32, "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "fluxdyn", "Dyn. net flux","W/m2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert,
     .                32, "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "fluxajs", "Dry adj. net flux","W/m2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert,
     .                32, "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "fluxec", "Cin. net flux","W/m2",
c    .                iim,jj_nb,nhori, klev,1,klev,nvert,
c    .                32, "ins(X)", zsto,zout)
c
      ENDIF !lev_histday.GE.3
c
c-------------------------------------------------------
      IF(lev_histday.GE.4) THEN
c
         CALL histdef(nid_ins, "dtdyn", "Dynamics dT", "K/s",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "dtphy", "Physics dT", "K/s",
c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
c    .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "dtvdf", "Boundary-layer dT", "K/s",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "dtajs", "Dry adjust. dT", "K/s",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "dtswr", "SW radiation dT", "K/s",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "dtlwr", "LW radiation dT", "K/s",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "dtec", "Cinetic dissip dT", "K/s",
c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
c    .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "duajs", "Dry convection dU", "m/s2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "dugwo", "GW oro dU", "m/s2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
         CALL histdef(nid_ins, "dugwno", "GW non-oro dU", "m/s2",
     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
     .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "dvvdf", "Boundary-layer dV", "m/s2",
c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
c    .                "ins(X)", zsto,zout)
c
      ENDIF !lev_histday.GE.4
c
c-------------------------------------------------------
      IF(lev_histday.GE.5) THEN
c
c        call histdef(nid_ins, "taux", 
c    $         "Zonal wind stress", "Pa",  
c    $         iim,jj_nb,nhori, 1,1,1, nvert, 32,
c    $         "ins(X)", zsto,zout)
c
c        call histdef(nid_ins, "tauy", 
c    $         "Meridional xind stress", "Pa",  
c    $         iim,jj_nb,nhori, 1,1,1, nvert, 32,
c    $         "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "cdrm", "Momentum drag coef.", "-",
c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
c    .                "ins(X)", zsto,zout)
c
c        CALL histdef(nid_ins, "cdrh", "Heat drag coef.", "-",
c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
c    .                "ins(X)", zsto,zout)
c
      ENDIF !lev_histday.GE.5
c-------------------------------------------------------
c
         CALL histend(nid_ins)
!$OMP END MASTER

      ENDIF
