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