1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_mean_saltflux.F,v 1.14 2010/02/06 02:43:03 heimbach 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_SIZE.h" |
38 |
#include "ctrl.h" |
39 |
#include "ctrl_dummy.h" |
40 |
#include "optim.h" |
41 |
|
42 |
c == routine arguments == |
43 |
|
44 |
integer myiter |
45 |
_RL mytime |
46 |
integer mythid |
47 |
|
48 |
c == local variables == |
49 |
|
50 |
integer bi,bj |
51 |
integer i,j,kk |
52 |
integer itlo,ithi |
53 |
integer jtlo,jthi |
54 |
integer jmin,jmax |
55 |
integer imin,imax |
56 |
integer irec |
57 |
integer levmon |
58 |
integer levoff |
59 |
integer ilsalt |
60 |
|
61 |
_RL tmpx |
62 |
_RL sumtot |
63 |
_RL fctiletot |
64 |
|
65 |
|
66 |
character*(80) fnamesflux |
67 |
|
68 |
logical doglobalread |
69 |
logical ladinit |
70 |
|
71 |
character*(MAX_LEN_MBUF) msgbuf |
72 |
|
73 |
c == external functions == |
74 |
|
75 |
integer ilnblnk |
76 |
external ilnblnk |
77 |
|
78 |
c == end of interface == |
79 |
|
80 |
jtlo = mybylo(mythid) |
81 |
jthi = mybyhi(mythid) |
82 |
itlo = mybxlo(mythid) |
83 |
ithi = mybxhi(mythid) |
84 |
jmin = 1 |
85 |
jmax = sny |
86 |
imin = 1 |
87 |
imax = snx |
88 |
|
89 |
c-- Read tiled data. |
90 |
doglobalread = .false. |
91 |
ladinit = .false. |
92 |
|
93 |
#ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION |
94 |
|
95 |
if (optimcycle .ge. 0) then |
96 |
ilsalt = ilnblnk( sfluxmeanbarfile ) |
97 |
write(fnamesflux(1:80),'(2a,i10.10)') |
98 |
& sfluxmeanbarfile(1:ilsalt),'.',optimcycle |
99 |
endif |
100 |
|
101 |
do irec = 1, MAX(1,nyearsrec) |
102 |
|
103 |
c-- Read time averages and the monthly mean data. |
104 |
call active_read_xy( fnamesflux, tmpfld2d, irec, |
105 |
& doglobalread, ladinit, |
106 |
& optimcycle, mythid, |
107 |
& xx_sflux_mean_dummy ) |
108 |
|
109 |
sumtot = 0. |
110 |
fctiletot = 0. |
111 |
do bj = jtlo,jthi |
112 |
do bi = itlo,ithi |
113 |
kk = 1 |
114 |
do j = jmin,jmax |
115 |
do i = imin,imax |
116 |
tmpx=tmpfld2d(i,j,bi,bj) |
117 |
if (maskC(i,j,kk,bi,bj) .ne. 0.) then |
118 |
fctiletot = fctiletot |
119 |
& + tmpx* _rA(i,j,bi,bj)/rhoConstFresh |
120 |
sumtot = sumtot |
121 |
& + _rA(i,j,bi,bj) |
122 |
num_sfluxmm(bi,bj) = num_sfluxmm(bi,bj) + 1 |
123 |
endif |
124 |
enddo |
125 |
enddo |
126 |
enddo |
127 |
enddo |
128 |
|
129 |
_GLOBAL_SUM_RL( sumtot , myThid ) |
130 |
_GLOBAL_SUM_RL( fctiletot , myThid ) |
131 |
|
132 |
if (sumtot.eq.0.) sumtot = 1. |
133 |
|
134 |
if ( wmean_sflux .NE. 0. ) then |
135 |
objf_sfluxmm = objf_sfluxmm |
136 |
& + ( (fctiletot/sumtot)/wmean_sflux )**2 |
137 |
else |
138 |
objf_sfluxmm = 0. _d 0 |
139 |
endif |
140 |
|
141 |
c-- diagnostic: imbalance per year: |
142 |
write(standardmessageunit,'(A,I5,2(X,D22.14))') |
143 |
& ' --> bal_sfluxmm =', irec, |
144 |
& fctiletot/sumtot, |
145 |
& objf_sfluxmm |
146 |
|
147 |
enddo |
148 |
|
149 |
#endif |
150 |
|
151 |
return |
152 |
end |
153 |
|