1 |
heimbach |
1.1 |
|
2 |
|
|
#include "COST_CPPOPTIONS.h" |
3 |
|
|
|
4 |
|
|
|
5 |
|
|
subroutine cost_mean_saltflux( |
6 |
|
|
I myiter, |
7 |
|
|
I mytime, |
8 |
|
|
I mythid |
9 |
|
|
& ) |
10 |
|
|
|
11 |
|
|
c ================================================================== |
12 |
|
|
c SUBROUTINE cost_mean_saltflux |
13 |
|
|
c ================================================================== |
14 |
|
|
c |
15 |
|
|
c o Evaluate cost function contribution of sea surface salinity. |
16 |
|
|
c |
17 |
|
|
c started: Elisabeth Remy 19-mar-2001 copy from cost_sst.F |
18 |
|
|
c |
19 |
|
|
c ================================================================== |
20 |
|
|
c SUBROUTINE cost_mean_saltflux |
21 |
|
|
c ================================================================== |
22 |
|
|
|
23 |
|
|
implicit none |
24 |
|
|
|
25 |
|
|
c == global variables == |
26 |
|
|
|
27 |
|
|
#include "EEPARAMS.h" |
28 |
|
|
#include "SIZE.h" |
29 |
|
|
#include "GRID.h" |
30 |
|
|
#include "DYNVARS.h" |
31 |
|
|
#include "PARAMS.h" |
32 |
|
|
|
33 |
|
|
#include "cal.h" |
34 |
|
|
#include "ecco_cost.h" |
35 |
|
|
#include "ctrl.h" |
36 |
|
|
#include "ctrl_dummy.h" |
37 |
|
|
#include "optim.h" |
38 |
|
|
|
39 |
|
|
c == routine arguments == |
40 |
|
|
|
41 |
|
|
integer myiter |
42 |
|
|
_RL mytime |
43 |
|
|
integer mythid |
44 |
|
|
|
45 |
|
|
c == local variables == |
46 |
|
|
|
47 |
|
|
integer bi,bj |
48 |
heimbach |
1.2 |
integer i,j,kk |
49 |
heimbach |
1.1 |
integer itlo,ithi |
50 |
|
|
integer jtlo,jthi |
51 |
|
|
integer jmin,jmax |
52 |
|
|
integer imin,imax |
53 |
|
|
integer irec |
54 |
|
|
integer levmon |
55 |
|
|
integer levoff |
56 |
|
|
integer ilsalt |
57 |
|
|
|
58 |
heimbach |
1.7 |
_RL tmpx |
59 |
heimbach |
1.5 |
_RL sumtot |
60 |
|
|
_RL fctiletot |
61 |
heimbach |
1.1 |
|
62 |
|
|
|
63 |
|
|
character*(80) fnamesflux |
64 |
|
|
|
65 |
|
|
logical doglobalread |
66 |
|
|
logical ladinit |
67 |
|
|
|
68 |
|
|
character*(MAX_LEN_MBUF) msgbuf |
69 |
|
|
|
70 |
|
|
c == external functions == |
71 |
|
|
|
72 |
|
|
integer ilnblnk |
73 |
|
|
external ilnblnk |
74 |
|
|
|
75 |
|
|
c == end of interface == |
76 |
|
|
|
77 |
|
|
jtlo = mybylo(mythid) |
78 |
|
|
jthi = mybyhi(mythid) |
79 |
|
|
itlo = mybxlo(mythid) |
80 |
|
|
ithi = mybxhi(mythid) |
81 |
|
|
jmin = 1 |
82 |
|
|
jmax = sny |
83 |
|
|
imin = 1 |
84 |
|
|
imax = snx |
85 |
|
|
|
86 |
|
|
c-- Read tiled data. |
87 |
|
|
doglobalread = .false. |
88 |
|
|
ladinit = .false. |
89 |
|
|
|
90 |
|
|
#ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION |
91 |
|
|
|
92 |
|
|
if (optimcycle .ge. 0) then |
93 |
|
|
ilsalt = ilnblnk( sfluxbarfile ) |
94 |
|
|
write(fnamesflux(1:80),'(2a,i10.10)') |
95 |
|
|
& sfluxbarfile(1:ilsalt),'.',optimcycle |
96 |
|
|
endif |
97 |
|
|
|
98 |
heimbach |
1.5 |
do irec = 1, MAX(1,nyearsrec) |
99 |
heimbach |
1.1 |
|
100 |
|
|
c-- Read time averages and the monthly mean data. |
101 |
|
|
call active_read_xy( fnamesflux, tmpfld2d, irec, |
102 |
|
|
& doglobalread, ladinit, |
103 |
|
|
& optimcycle, mythid, |
104 |
|
|
& xx_sflux_mean_dummy ) |
105 |
|
|
|
106 |
heimbach |
1.7 |
sumtot = 0. |
107 |
|
|
fctiletot = 0. |
108 |
heimbach |
1.1 |
do bj = jtlo,jthi |
109 |
|
|
do bi = itlo,ithi |
110 |
|
|
kk = 1 |
111 |
|
|
do j = jmin,jmax |
112 |
|
|
do i = imin,imax |
113 |
|
|
tmpx=tmpfld2d(i,j,bi,bj) |
114 |
heimbach |
1.2 |
if (maskC(i,j,kk,bi,bj) .ne. 0.) then |
115 |
heimbach |
1.7 |
fctiletot = fctiletot |
116 |
|
|
& + tmpx*cos(yc(i,j,bi,bj)*deg2rad) |
117 |
|
|
sumtot = sumtot |
118 |
|
|
& + cos(yc(i,j,bi,bj)*deg2rad) |
119 |
heimbach |
1.4 |
num_sfluxmm(bi,bj) = num_sfluxmm(bi,bj) + 1 |
120 |
heimbach |
1.1 |
endif |
121 |
|
|
enddo |
122 |
|
|
enddo |
123 |
heimbach |
1.5 |
enddo |
124 |
|
|
enddo |
125 |
heimbach |
1.1 |
|
126 |
heimbach |
1.5 |
_GLOBAL_SUM_R8( sumtot , myThid ) |
127 |
|
|
_GLOBAL_SUM_R8( fctiletot , myThid ) |
128 |
|
|
|
129 |
|
|
if (sumtot.eq.0.) sumtot = 1. |
130 |
heimbach |
1.1 |
|
131 |
heimbach |
1.6 |
if ( wmean_sflux .NE. 0. ) then |
132 |
heimbach |
1.7 |
objf_sfluxmm = objf_sfluxmm |
133 |
heimbach |
1.8 |
& + ( (fctiletot/sumtot-1.D0)/wmean_sflux )**2 |
134 |
heimbach |
1.7 |
else |
135 |
|
|
objf_sfluxmm = 0. _d 0 |
136 |
heimbach |
1.6 |
endif |
137 |
heimbach |
1.5 |
|
138 |
|
|
c-- diagnostic: imbalance per year: |
139 |
heimbach |
1.7 |
write(standardmessageunit,'(A,I5,2(X,D22.14))') |
140 |
|
|
& ' --> bal_sfluxmm =', irec, |
141 |
|
|
& fctiletot/sumtot, |
142 |
|
|
& (fctiletot/sumtot/wmean_sflux)**2 |
143 |
heimbach |
1.1 |
|
144 |
heimbach |
1.5 |
enddo |
145 |
heimbach |
1.1 |
|
146 |
|
|
#endif |
147 |
|
|
|
148 |
|
|
return |
149 |
|
|
end |
150 |
|
|
|