C $Header: /u/gcmpack/MITgcm/pkg/ecco/ecco.h,v 1.25 2017/04/03 23:16:38 ou.wang Exp $
C $Name:  $

c     ==================================================================
c     HEADER ECCO
c     ==================================================================
c
c     o Header for the ECCO project.
c
c     started: Christian Eckert eckert@mit.edu  23-Feb-1999
c
c     changed: Christian Eckert eckert@mit.edu
c
c
c     ==================================================================
c     HEADER ECCO
c     ==================================================================

c     Version of the release and versions of used packages:
c     =====================================================
c
c     eccoVersion                - ecco release version.
c     usesCalendarVersion        - version of the calendar that has to
c                                  be used.
c     usesExternalForcingVersion - version of the external forcing that
c                                  has to be used.
c     usesAdjointSupportVersion  - version of the adjoint support routines
c                                  that have to be used.
c     usesOptimizationVersion    - version of the oof-line optimization
c                                  that has to be used.

      character*(5) eccoVersion
      character*(5) eccoUsesCalVersion
      character*(5) eccoUsesExfVersion
      character*(5) eccoUsesAdsuppVersion
      character*(5) eccoUsesOptimVersion

      parameter(    eccoVersion           = '0.1.0' )
      parameter(    eccoUsesCalVersion    = '0.1.4' )
      parameter(    eccoUsesExfVersion    = '0.1.1' )
      parameter(    eccoUsesAdsuppVersion = '0.1.0' )
      parameter(    eccoUsesOptimVersion  = '2.1.0' )


c     Experiment name:
c     ================

      common /ecco_c/
     &                expId
      character*(10)  expId


c     Integration information:
c     ========================
c
c     nyears - number of calendar years that are affected by the
c              current integration.

      common /ecco_i/
     &                nyears, nmonths, ndays, numsteps,
     &                eccoiter, ecco_prevcall
      integer nyears
      integer nmonths
      integer ndays
      integer numsteps
      integer eccoiter
      integer ecco_prevcall

c     Averaging counters:
c     ===================
c
c     sum1day - counter for the daily averaging
c     sum1mon - counter for the monthly averaging
c     dayrec  - number of averaged surface pressure records.
c     monrec  - number of averaged theta and salinity records.

      common /average_i/
     &                   sum1day,sum1mon,sum1year,
     &                   dayrec,monrec,yearrec
      integer sum1day
      integer sum1mon
      integer sum1year
      integer dayrec
      integer monrec
      integer yearrec

c     Flags used in the model-data comparison:
c     ========================================
c
c     using_ers - flag that indicates the use of ERS data

      common /ecco_cost_data_flags/
     &                         using_mdt,
     &                         using_tpj,
     &                         using_topex,
     &                         using_ers,
     &                         using_gfo,
     &                         using_cost_altim,
     &                         using_cost_bp,
     &                         using_cost_sst,
     &                         using_cost_scat,
     &                         using_cost_seaice
     &                        ,using_cost_transp
      logical using_mdt
      logical using_tpj
      logical using_topex
      logical using_ers
      logical using_gfo
      logical using_cost_altim
      logical using_cost_bp
      logical using_cost_sst
      logical using_cost_scat
      logical using_cost_seaice
      logical using_cost_transp

c     Record counters relevant for the cost function evaluation.
c     ==========================================================
c
c     nyearsrec - number of yearly records that will be generated by
c                 the current model integration.
c     nmonsrec  - number of monthly records that will be generated by
c                 the current model integration.
c     ndaysrec  - number of  daily  records that will be generated by
c                 the current model integration.

      common /ecco_i/
     &                nyearsrec,
     &                nmonsrec,
     &                ndaysrec
      integer nyearsrec
      integer nmonsrec
      integer ndaysrec

      common /ecco_r/
     &                    m_eta,m_UE,m_VN,
#ifdef ALLOW_PSBAR_STERIC
     &                    sterGloH,
#endif
     &                    msktrVolW,msktrVolS,
     &                    trVol, trHeat, trSalt,
     &                    VOLsumGlob_0, VOLsumGlob,
     &                    RHOsumGlob_0, RHOsumGlob,
     &                    frame, cosphi, eccoVol_0
      _RL VOLsumGlob_0, VOLsumGlob, RHOsumGlob_0, RHOsumGlob
      _RL frame   (1-olx:snx+olx,1-oly:sny+oly           )
      _RL cosphi  (1-olx:snx+olx,1-oly:sny+oly,   nsx,nsy)
      _RL m_eta(1-olx:snx+olx,1-oly:sny+oly,   nsx,nsy)
#ifdef ALLOW_PSBAR_STERIC
      _RL sterGloH
