1 |
torge |
1.1 |
C $Header: /u/gcmpack/MITgcm/pkg/seaice/seaice_cost_final.F,v 1.15 2012/03/06 16:45:20 jmc Exp $ |
2 |
|
|
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "SEAICE_OPTIONS.h" |
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_SIZE.h" |
21 |
|
|
#include "SEAICE_PARAMS.h" |
22 |
|
|
#ifdef ALLOW_COST |
23 |
|
|
#include "SEAICE_COST.h" |
24 |
|
|
#include "cost.h" |
25 |
|
|
#include "ctrl.h" |
26 |
|
|
#include "optim.h" |
27 |
|
|
#endif |
28 |
|
|
|
29 |
|
|
c == routine arguments == |
30 |
|
|
|
31 |
|
|
integer mythid |
32 |
|
|
|
33 |
|
|
#ifdef ALLOW_COST |
34 |
|
|
|
35 |
|
|
C === Functions ==== |
36 |
|
|
LOGICAL MASTER_CPU_THREAD |
37 |
|
|
EXTERNAL MASTER_CPU_THREAD |
38 |
|
|
|
39 |
|
|
c == local variables == |
40 |
|
|
|
41 |
|
|
integer bi,bj |
42 |
|
|
integer itlo,ithi |
43 |
|
|
integer jtlo,jthi |
44 |
|
|
integer ifc |
45 |
|
|
integer totnum |
46 |
|
|
|
47 |
|
|
_RL f_ice |
48 |
|
|
_RL f_smrarea |
49 |
|
|
_RL f_smrsst |
50 |
|
|
_RL f_smrsss |
51 |
|
|
|
52 |
|
|
_RL no_ice |
53 |
|
|
_RL no_smrarea |
54 |
|
|
_RL no_smrsst |
55 |
|
|
_RL no_smrsss |
56 |
|
|
|
57 |
|
|
character*23 cfname |
58 |
|
|
#ifdef ECCO_VERBOSE |
59 |
|
|
character*(MAX_LEN_MBUF) msgbuf |
60 |
|
|
#endif |
61 |
|
|
|
62 |
|
|
c == end of interface == |
63 |
|
|
|
64 |
|
|
jtlo = mybylo(mythid) |
65 |
|
|
jthi = mybyhi(mythid) |
66 |
|
|
itlo = mybxlo(mythid) |
67 |
|
|
ithi = mybxhi(mythid) |
68 |
|
|
|
69 |
|
|
ifc = 30 |
70 |
|
|
|
71 |
|
|
f_ice = 0. _d 0 |
72 |
|
|
f_smrarea = 0. _d 0 |
73 |
|
|
f_smrsst = 0. _d 0 |
74 |
|
|
f_smrsss = 0. _d 0 |
75 |
|
|
c |
76 |
|
|
no_ice = 0. _d 0 |
77 |
|
|
no_smrarea = 0. _d 0 |
78 |
|
|
no_smrsst = 0. _d 0 |
79 |
|
|
no_smrsss = 0. _d 0 |
80 |
|
|
|
81 |
|
|
#ifdef ALLOW_SEAICE_COST_EXPORT |
82 |
|
|
call seaice_cost_export( myThid ) |
83 |
|
|
#endif |
84 |
|
|
|
85 |
|
|
c-- Sum up all contributions. |
86 |
|
|
do bj = jtlo,jthi |
87 |
|
|
do bi = itlo,ithi |
88 |
|
|
|
89 |
|
|
fc = fc |
90 |
|
|
& + mult_ice_export * objf_ice_export(bi,bj) |
91 |
|
|
& + mult_ice * objf_ice(bi,bj) |
92 |
|
|
& + mult_smrarea * objf_smrarea(bi,bj) |
93 |
|
|
& + mult_smrsst * objf_smrsst(bi,bj) |
94 |
|
|
& + mult_smrsss * objf_smrsss(bi,bj) |
95 |
|
|
|
96 |
|
|
f_ice = f_ice + objf_ice(bi,bj) |
97 |
|
|
f_smrarea = f_smrarea + objf_smrarea(bi,bj) |
98 |
|
|
f_smrsst = f_smrsst + objf_smrsst(bi,bj) |
99 |
|
|
f_smrsss = f_smrsss + objf_smrsss(bi,bj) |
100 |
|
|
|
101 |
|
|
no_ice = no_ice + num_ice(bi,bj) |
102 |
|
|
no_smrarea = no_smrarea + num_smrarea(bi,bj) |
103 |
|
|
no_smrsst = no_smrsst + num_smrsst(bi,bj) |
104 |
|
|
no_smrsss = no_smrsss + num_smrsss(bi,bj) |
105 |
|
|
|
106 |
|
|
enddo |
107 |
|
|
enddo |
108 |
|
|
|
109 |
|
|
c-- Do global summation. |
110 |
|
|
cph this is done only in ecco_cost_final! |
111 |
|
|
cph _GLOBAL_SUM_RL( fc , myThid ) |
112 |
|
|
|
113 |
|
|
c-- Do global summation for each part of the cost function |
114 |
|
|
|
115 |
|
|
_GLOBAL_SUM_RL( f_ice , myThid ) |
116 |
|
|
_GLOBAL_SUM_RL( f_smrarea , myThid ) |
117 |
|
|
_GLOBAL_SUM_RL( f_smrsst , myThid ) |
118 |
|
|
_GLOBAL_SUM_RL( f_smrsss , myThid ) |
119 |
|
|
|
120 |
|
|
_GLOBAL_SUM_RL( no_ice , myThid ) |
121 |
|
|
_GLOBAL_SUM_RL( no_smrarea , myThid ) |
122 |
|
|
_GLOBAL_SUM_RL( no_smrsst , myThid ) |
123 |
|
|
_GLOBAL_SUM_RL( no_smrsss , myThid ) |
124 |
|
|
|
125 |
|
|
write(standardmessageunit,'(A,D22.15)') |
126 |
|
|
& ' --> f_ice =',f_ice |
127 |
|
|
write(standardmessageunit,'(A,D22.15)') |
128 |
|
|
& ' --> f_smrarea =',f_smrarea |
129 |
|
|
write(standardmessageunit,'(A,D22.15)') |
130 |
|
|
& ' --> f_smrarea =',f_smrsst |
131 |
|
|
write(standardmessageunit,'(A,D22.15)') |
132 |
|
|
& ' --> f_smrarea =',f_smrsss |
133 |
|
|
|
134 |
|
|
c-- Each process has calculated the global part for itself. |
135 |
|
|
IF ( MASTER_CPU_THREAD(myThid) ) THEN |
136 |
|
|
|
137 |
|
|
write(cfname,'(A,i4.4)') 'costfunction_seaice',optimcycle |
138 |
|
|
open(unit=ifc,file=cfname) |
139 |
|
|
|
140 |
|
|
write(ifc,*) 'fc =', fc |
141 |
|
|
write(ifc,*) 'f_ice =', f_ice, no_ice |
142 |
|
|
write(ifc,*) 'f_smrarea =', f_smrarea, no_smrarea |
143 |
|
|
write(ifc,*) 'f_smrsst =', f_smrsst, no_smrsst |
144 |
|
|
write(ifc,*) 'f_smrsss =', f_smrsss, no_smrsss |
145 |
|
|
|
146 |
|
|
close(ifc) |
147 |
|
|
|
148 |
|
|
ENDIF |
149 |
|
|
|
150 |
|
|
SEAICE_dumpFreq = 0. |
151 |
|
|
SEAICE_taveFreq = 0. |
152 |
|
|
|
153 |
|
|
#endif /* ALLOW_COST */ |
154 |
|
|
|
155 |
|
|
return |
156 |
|
|
end |