/[MITgcm]/MITgcm/pkg/cost/cost_final.F
ViewVC logotype

Contents of /MITgcm/pkg/cost/cost_final.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.33 - (show annotations) (download)
Fri Apr 4 21:05:31 2014 UTC (10 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65d, checkpoint65e, checkpoint65, checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64w, checkpoint64v
Changes since 1.32: +5 -2 lines
- Start to include explicitly AUTODIFF_OPTIONS.h, COST_OPTIONS.h,
  and CTRL_OPTIONS.h in src files (to enable to skip the ECCO_CPPOPTIONS.h)
  For now, only in pkgs used in verification/hs94.1x64x5.
- Replace ALLOW_AUTODIFF_TAMC by ALLOW_AUTODIFF (except for tape/storage
  which are specific to TAF/TAMC).

1 C $Header: /u/gcmpack/MITgcm/pkg/cost/cost_final.F,v 1.32 2013/11/06 18:53:48 jmc Exp $
2 C $Name: $
3
4 #include "COST_OPTIONS.h"
5 #ifdef ALLOW_CTRL
6 # include "CTRL_OPTIONS.h"
7 #endif
8
9 SUBROUTINE COST_FINAL( myThid )
10
11 c ==================================================================
12 c SUBROUTINE cost_final
13 c ==================================================================
14 c
15 c o Sum of all cost function contributions.
16 c
17 c ==================================================================
18 c SUBROUTINE cost_final
19 c ==================================================================
20
21 IMPLICIT NONE
22
23 c == global variables ==
24 #include "EEPARAMS.h"
25 #include "SIZE.h"
26 #include "PARAMS.h"
27
28 #include "cost.h"
29 #ifdef ALLOW_CTRL
30 # include "ctrl.h"
31 #endif
32 #ifdef ALLOW_DIC
33 # include "DIC_COST.h"
34 #endif
35 #ifdef ALLOW_COST_SHELFICE
36 # include "SHELFICE_COST.h"
37 #endif
38
39 c == routine arguments ==
40 INTEGER myThid
41
42 #ifdef ALLOW_COST
43 c == local variables ==
44 INTEGER bi,bj
45 _RL glob_fc, loc_fc
46
47 c == end of interface ==
48
49 #ifdef ALLOW_SEAICE
50 if (useSEAICE) CALL SEAICE_COST_FINAL (myThid)
51 #endif
52
53 #ifdef ALLOW_SHELFICE
54 CALL SHELFICE_COST_FINAL (myThid)
55 #endif
56
57 c print *, 'ph-1 in thsice_cost_final'
58 #ifdef ALLOW_THSICE
59 IF (useThSIce) CALL THSICE_COST_FINAL (myThid)
60 #endif
61 c print *, 'ph-3 in thsice_cost_final'
62
63 #ifdef ALLOW_ECCO
64 CALL ECCO_COST_FINAL (myThid)
65 #endif
66
67 #ifdef ALLOW_COST_STATE_FINAL
68 CALL COST_STATE_FINAL (myThid)
69 cgf : effectively using this in adjoint requires the
70 c use of adjoint_state_final. That will activate the
71 c objf_state_final vector in place of the fc scalar.
72 c objf_state_final is therefore not added to fc.
73 #endif
74
75 #ifdef ALLOW_COST_VECTOR
76 cgf : same idea as for ALLOW_COST_STATE_FINAL
77 CALL COST_VECTOR (myThid)
78 #endif
79
80 # ifdef ALLOW_COST_TEST
81 CALL COST_TEST (myThid)
82 # endif
83
84 # ifdef ALLOW_COST_ATLANTIC_HEAT
85 CALL COST_ATLANTIC_HEAT (myThid)
86 # endif
87
88 #ifdef ALLOW_COST_HFLUXM
89 cgf : to compile previous line user is expected to provide cost_hflux.F
90 CALL COST_HFLUX (myThid)
91 #endif
92
93 #ifdef ALLOW_COST_TEMP
94 CALL COST_TEMP (myThid)
95 cgf : to compile previous line user is expected to provide cost_temp.F
96 #endif
97
98 write(standardmessageunit,'(A,D22.15)') ' early fc = ', fc
99
100 c-- Sum up all contributions.
101 loc_fc = 0.
102 DO bj = myByLo(myThid), myByHi(myThid)
103 DO bi = myBxLo(myThid), myBxHi(myThid)
104
105 write(standardmessageunit,'(A,D22.15)')
106 & ' --> objf_test(bi,bj) = ', objf_test(bi,bj)
107 write(standardmessageunit,'(A,D22.15)')
108 & ' --> objf_tracer(bi,bj) = ', objf_tracer(bi,bj)
109 #if ( !defined (ALLOW_ECCO) || !defined (ALLOW_COST_ATLANTIC) )
110 write(standardmessageunit,'(A,D22.15)')
111 & ' --> objf_atl(bi,bj) = ', objf_atl(bi,bj)
112 #endif
113 #ifdef ALLOW_COST_TEMP
114 write(standardmessageunit,'(A,D22.15)')
115 & ' --> objf_temp_tut(bi,bj) = ', objf_temp_tut(bi,bj)
116 #endif
117 #ifdef ALLOW_COST_HFLUXM
118 write(standardmessageunit,'(A,D22.15)')
119 & ' --> objf_hflux_tut(bi,bj) = ', objf_hflux_tut(bi,bj)
120 #endif
121 #ifdef ALLOW_COST_TRANSPORT
122 write(standardmessageunit,'(A,D22.15)')
123 & ' --> objf_transport(bi,bj) = ', objf_transport(bi,bj)
124 #endif
125
126 tile_fc(bi,bj) = tile_fc(bi,bj)
127 & + mult_test * objf_test(bi,bj)
128 & + mult_tracer * objf_tracer(bi,bj)
129 #if ( !defined (ALLOW_ECCO) || !defined (ALLOW_COST_ATLANTIC) )
130 & + mult_atl * objf_atl(bi,bj)
131 #endif
132 #ifdef ALLOW_COST_TRANSPORT
133 & + mult_transport * objf_transport(bi,bj)
134 #endif
135 #ifdef ALLOW_COST_TEMP
136 & + mult_temp_tut * objf_temp_tut(bi,bj)
137 #endif
138 #ifdef ALLOW_COST_HFLUXM
139 & + mult_hflux_tut * objf_hflux_tut(bi,bj)
140 #endif
141 loc_fc = loc_fc + tile_fc(bi,bj)
142 ENDDO
143 ENDDO
144
145 write(standardmessageunit,'(A,D22.15)') ' local fc = ', loc_fc
146
147 c-- Do global summation.
148 CALL GLOBAL_SUM_TILE_RL( tile_fc, glob_fc, myThid )
149 _BEGIN_MASTER( myThid )
150 fc = fc + glob_fc
151 _END_MASTER( myThid )
152
153 c-- Add contributions from global mean constraints
154 _BEGIN_MASTER( myThid )
155 fc = fc + glofc
156 _END_MASTER( myThid )
157
158 #ifdef ALLOW_DIC_COST
159 cph-- quickly for testing
160 fc = totcost
161 #endif
162
163 write(standardmessageunit,'(A,D22.15)') ' global fc = ', fc
164
165 c-- to avoid re-write of output in reverse checkpointing loops,
166 c-- switch off output flag :
167 CALL TURNOFF_MODEL_IO( 0, myThid )
168
169 #endif /* ALLOW_COST */
170
171 return
172 end

  ViewVC Help
Powered by ViewVC 1.1.22