1 |
C $Header$ |
C $Header$ |
2 |
|
|
3 |
|
#include "PACKAGES_CONFIG.h" |
4 |
#include "COST_CPPOPTIONS.h" |
#include "COST_CPPOPTIONS.h" |
5 |
|
|
6 |
|
subroutine cost_final( mythid ) |
|
subroutine cost_Final( |
|
|
I mythid |
|
|
& ) |
|
7 |
|
|
8 |
c ================================================================== |
c ================================================================== |
9 |
c SUBROUTINE cost_Final |
c SUBROUTINE cost_final |
10 |
c ================================================================== |
c ================================================================== |
11 |
c |
c |
12 |
c o Sum of all cost function contributions. |
c o Sum of all cost function contributions. |
13 |
c |
c |
14 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
|
c |
|
15 |
c changed: Christian Eckert eckert@mit.edu 25-Feb-2000 |
c changed: Christian Eckert eckert@mit.edu 25-Feb-2000 |
16 |
c |
c heimbach@mit.edu 05-Nov-2003 Modularize cost package |
|
c - Restructured the code in order to create a package |
|
|
c for the MITgcmUV. |
|
17 |
c |
c |
18 |
c ================================================================== |
c ================================================================== |
19 |
c SUBROUTINE cost_Final |
c SUBROUTINE cost_final |
20 |
c ================================================================== |
c ================================================================== |
21 |
|
|
22 |
implicit none |
implicit none |
25 |
|
|
26 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
27 |
#include "SIZE.h" |
#include "SIZE.h" |
28 |
|
#include "PARAMS.h" |
29 |
|
|
30 |
#include "cost.h" |
#include "cost.h" |
31 |
#include "ctrl.h" |
#include "ctrl.h" |
34 |
|
|
35 |
integer mythid |
integer mythid |
36 |
|
|
37 |
|
#ifdef ALLOW_COST |
38 |
c == local variables == |
c == local variables == |
39 |
|
|
40 |
|
integer i,j,k |
41 |
integer bi,bj |
integer bi,bj |
42 |
integer itlo,ithi |
integer itlo,ithi |
43 |
integer jtlo,jthi |
integer jtlo,jthi |
44 |
|
|
|
#ifdef ECCO_VERBOSE |
|
|
character*(MAX_LEN_MBUF) msgbuf |
|
|
#endif |
|
|
|
|
45 |
c == end of interface == |
c == end of interface == |
46 |
|
|
47 |
jtlo = mybylo(mythid) |
jtlo = mybylo(mythid) |
49 |
itlo = mybxlo(mythid) |
itlo = mybxlo(mythid) |
50 |
ithi = mybxhi(mythid) |
ithi = mybxhi(mythid) |
51 |
|
|
52 |
#ifdef ECCO_VERBOSE |
#if (defined (ALLOW_ECCO)) |
53 |
write(msgbuf,'(a)') ' ' |
CALL ECCO_COST_FINAL (myThid) |
54 |
call print_message( msgbuf, standardmessageunit, |
|
55 |
& SQUEEZE_RIGHT , mythid) |
#elif (defined (ALLOW_COST_VECTOR)) |
56 |
write(msgbuf,'(a)') ' ' |
CALL COST_VECTOR (myThid) |
57 |
call print_message( msgbuf, standardmessageunit, |
|
58 |
& SQUEEZE_RIGHT , mythid) |
#elif (defined (ALLOW_COST_STATE_FINAL)) |
59 |
write(msgbuf,'(a)') |
CALL COST_STATE_FINAL (myThid) |
60 |
& ' cost_Final: Evaluating the final cost function.' |
|
61 |
call print_message( msgbuf, standardmessageunit, |
#endif /* above stuff undef */ |
62 |
& SQUEEZE_RIGHT , mythid) |
|
63 |
write(msgbuf,'(a)') ' ' |
#ifndef ALLOW_ECCO |
64 |
call print_message( msgbuf, standardmessageunit, |
|
65 |
& SQUEEZE_RIGHT , mythid) |
# ifdef ALLOW_COST_TEST |
66 |
#endif |
CALL COST_TEST (myThid) |
67 |
|
# endif |
68 |
|
# ifdef ALLOW_COST_ATLANTIC_HEAT |
69 |
|
CALL COST_ATLANTIC_HEAT (myThid) |
70 |
|
# endif |
71 |
|
|
72 |
c-- Sum up all contributions. |
c-- Sum up all contributions. |
73 |
do bj = jtlo,jthi |
do bj = jtlo,jthi |
74 |
do bi = itlo,ithi |
do bi = itlo,ithi |
75 |
|
|
76 |
print*,' --> objf_temp(bi,bj) =',objf_temp(bi,bj) |
write(standardmessageunit,'(A,E22.14)') |
77 |
print*,' --> objf_salt(bi,bj) =',objf_salt(bi,bj) |
& ' --> objf_test(bi,bj) = ', objf_test(bi,bj) |
78 |
print*,' --> objf_tauu(bi,bj) =',objf_tauu(bi,bj) |
write(standardmessageunit,'(A,E22.14)') |
79 |
print*,' --> objf_tauv(bi,bj) =',objf_tauv(bi,bj) |
& ' --> objf_tracer(bi,bj) = ', objf_tracer(bi,bj) |
80 |
print*,' --> objf_hflux(bi,bj) =',objf_hflux(bi,bj) |
write(standardmessageunit,'(A,E22.14)') |
81 |
print*,' --> objf_sflux(bi,bj) =',objf_sflux(bi,bj) |
& ' --> objf_atl(bi,bj) = ', objf_atl(bi,bj) |
|
print*,' --> objf_sst(bi,bj) =',objf_sst(bi,bj) |
|
|
print*,' --> objf_h(bi,bj) =',objf_h(bi,bj) |
|
|
print*,' --> objf_atl(bi,bj) =',objf_atl(bi,bj) |
|
|
print*,' --> objf_ctdt(bi,bj) =',objf_ctdt(bi,bj) |
|
|
print*,' --> objf_ctds(bi,bj) =',objf_ctds(bi,bj) |
|
|
print*,' --> objf_test(bi,bj) =',objf_test(bi,bj) |
|
82 |
|
|
83 |
fc = fc |
fc = fc |
84 |
& + mult_temp * objf_temp(bi,bj) |
& + mult_test * objf_test(bi,bj) |
85 |
& + mult_salt * objf_salt(bi,bj) |
& + mult_tracer * objf_tracer(bi,bj) |
86 |
& + mult_tauu * objf_tauu(bi,bj) |
& + mult_atl * objf_atl(bi,bj) |
|
& + mult_tauv * objf_tauv(bi,bj) |
|
|
& + mult_hq * objf_hflux(bi,bj) |
|
|
& + mult_hs * objf_sflux(bi,bj) |
|
|
& + mult_sst * objf_sst(bi,bj) |
|
|
& + mult_h * objf_h(bi,bj) |
|
|
& + mult_atl * objf_atl(bi,bj) |
|
|
& + mult_ctdt * objf_ctdt(bi,bj) |
|
|
& + mult_ctds * objf_ctds(bi,bj) |
|
|
& + mult_test * objf_test(bi,bj) |
|
87 |
enddo |
enddo |
88 |
enddo |
enddo |
89 |
|
|
90 |
|
write(standardmessageunit,'(A,E22.14)') ' local fc = ', fc |
91 |
|
|
92 |
c-- Do global summation. |
c-- Do global summation. |
93 |
_GLOBAL_SUM_R8( fc , myThid ) |
_GLOBAL_SUM_R8( fc , myThid ) |
94 |
|
|
95 |
c-- Each process has calculated the global part for itself. |
write(standardmessageunit,'(A,E22.14)') ' global fc = ', fc |
96 |
_BEGIN_MASTER( mythid ) |
|
97 |
fc = fc + mult_hmean*objf_hmean |
#endif /* ALLOW_ECCO */ |
98 |
_END_MASTER( mythid ) |
|
99 |
print*,' --> fc =',fc |
c-- set averaging freq. to zero to avoid re-write of |
100 |
|
c-- averaged fields in reverse checkpointing loops |
101 |
#ifdef ECCO_VERBOSE |
taveFreq = 0. |
102 |
write(msgbuf,'(a,D22.15)') |
dumpFreq = 0. |
103 |
& ' cost_Final: final cost function = ',fc |
pChkptFreq = 0. |
104 |
call print_message( msgbuf, standardmessageunit, |
monitorFreq = 0. |
105 |
& SQUEEZE_RIGHT , mythid) |
|
106 |
write(msgbuf,'(a)') ' ' |
#endif /* ALLOW_COST */ |
|
call print_message( msgbuf, standardmessageunit, |
|
|
& SQUEEZE_RIGHT , mythid) |
|
|
write(msgbuf,'(a)') |
|
|
& ' cost function evaluation finished.' |
|
|
call print_message( msgbuf, standardmessageunit, |
|
|
& SQUEEZE_RIGHT , mythid) |
|
|
write(msgbuf,'(a)') ' ' |
|
|
call print_message( msgbuf, standardmessageunit, |
|
|
& SQUEEZE_RIGHT , mythid) |
|
|
#endif |
|
107 |
|
|
108 |
return |
return |
109 |
end |
end |