/[MITgcm]/MITgcm/pkg/ecco/cost_driftw.F
ViewVC logotype

Contents of /MITgcm/pkg/ecco/cost_driftw.F

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


Revision 1.8 - (show annotations) (download)
Tue Apr 28 18:13:28 2009 UTC (15 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63p, checkpoint63q, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint62, checkpoint63, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint61n, checkpoint61o, checkpoint61m, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.7: +2 -2 lines
change macros (EXCH & GLOBAL_SUM/MAX) sufix _R4/_R8 to _RS/_RL
 when applied to _RS/_RL variable

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_driftw.F,v 1.7 2008/05/03 00:31:07 heimbach Exp $
2 C $Name: $
3
4 #include "COST_CPPOPTIONS.h"
5
6
7 subroutine cost_driftw(
8 I myiter,
9 I mytime,
10 I mythid
11 & )
12
13 c ==================================================================
14 c SUBROUTINE cost_Driftw
15 c ==================================================================
16 c
17 c o Evaluate cost function contribution of the w difference
18 c between the first and the last year.
19 c
20 c started: from cost_drift
21 c
22 c Armin Koehl akoehl@ucsd.edu 26-Feb-2002
23 c
24 c ==================================================================
25 c SUBROUTINE cost_Driftw
26 c ==================================================================
27
28 implicit none
29
30 c == global variables ==
31
32 #include "EEPARAMS.h"
33 #include "SIZE.h"
34 #include "GRID.h"
35 #include "DYNVARS.h"
36
37 #include "cal.h"
38 #include "ecco_cost.h"
39 #include "ctrl.h"
40 #include "ctrl_dummy.h"
41 #include "optim.h"
42
43 c == routine arguments ==
44
45 integer myiter
46 _RL mytime
47 integer mythid
48
49 c == local variables ==
50
51 _RS one_rs
52 parameter( one_rs = 1. )
53
54 integer bi,bj
55 integer i,j,k
56 integer itlo,ithi
57 integer jtlo,jthi
58 integer jmin,jmax
59 integer imin,imax
60 integer irec
61 integer ilw
62 integer nf, nl, nfmin
63 integer minrec
64
65 _RL fctilew
66 _RL fcthread_wdrift
67
68 character*(80) fnamew
69
70 logical doglobalread
71 logical ladinit
72
73 character*(MAX_LEN_MBUF) msgbuf
74
75 c == external functions ==
76
77 integer ilnblnk
78 external ilnblnk
79
80 c == end of interface ==
81
82 jtlo = mybylo(mythid)
83 jthi = mybyhi(mythid)
84 itlo = mybxlo(mythid)
85 ithi = mybxhi(mythid)
86 jmin = 1
87 jmax = sny
88 imin = 1
89 imax = snx
90
91 c-- Read tiled data.
92 doglobalread = .false.
93 ladinit = .false.
94
95 #ifdef ALLOW_DRIFTW_COST_CONTRIBUTION
96
97 if (optimcycle .ge. 0) then
98 ilw = ilnblnk( wbarfile )
99 write(fnamew(1:80),'(2a,i10.10)')
100 & wbarfile(1:ilw),'.',optimcycle
101 endif
102
103 fcthread_wdrift = 0. _d 0
104
105 do bj = jtlo,jthi
106 do bi = itlo,ithi
107 do k = 1,nr
108 do j = jmin,jmax
109 do i = imin,imax
110 wfmean(i,j,k,bi,bj) = 0.0
111 wlmean(i,j,k,bi,bj) = 0.0
112 enddo
113 enddo
114 enddo
115 enddo
116 enddo
117
118 nf = 0
119 nl = 0
120 c-- Number of full years
121 nfmin = MAX(INT(FLOAT(nmonsrec)/12.),1)
122 c-- Prevent code from crashing if integrated for less than a year
123 minrec = MIN(nmonsrec,12)
124
125 c-- Loop over records.
126 do irec = 1,minrec
127
128 c-- Read time averages and the monthly mean data.
129 call active_read_xyz( fnamew, wbar, irec,
130 & doglobalread, ladinit,
131 & optimcycle, mythid,
132 & xx_wbar_mean_dummy )
133
134 nf = nf + 1
135 do bj = jtlo,jthi
136 do bi = itlo,ithi
137 do k = 1,nr
138 do j = jmin,jmax
139 do i = imin,imax
140 wfmean(i,j,k,bi,bj) = wfmean(i,j,k,bi,bj) +
141 & wbar(i,j,k,bi,bj)
142 enddo
143 enddo
144 enddo
145 enddo
146 enddo
147
148 enddo
149
150 do irec = nmonsrec-minrec+1, nmonsrec
151
152 c-- Read time averages and the monthly mean data.
153 call active_read_xyz( fnamew, wbar, irec,
154 & doglobalread, ladinit,
155 & optimcycle, mythid,
156 & xx_wbar_mean_dummy )
157
158 nl = nl + 1
159
160 do bj = jtlo,jthi
161 do bi = itlo,ithi
162 do k = 1,nr
163 do j = jmin,jmax
164 do i = imin,imax
165 wlmean(i,j,k,bi,bj) = wlmean(i,j,k,bi,bj) +
166 & wbar(i,j,k,bi,bj)
167 enddo
168 enddo
169 enddo
170 enddo
171 enddo
172
173 enddo
174
175
176 do bj = jtlo,jthi
177 do bi = itlo,ithi
178
179 c-- Loop over the model layers
180 fctilew = 0. _d 0
181
182 do k = 1,nr
183
184 c-- Compute model misfit and cost function term for
185 c the vertical velovity field. The error is 1e-4 m/s.
186 do j = jmin,jmax
187 do i = imin,imax
188 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
189 fctilew = fctilew +
190 & (2.5e11*cosphi(i,j,bi,bj)*
191 & (wlmean(i,j,k,bi,bj)/nl - wfmean(i,j,k,bi,bj)/nf)*
192 & (wlmean(i,j,k,bi,bj)/nl - wfmean(i,j,k,bi,bj)/nf))
193 if ( cosphi(i,j,bi,bj) .ne. 0. )
194 & num_wdrift(bi,bj) = num_wdrift(bi,bj) + 1. _d 0
195 endif
196 enddo
197 enddo
198
199 enddo
200 c-- End of loop over layers.
201
202 fcthread_wdrift = fcthread_wdrift + fctilew
203 objf_wdrift(bi,bj) = objf_wdrift(bi,bj) + fctilew
204
205 #ifdef ECCO_VERBOSE
206 c-- Print cost function for each tile in each thread.
207 write(msgbuf,'(a)') ' '
208 call print_message( msgbuf, standardmessageunit,
209 & SQUEEZE_RIGHT , mythid)
210 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
211 & ' cost_Driftw: irec,bi,bj = ',irec,bi,bj
212 call print_message( msgbuf, standardmessageunit,
213 & SQUEEZE_RIGHT , mythid)
214 write(msgbuf,'(a,d22.15)')
215 & ' cost function (wvel) = ',
216 & fcthread_wdrift
217 call print_message( msgbuf, standardmessageunit,
218 & SQUEEZE_RIGHT , mythid)
219 write(msgbuf,'(a)') ' '
220 call print_message( msgbuf, standardmessageunit,
221 & SQUEEZE_RIGHT , mythid)
222 #endif
223
224 enddo
225 enddo
226
227 #ifdef ECCO_VERBOSE
228 c-- Print cost function for all tiles.
229 _GLOBAL_SUM_RL( fcthread_wdrift , myThid )
230 write(msgbuf,'(a)') ' '
231 call print_message( msgbuf, standardmessageunit,
232 & SQUEEZE_RIGHT , mythid)
233 write(msgbuf,'(a,i8.8)')
234 & ' cost_Driftw: irec = ',irec
235 call print_message( msgbuf, standardmessageunit,
236 & SQUEEZE_RIGHT , mythid)
237 write(msgbuf,'(a,a,d22.15)')
238 & ' cost function value',
239 & ' (wvel) = ',fcthread_wdrift
240 call print_message( msgbuf, standardmessageunit,
241 & SQUEEZE_RIGHT , mythid)
242 write(msgbuf,'(a)') ' '
243 call print_message( msgbuf, standardmessageunit,
244 & SQUEEZE_RIGHT , mythid)
245 #endif
246
247 #endif
248
249 return
250 end
251

  ViewVC Help
Powered by ViewVC 1.1.22