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 = 25.0 |
88 |
|
89 |
c-- Read tiled data. |
90 |
doglobalread = .false. |
91 |
ladinit = .false. |
92 |
|
93 |
#ifdef ALLOW_SSS_COST_CONTRIBUTION |
94 |
|
95 |
if (optimcycle .ge. 0) then |
96 |
ilsalt = ilnblnk( sbarfile ) |
97 |
write(fnamesalt(1:80),'(2a,i10.10)') |
98 |
& sbarfile(1:ilsalt),'.',optimcycle |
99 |
endif |
100 |
|
101 |
fcthread_sss = 0. _d 0 |
102 |
|
103 |
c-- Loop over records. |
104 |
do irec = 1,nmonsrec |
105 |
|
106 |
c-- Read time averages and the monthly mean data. |
107 |
call active_read_xyz( fnamesalt, sbar, irec, |
108 |
& doglobalread, ladinit, |
109 |
& optimcycle, mythid, |
110 |
& xx_sbar_mean_dummy ) |
111 |
|
112 |
call cost_ReadSSSFields( irec, mythid ) |
113 |
|
114 |
do bj = jtlo,jthi |
115 |
do bi = itlo,ithi |
116 |
|
117 |
c-- Loop over the model layers |
118 |
fctile_sss = 0. _d 0 |
119 |
k = 1 |
120 |
|
121 |
c-- Determine the mask on weights |
122 |
do j = jmin,jmax |
123 |
do i = imin,imax |
124 |
cmask(i,j) = 1. _d 0 |
125 |
if (sssdat(i,j,bi,bj) .eq. 0.) then |
126 |
cmask(i,j) = 0. _d 0 |
127 |
endif |
128 |
|
129 |
if (sssdat(i,j,bi,bj) .lt. spval) then |
130 |
cmask(i,j) = 0. _d 0 |
131 |
endif |
132 |
|
133 |
cph( |
134 |
cph print *, 'WARNING: SPECIFIC SETUP FOR ECCO' |
135 |
cph below statement could be replaced by following |
136 |
cph to make it independnet of Nr: |
137 |
cph |
138 |
cph if ( rC(K) .GT. -1000. ) then |
139 |
cph) |
140 |
c set cmask=0 in areas shallower than 1000m |
141 |
if (_hFacC(i,j,13,bi,bj) .eq. 0.) then |
142 |
cmask(i,j) = 0. _d 0 |
143 |
endif |
144 |
|
145 |
enddo |
146 |
enddo |
147 |
|
148 |
c-- Compute cost rel. to monthly SSS field. |
149 |
do j = jmin,jmax |
150 |
do i = imin,imax |
151 |
if (_hFacC(i,j,k,bi,bj) .ne. 0.) then |
152 |
fctile_sss = fctile_sss + |
153 |
& wsss(i,j,bi,bj)*cosphi(i,j,bi,bj)*cmask(i,j)* |
154 |
& ( (sbar(i,j,k,bi,bj)-sssdat(i,j,bi,bj))* |
155 |
& (sbar(i,j,k,bi,bj)-sssdat(i,j,bi,bj))* |
156 |
& sssmask(i,j,bi,bj) ) |
157 |
endif |
158 |
enddo |
159 |
enddo |
160 |
|
161 |
|
162 |
fcthread_sss = fcthread_sss + fctile_sss |
163 |
objf_sss(bi,bj) = objf_sss(bi,bj) + fctile_sss |
164 |
|
165 |
#ifdef ECCO_VERBOSE |
166 |
c-- Print cost function for each tile in each thread. |
167 |
write(msgbuf,'(a)') ' ' |
168 |
call print_message( msgbuf, standardmessageunit, |
169 |
& SQUEEZE_RIGHT , mythid) |
170 |
write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)') |
171 |
& ' cost_sss: irec,bi,bj = ',irec,bi,bj |
172 |
call print_message( msgbuf, standardmessageunit, |
173 |
& SQUEEZE_RIGHT , mythid) |
174 |
write(msgbuf,'(a,d22.15)') |
175 |
& ' cost function (sss) = ', |
176 |
& fctile_sss |
177 |
call print_message( msgbuf, standardmessageunit, |
178 |
& SQUEEZE_RIGHT , mythid) |
179 |
#endif |
180 |
|
181 |
enddo |
182 |
enddo |
183 |
|
184 |
#ifdef ECCO_VERBOSE |
185 |
c-- Print cost function for all tiles. |
186 |
_GLOBAL_SUM_R8( fcthread_sss , myThid ) |
187 |
write(msgbuf,'(a)') ' ' |
188 |
call print_message( msgbuf, standardmessageunit, |
189 |
& SQUEEZE_RIGHT , mythid) |
190 |
write(msgbuf,'(a,i8.8)') |
191 |
& ' cost_sss: irec = ',irec |
192 |
call print_message( msgbuf, standardmessageunit, |
193 |
& SQUEEZE_RIGHT , mythid) |
194 |
write(msgbuf,'(a,a,d22.15)') |
195 |
& ' global cost function value', |
196 |
& ' ( SST ) = ',fcthread_sss |
197 |
call print_message( msgbuf, standardmessageunit, |
198 |
& SQUEEZE_RIGHT , mythid) |
199 |
write(msgbuf,'(a)') ' ' |
200 |
call print_message( msgbuf, standardmessageunit, |
201 |
& SQUEEZE_RIGHT , mythid) |
202 |
#endif |
203 |
|
204 |
enddo |
205 |
c-- End of loop over records. |
206 |
|
207 |
#else |
208 |
c-- Do not enter the calculation of the temperature contribution to |
209 |
c-- the final cost function. |
210 |
|
211 |
fctile_sss = 0. _d 0 |
212 |
fcthread_sss = 0. _d 0 |
213 |
|
214 |
#ifdef ECCO_VERBOSE |
215 |
_BEGIN_MASTER( mythid ) |
216 |
write(msgbuf,'(a)') ' ' |
217 |
call print_message( msgbuf, standardmessageunit, |
218 |
& SQUEEZE_RIGHT , mythid) |
219 |
write(msgbuf,'(a,a)') |
220 |
& ' cost_sss: no contribution of temperature field ', |
221 |
& 'to cost function.' |
222 |
call print_message( msgbuf, standardmessageunit, |
223 |
& SQUEEZE_RIGHT , mythid) |
224 |
write(msgbuf,'(a,a,i9.8)') |
225 |
& ' cost_sss: number of records that would have', |
226 |
& ' been processed: ',nmonsrec |
227 |
call print_message( msgbuf, standardmessageunit, |
228 |
& SQUEEZE_RIGHT , mythid) |
229 |
write(msgbuf,'(a)') ' ' |
230 |
call print_message( msgbuf, standardmessageunit, |
231 |
& SQUEEZE_RIGHT , mythid) |
232 |
_END_MASTER( mythid ) |
233 |
#endif |
234 |
|
235 |
#endif |
236 |
|
237 |
return |
238 |
end |
239 |
|