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 |
integer i,j,kk |
49 |
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 |
_RL tmpx |
59 |
_RL sumtot |
60 |
_RL fctiletot |
61 |
|
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 |
do irec = 1, MAX(1,nyearsrec) |
99 |
|
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 |
sumtot = 0. |
107 |
fctiletot = 0. |
108 |
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 |
if (maskC(i,j,kk,bi,bj) .ne. 0.) then |
115 |
fctiletot = fctiletot |
116 |
& + tmpx*cos(yc(i,j,bi,bj)*deg2rad) |
117 |
sumtot = sumtot |
118 |
& + cos(yc(i,j,bi,bj)*deg2rad) |
119 |
num_sfluxmm(bi,bj) = num_sfluxmm(bi,bj) + 1 |
120 |
endif |
121 |
enddo |
122 |
enddo |
123 |
enddo |
124 |
enddo |
125 |
|
126 |
_GLOBAL_SUM_R8( sumtot , myThid ) |
127 |
_GLOBAL_SUM_R8( fctiletot , myThid ) |
128 |
|
129 |
if (sumtot.eq.0.) sumtot = 1. |
130 |
|
131 |
if ( wmean_sflux .NE. 0. ) then |
132 |
objf_sfluxmm = objf_sfluxmm |
133 |
& + ( (fctiletot/sumtot-1.D0)/wmean_sflux )**2 |
134 |
else |
135 |
objf_sfluxmm = 0. _d 0 |
136 |
endif |
137 |
|
138 |
c-- diagnostic: imbalance per year: |
139 |
write(standardmessageunit,'(A,I5,2(X,D22.14))') |
140 |
& ' --> bal_sfluxmm =', irec, |
141 |
& fctiletot/sumtot, |
142 |
& (fctiletot/sumtot/wmean_sflux)**2 |
143 |
|
144 |
enddo |
145 |
|
146 |
#endif |
147 |
|
148 |
return |
149 |
end |
150 |
|