#endif
      _RL m_UE (1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy)
      _RL m_VN (1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy)
      _RL msktrVolW (1-OLx:sNx+OLx,1-OLy:sNy+OLy,   nSx,nSy)
      _RL msktrVolS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,   nSx,nSy)
      _RL trVol(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
      _RL trHeat(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
      _RL trSalt(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
      _RL eccoVol_0(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)

c     file precision and field type
      common /prec_type_cost/
     &                        cost_iprec,
     &                        cost_yftype

      integer cost_iprec
      character*(2) cost_yftype

c     Number of User Cost terms:
c     =============================
      INTEGER NUSERCOST
      PARAMETER ( NUSERCOST=10 )

c     Number of Generic Cost terms:
c     =============================
      INTEGER NGENCOST
      PARAMETER ( NGENCOST=30 )

      INTEGER NGENCOST3D
#ifdef ALLOW_GENCOST3D
      PARAMETER ( NGENCOST3D=6 )
#else
      PARAMETER ( NGENCOST3D=0 )
#endif

      INTEGER NGENPPROC
      PARAMETER ( NGENPPROC=10 )

      INTEGER N1DDATA
      PARAMETER ( N1DDATA=300 )

c     empty pre/post-processing :
c     =========================
      common /ecco_nogencost_c/
     &       no_preproc,
     &       no_preproc_c,
     &       no_posproc,
     &       no_posproc_c,
     &       clim_preproc,
     &       anom_preproc
      character*(MAX_LEN_FNAM) no_preproc(NGENPPROC)
      character*(MAX_LEN_FNAM) no_preproc_c(NGENPPROC)
      character*(MAX_LEN_FNAM) no_posproc(NGENPPROC)
      character*(MAX_LEN_FNAM) no_posproc_c(NGENPPROC)
      character*(MAX_LEN_FNAM) clim_preproc(NGENPPROC)
      character*(MAX_LEN_FNAM) anom_preproc(NGENPPROC)

      common /ecco_nogencost_r/
     &       no_preproc_r, no_posproc_r
      _RL no_preproc_r(NGENPPROC)
      _RL no_posproc_r(NGENPPROC)

      common /ecco_nogencost_i/
     &       no_preproc_i, no_posproc_i, clim_preproc_i
      integer no_preproc_i(NGENPPROC)
      integer no_posproc_i(NGENPPROC)
      integer clim_preproc_i(NGENPPROC)

c     gencost common blocs:
c     =====================

#ifdef ALLOW_GENCOST_CONTRIBUTION
c     objf_gencost - gencost user defined contribution
      common /ecco_gencost_ctrl/
     &       gencost_dummy
      _RL  gencost_dummy(NGENCOST)

      common /ecco_gencost_r_1/
     &       objf_gencost, num_gencost, mult_gencost, gencost_storefld,
     &       gencost_barfld, gencost_modfld, gencost_weight,
     &       gencost_mskCsurf, gencost_mskWsurf, gencost_mskSsurf,
     &       gencost_mskVertical,
#ifdef ALLOW_GENCOST3D
     &       gencost_bar3d, gencost_mod3d, gencost_wei3d,
     &       gencost_mskC, gencost_mskW, gencost_mskS,
#endif
     &       gencost_spmin, gencost_spmax, gencost_spzero,
     &       gencost_period, gencost_preproc_r, gencost_posproc_r,
     &       gencost_wei1d, gencost_1ddata

      _RL  objf_gencost(nsx,nsy,NGENCOST)
      _RL  num_gencost(nsx,nsy,NGENCOST)
      _RL  mult_gencost(NGENCOST)
      _RL  gencost_spmin(NGENCOST)
      _RL  gencost_spmax(NGENCOST)
      _RL  gencost_spzero(NGENCOST)
      _RL  gencost_period(NGENCOST)
      _RL  gencost_storefld(1-olx:snx+olx,1-oly:sny+oly,
     &       nsx,nsy,NGENCOST)
      _RL  gencost_barfld(1-olx:snx+olx,1-oly:sny+oly,
     &       nsx,nsy,NGENCOST)
      _RL  gencost_modfld(1-olx:snx+olx,1-oly:sny+oly,
     &       nsx,nsy,NGENCOST)
      _RL  gencost_weight(1-olx:snx+olx,1-oly:sny+oly,
     &       nsx,nsy,NGENCOST)
      _RL  gencost_mskCsurf(1-olx:snx+olx,1-oly:sny+oly,
     &       nsx,nsy,NGENCOST)
      _RL  gencost_mskWsurf(1-olx:snx+olx,1-oly:sny+oly,
     &       nsx,nsy,NGENCOST)
      _RL  gencost_mskSsurf(1-olx:snx+olx,1-oly:sny+oly,
     &       nsx,nsy,NGENCOST)
      _RL  gencost_mskVertical(nr,NGENCOST)
#ifdef ALLOW_GENCOST3D
      _RL  gencost_bar3d(1-olx:snx+olx,1-oly:sny+oly,
     &       nr,nsx,nsy,NGENCOST3D)
      _RL  gencost_mod3d(1-olx:snx+olx,1-oly:sny+oly,
     &       nr,nsx,nsy,NGENCOST3D)
      _RL  gencost_wei3d(1-olx:snx+olx,1-oly:sny+oly,
     &       nr,nsx,nsy,NGENCOST3D)
      _RL  gencost_mskC(1-olx:snx+olx,1-oly:sny+oly,
     &       nr,nsx,nsy,NGENCOST3D)
      _RL  gencost_mskW(1-olx:snx+olx,1-oly:sny+oly,
     &       nr,nsx,nsy,NGENCOST3D)
      _RL  gencost_mskS(1-olx:snx+olx,1-oly:sny+oly,
     &       nr,nsx,nsy,NGENCOST3D)
#endif
      _RL gencost_preproc_r(NGENPPROC,NGENCOST)
      _RL gencost_posproc_r(NGENPPROC,NGENCOST)
      _RL gencost_wei1d(NGENCOST)
      _RL gencost_1ddata(N1DDATA, NGENCOST)

      common /ecco_gencost_i_1/
     &       gencost_nrec, gencost_nrecperiod,
     &       gencost_flag, gencost_outputlevel,
     &       gencost_startdate1, gencost_startdate2,
     &       gencost_enddate1, gencost_enddate2,
     &       gencost_startdate, gencost_enddate,
     &       gencost_pointer3d, gencost_smooth2Ddiffnbt,
     &       gencost_preproc_i, gencost_posproc_i,
     &       gencost_msk_pointer3d, gencost_itracer

      integer gencost_nrec(NGENCOST)
      integer gencost_nrecperiod(NGENCOST)
      integer gencost_flag(NGENCOST)
      integer gencost_outputlevel(NGENCOST)
      integer gencost_startdate1(NGENCOST)
      integer gencost_startdate2(NGENCOST)
      integer gencost_startdate(4,NGENCOST)
      integer gencost_enddate1(NGENCOST)
      integer gencost_enddate2(NGENCOST)
      integer gencost_enddate(4,NGENCOST)
      integer gencost_pointer3d(NGENCOST)
      integer  gencost_smooth2Ddiffnbt(NGENCOST)
      integer gencost_preproc_i(NGENPPROC,NGENCOST)
      integer gencost_posproc_i(NGENPPROC,NGENCOST)
      integer gencost_msk_pointer3d(NGENCOST)
      integer gencost_itracer(NGENCOST)

      common /ecco_gencost_l_1/
     &       gencost_timevaryweight, gencost_barskip,
     &       using_gencost, gencost_is3d, gencost_msk_is3d,
     &       gencost_is1d
      LOGICAL using_gencost(NGENCOST)
      LOGICAL gencost_is3d(NGENCOST)
      LOGICAL gencost_is1d(NGENCOST)
      LOGICAL gencost_msk_is3d(NGENCOST)
      LOGICAL gencost_timevaryweight(NGENCOST)
      LOGICAL gencost_barskip(NGENCOST)

      common /ecco_gencost_c/
     &       gencost_name,
     &       gencost_scalefile,
     &       gencost_errfile,
     &       gencost_datafile,
     &       gencost_barfile,
     &       gencost_avgperiod,
     &       gencost_preproc,
     &       gencost_preproc_c,
     &       gencost_posproc,
     &       gencost_posproc_c,
     &       gencost_mask
      character*(MAX_LEN_FNAM) gencost_name(NGENCOST)
      character*(MAX_LEN_FNAM) gencost_scalefile(NGENCOST)
      character*(MAX_LEN_FNAM) gencost_errfile(NGENCOST)
      character*(MAX_LEN_FNAM) gencost_datafile(NGENCOST)
      character*(MAX_LEN_FNAM) gencost_barfile(NGENCOST)
      character*(5)            gencost_avgperiod(NGENCOST)
      character*(MAX_LEN_FNAM) gencost_preproc(NGENPPROC,NGENCOST)
      character*(MAX_LEN_FNAM) gencost_posproc_c(NGENPPROC,NGENCOST)
      character*(MAX_LEN_FNAM) gencost_posproc(NGENPPROC,NGENCOST)
      character*(MAX_LEN_FNAM) gencost_preproc_c(NGENPPROC,NGENCOST)
      character*(MAX_LEN_FNAM) gencost_mask(NGENCOST)

#endif /* ALLOW_GENCOST_CONTRIBUTION */

c     ==================================================================
c     END OF HEADER ECCO
c     ==================================================================