/[MITgcm]/MITgcm/pkg/cost/cost_ssh.F
ViewVC logotype

Contents of /MITgcm/pkg/cost/cost_ssh.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.2.1 - (show annotations) (download)
Tue Feb 5 20:23:57 2002 UTC (22 years, 4 months ago) by heimbach
Branch: ecco-branch
CVS Tags: ecco_c44_e16, ecco-branch-mod1, ecco-branch-mod2, ecco-branch-mod3, ecco-branch-mod4, ecco-branch-mod5
Changes since 1.1: +298 -0 lines
Starting from ecco-branch, replacing packages
cost, ctrl, ecco, obcs by ECCO packages.
Will create tag ecco-branch-mod1 after this modif.

1 C $Header: /u/gcmpack/development/heimbach/ecco_env/pkg/cost/cost_ssh.F,v 1.12 2001/06/12 19:13:37 ralf Exp $
2
3 #include "COST_CPPOPTIONS.h"
4
5
6 subroutine cost_ssh(
7 I myiter,
8 I mytime,
9 I mythid
10 & )
11
12 c ==================================================================
13 c SUBROUTINE cost_ssh
14 c ==================================================================
15 c
16 c o Evaluate cost function contribution of sea surface height.
17 c using of geoid error covariances requires regular model grid
18 c
19 c started: Detlef Stammer, Ralf Giering Jul-1996
20 c
21 c changed: Christian Eckert eckert@mit.edu 25-Feb-2000
22 c
23 c - Restructured the code in order to create a package
24 c for the MITgcmUV.
25 c
26 c changed: Ralf Giering Ralf.Giering@FastOpt.de 12-Jun-2001
27 c
28 c - totally rewrite for parallel processing
29 c
30 c ==================================================================
31 c SUBROUTINE cost_ssh
32 c ==================================================================
33
34 implicit none
35
36 c == global variables ==
37
38 #include "EEPARAMS.h"
39 #include "SIZE.h"
40 #include "PARAMS.h"
41
42 #include "cost.h"
43 #include "optim.h"
44
45 c == routine arguments ==
46
47 integer myiter
48 _RL mytime
49 integer mythid
50
51 #ifdef ALLOW_SSH_COST_CONTRIBUTION
52 c == local variables ==
53
54 integer bi,bj
55 integer i,j
56 integer itlo,ithi
57 integer jtlo,jthi
58 integer jmin,jmax
59 integer imin,imax
60 integer irec
61 integer ilps
62
63 logical doglobalread
64 logical ladinit
65
66 _RL offset
67 _RL erscost
68 _RL tpcost
69 _RL costmean
70 _RL offset_sum
71 _RL dummy
72 _RL psmean ( 1-olx:snx+olx, 1-oly:sny+oly, nsx, nsy )
73 _RL wwwtp ( 1-olx:snx+olx, 1-oly:sny+oly )
74 _RL wwwers ( 1-olx:snx+olx, 1-oly:sny+oly )
75 _RL junk
76
77 character*(80) fname
78 #ifdef ECCO_VERBOSE
79 character*(MAX_LEN_MBUF) msgbuf
80 #endif
81
82 c == external functions ==
83
84 integer ilnblnk
85 external ilnblnk
86
87 c == end of interface ==
88
89 jtlo = mybylo(mythid)
90 jthi = mybyhi(mythid)
91 itlo = mybxlo(mythid)
92 ithi = mybxhi(mythid)
93 jmin = 1
94 jmax = sny
95 imin = 1
96 imax = snx
97
98 c-- Initialise local variables.
99 costmean = 0. _d 0
100
101 do j = jmin, jmax
102 do i = imin, imax
103 wwwtp(i,j) = 0. _d 0
104 wwwers(i,j) = 0. _d 0
105 enddo
106 enddo
107
108 c-- First, read tiled data.
109 doglobalread = .false.
110 ladinit = .true.
111
112 write(fname(1:80),'(80a)') ' '
113 ilps=ilnblnk( psbarfile )
114 write(fname(1:80),'(2a,i10.10)')
115 & psbarfile(1:ilps),'.',optimcycle
116
117 c-- ============
118 c-- Mean values.
119 c-- ============
120
121 do bj = jtlo,jthi
122 do bi = itlo,ithi
123 do j = jmin,jmax
124 do i = imin,imax
125 psmean(i,j,bi,bj) = 0. _d 0
126 enddo
127 enddo
128 enddo
129 enddo
130
131 c-- Loop over records for the first time.
132 do irec = 1, ndaysrec
133
134 c-- Compute the mean over all psbar records.
135 call active_read_xy( fname, psbar, irec, doglobalread,
136 & ladinit, optimcycle, mythid, dummy)
137
138 do bj = jtlo,jthi
139 do bi = itlo,ithi
140 do j = jmin,jmax
141 do i = imin,imax
142 psmean(i,j,bi,bj) = psmean(i,j,bi,bj) +
143 & psbar(i,j,bi,bj)*frame(i,j)/float(ndaysrec)
144 enddo
145 enddo
146 enddo
147 enddo
148
149 enddo
150
151 call cost_ReadTopexMean( mythid )
152
153 c-- Compute and remove offset for current tile and sum over all
154 c-- tiles of this instance.
155 offset = 0. _d 0
156 offset_sum = 0. _d 0
157
158 c-- Sum over this thread's tiles.
159 do bj = jtlo,jthi
160 do bi = itlo,ithi
161 do j = 1,sny
162 do i = 1,snx
163 offset = offset +
164 & tpmeanmask(i,j,bi,bj)*cosphi(i,j,bi,bj)*
165 & (tpmean(i,j,bi,bj) - psmean(i,j,bi,bj))
166 offset_sum = offset_sum +
167 & tpmeanmask(i,j,bi,bj)*cosphi(i,j,bi,bj)
168 enddo
169 enddo
170 enddo
171 enddo
172
173 c-- Do a global summation.
174 _GLOBAL_SUM_R8( offset , mythid )
175 _GLOBAL_SUM_R8( offset_sum , mythid )
176
177 if (offset_sum .eq. 0.0) then
178 _BEGIN_MASTER( mythid )
179 print*
180 print*,' cost_ssh: offset_sum = zero!'
181 print*
182 _END_MASTER( mythid )
183 stop ' ... stopped in cost_ssh.'
184 else
185 _BEGIN_MASTER( mythid )
186 print*
187 print*,' cost_ssh: offset_sum = ',offset_sum
188 print*
189 _END_MASTER( mythid )
190 endif
191
192 offset = offset / offset_sum
193
194 #ifdef ALLOW_SSH_MEAN_COST_CONTRIBUTION
195
196 c-- ==========
197 c-- Mean
198 c-- ==========
199 c-- compute mean ssh difference cost contribution
200 call cost_ssh_mean(
201 I psmean, offset
202 O , costmean
203 I , mythid
204 & )
205
206
207 objf_hmean = costmean
208
209 #endif /* ALLOW_SSH_MEAN_COST_CONTRIBUTION */
210
211 c-- ==========
212 c-- Anomalies.
213 c-- ==========
214
215 erscost = 0. _d 0
216 tpcost = 0. _d 0
217
218 c-- Loop over records for the second time.
219 do irec = 1, ndaysrec
220
221 call active_read_xy( fname, psbar, irec, doglobalread,
222 & ladinit, optimcycle, mythid, dummy)
223
224 #ifdef ALLOW_SSH_TPANOM_COST_CONTRIBUTION
225 call cost_ReadTopex( irec, mythid )
226 #endif
227
228 #ifdef ALLOW_SSH_ERSANOM_COST_CONTRIBUTION
229 call cost_ReadERS( irec, mythid )
230 #endif
231
232 do bj = jtlo,jthi
233 do bi = itlo,ithi
234
235 erscost = 0. _d 0
236 tpcost = 0. _d 0
237
238 #ifdef ALLOW_SSH_TPANOM_COST_CONTRIBUTION
239 do j = jmin,jmax
240 do i = imin,imax
241 c-- The array psobs contains SSH anomalies.
242 wwwtp(i,j) = wtp(i,j,bi,bj) *cosphi(i,j,bi,bj)
243 junk = ((psbar(i,j,bi,bj) - psmean(i,j,bi,bj)) -
244 & tpobs(i,j,bi,bj))*tpmask(i,j,bi,bj)
245 tpcost = tpcost + junk*junk*wwwtp(i,j)
246 enddo
247 enddo
248 #endif
249
250 #ifdef ALLOW_SSH_ERSANOM_COST_CONTRIBUTION
251 do j = jmin,jmax
252 do i = imin,imax
253 c-- The array ersobs contains SSH anomalies.
254 wwwers(i,j) = wers(i,j,bi,bj)*cosphi(i,j,bi,bj)
255 junk = ((psbar(i,j,bi,bj) - psmean(i,j,bi,bj)) -
256 & ersobs(i,j,bi,bj))*ersmask(i,j,bi,bj)
257 erscost = erscost + junk*junk*wwwers(i,j)
258 enddo
259
260 enddo
261 #endif
262
263 objf_h(bi,bj) = objf_h(bi,bj) + tpcost + erscost
264
265 #ifdef ECCO_VERBOSE
266 write(msgbuf,'(a)') ' '
267 call print_message( msgbuf, standardmessageunit,
268 & SQUEEZE_RIGHT , mythid)
269 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
270 & ' COST_SSH: irec,bi,bj = ',irec,bi,bj
271 call print_message( msgbuf, standardmessageunit,
272 & SQUEEZE_RIGHT , mythid)
273 write(msgbuf,'(a,d22.15)')
274 & ' COST_SSH: cost function (TOPEX) = ',tpcost
275 call print_message( msgbuf, standardmessageunit,
276 & SQUEEZE_RIGHT , mythid)
277 write(msgbuf,'(a,d22.15)')
278 & ' COST_SSH: cost function (ERS) = ',erscost
279 call print_message( msgbuf, standardmessageunit,
280 & SQUEEZE_RIGHT , mythid)
281 write(msgbuf,'(a,d22.15)')
282 & ' COST_SSH: cost function (Total) = ',objf_h(bi,bj)
283 call print_message( msgbuf, standardmessageunit,
284 & SQUEEZE_RIGHT , mythid)
285 write(msgbuf,'(a)') ' '
286 call print_message( msgbuf, standardmessageunit,
287 & SQUEEZE_RIGHT , mythid)
288 #endif
289
290 enddo
291 enddo
292
293 enddo
294 c-- End of second loop over records.
295
296 #endif /* ifdef ALLOW_SSH_COST_CONTRIBUTION */
297
298 end

  ViewVC Help
Powered by ViewVC 1.1.22