1 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/Attic/cost_sss.F,v 1.1.2.3 2002/04/04 10:58:59 heimbach Exp $ |
2 |
|
3 |
#include "COST_CPPOPTIONS.h" |
4 |
|
5 |
|
6 |
subroutine cost_sss( |
7 |
I myiter, |
8 |
I mytime, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_sss |
14 |
c ================================================================== |
15 |
c |
16 |
c o Evaluate cost function contribution of sea surface salinity. |
17 |
c |
18 |
c started: Elisabeth Remy 19-mar-2001 copy from cost_sst.F |
19 |
c |
20 |
c ================================================================== |
21 |
c SUBROUTINE cost_sss |
22 |
c ================================================================== |
23 |
|
24 |
implicit none |
25 |
|
26 |
c == global variables == |
27 |
|
28 |
#include "EEPARAMS.h" |
29 |
#include "SIZE.h" |
30 |
#include "GRID.h" |
31 |
#include "DYNVARS.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,k |
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 fctile_sss |
59 |
_RL fcthread_sss |
60 |
|
61 |
_RL cmask (1-olx:snx+olx,1-oly:sny+oly) |
62 |
_RL spval |
63 |
|
64 |
character*(80) fnamesalt |
65 |
|
66 |
logical doglobalread |
67 |
logical ladinit |
68 |
|
69 |
character*(MAX_LEN_MBUF) msgbuf |
70 |
|
71 |
c == external functions == |
72 |
|
73 |
integer ilnblnk |
74 |
external ilnblnk |
75 |
|
76 |
c == end of interface == |
77 |
|
78 |
jtlo = mybylo(mythid) |
79 |
jthi = mybyhi(mythid) |
80 |
itlo = mybxlo(mythid) |
81 |
ithi = mybxhi(mythid) |
82 |
jmin = 1 |
83 |
jmax = sny |
84 |
imin = 1 |
85 |
imax = snx |
86 |
|
87 |
spval = -9.0 |
88 |
|
89 |
c-- Read tiled data. |
90 |
doglobalread = .false. |
91 |
ladinit = .false. |
92 |
|
93 |
#ifdef ALLOW_SSS_COST_CONTRIBUTION |
94 |
|
95 |
#ifdef ECCO_VERBOSE |
96 |
_BEGIN_MASTER( mythid ) |
97 |
write(msgbuf,'(a)') ' ' |
98 |
call print_message( msgbuf, standardmessageunit, |
99 |
& SQUEEZE_RIGHT , mythid) |
100 |
write(msgbuf,'(a,i8.8)') |
101 |
& ' cost_sss: number of records to process = ',nmonsrec |
102 |
call print_message( msgbuf, standardmessageunit, |
103 |
& SQUEEZE_RIGHT , mythid) |
104 |
write(msgbuf,'(a)') ' ' |
105 |
call print_message( msgbuf, standardmessageunit, |
106 |
& SQUEEZE_RIGHT , mythid) |
107 |
_END_MASTER( mythid ) |
108 |
#endif |
109 |
|
110 |
if (optimcycle .ge. 0) then |
111 |
ilsalt = ilnblnk( sbarfile ) |
112 |
write(fnamesalt(1:80),'(2a,i10.10)') |
113 |
& sbarfile(1:ilsalt),'.',optimcycle |
114 |
else |
115 |
print* |
116 |
print*,' cost_sss: optimcycle has a wrong value.' |
117 |
print*,' optimcycle = ',optimcycle |
118 |
print* |
119 |
stop ' ... stopped in cost_sss.' |
120 |
endif |
121 |
|
122 |
fcthread_sss = 0. _d 0 |
123 |
|
124 |
c-- Loop over records. |
125 |
do irec = 1,nmonsrec |
126 |
|
127 |
c-- Read time averages and the monthly mean data. |
128 |
call active_read_xyz( fnamesalt, sbar, irec, |
129 |
& doglobalread, ladinit, |
130 |
& optimcycle, mythid, |
131 |
& xx_sbar_mean_dummy ) |
132 |
|
133 |
do bj = jtlo,jthi |
134 |
do bi = itlo,ithi |
135 |
|
136 |
c-- Loop over the model layers |
137 |
fctile_sss = 0. _d 0 |
138 |
k = 1 |
139 |
|
140 |
call cost_ReadSSSFields( irec, mythid ) |
141 |
|
142 |
c-- Determine the mask on weights |
143 |
do j = jmin,jmax |
144 |
do i = imin,imax |
145 |
cmask(i,j) = 1. _d 0 |
146 |
if (sssdat(i,j,bi,bj) .eq. 0.) then |
147 |
cmask(i,j) = 0. _d 0 |
148 |
endif |
149 |
|
150 |
if (sssdat(i,j,bi,bj) .lt. spval) then |
151 |
cmask(i,j) = 0. _d 0 |
152 |
endif |
153 |
|
154 |
cph( |
155 |
cph print *, 'WARNING: SPECIFIC SETUP FOR ECCO' |
156 |
cph below statement could be replaced by following |
157 |
cph to make it independnet of Nr: |
158 |
cph |
159 |
cph if ( rC(K) .GT. -1000. ) then |
160 |
cph) |
161 |
c set cmask=0 in areas shallower than 1000m |
162 |
if (_hFacC(i,j,13,bi,bj) .eq. 0.) then |
163 |
cmask(i,j) = 0. _d 0 |
164 |
endif |
165 |
|
166 |
enddo |
167 |
enddo |
168 |
|
169 |
c-- Compute cost rel. to monthly SSS field. |
170 |
do j = jmin,jmax |
171 |
do i = imin,imax |
172 |
if (_hFacC(i,j,k,bi,bj) .ne. 0.) then |
173 |
fctile_sss = fctile_sss + |
174 |
& wsss(i,j,bi,bj)*cosphi(i,j,bi,bj)*cmask(i,j)* |
175 |
& ( (sbar(i,j,k,bi,bj)-sssdat(i,j,bi,bj))* |
176 |
& (sbar(i,j,k,bi,bj)-sssdat(i,j,bi,bj))* |
177 |
& sssmask(i,j,bi,bj) ) |
178 |
endif |
179 |
enddo |
180 |
enddo |
181 |
|
182 |
|
183 |
fcthread_sss = fcthread_sss + fctile_sss |
184 |
objf_sss(bi,bj) = objf_sss(bi,bj) + fctile_sss |
185 |
|
186 |
#ifdef ECCO_VERBOSE |
187 |
c-- Print cost function for each tile in each thread. |
188 |
write(msgbuf,'(a)') ' ' |
189 |
call print_message( msgbuf, standardmessageunit, |
190 |
& SQUEEZE_RIGHT , mythid) |
191 |
write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)') |
192 |
& ' cost_sss: irec,bi,bj = ',irec,bi,bj |
193 |
call print_message( msgbuf, standardmessageunit, |
194 |
& SQUEEZE_RIGHT , mythid) |
195 |
write(msgbuf,'(a,d22.15)') |
196 |
& ' cost function (sss) = ', |
197 |
& fctile_sss |
198 |
call print_message( msgbuf, standardmessageunit, |
199 |
& SQUEEZE_RIGHT , mythid) |
200 |
#endif |
201 |
|
202 |
enddo |
203 |
enddo |
204 |
|
205 |
#ifdef ECCO_VERBOSE |
206 |
c-- Print cost function for all tiles. |
207 |
_GLOBAL_SUM_R8( fcthread_sss , myThid ) |
208 |
write(msgbuf,'(a)') ' ' |
209 |
call print_message( msgbuf, standardmessageunit, |
210 |
& SQUEEZE_RIGHT , mythid) |
211 |
write(msgbuf,'(a,i8.8)') |
212 |
& ' cost_sss: irec = ',irec |
213 |
call print_message( msgbuf, standardmessageunit, |
214 |
& SQUEEZE_RIGHT , mythid) |
215 |
write(msgbuf,'(a,a,d22.15)') |
216 |
& ' global cost function value', |
217 |
& ' ( SST ) = ',fcthread_sss |
218 |
call print_message( msgbuf, standardmessageunit, |
219 |
& SQUEEZE_RIGHT , mythid) |
220 |
write(msgbuf,'(a)') ' ' |
221 |
call print_message( msgbuf, standardmessageunit, |
222 |
& SQUEEZE_RIGHT , mythid) |
223 |
#endif |
224 |
|
225 |
enddo |
226 |
c-- End of loop over records. |
227 |
|
228 |
#else |
229 |
c-- Do not enter the calculation of the temperature contribution to |
230 |
c-- the final cost function. |
231 |
|
232 |
fctile_sss = 0. _d 0 |
233 |
fcthread_sss = 0. _d 0 |
234 |
|
235 |
#ifdef ECCO_VERBOSE |
236 |
_BEGIN_MASTER( mythid ) |
237 |
write(msgbuf,'(a)') ' ' |
238 |
call print_message( msgbuf, standardmessageunit, |
239 |
& SQUEEZE_RIGHT , mythid) |
240 |
write(msgbuf,'(a,a)') |
241 |
& ' cost_sss: no contribution of temperature field ', |
242 |
& 'to cost function.' |
243 |
call print_message( msgbuf, standardmessageunit, |
244 |
& SQUEEZE_RIGHT , mythid) |
245 |
write(msgbuf,'(a,a,i9.8)') |
246 |
& ' cost_sss: number of records that would have', |
247 |
& ' been processed: ',nmonsrec |
248 |
call print_message( msgbuf, standardmessageunit, |
249 |
& SQUEEZE_RIGHT , mythid) |
250 |
write(msgbuf,'(a)') ' ' |
251 |
call print_message( msgbuf, standardmessageunit, |
252 |
& SQUEEZE_RIGHT , mythid) |
253 |
_END_MASTER( mythid ) |
254 |
#endif |
255 |
|
256 |
#endif |
257 |
|
258 |
return |
259 |
end |
260 |
|