/[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.29 - (show annotations) (download)
Fri Aug 10 19:36:02 2012 UTC (11 years, 9 months ago) by jmc
Branch: MAIN
Changes since 1.28: +3 -3 lines
rename COST_CPPOPTIONS.h to COST_OPTIONS.h

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

  ViewVC Help
Powered by ViewVC 1.1.22