1 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/cost_final.F,v 1.18 2008/01/17 20:53:08 dfer Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "COST_CPPOPTIONS.h" |
6 |
|
7 |
subroutine cost_final( mythid ) |
8 |
|
9 |
c ================================================================== |
10 |
c SUBROUTINE cost_final |
11 |
c ================================================================== |
12 |
c |
13 |
c o Sum of all cost function contributions. |
14 |
c |
15 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
16 |
c changed: Christian Eckert eckert@mit.edu 25-Feb-2000 |
17 |
c heimbach@mit.edu 05-Nov-2003 Modularize cost package |
18 |
c |
19 |
c ================================================================== |
20 |
c SUBROUTINE cost_final |
21 |
c ================================================================== |
22 |
|
23 |
implicit none |
24 |
|
25 |
c == global variables == |
26 |
|
27 |
#include "EEPARAMS.h" |
28 |
#include "SIZE.h" |
29 |
#include "PARAMS.h" |
30 |
|
31 |
#include "cost.h" |
32 |
#ifdef ALLOW_CTRL |
33 |
# include "ctrl.h" |
34 |
#endif |
35 |
|
36 |
c == routine arguments == |
37 |
|
38 |
integer mythid |
39 |
|
40 |
#ifdef ALLOW_COST |
41 |
c == local variables == |
42 |
|
43 |
integer i,j,k |
44 |
integer bi,bj |
45 |
integer itlo,ithi |
46 |
integer jtlo,jthi |
47 |
|
48 |
c == end of interface == |
49 |
|
50 |
jtlo = mybylo(mythid) |
51 |
jthi = mybyhi(mythid) |
52 |
itlo = mybxlo(mythid) |
53 |
ithi = mybxhi(mythid) |
54 |
|
55 |
#ifdef ALLOW_SEAICE |
56 |
CALL SEAICE_COST_FINAL (myThid) |
57 |
#endif |
58 |
|
59 |
#if (defined (ALLOW_ECCO)) |
60 |
CALL ECCO_COST_FINAL (myThid) |
61 |
|
62 |
#elif (defined (ALLOW_COST_VECTOR)) |
63 |
CALL COST_VECTOR (myThid) |
64 |
|
65 |
#elif (defined (ALLOW_COST_STATE_FINAL)) |
66 |
CALL COST_STATE_FINAL (myThid) |
67 |
|
68 |
#endif /* above stuff undef */ |
69 |
|
70 |
#ifndef ALLOW_ECCO |
71 |
|
72 |
# ifdef ALLOW_COST_TEST |
73 |
CALL COST_TEST (myThid) |
74 |
# endif |
75 |
# ifdef ALLOW_COST_ATLANTIC_HEAT |
76 |
CALL COST_ATLANTIC_HEAT (myThid) |
77 |
# endif |
78 |
#ifdef ALLOW_COST_HFLUXM |
79 |
CALL COST_HFLUX (myThid) |
80 |
#endif |
81 |
#ifdef ALLOW_COST_TEMP |
82 |
CALL COST_TEMP (myThid) |
83 |
#endif |
84 |
|
85 |
c-- Sum up all contributions. |
86 |
do bj = jtlo,jthi |
87 |
do bi = itlo,ithi |
88 |
|
89 |
write(standardmessageunit,'(A,D22.15)') |
90 |
& ' --> objf_test(bi,bj) = ', objf_test(bi,bj) |
91 |
write(standardmessageunit,'(A,D22.15)') |
92 |
& ' --> objf_tracer(bi,bj) = ', objf_tracer(bi,bj) |
93 |
write(standardmessageunit,'(A,D22.15)') |
94 |
& ' --> objf_atl(bi,bj) = ', objf_atl(bi,bj) |
95 |
#ifdef ALLOW_COST_TEMP |
96 |
write(standardmessageunit,'(A,D22.15)') |
97 |
& ' --> objf_temp_tut(bi,bj) = ', objf_temp_tut(bi,bj) |
98 |
#endif |
99 |
#ifdef ALLOW_COST_HFLUXM |
100 |
write(standardmessageunit,'(A,D22.15)') |
101 |
& ' --> objf_hflux_tut(bi,bj) = ', objf_hflux_tut(bi,bj) |
102 |
#endif |
103 |
#ifdef ALLOW_COST_TRANSPORT |
104 |
write(standardmessageunit,'(A,D22.15)') |
105 |
& ' --> objf_transport(bi,bj) = ', objf_transport(bi,bj) |
106 |
#endif |
107 |
|
108 |
fc = fc |
109 |
& + mult_test * objf_test(bi,bj) |
110 |
& + mult_tracer * objf_tracer(bi,bj) |
111 |
& + mult_atl * objf_atl(bi,bj) |
112 |
#ifdef ALLOW_COST_TRANSPORT |
113 |
& + mult_transport * objf_transport(bi,bj) |
114 |
#endif |
115 |
#ifdef ALLOW_COST_TEMP |
116 |
& + mult_temp_tut * objf_temp_tut(bi,bj) |
117 |
#endif |
118 |
#ifdef ALLOW_COST_HFLUXM |
119 |
& + mult_hflux_tut * objf_hflux_tut(bi,bj) |
120 |
#endif |
121 |
enddo |
122 |
enddo |
123 |
|
124 |
write(standardmessageunit,'(A,D22.15)') ' local fc = ', fc |
125 |
|
126 |
c-- Do global summation. |
127 |
_GLOBAL_SUM_RL( fc , myThid ) |
128 |
|
129 |
write(standardmessageunit,'(A,D22.15)') ' global fc = ', fc |
130 |
|
131 |
#endif /* ALLOW_ECCO */ |
132 |
|
133 |
c-- set averaging freq. to zero to avoid re-write of |
134 |
c-- averaged fields in reverse checkpointing loops |
135 |
taveFreq = 0. |
136 |
dumpFreq = 0. |
137 |
pChkptFreq = 0. |
138 |
monitorFreq = 0. |
139 |
|
140 |
#endif /* ALLOW_COST */ |
141 |
|
142 |
return |
143 |
end |
144 |
|