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