Back to home page

MITgcm

 
 

    


File indexing completed on 2023-09-21 05:10:12 UTC

view on githubraw file Latest commit 96b00645 on 2023-09-20 15:15:14 UTC
5ed655852f Jean*0001 #include "COST_OPTIONS.h"
eaa2114d11 Jean*0002 #ifdef ALLOW_AUTODIFF
                0003 # include "AUTODIFF_OPTIONS.h"
                0004 #endif
bbf42b7711 Patr*0005 
fc355c3e08 Patr*0006 CBOI
                0007 C
                0008 C !TITLE: COST FUNCTION
                0009 C !AUTHORS: mitgcm developers ( support@mitgcm.org )
                0010 C !AFFILIATION: Massachussetts Institute of Technology
                0011 C !DATE:
                0012 C !INTRODUCTION: cost function evaluation
                0013 C \bv
                0014 c The cost function package is connected to the differntiability
                0015 c of the code. Differentiability refers to computing the derivative
                0016 c of a cost function with respect to a set of control variables
                0017 c (initial state, boundary values, model parameters).
                0018 c The cost function may be an element of the final state,
                0019 c a diagonstic thereof, a quantity that is integrated over the
                0020 c model trajectory, or some model vs. data misfit.
                0021 c This routine controls the cost function evaluation
                0022 c at each time step.
                0023 c Different contributions to the cost function are called from here.
                0024 c The present package contains the basic handling of the
                0025 c cost function evaluation along with two prototype cost terms.
                0026 c The cost package is connected with the mitgcm code as follows:
                0027 c
                0028 C     !CALLING SEQUENCE:
                0029 c    ...
                0030 c     |-- initialise_fixed
                0031 c         |
                0032 c         |-- packages_readparms
                0033 c             |
                0034 c             |-- cost_readparms
                0035 c    ...
                0036 c     |-- initialise_varia
                0037 c         |
                0038 c         |-- packages_init_variables
                0039 c             |
                0040 c             |-- cost_init
                0041 c    ...
                0042 c     |-- the_main_loop
                0043 c         |
                0044 c         |-- do iloop = 1,nTimeSteps
                0045 c         |     forward_step
                0046 c         |     cost_tile
                0047 c         |     |
                0048 c         |     |-- cost_tracer
                0049 c         |
                0050 c         |   enddo
                0051 c         |
                0052 c         |-- cost_final
                0053 C \ev
f855e1a625 Patr*0054 CEOI
fc355c3e08 Patr*0055 
                0056 CBOP
96b006450c dngo*0057 C     !ROUTINE: COST_TILE
fc355c3e08 Patr*0058 C     !INTERFACE:
96b006450c dngo*0059       SUBROUTINE COST_TILE( myTime, myIter, myThid )
fc355c3e08 Patr*0060 
                0061 C     !DESCRIPTION: \bv
                0062 C     *================================================================*
951926fb9b Jean*0063 C     | subroutine cost_tile
fc355c3e08 Patr*0064 C     | o this routine computes is called at each time step to
951926fb9b Jean*0065 C     |   accumulate the cost function for the tiles of this processor
fc355c3e08 Patr*0066 C     *================================================================*
                0067 C     \ev
                0068 
                0069 C     !USES:
96b006450c dngo*0070       IMPLICIT NONE
bbf42b7711 Patr*0071 
                0072 C     == Global variables ===
                0073 #include "SIZE.h"
                0074 #include "EEPARAMS.h"
                0075 #include "PARAMS.h"
                0076 #include "DYNVARS.h"
                0077 #include "GRID.h"
449f3c105b Patr*0078 #include "cost.h"
eaa2114d11 Jean*0079 #ifdef ALLOW_AUTODIFF
7c50f07931 Mart*0080 # ifdef ALLOW_AUTODIFF_TAMC
                0081 #  include "tamc.h"
                0082 # endif
ec6be1154b Patr*0083 # ifdef ALLOW_PTRACERS
                0084 #  include "PTRACERS_SIZE.h"
                0085 #  include "PTRACERS_FIELDS.h"
                0086 # endif
