1 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/cost_final.F,v 1.26 2011/05/24 22:14:36 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_CPPOPTIONS.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 |
#if (defined (ALLOW_ECCO)) |
65 |
CALL ECCO_COST_FINAL (myThid) |
66 |
|
67 |
#elif (defined (ALLOW_COST_VECTOR)) |
68 |
CALL COST_VECTOR (myThid) |
69 |
|
70 |
#elif (defined (ALLOW_COST_STATE_FINAL)) |
71 |
CALL COST_STATE_FINAL (myThid) |
72 |
|
73 |
#endif /* above stuff undef */ |
74 |
|
75 |
#ifndef ALLOW_ECCO |
76 |
|
77 |
# ifdef ALLOW_COST_TEST |
78 |
CALL COST_TEST (myThid) |
79 |
# endif |
80 |
# ifdef ALLOW_COST_ATLANTIC_HEAT |
81 |
CALL COST_ATLANTIC_HEAT (myThid) |
82 |
# endif |
83 |
#ifdef ALLOW_COST_HFLUXM |
84 |
CALL COST_HFLUX (myThid) |
85 |
#endif |
86 |
#ifdef ALLOW_COST_TEMP |
87 |
CALL COST_TEMP (myThid) |
88 |
#endif |
89 |
|
90 |
c-- Sum up all contributions. |
91 |
do bj = jtlo,jthi |
92 |
do bi = itlo,ithi |
93 |
|
94 |
write(standardmessageunit,'(A,D22.15)') |
95 |
& ' --> objf_test(bi,bj) = ', objf_test(bi,bj) |
96 |
write(standardmessageunit,'(A,D22.15)') |
97 |
& ' --> objf_tracer(bi,bj) = ', objf_tracer(bi,bj) |
98 |
write(standardmessageunit,'(A,D22.15)') |
99 |
& ' --> objf_atl(bi,bj) = ', objf_atl(bi,bj) |
100 |
#ifdef ALLOW_COST_TEMP |
101 |
write(standardmessageunit,'(A,D22.15)') |
102 |
& ' --> objf_temp_tut(bi,bj) = ', objf_temp_tut(bi,bj) |
103 |
#endif |
104 |
#ifdef ALLOW_COST_HFLUXM |
105 |
write(standardmessageunit,'(A,D22.15)') |
106 |
& ' --> objf_hflux_tut(bi,bj) = ', objf_hflux_tut(bi,bj) |
107 |
#endif |
108 |
#ifdef ALLOW_COST_TRANSPORT |
109 |
write(standardmessageunit,'(A,D22.15)') |
110 |
& ' --> objf_transport(bi,bj) = ', objf_transport(bi,bj) |
111 |
#endif |
112 |
|
113 |
fc = fc |
114 |
& + mult_test * objf_test(bi,bj) |
115 |
& + mult_tracer * objf_tracer(bi,bj) |
116 |
& + mult_atl * objf_atl(bi,bj) |
117 |
#ifdef ALLOW_COST_TRANSPORT |
118 |
& + mult_transport * objf_transport(bi,bj) |
119 |
#endif |
120 |
#ifdef ALLOW_COST_TEMP |
121 |
& + mult_temp_tut * objf_temp_tut(bi,bj) |
122 |
#endif |
123 |
#ifdef ALLOW_COST_HFLUXM |
124 |
& + mult_hflux_tut * objf_hflux_tut(bi,bj) |
125 |
#endif |
126 |
enddo |
127 |
enddo |
128 |
|
129 |
write(standardmessageunit,'(A,D22.15)') ' local fc = ', fc |
130 |
|
131 |
c-- Do global summation. |
132 |
_GLOBAL_SUM_RL( fc , myThid ) |
133 |
|
134 |
#ifdef ALLOW_DIC_COST |
135 |
cph-- quickly for testing |
136 |
fc = totcost |
137 |
#endif |
138 |
|
139 |
write(standardmessageunit,'(A,D22.15)') ' global fc = ', fc |
140 |
|
141 |
#endif /* ALLOW_ECCO */ |
142 |
|
143 |
c-- to avoid re-write of output in reverse checkpointing loops, |
144 |
c-- switch off output flag : |
145 |
CALL TURNOFF_MODEL_IO( 0, myThid ) |
146 |
|
147 |
#endif /* ALLOW_COST */ |
148 |
|
149 |
return |
150 |
end |