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

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

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


Revision 1.4 - (show annotations) (download)
Mon Oct 11 16:38:53 2004 UTC (19 years, 8 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint57d_post, checkpoint57b_post, checkpoint57c_pre, checkpoint55j_post, checkpoint56b_post, checkpoint55h_post, checkpoint57e_post, checkpoint56c_post, checkpoint57a_post, checkpoint55g_post, checkpoint55f_post, checkpoint57a_pre, checkpoint55i_post, checkpoint57, checkpoint56, eckpoint57e_pre, checkpoint57c_post, checkpoint55e_post, checkpoint56a_post, checkpoint55d_post
Changes since 1.3: +30 -51 lines
o ECCO specific cost function terms (up-to-date with 1x1 runs)
o ecco_cost_weights is modified to 1x1 runs
o modifs to allow observations to be read in as
  single file or yearly files

1 C $Header: /u/gcmpack/MITgcm/pkg/cost/Attic/cost_theta.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_Theta(
7 I myiter,
8 I mytime,
9 I mythid
10 & )
11
12 c ==================================================================
13 c SUBROUTINE cost_Theta
14 c ==================================================================
15 c
16 c o Evaluate cost function contribution of temperature.
17 c
18 c started: Christian Eckert eckert@mit.edu 30-Jun-1999
19 c
20 c changed: Christian Eckert eckert@mit.edu 25-Feb-2000
21 c
22 c - Restructured the code in order to create a package
23 c for the MITgcmUV.
24 c
25 c changed: Patrick Heimbach heimbach@mit.edu 27-May-2000
26 c
27 c - set ladinit to .true. to initialise adtbar file
28 c
29 c ==================================================================
30 c SUBROUTINE cost_Theta
31 c ==================================================================
32
33 implicit none
34
35 c == global variables ==
36
37 #include "EEPARAMS.h"
38 #include "SIZE.h"
39 #include "GRID.h"
40 #include "DYNVARS.h"
41
42 #include "cal.h"
43 #include "ecco_cost.h"
44 #include "ctrl.h"
45 #include "ctrl_dummy.h"
46 #include "optim.h"
47
48 c == routine arguments ==
49
50 integer myiter
51 _RL mytime
52 integer mythid
53
54 c == local variables ==
55
56 integer bi,bj
57 integer i,j,k
58 integer itlo,ithi
59 integer jtlo,jthi
60 integer jmin,jmax
61 integer imin,imax
62 integer irec
63 integer levmon
64 integer levoff
65 integer iltheta
66
67 _RL fctile
68 _RL fcthread
69
70 _RL cmask (1-olx:snx+olx,1-oly:sny+oly)
71 _RL spval
72
73 character*(80) fnametheta
74
75 logical doglobalread
76 logical ladinit
77
78 character*(MAX_LEN_MBUF) msgbuf
79 #ifdef GENERIC_BAR_MONTH
80 integer mrec, nyears, iyear
81 #endif
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 spval = -1.8
99
100 c-- Read tiled data.
101 doglobalread = .false.
102 ladinit = .false.
103
104 #ifdef ALLOW_THETA_COST_CONTRIBUTION
105
106 if (optimcycle .ge. 0) then
107 iltheta = ilnblnk( tbarfile )
108 write(fnametheta(1:80),'(2a,i10.10)')
109 & tbarfile(1:iltheta),'.',optimcycle
110 endif
111
112 fcthread = 0. _d 0
113
114 #ifdef GENERIC_BAR_MONTH
115 c-- Loop over month
116 do irec = 1,12
117 nyears=int((nmonsrec-irec)/12)+1
118 if(nyears.gt.0) then
119 do iyear=1,nyears
120 mrec=irec+(iyear-1)*12
121 c-- Read time averages and the monthly mean data.
122 call active_read_xyz( fnametheta, tbar, mrec,
123 & doglobalread, ladinit,
124 & optimcycle, mythid,
125 & xx_tbar_mean_dummy )
126 do bj = jtlo,jthi
127 do bi = itlo,ithi
128 do k = 1,nr
129 do j = jmin,jmax
130 do i = imin,imax
131 if(iyear.eq.1) then
132 tbar_gen(i,j,k,bi,bj) =tbar(i,j,k,bi,bj)
133 elseif(iyear.eq.nyears) then
134 tbar(i,j,k,bi,bj) =(tbar_gen(i,j,k,bi,bj)
135 $ +tbar(i,j,k,bi,bj))/float(nyears)
136 else
137 tbar_gen(i,j,k,bi,bj) =tbar_gen(i,j,k,bi,bj)
138 $ +tbar(i,j,k,bi,bj)
139 endif
140 enddo
141 enddo
142 enddo
143 enddo
144 enddo
145 enddo
146 #else
147 c-- Loop over records.
148 do irec = 1,nmonsrec
149
150 c-- Read time averages and the monthly mean data.
151 call active_read_xyz( fnametheta, tbar, irec,
152 & doglobalread, ladinit,
153 & optimcycle, mythid,
154 & xx_tbar_mean_dummy )
155 #endif
156 c-- Determine the month to be read.
157 levoff = mod(modelstartdate(1)/100,100)
158 levmon = (irec-1) + levoff
159 levmon = mod(levmon-1,12)+1
160
161 call mdsreadfield( tdatfile, cost_iprec, cost_yftype,
162 & nr, tdat, levmon, mythid)
163
164 do bj = jtlo,jthi
165 do bi = itlo,ithi
166
167 c-- Loop over the model layers
168 fctile = 0. _d 0
169 do k = 1,nr
170
171 c-- Determine the mask on weights
172 do j = jmin,jmax
173 do i = imin,imax
174 cmask(i,j) = 1. _d 0
175 if (tdat(i,j,k,bi,bj) .eq. 0.) then
176 cmask(i,j) = 0. _d 0
177 endif
178
179 if (tdat(i,j,k,bi,bj) .lt. spval) then
180 cmask(i,j) = 0. _d 0
181 endif
182
183 cph(
184 cph print *, 'WARNING: SPECIFIC SETUP FOR ECCO'
185 cph below statement could be replaced by following
186 cph to make it independnet of Nr:
187 cph
188 cph if ( rC(K) .GT. -1000. ) then
189 cph)
190 c set cmask=0 in areas shallower than 1000m
191 if (_hFacC(i,j,13,bi,bj) .eq. 0.) then
192 cmask(i,j) = 0. _d 0
193 endif
194 enddo
195 enddo
196
197 c-- Compute model data misfit and cost function term for
198 c the temperature field.
199 do j = jmin,jmax
200 do i = imin,imax
201 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
202 fctile = fctile +
203 & (wtheta(k,bi,bj)*cosphi(i,j,bi,bj)*cmask(i,j)*
204 & (tbar(i,j,k,bi,bj) - tdat(i,j,k,bi,bj))*
205 & (tbar(i,j,k,bi,bj) - tdat(i,j,k,bi,bj)) )
206 endif
207 enddo
208 enddo
209
210 enddo
211 c-- End of loop over layers.
212
213 fcthread = fcthread + fctile
214 objf_temp(bi,bj) = objf_temp(bi,bj) + fctile
215
216 #ifdef ECCO_VERBOSE
217 c-- Print cost function for each tile in each thread.
218 write(msgbuf,'(a)') ' '
219 call print_message( msgbuf, standardmessageunit,
220 & SQUEEZE_RIGHT , mythid)
221 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
222 & ' cost_Theta: irec,bi,bj = ',irec,bi,bj
223 call print_message( msgbuf, standardmessageunit,
224 & SQUEEZE_RIGHT , mythid)
225 write(msgbuf,'(a,d22.15)')
226 & ' cost function (temperature) = ',
227 & fctile
228 call print_message( msgbuf, standardmessageunit,
229 & SQUEEZE_RIGHT , mythid)
230 write(msgbuf,'(a)') ' '
231 call print_message( msgbuf, standardmessageunit,
232 & SQUEEZE_RIGHT , mythid)
233 #endif
234
235 enddo
236 enddo
237
238 #ifdef ECCO_VERBOSE
239 c-- Print cost function for all tiles.
240 _GLOBAL_SUM_R8( fcthread , myThid )
241 write(msgbuf,'(a)') ' '
242 call print_message( msgbuf, standardmessageunit,
243 & SQUEEZE_RIGHT , mythid)
244 write(msgbuf,'(a,i8.8)')
245 & ' cost_Theta: irec = ',irec
246 call print_message( msgbuf, standardmessageunit,
247 & SQUEEZE_RIGHT , mythid)
248 write(msgbuf,'(a,a,d22.15)')
249 & ' global cost function value',
250 & ' (temperature) = ',fcthread
251 call print_message( msgbuf, standardmessageunit,
252 & SQUEEZE_RIGHT , mythid)
253 write(msgbuf,'(a)') ' '
254 call print_message( msgbuf, standardmessageunit,
255 & SQUEEZE_RIGHT , mythid)
256 #endif
257
258 #ifdef GENERIC_BAR_MONTH
259 endif
260 #endif
261 enddo
262 c-- End of loop over records.
263
264 #else
265 c-- Do not enter the calculation of the temperature contribution to
266 c-- the final cost function.
267
268 #ifdef ECCO_VERBOSE
269 _BEGIN_MASTER( mythid )
270 write(msgbuf,'(a)') ' '
271 call print_message( msgbuf, standardmessageunit,
272 & SQUEEZE_RIGHT , mythid)
273 write(msgbuf,'(a,a)')
274 & ' cost_Theta: no contribution of temperature field ',
275 & 'to cost function.'
276 call print_message( msgbuf, standardmessageunit,
277 & SQUEEZE_RIGHT , mythid)
278 write(msgbuf,'(a,a,i9.8)')
279 & ' cost_Theta: number of records that would have',
280 & ' been processed: ',nmonsrec
281 call print_message( msgbuf, standardmessageunit,
282 & SQUEEZE_RIGHT , mythid)
283 write(msgbuf,'(a)') ' '
284 call print_message( msgbuf, standardmessageunit,
285 & SQUEEZE_RIGHT , mythid)
286 _END_MASTER( mythid )
287 #endif
288
289 #endif
290
291 return
292 end
293

  ViewVC Help
Powered by ViewVC 1.1.22