616600b8d2 Patr*0087 #endif
bbf42b7711 Patr*0088 
fc355c3e08 Patr*0089 C     !INPUT/OUTPUT PARAMETERS:
96b006450c dngo*0090 C     myThid :: my Thread Id number
449f3c105b Patr*0091       _RL myTime
96b006450c dngo*0092       INTEGER myIter
                0093       INTEGER myThid
bbf42b7711 Patr*0094 
                0095 #ifdef ALLOW_COST
fc355c3e08 Patr*0096 C     !LOCAL VARIABLES:
96b006450c dngo*0097 #ifdef ALLOW_COST_TRACER
                0098       INTEGER bi, bj
                0099 #endif
fc355c3e08 Patr*0100 CEOP
bbf42b7711 Patr*0101 
781d8676b2 Patr*0102 #ifdef ALLOW_AUTODIFF_TAMC
95c72ef3a1 Patr*0103 CADJ STORE theta         = comlev1, key = ikey_dynamics,
                0104 CADJ &     kind = isbyte
                0105 CADJ STORE uvel, vvel    = comlev1, key = ikey_dynamics,
                0106 CADJ &     kind = isbyte
781d8676b2 Patr*0107 # ifdef ALLOW_DEPTH_CONTROL
95c72ef3a1 Patr*0108 CADJ STORE hfacw, hfacs  = comlev1, key = ikey_dynamics,
                0109 CADJ &     kind = isbyte
616600b8d2 Patr*0110 # endif
ec6be1154b Patr*0111 # ifdef ALLOW_PTRACERS
                0112 #  ifdef NONLIN_FRSURF
                0113 CADJ STORE hFacC  = comlev1, key = ikey_dynamics,
                0114 CADJ &     kind = isbyte
                0115 CADJ STORE ptracer = comlev1, key = ikey_dynamics,
                0116 CADJ &     kind = isbyte
                0117 #  endif
                0118 # endif
616600b8d2 Patr*0119 #endif
bbf42b7711 Patr*0120 
96b006450c dngo*0121       IF ( myTime .GT. (endTime - lastinterval) ) THEN
1e22f5fc71 Patr*0122 
913151f332 Davi*0123 #if (defined (ALLOW_COST_TEST) || defined (ALLOW_COST_ATLANTIC_HEAT) || defined (ALLOW_COST_TEMP) )
96b006450c dngo*0124         CALL COST_ACCUMULATE_MEAN (myThid)
1e22f5fc71 Patr*0125 #endif
                0126 
64c318b5ee Patr*0127 #ifdef ALLOW_COST_SHELFICE
96b006450c dngo*0128         CALL SHELFICE_COST_ACCUMULATE (myThid)
                0129 #endif
                0130 
                0131 #if ( defined(ALLOW_STREAMICE) && defined(ALLOW_COST_STREAMICE) )
                0132         IF (useStreamIce) CALL STREAMICE_COST_ACCUM (myIter, myThid)
64c318b5ee Patr*0133 #endif
                0134 
65d2de27de Mart*0135 #if (defined ALLOW_THSICE && defined ALLOW_THSICE_COST_TEST)
96b006450c dngo*0136         IF (useThSIce) CALL THSICE_COST_DRIVER (myTime, myIter, myThid)
6c747cb1b2 Patr*0137 #endif
                0138 
1e22f5fc71 Patr*0139       ENDIF
                0140 
96b006450c dngo*0141 #ifdef ALLOW_COST_TRACER
bbf42b7711 Patr*0142       DO bj=myByLo(myThid),myByHi(myThid)
                0143         DO bi=myBxLo(myThid),myBxHi(myThid)
449f3c105b Patr*0144            CALL COST_TRACER( bi, bj, myThid )
bbf42b7711 Patr*0145         ENDDO
                0146       ENDDO
96b006450c dngo*0147 #endif
bbf42b7711 Patr*0148 
                0149 #endif /* ALLOW_COST */
                0150 
                0151       RETURN
                0152       END