1 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/Attic/cost_argo_salt.F,v 1.1.2.1 2002/04/04 10:58:58 heimbach Exp $ |
2 |
|
3 |
#include "COST_CPPOPTIONS.h" |
4 |
|
5 |
|
6 |
subroutine cost_argo_salt( |
7 |
I myiter, |
8 |
I mytime, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_argo_salt |
14 |
c ================================================================== |
15 |
c |
16 |
c o Evaluate cost function contribution of ARGO salt data. |
17 |
c |
18 |
c started: Elisabeth Remy eremy@ucsd.edu 30-Aug-2000 |
19 |
c |
20 |
c |
21 |
c ================================================================== |
22 |
c SUBROUTINE cost_argo_salt |
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 |
|
34 |
#include "cal.h" |
35 |
#include "ecco_cost.h" |
36 |
#include "ctrl.h" |
37 |
#include "ctrl_dummy.h" |
38 |
#include "optim.h" |
39 |
|
40 |
c == routine arguments == |
41 |
|
42 |
integer myiter |
43 |
_RL mytime |
44 |
integer mythid |
45 |
|
46 |
c == local variables == |
47 |
|
48 |
integer bi,bj |
49 |
integer i,j,k |
50 |
integer itlo,ithi |
51 |
integer jtlo,jthi |
52 |
integer jmin,jmax |
53 |
integer imin,imax |
54 |
integer nrec |
55 |
integer irec |
56 |
integer ilu |
57 |
|
58 |
_RL fctile_argos |
59 |
_RL fcthread_argos |
60 |
_RL www (1-olx:snx+olx,1-oly:sny+oly) |
61 |
_RL wtmp (1-olx:snx+olx,1-oly:sny+oly) |
62 |
_RL tmpobs (1-olx:snx+olx,1-oly:sny+oly) |
63 |
_RL tmpbar (1-olx:snx+olx,1-oly:sny+oly) |
64 |
_RL spval |
65 |
|
66 |
character*(80) fnamesalt |
67 |
|
68 |
logical doglobalread |
69 |
logical ladinit |
70 |
|
71 |
character*(MAX_LEN_MBUF) msgbuf |
72 |
|
73 |
cnew( |
74 |
integer il |
75 |
integer mody, modm |
76 |
integer iyear, imonth |
77 |
character*(80) fnametmp |
78 |
logical exst |
79 |
cnew) |
80 |
|
81 |
c == external functions == |
82 |
|
83 |
integer ilnblnk |
84 |
external ilnblnk |
85 |
|
86 |
c == end of interface == |
87 |
|
88 |
jtlo = mybylo(mythid) |
89 |
jthi = mybyhi(mythid) |
90 |
itlo = mybxlo(mythid) |
91 |
ithi = mybxhi(mythid) |
92 |
jmin = 1 |
93 |
jmax = sny |
94 |
imin = 1 |
95 |
imax = snx |
96 |
|
97 |
spval = -1. |
98 |
|
99 |
c-- Read state record from global file. |
100 |
doglobalread = .false. |
101 |
ladinit = .false. |
102 |
|
103 |
#ifdef ALLOW_ARGO_SALT_COST_CONTRIBUTION |
104 |
|
105 |
if (optimcycle .ge. 0) then |
106 |
ilu=ilnblnk( sbarfile ) |
107 |
write(fnamesalt(1:80),'(2a,i10.10)') |
108 |
& sbarfile(1:ilu),'.', optimcycle |
109 |
endif |
110 |
|
111 |
fcthread_argos = 0. _d 0 |
112 |
|
113 |
cnew( |
114 |
mody = modelstartdate(1)/10000 |
115 |
modm = modelstartdate(1)/100 - mody*100 |
116 |
cnew) |
117 |
|
118 |
c-- Loop over records. |
119 |
do irec = 1,nmonsrec |
120 |
|
121 |
c-- Read time averages and the monthly mean data. |
122 |
call active_read_xyz( fnamesalt, sbar, irec, |
123 |
& doglobalread, ladinit, |
124 |
& optimcycle, mythid |
125 |
& , xx_sbar_mean_dummy ) |
126 |
|
127 |
cnew( |
128 |
iyear = mody + INT((modm-1+irec-1)/12) |
129 |
imonth = 1 + MOD(modm-1+irec-1,12) |
130 |
il=ilnblnk(argosfile) |
131 |
write(fnametmp(1:80),'(2a,i4)') |
132 |
& argosfile(1:il), '_', iyear |
133 |
inquire( file=fnametmp, exist=exst ) |
134 |
if (.NOT. exst) then |
135 |
write(fnametmp(1:80),'(a)') argosfile(1:il) |
136 |
imonth = irec |
137 |
endif |
138 |
|
139 |
call mdsreadfield( fnametmp, cost_iprec, 'RL', nr, argosobs, |
140 |
& imonth, mythid) |
141 |
cnew) |
142 |
|
143 |
c-- Loop over this thread's tiles. |
144 |
do bj = jtlo,jthi |
145 |
do bi = itlo,ithi |
146 |
c-- Loop over the model layers |
147 |
|
148 |
fctile_argos = 0. _d 0 |
149 |
do k = 1,nr |
150 |
|
151 |
c-- |
152 |
cph( |
153 |
cph print *, 'WARNING: SPECIFIC SETUP FOR ECCO' |
154 |
cph below statement could be replaced by following |
155 |
cph to make it independnet of Nr: |
156 |
cph |
157 |
cph if ( rC(K) .GT. -1000. ) then |
158 |
cph) |
159 |
do j = jmin,jmax |
160 |
do i = imin,imax |
161 |
if (argosobs(i,j,k,bi,bj) .ge. spval .and. |
162 |
$ _hFacC(i,j,13,bi,bj) .ne. 0. .and. |
163 |
$ _hFacC(i,j,k,bi,bj) .ne. 0.) then |
164 |
fctile_argos = fctile_argos + |
165 |
& wsalt2(i,j,k,bi,bj)*cosphi(i,j,bi,bj)* |
166 |
& (sbar(i,j,k,bi,bj)-argosobs(i,j,k,bi,bj))* |
167 |
& (sbar(i,j,k,bi,bj)-argosobs(i,j,k,bi,bj)) |
168 |
endif |
169 |
enddo |
170 |
enddo |
171 |
enddo |
172 |
c-- End of loop over layers. |
173 |
|
174 |
fcthread_argos = fcthread_argos + fctile_argos |
175 |
objf_argos(bi,bj) = objf_argos(bi,bj) + fctile_argos |
176 |
|
177 |
#ifdef ECCO_VERBOSE |
178 |
write(msgbuf,'(a)') ' ' |
179 |
call print_message( msgbuf, standardmessageunit, |
180 |
& SQUEEZE_RIGHT , mythid) |
181 |
write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3,i6)') |
182 |
& ' COST_ARGO_SALT: irec,bi,bj = ',irec,bi,bj |
183 |
call print_message( msgbuf, standardmessageunit, |
184 |
& SQUEEZE_RIGHT , mythid) |
185 |
write(msgbuf,'(a,d22.15)') |
186 |
& ' COST_ARGO_SALT: cost function = ', fctile_argos |
187 |
call print_message( msgbuf, standardmessageunit, |
188 |
& SQUEEZE_RIGHT , mythid) |
189 |
write(msgbuf,'(a)') ' ' |
190 |
call print_message( msgbuf, standardmessageunit, |
191 |
& SQUEEZE_RIGHT , mythid) |
192 |
#endif |
193 |
|
194 |
enddo |
195 |
enddo |
196 |
|
197 |
#ifdef ECCO_VERBOSE |
198 |
c-- Print cost function for all tiles. |
199 |
c _GLOBAL_SUM_R8( fcthread_argos , myThid ) |
200 |
write(msgbuf,'(a)') ' ' |
201 |
call print_message( msgbuf, standardmessageunit, |
202 |
& SQUEEZE_RIGHT , mythid) |
203 |
write(msgbuf,'(a,i8.8)') |
204 |
& ' cost_ARGOT: irec = ',irec |
205 |
call print_message( msgbuf, standardmessageunit, |
206 |
& SQUEEZE_RIGHT , mythid) |
207 |
write(msgbuf,'(a,a,d22.15)') |
208 |
& ' global cost function value', |
209 |
& ' ( ARGO salt. ) = ',fcthread_argos |
210 |
call print_message( msgbuf, standardmessageunit, |
211 |
& SQUEEZE_RIGHT , mythid) |
212 |
write(msgbuf,'(a)') ' ' |
213 |
call print_message( msgbuf, standardmessageunit, |
214 |
& SQUEEZE_RIGHT , mythid) |
215 |
#endif |
216 |
|
217 |
enddo |
218 |
c-- End of second loop over records. |
219 |
|
220 |
#else |
221 |
c-- Do not enter the calculation of the ARGO salinity contribution |
222 |
c-- to the final cost function. |
223 |
|
224 |
fctile_argos = 0. _d 0 |
225 |
fcthread_argos = 0. _d 0 |
226 |
|
227 |
crg |
228 |
nrec = 1 |
229 |
crg |
230 |
|
231 |
_BEGIN_MASTER( mythid ) |
232 |
write(msgbuf,'(a)') ' ' |
233 |
call print_message( msgbuf, standardmessageunit, |
234 |
& SQUEEZE_RIGHT , mythid) |
235 |
write(msgbuf,'(a,a)') |
236 |
& ' cost_ARGOS: no contribution of ARGO salt ', |
237 |
& ' to cost function.' |
238 |
call print_message( msgbuf, standardmessageunit, |
239 |
& SQUEEZE_RIGHT , mythid) |
240 |
write(msgbuf,'(a,a,i9.8)') |
241 |
& ' cost_ARGOS: number of records that would have', |
242 |
& ' been processed: ',nrec |
243 |
call print_message( msgbuf, standardmessageunit, |
244 |
& SQUEEZE_RIGHT , mythid) |
245 |
write(msgbuf,'(a)') ' ' |
246 |
call print_message( msgbuf, standardmessageunit, |
247 |
& SQUEEZE_RIGHT , mythid) |
248 |
_END_MASTER( mythid ) |
249 |
#endif |
250 |
|
251 |
return |
252 |
end |