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

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

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


Revision 1.37 - (hide annotations) (download)
Sat Feb 18 16:20:12 2017 UTC (7 years, 3 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, HEAD
Changes since 1.36: +11 -4 lines
- cost_check.F: reformat message as in most other packages
- cost_final.F: use print_message to print cost functions to STDOUT rather than printing directly to standardMessageUnit

1 gforget 1.37 C $Header: /u/gcmpack/MITgcm/pkg/cost/cost_final.F,v 1.36 2015/12/29 14:30:32 gforget Exp $
2 jmc 1.16 C $Name: $
3 heimbach 1.1
4 jmc 1.29 #include "COST_OPTIONS.h"
5 jmc 1.33 #ifdef ALLOW_CTRL
6     # include "CTRL_OPTIONS.h"
7     #endif
8 heimbach 1.1
9 jmc 1.32 SUBROUTINE COST_FINAL( myThid )
10 heimbach 1.1
11     c ==================================================================
12 heimbach 1.3 c SUBROUTINE cost_final
13 heimbach 1.1 c ==================================================================
14     c
15     c o Sum of all cost function contributions.
16     c
17     c ==================================================================
18 heimbach 1.3 c SUBROUTINE cost_final
19 heimbach 1.1 c ==================================================================
20    
21 jmc 1.32 IMPLICIT NONE
22 heimbach 1.1
23     c == global variables ==
24     #include "EEPARAMS.h"
25     #include "SIZE.h"
26 heimbach 1.5 #include "PARAMS.h"
27 heimbach 1.1
28     #include "cost.h"
29 heimbach 1.14 #ifdef ALLOW_CTRL
30     # include "ctrl.h"
31     #endif
32 heimbach 1.20 #ifdef ALLOW_DIC
33     # include "DIC_COST.h"
34     #endif
35 heimbach 1.23 #ifdef ALLOW_COST_SHELFICE
36     # include "SHELFICE_COST.h"
37     #endif
38    
39 gforget 1.35 #ifdef ALLOW_PROFILES
40     # include "PROFILES_SIZE.h"
41     # include "profiles.h"
42     #endif
43    
44 heimbach 1.1 c == routine arguments ==
45 jmc 1.32 INTEGER myThid
46 heimbach 1.1
47 heimbach 1.2 #ifdef ALLOW_COST
48 heimbach 1.1 c == local variables ==
49 jmc 1.32 INTEGER bi,bj
50     _RL glob_fc, loc_fc
51 gforget 1.35 #ifdef ALLOW_PROFILES
52     integer num_file,num_var
53     #endif
54 gforget 1.37 character*(MAX_LEN_MBUF) msgBuf
55 heimbach 1.1
56     c == end of interface ==
57    
58 heimbach 1.13 #ifdef ALLOW_SEAICE
59 heimbach 1.31 if (useSEAICE) CALL SEAICE_COST_FINAL (myThid)
60 heimbach 1.13 #endif
61    
62 mlosch 1.25 #ifdef ALLOW_SHELFICE
63     CALL SHELFICE_COST_FINAL (myThid)
64     #endif
65    
66 jmc 1.32 c print *, 'ph-1 in thsice_cost_final'
67 heimbach 1.31 #ifdef ALLOW_THSICE
68 jmc 1.33 IF (useThSIce) CALL THSICE_COST_FINAL (myThid)
69 heimbach 1.31 #endif
70 jmc 1.32 c print *, 'ph-3 in thsice_cost_final'
71 heimbach 1.31
72 gforget 1.28 #ifdef ALLOW_ECCO
73 gforget 1.35 IF (useECCO) CALL ECCO_COST_FINAL (myThid)
74 gforget 1.28 #endif
75 heimbach 1.3
76 gforget 1.28 #ifdef ALLOW_COST_STATE_FINAL
77 heimbach 1.6 CALL COST_STATE_FINAL (myThid)
78 jmc 1.29 cgf : effectively using this in adjoint requires the
79 gforget 1.28 c use of adjoint_state_final. That will activate the
80     c objf_state_final vector in place of the fc scalar.
81     c objf_state_final is therefore not added to fc.
82     #endif
83 heimbach 1.3
84 gforget 1.28 #ifdef ALLOW_COST_VECTOR
85     cgf : same idea as for ALLOW_COST_STATE_FINAL
86     CALL COST_VECTOR (myThid)
87     #endif
88 heimbach 1.3
89 heimbach 1.7 # ifdef ALLOW_COST_TEST
90 heimbach 1.2 CALL COST_TEST (myThid)
91 heimbach 1.7 # endif
92 gforget 1.28
93 heimbach 1.7 # ifdef ALLOW_COST_ATLANTIC_HEAT
94 heimbach 1.3 CALL COST_ATLANTIC_HEAT (myThid)
95 heimbach 1.7 # endif
96 gforget 1.28
97 dfer 1.17 #ifdef ALLOW_COST_HFLUXM
98 gforget 1.28 cgf : to compile previous line user is expected to provide cost_hflux.F
99 dfer 1.17 CALL COST_HFLUX (myThid)
100     #endif
101 gforget 1.28
102 dfer 1.17 #ifdef ALLOW_COST_TEMP
103     CALL COST_TEMP (myThid)
104 gforget 1.28 cgf : to compile previous line user is expected to provide cost_temp.F
105 dfer 1.17 #endif
106 heimbach 1.3
107 gforget 1.37 write(msgBuf,'(A,D22.15)') ' early fc = ', fc
108     call print_message( msgBuf, standardmessageunit,
109     & SQUEEZE_RIGHT , mythid)
110 jmc 1.32
111 heimbach 1.1 c-- Sum up all contributions.
112 jmc 1.32 loc_fc = 0.
113     DO bj = myByLo(myThid), myByHi(myThid)
114     DO bi = myBxLo(myThid), myBxHi(myThid)
115 heimbach 1.1
116 gforget 1.34 #ifdef ALLOW_COST_TEST
117 jmc 1.16 write(standardmessageunit,'(A,D22.15)')
118 heimbach 1.11 & ' --> objf_test(bi,bj) = ', objf_test(bi,bj)
119 gforget 1.34 #endif
120     #ifdef ALLOW_COST_TRACER
121 jmc 1.16 write(standardmessageunit,'(A,D22.15)')
122 heimbach 1.11 & ' --> objf_tracer(bi,bj) = ', objf_tracer(bi,bj)
123 gforget 1.34 #endif
124 gforget 1.28 #if ( !defined (ALLOW_ECCO) || !defined (ALLOW_COST_ATLANTIC) )
125 gforget 1.34 # ifdef ALLOW_COST_ATLANTIC_HEAT
126 jmc 1.16 write(standardmessageunit,'(A,D22.15)')
127 heimbach 1.11 & ' --> objf_atl(bi,bj) = ', objf_atl(bi,bj)
128 gforget 1.34 # endif
129 gforget 1.28 #endif
130 dfer 1.17 #ifdef ALLOW_COST_TEMP
131     write(standardmessageunit,'(A,D22.15)')
132 dfer 1.18 & ' --> objf_temp_tut(bi,bj) = ', objf_temp_tut(bi,bj)
133 dfer 1.17 #endif
134     #ifdef ALLOW_COST_HFLUXM
135     write(standardmessageunit,'(A,D22.15)')
136 dfer 1.18 & ' --> objf_hflux_tut(bi,bj) = ', objf_hflux_tut(bi,bj)
137 dfer 1.17 #endif
138 heimbach 1.15 #ifdef ALLOW_COST_TRANSPORT
139 jmc 1.16 write(standardmessageunit,'(A,D22.15)')
140 heimbach 1.15 & ' --> objf_transport(bi,bj) = ', objf_transport(bi,bj)
141     #endif
142 heimbach 1.1
143 jmc 1.32 tile_fc(bi,bj) = tile_fc(bi,bj)
144 gforget 1.34 #ifdef ALLOW_COST_TEST
145 heimbach 1.2 & + mult_test * objf_test(bi,bj)
146 gforget 1.34 #endif
147     #ifdef ALLOW_COST_TRACER
148 heimbach 1.2 & + mult_tracer * objf_tracer(bi,bj)
149 gforget 1.34 #endif
150 gforget 1.28 #if ( !defined (ALLOW_ECCO) || !defined (ALLOW_COST_ATLANTIC) )
151 gforget 1.34 # ifdef ALLOW_COST_ATLANTIC_HEAT
152 heimbach 1.3 & + mult_atl * objf_atl(bi,bj)
153 gforget 1.34 # endif
154 gforget 1.28 #endif
155 heimbach 1.15 #ifdef ALLOW_COST_TRANSPORT
156     & + mult_transport * objf_transport(bi,bj)
157     #endif
158 dfer 1.17 #ifdef ALLOW_COST_TEMP
159 dfer 1.18 & + mult_temp_tut * objf_temp_tut(bi,bj)
160 dfer 1.17 #endif
161     #ifdef ALLOW_COST_HFLUXM
162 dfer 1.18 & + mult_hflux_tut * objf_hflux_tut(bi,bj)
163 dfer 1.17 #endif
164 gforget 1.35
165     #ifdef ALLOW_PROFILES
166 gforget 1.36 if (.NOT.useECCO) then
167 gforget 1.35 do num_file=1,NFILESPROFMAX
168     do num_var=1,NVARMAX
169     tile_fc(bi,bj) = tile_fc(bi,bj)
170     & + mult_profiles(num_file,num_var)
171     & *objf_profiles(num_file,num_var,bi,bj)
172     enddo
173     enddo
174 gforget 1.36 endif
175 gforget 1.35 #endif
176    
177 jmc 1.32 loc_fc = loc_fc + tile_fc(bi,bj)
178 gforget 1.35
179 jmc 1.32 ENDDO
180     ENDDO
181 heimbach 1.1
182 gforget 1.37 write(msgBuf,'(A,D22.15)') ' local fc = ', loc_fc
183     call print_message( msgBuf, standardmessageunit,
184     & SQUEEZE_RIGHT , mythid)
185 heimbach 1.1
186     c-- Do global summation.
187 jmc 1.32 CALL GLOBAL_SUM_TILE_RL( tile_fc, glob_fc, myThid )
188     _BEGIN_MASTER( myThid )
189     fc = fc + glob_fc
190     _END_MASTER( myThid )
191 heimbach 1.3
192 gforget 1.30 c-- Add contributions from global mean constraints
193 jmc 1.32 _BEGIN_MASTER( myThid )
194     fc = fc + glofc
195     _END_MASTER( myThid )
196 gforget 1.30
197 heimbach 1.27 #ifdef ALLOW_DIC_COST
198 heimbach 1.20 cph-- quickly for testing
199     fc = totcost
200     #endif
201    
202 gforget 1.37 write(msgBuf,'(A,D22.15)') ' global fc = ', fc
203     call print_message( msgBuf, standardmessageunit,
204     & SQUEEZE_RIGHT , mythid)
205 heimbach 1.6
206 jmc 1.22 c-- to avoid re-write of output in reverse checkpointing loops,
207     c-- switch off output flag :
208     CALL TURNOFF_MODEL_IO( 0, myThid )
209 heimbach 1.1
210 heimbach 1.2 #endif /* ALLOW_COST */
211 heimbach 1.1
212     return
213     end

  ViewVC Help
Powered by ViewVC 1.1.22