1 |
mlosch |
1.25 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/cost_final.F,v 1.24 2011/03/15 16:06:09 mlosch Exp $ |
2 |
jmc |
1.16 |
C $Name: $ |
3 |
heimbach |
1.1 |
|
4 |
heimbach |
1.7 |
#include "PACKAGES_CONFIG.h" |
5 |
heimbach |
1.1 |
#include "COST_CPPOPTIONS.h" |
6 |
|
|
|
7 |
heimbach |
1.3 |
subroutine cost_final( mythid ) |
8 |
heimbach |
1.1 |
|
9 |
|
|
c ================================================================== |
10 |
heimbach |
1.3 |
c SUBROUTINE cost_final |
11 |
heimbach |
1.1 |
c ================================================================== |
12 |
|
|
c |
13 |
|
|
c o Sum of all cost function contributions. |
14 |
|
|
c |
15 |
|
|
c ================================================================== |
16 |
heimbach |
1.3 |
c SUBROUTINE cost_final |
17 |
heimbach |
1.1 |
c ================================================================== |
18 |
|
|
|
19 |
|
|
implicit none |
20 |
|
|
|
21 |
|
|
c == global variables == |
22 |
|
|
|
23 |
|
|
#include "EEPARAMS.h" |
24 |
|
|
#include "SIZE.h" |
25 |
heimbach |
1.5 |
#include "PARAMS.h" |
26 |
heimbach |
1.1 |
|
27 |
|
|
#include "cost.h" |
28 |
heimbach |
1.14 |
#ifdef ALLOW_CTRL |
29 |
|
|
# include "ctrl.h" |
30 |
|
|
#endif |
31 |
heimbach |
1.20 |
#ifdef ALLOW_DIC |
32 |
|
|
# include "DIC_COST.h" |
33 |
|
|
#endif |
34 |
heimbach |
1.23 |
#ifdef ALLOW_COST_SHELFICE |
35 |
|
|
# include "SHELFICE_COST.h" |
36 |
|
|
#endif |
37 |
|
|
|
38 |
heimbach |
1.1 |
|
39 |
|
|
c == routine arguments == |
40 |
|
|
|
41 |
|
|
integer mythid |
42 |
|
|
|
43 |
heimbach |
1.2 |
#ifdef ALLOW_COST |
44 |
heimbach |
1.1 |
c == local variables == |
45 |
|
|
|
46 |
|
|
integer bi,bj |
47 |
|
|
integer itlo,ithi |
48 |
|
|
integer jtlo,jthi |
49 |
|
|
|
50 |
|
|
c == end of interface == |
51 |
|
|
|
52 |
|
|
jtlo = mybylo(mythid) |
53 |
|
|
jthi = mybyhi(mythid) |
54 |
|
|
itlo = mybxlo(mythid) |
55 |
|
|
ithi = mybxhi(mythid) |
56 |
|
|
|
57 |
heimbach |
1.13 |
#ifdef ALLOW_SEAICE |
58 |
|
|
CALL SEAICE_COST_FINAL (myThid) |
59 |
|
|
#endif |
60 |
|
|
|
61 |
mlosch |
1.25 |
#ifdef ALLOW_SHELFICE |
62 |
|
|
CALL SHELFICE_COST_FINAL (myThid) |
63 |
|
|
#endif |
64 |
|
|
|
65 |
heimbach |
1.7 |
#if (defined (ALLOW_ECCO)) |
66 |
|
|
CALL ECCO_COST_FINAL (myThid) |
67 |
heimbach |
1.3 |
|
68 |
heimbach |
1.7 |
#elif (defined (ALLOW_COST_VECTOR)) |
69 |
heimbach |
1.3 |
CALL COST_VECTOR (myThid) |
70 |
|
|
|
71 |
heimbach |
1.6 |
#elif (defined (ALLOW_COST_STATE_FINAL)) |
72 |
|
|
CALL COST_STATE_FINAL (myThid) |
73 |
heimbach |
1.3 |
|
74 |
heimbach |
1.8 |
#endif /* above stuff undef */ |
75 |
|
|
|
76 |
|
|
#ifndef ALLOW_ECCO |
77 |
heimbach |
1.3 |
|
78 |
heimbach |
1.7 |
# ifdef ALLOW_COST_TEST |
79 |
heimbach |
1.2 |
CALL COST_TEST (myThid) |
80 |
heimbach |
1.7 |
# endif |
81 |
|
|
# ifdef ALLOW_COST_ATLANTIC_HEAT |
82 |
heimbach |
1.3 |
CALL COST_ATLANTIC_HEAT (myThid) |
83 |
heimbach |
1.7 |
# endif |
84 |
dfer |
1.17 |
#ifdef ALLOW_COST_HFLUXM |
85 |
|
|
CALL COST_HFLUX (myThid) |
86 |
|
|
#endif |
87 |
|
|
#ifdef ALLOW_COST_TEMP |
88 |
|
|
CALL COST_TEMP (myThid) |
89 |
|
|
#endif |
90 |
heimbach |
1.3 |
|
91 |
heimbach |
1.1 |
c-- Sum up all contributions. |
92 |
|
|
do bj = jtlo,jthi |
93 |
|
|
do bi = itlo,ithi |
94 |
|
|
|
95 |
jmc |
1.16 |
write(standardmessageunit,'(A,D22.15)') |
96 |
heimbach |
1.11 |
& ' --> objf_test(bi,bj) = ', objf_test(bi,bj) |
97 |
jmc |
1.16 |
write(standardmessageunit,'(A,D22.15)') |
98 |
heimbach |
1.11 |
& ' --> objf_tracer(bi,bj) = ', objf_tracer(bi,bj) |
99 |
jmc |
1.16 |
write(standardmessageunit,'(A,D22.15)') |
100 |
heimbach |
1.11 |
& ' --> objf_atl(bi,bj) = ', objf_atl(bi,bj) |
101 |
dfer |
1.17 |
#ifdef ALLOW_COST_TEMP |
102 |
|
|
write(standardmessageunit,'(A,D22.15)') |
103 |
dfer |
1.18 |
& ' --> objf_temp_tut(bi,bj) = ', objf_temp_tut(bi,bj) |
104 |
dfer |
1.17 |
#endif |
105 |
|
|
#ifdef ALLOW_COST_HFLUXM |
106 |
|
|
write(standardmessageunit,'(A,D22.15)') |
107 |
dfer |
1.18 |
& ' --> objf_hflux_tut(bi,bj) = ', objf_hflux_tut(bi,bj) |
108 |
dfer |
1.17 |
#endif |
109 |
heimbach |
1.15 |
#ifdef ALLOW_COST_TRANSPORT |
110 |
jmc |
1.16 |
write(standardmessageunit,'(A,D22.15)') |
111 |
heimbach |
1.15 |
& ' --> objf_transport(bi,bj) = ', objf_transport(bi,bj) |
112 |
|
|
#endif |
113 |
heimbach |
1.1 |
|
114 |
|
|
fc = fc |
115 |
heimbach |
1.2 |
& + mult_test * objf_test(bi,bj) |
116 |
|
|
& + mult_tracer * objf_tracer(bi,bj) |
117 |
heimbach |
1.3 |
& + mult_atl * objf_atl(bi,bj) |
118 |
heimbach |
1.15 |
#ifdef ALLOW_COST_TRANSPORT |
119 |
|
|
& + mult_transport * objf_transport(bi,bj) |
120 |
|
|
#endif |
121 |
dfer |
1.17 |
#ifdef ALLOW_COST_TEMP |
122 |
dfer |
1.18 |
& + mult_temp_tut * objf_temp_tut(bi,bj) |
123 |
dfer |
1.17 |
#endif |
124 |
|
|
#ifdef ALLOW_COST_HFLUXM |
125 |
dfer |
1.18 |
& + mult_hflux_tut * objf_hflux_tut(bi,bj) |
126 |
dfer |
1.17 |
#endif |
127 |
heimbach |
1.1 |
enddo |
128 |
|
|
enddo |
129 |
|
|
|
130 |
heimbach |
1.12 |
write(standardmessageunit,'(A,D22.15)') ' local fc = ', fc |
131 |
heimbach |
1.1 |
|
132 |
|
|
c-- Do global summation. |
133 |
jmc |
1.19 |
_GLOBAL_SUM_RL( fc , myThid ) |
134 |
heimbach |
1.3 |
|
135 |
heimbach |
1.20 |
#ifdef ALLOW_DIC |
136 |
|
|
cph-- quickly for testing |
137 |
|
|
fc = totcost |
138 |
|
|
#endif |
139 |
|
|
|
140 |
heimbach |
1.12 |
write(standardmessageunit,'(A,D22.15)') ' global fc = ', fc |
141 |
heimbach |
1.6 |
|
142 |
heimbach |
1.7 |
#endif /* ALLOW_ECCO */ |
143 |
heimbach |
1.5 |
|
144 |
jmc |
1.22 |
c-- to avoid re-write of output in reverse checkpointing loops, |
145 |
|
|
c-- switch off output flag : |
146 |
|
|
CALL TURNOFF_MODEL_IO( 0, myThid ) |
147 |
heimbach |
1.1 |
|
148 |
heimbach |
1.2 |
#endif /* ALLOW_COST */ |
149 |
heimbach |
1.1 |
|
150 |
|
|
return |
151 |
|
|
end |