1 |
C $Header: /u/gcmpack/MITgcm/pkg/seaice/seaice_cost_final.F,v 1.8 2006/10/19 16:02:53 heimbach Exp $ |
2 |
|
3 |
#include "SEAICE_OPTIONS.h" |
4 |
|
5 |
|
6 |
subroutine seaice_cost_final( mythid ) |
7 |
|
8 |
c ================================================================== |
9 |
c SUBROUTINE seaice_cost_final |
10 |
c ================================================================== |
11 |
|
12 |
implicit none |
13 |
|
14 |
c == global variables == |
15 |
|
16 |
#include "EEPARAMS.h" |
17 |
#include "SIZE.h" |
18 |
#include "PARAMS.h" |
19 |
#include "DYNVARS.h" |
20 |
#include "SEAICE_PARAMS.h" |
21 |
#ifdef ALLOW_COST |
22 |
#include "SEAICE_COST.h" |
23 |
#include "cost.h" |
24 |
#include "ctrl.h" |
25 |
#include "optim.h" |
26 |
#endif |
27 |
|
28 |
c == routine arguments == |
29 |
|
30 |
integer mythid |
31 |
|
32 |
#ifdef ALLOW_COST |
33 |
|
34 |
c == local variables == |
35 |
|
36 |
integer bi,bj |
37 |
integer itlo,ithi |
38 |
integer jtlo,jthi |
39 |
integer ifc |
40 |
integer totnum |
41 |
|
42 |
_RL f_ice |
43 |
_RL f_smrarea |
44 |
|
45 |
_RL no_ice |
46 |
_RL no_smrarea |
47 |
|
48 |
character*23 cfname |
49 |
#ifdef ECCO_VERBOSE |
50 |
character*(MAX_LEN_MBUF) msgbuf |
51 |
#endif |
52 |
|
53 |
c == end of interface == |
54 |
|
55 |
jtlo = mybylo(mythid) |
56 |
jthi = mybyhi(mythid) |
57 |
itlo = mybxlo(mythid) |
58 |
ithi = mybxhi(mythid) |
59 |
|
60 |
ifc = 30 |
61 |
|
62 |
f_ice = 0. _d 0 |
63 |
f_smrarea = 0. _d 0 |
64 |
c |
65 |
no_ice = 0. _d 0 |
66 |
no_smrarea = 0. _d 0 |
67 |
|
68 |
#ifdef ALLOW_SEAICE_COST_EXPORT |
69 |
call seaice_cost_export( myThid ) |
70 |
#endif |
71 |
|
72 |
c-- Sum up all contributions. |
73 |
do bj = jtlo,jthi |
74 |
do bi = itlo,ithi |
75 |
|
76 |
fc = fc |
77 |
& + mult_ice_export * objf_ice_export(bi,bj) |
78 |
& + mult_ice * objf_ice(bi,bj) |
79 |
& + mult_smrarea * objf_smrarea(bi,bj) |
80 |
|
81 |
f_ice = f_ice + objf_ice(bi,bj) |
82 |
f_smrarea = f_smrarea + objf_smrarea(bi,bj) |
83 |
|
84 |
no_ice = no_ice + num_ice(bi,bj) |
85 |
no_smrarea = no_smrarea + num_smrarea(bi,bj) |
86 |
|
87 |
enddo |
88 |
enddo |
89 |
|
90 |
c-- Do global summation. |
91 |
cph this is done only in ecco_cost_final! |
92 |
cph _GLOBAL_SUM_R8( fc , myThid ) |
93 |
|
94 |
c-- Do global summation for each part of the cost function |
95 |
|
96 |
_GLOBAL_SUM_R8( f_ice , myThid ) |
97 |
_GLOBAL_SUM_R8( f_smrarea , myThid ) |
98 |
|
99 |
_GLOBAL_SUM_R8( no_ice , myThid ) |
100 |
_GLOBAL_SUM_R8( no_smrarea , myThid ) |
101 |
|
102 |
write(standardmessageunit,'(A,D22.15)') |
103 |
& ' --> f_ice =',f_ice |
104 |
write(standardmessageunit,'(A,D22.15)') |
105 |
& ' --> f_smrarea =',f_smrarea |
106 |
|
107 |
c-- Each process has calculated the global part for itself. |
108 |
_BEGIN_MASTER( mythid ) |
109 |
|
110 |
write(cfname,'(A,i4.4)') 'costfunction_seaice',optimcycle |
111 |
open(unit=ifc,file=cfname) |
112 |
|
113 |
write(ifc,*) 'fc =', fc |
114 |
write(ifc,*) 'f_ice =', f_ice, no_ice |
115 |
write(ifc,*) 'f_smrarea =', f_smrarea, no_smrarea |
116 |
|
117 |
close(ifc) |
118 |
|
119 |
_END_MASTER( mythid ) |
120 |
|
121 |
SEAICE_dumpFreq = 0. |
122 |
SEAICE_taveFreq = 0. |
123 |
|
124 |
#endif |
125 |
|
126 |
end |