C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_internal_params.F,v 1.4 2008/05/30 02:49:04 gforget Exp $
C $Name:  $

#include "COST_CPPOPTIONS.h"


      subroutine COST_INTERNAL_PARAMS( myiter, mytime, mythid )

c     ==================================================================
c     SUBROUTINE cost_internal_params
c     ==================================================================
c
c     o Evaluate cost function contributions of internal parameters adjustments.
c
c     started: Gael Forget 17-Aug-2007
c
c     ==================================================================
c     SUBROUTINE cost_internal_params
c     ==================================================================

      implicit none

c     == global variables ==
#include "EEPARAMS.h"
#include "SIZE.h"
#include "PARAMS.h"
#include "GRID.h"

#include "cal.h"
#include "ctrl.h"
#include "ctrl_dummy.h"
#include "ecco_cost.h"

c     == routine arguments ==

      integer myiter
      _RL     mytime
      integer mythid

c     == end of interface ==


c--   Eddy stress penalty term
#ifdef ALLOW_EDDYPSI_COST_CONTRIBUTION
      call TIMER_START('cost_tau_eddy      [ECCO SPIN-DOWN]', mythid)
      call COST_TAU_EDDY( myiter, mytime, mythid )
      call TIMER_STOP ('cost_tau_eddy      [ECCO SPIN-DOWN]', mythid)
#endif
      _BARRIER

c--   GM coeffs penalty term
#ifdef ALLOW_KAPGM_COST_CONTRIBUTION
      call TIMER_START('cost_kapgm      [ECCO SPIN-DOWN]', mythid)
      call COST_KAPGM( myiter, mytime, mythid )
      call TIMER_STOP ('cost_kapgm      [ECCO SPIN-DOWN]', mythid)
#endif
      _BARRIER

c--   REDI coeffs penalty term
#ifdef ALLOW_KAPREDI_COST_CONTRIBUTION
      call TIMER_START('cost_kapredi      [ECCO SPIN-DOWN]', mythid)
      call COST_KAPREDI( myiter, mytime, mythid )
      call TIMER_STOP ('cost_kapredi      [ECCO SPIN-DOWN]', mythid)
#endif
      _BARRIER 

c--   DIFFKR coeffs penalty term
#ifdef ALLOW_DIFFKR_COST_CONTRIBUTION
      call TIMER_START('cost_diffkr      [ECCO SPIN-DOWN]', mythid)
      call COST_DIFFKR( myiter, mytime, mythid )
      call TIMER_STOP ('cost_diffkr      [ECCO SPIN-DOWN]', mythid)
#endif
      _BARRIER

c--   Bottom Drag penalty term
#ifdef ALLOW_BOTTOMDRAG_COST_CONTRIBUTION
      call TIMER_START('cost_bottomdrag      [ECCO SPIN-DOWN]', mythid)
      call COST_BOTTOMDRAG( myiter, mytime, mythid )
      call TIMER_STOP ('cost_bottomdrag      [ECCO SPIN-DOWN]', mythid)
#endif
      _BARRIER

      end