/[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.34 - (show annotations) (download)
Wed Oct 1 12:55:58 2014 UTC (9 years, 8 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65l, checkpoint65m, checkpoint65f, checkpoint65g, checkpoint65o
Changes since 1.33: +13 -1 lines
- pkg/cost/cost_final.F : add CPP brackets

1 C $Header: /u/gcmpack/MITgcm/pkg/cost/cost_final.F,v 1.33 2014/04/04 21:05:31 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 #ifdef ALLOW_COST_TEST
106 write(standardmessageunit,'(A,D22.15)')
107 & ' --> objf_test(bi,bj) = ', objf_test(bi,bj)
108 #endif
109 #ifdef ALLOW_COST_TRACER
110 write(standardmessageunit,'(A,D22.15)')
111 & ' --> objf_tracer(bi,bj) = ', objf_tracer(bi,bj)
112 #endif
113 #if ( !defined (ALLOW_ECCO) || !defined (ALLOW_COST_ATLANTIC) )
114 # ifdef ALLOW_COST_ATLANTIC_HEAT
115 write(standardmessageunit,'(A,D22.15)')
116 & ' --> objf_atl(bi,bj) = ', objf_atl(bi,bj)
117 # endif
118 #endif
119 #ifdef ALLOW_COST_TEMP
120 write(standardmessageunit,'(A,D22.15)')
121 & ' --> objf_temp_tut(bi,bj) = ', objf_temp_tut(bi,bj)
122 #endif
123 #ifdef ALLOW_COST_HFLUXM
124 write(standardmessageunit,'(A,D22.15)')
125 & ' --> objf_hflux_tut(bi,bj) = ', objf_hflux_tut(bi,bj)
126 #endif
127 #ifdef ALLOW_COST_TRANSPORT
128 write(standardmessageunit,'(A,D22.15)')
129 & ' --> objf_transport(bi,bj) = ', objf_transport(bi,bj)
130 #endif
131
132 tile_fc(bi,bj) = tile_fc(bi,bj)
133 #ifdef ALLOW_COST_TEST
134 & + mult_test * objf_test(bi,bj)
135 #endif
136 #ifdef ALLOW_COST_TRACER
137 & + mult_tracer * objf_tracer(bi,bj)
138 #endif
139 #if ( !defined (ALLOW_ECCO) || !defined (ALLOW_COST_ATLANTIC) )
140 # ifdef ALLOW_COST_ATLANTIC_HEAT
141 & + mult_atl * objf_atl(bi,bj)
142 # endif
143 #endif
144 #ifdef ALLOW_COST_TRANSPORT
145 & + mult_transport * objf_transport(bi,bj)
146 #endif
147 #ifdef ALLOW_COST_TEMP
148 & + mult_temp_tut * objf_temp_tut(bi,bj)
149 #endif
150 #ifdef ALLOW_COST_HFLUXM
151 & + mult_hflux_tut * objf_hflux_tut(bi,bj)
152 #endif
153 loc_fc = loc_fc + tile_fc(bi,bj)
154 ENDDO
155 ENDDO
156
157 write(standardmessageunit,'(A,D22.15)') ' local fc = ', loc_fc
158
159 c-- Do global summation.
160 CALL GLOBAL_SUM_TILE_RL( tile_fc, glob_fc, myThid )
161 _BEGIN_MASTER( myThid )
162 fc = fc + glob_fc
163 _END_MASTER( myThid )
164
165 c-- Add contributions from global mean constraints
166 _BEGIN_MASTER( myThid )
167 fc = fc + glofc
168 _END_MASTER( myThid )
169
170 #ifdef ALLOW_DIC_COST
171 cph-- quickly for testing
172 fc = totcost
173 #endif
174
175 write(standardmessageunit,'(A,D22.15)') ' global fc = ', fc
176
177 c-- to avoid re-write of output in reverse checkpointing loops,
178 c-- switch off output flag :
179 CALL TURNOFF_MODEL_IO( 0, myThid )
180
181 #endif /* ALLOW_COST */
182
183 return
184 end

  ViewVC Help
Powered by ViewVC 1.1.22