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

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

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


Revision 1.11 - (show annotations) (download)
Fri Aug 10 19:45:25 2012 UTC (11 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63r, checkpoint63s, checkpoint64, checkpoint65, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65d, checkpoint65e
Changes since 1.10: +2 -2 lines
include ECCO_OPTIONS.h instead of COST_CPPOPTIONS.h

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_ctdt.F,v 1.10 2012/08/06 20:41:54 heimbach Exp $
2 C $Name: $
3
4 #include "ECCO_OPTIONS.h"
5
6
7 subroutine cost_CTDT(
8 I myiter,
9 I mytime,
10 I mythid
11 & )
12
13 c ==================================================================
14 c SUBROUTINE cost_CTDT
15 c ==================================================================
16 c
17 c o Evaluate cost function contribution of CTD temperature data.
18 c
19 c started: Elisabeth Remy eremy@ucsd.edu 30-Aug-2000
20 c
21 c
22 c ==================================================================
23 c SUBROUTINE cost_CTDT
24 c ==================================================================
25
26 implicit none
27
28 c == global variables ==
29
30 #include "EEPARAMS.h"
31 #include "SIZE.h"
32 #include "GRID.h"
33 #include "DYNVARS.h"
34
35 #include "cal.h"
36 #include "ecco_cost.h"
37 #include "CTRL_SIZE.h"
38 #include "ctrl.h"
39 #include "ctrl_dummy.h"
40 #include "optim.h"
41
42 c == routine arguments ==
43
44 integer myiter
45 _RL mytime
46 integer mythid
47
48 c == local variables ==
49
50 integer bi,bj
51 integer i,j,k
52 integer itlo,ithi
53 integer jtlo,jthi
54 integer jmin,jmax
55 integer imin,imax
56 integer nrec
57 integer irec
58 integer ilu
59
60 _RL fctile_ctdt
61 _RL fcthread_ctdt
62 _RL www (1-olx:snx+olx,1-oly:sny+oly)
63 _RL wtmp (1-olx:snx+olx,1-oly:sny+oly)
64 _RL tmpobs (1-olx:snx+olx,1-oly:sny+oly)
65 _RL tmpbar (1-olx:snx+olx,1-oly:sny+oly)
66 _RL cmask (1-olx:snx+olx,1-oly:sny+oly)
67 _RL spval
68 _RL spmax
69
70 character*(80) fnametheta
71
72 logical doglobalread
73 logical ladinit
74
75 character*(MAX_LEN_MBUF) msgbuf
76
77 cnew(
78 integer il
79 integer mody, modm
80 integer iyear, imonth
81 character*(80) fnametmp
82 logical exst
83 cnew)
84
85 c == external functions ==
86
87 integer ilnblnk
88 external ilnblnk
89
90 c == end of interface ==
91
92 jtlo = mybylo(mythid)
93 jthi = mybyhi(mythid)
94 itlo = mybxlo(mythid)
95 ithi = mybxhi(mythid)
96 jmin = 1
97 jmax = sny
98 imin = 1
99 imax = snx
100
101 spval = -1.8
102 spmax = 40.
103
104 c-- Read state record from global file.
105 doglobalread = .false.
106 ladinit = .false.
107
108 #ifdef ALLOW_CTDT_COST_CONTRIBUTION
109
110 if (optimcycle .ge. 0) then
111 ilu=ilnblnk( tbarfile )
112 write(fnametheta(1:80),'(2a,i10.10)')
113 & tbarfile(1:ilu),'.',optimcycle
114 endif
115
116 fcthread_ctdt = 0. _d 0
117
118 cnew(
119 mody = modelstartdate(1)/10000
120 modm = modelstartdate(1)/100 - mody*100
121 cnew)
122
123 c-- Loop over records.
124 do irec = 1,nmonsrec
125
126 c-- Read time averages and the monthly mean data.
127 call active_read_xyz( fnametheta, tbar, irec,
128 & doglobalread, ladinit,
129 & optimcycle, mythid, xx_tbar_mean_dummy )
130
131 cnew(
132 iyear = mody + INT((modm-1+irec-1)/12)
133 imonth = 1 + MOD(modm-1+irec-1,12)
134 il=ilnblnk(ctdtfile)
135 write(fnametmp(1:80),'(2a,i4)')
136 & ctdtfile(1:il), '_', iyear
137 inquire( file=fnametmp, exist=exst )
138 if (.NOT. exst) then
139 write(fnametmp(1:80),'(a)') ctdtfile(1:il)
140 imonth = irec
141 endif
142
143 call mdsreadfield( fnametmp, cost_iprec, 'RL', nr, ctdtobs,
144 & imonth, mythid)
145 cnew)
146
147 c-- Loop over this thread tiles.
148 do bj = jtlo,jthi
149 do bi = itlo,ithi
150 c-- Loop over the model layers
151
152 fctile_ctdt = 0. _d 0
153
154 do k = 1,nr
155
156 c-- Determine the weights to be used.
157 do j = jmin,jmax
158 do i = imin,imax
159 cmask(i,j) = 1. _d 0
160 if (ctdtobs(i,j,k,bi,bj) .lt. spval .or.
161 & ctdtobs(i,j,k,bi,bj) .gt. spmax .or.
162 & ctdtobs(i,j,k,bi,bj) .eq. 0. ) then
163 cmask(i,j) = 0. _d 0
164 endif
165
166 c set cmask=0 in areas shallower than 1000m
167
168 if ( _hFacC(i,j,k,bi,bj) .ne. 0. ) then
169
170 www(i,j) = cosphi(i,j,bi,bj)*cmask(i,j)
171 tmpobs(i,j) = ctdtobs(i,j,k,bi,bj)
172 tmpbar(i,j) = tbar(i,j,k,bi,bj)
173 wtmp(i,j) = wtheta2(i,j,k,bi,bj)
174
175 c-- The array ctdtobs contains CTD temperature.
176 fctile_ctdt = fctile_ctdt +
177 & (wtmp(i,j)*www(i,j))*
178 & (tmpbar(i,j)-tmpobs(i,j))*
179 & (tmpbar(i,j)-tmpobs(i,j))
180 if ( wtmp(i,j)*www(i,j) .ne. 0. )
181 & num_ctdt(bi,bj) = num_ctdt(bi,bj) + 1. _d 0
182 endif
183 enddo
184 enddo
185 enddo
186 c-- End of loop over layers.
187
188 fcthread_ctdt = fcthread_ctdt + fctile_ctdt
189 objf_ctdt(bi,bj) = objf_ctdt(bi,bj) + fctile_ctdt
190
191 #ifdef ECCO_VERBOSE
192 write(msgbuf,'(a)') ' '
193 call print_message( msgbuf, standardmessageunit,
194 & SQUEEZE_RIGHT , mythid)
195 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
196 & ' COST_CTDT: irec,bi,bj = ',irec,bi,bj
197 call print_message( msgbuf, standardmessageunit,
198 & SQUEEZE_RIGHT , mythid)
199 write(msgbuf,'(a,d22.15)')
200 & ' COST_CTDT: cost function = ', fctile_ctdt
201 call print_message( msgbuf, standardmessageunit,
202 & SQUEEZE_RIGHT , mythid)
203 write(msgbuf,'(a)') ' '
204 call print_message( msgbuf, standardmessageunit,
205 & SQUEEZE_RIGHT , mythid)
206 #endif
207
208 enddo
209 enddo
210
211 #ifdef ECCO_VERBOSE
212 c-- Print cost function for all tiles.
213 _GLOBAL_SUM_RL( fcthread_ctdt , myThid )
214 write(msgbuf,'(a)') ' '
215 call print_message( msgbuf, standardmessageunit,
216 & SQUEEZE_RIGHT , mythid)
217 write(msgbuf,'(a,i8.8)')
218 & ' cost_CTDT: irec = ',irec
219 call print_message( msgbuf, standardmessageunit,
220 & SQUEEZE_RIGHT , mythid)
221 write(msgbuf,'(a,a,d22.15)')
222 & ' global cost function value',
223 & ' ( CTD temp. ) = ',fcthread_ctdt
224 call print_message( msgbuf, standardmessageunit,
225 & SQUEEZE_RIGHT , mythid)
226 write(msgbuf,'(a)') ' '
227 call print_message( msgbuf, standardmessageunit,
228 & SQUEEZE_RIGHT , mythid)
229 #endif
230
231 enddo
232 c-- End of second loop over records.
233
234 #else
235 c-- Do not enter the calculation of the CTD temperature contribution
236 c-- to the final cost function.
237
238 fctile_ctdt = 0. _d 0
239 fcthread_ctdt = 0. _d 0
240
241 crg
242 nrec = 1
243 crg
244
245 _BEGIN_MASTER( mythid )
246 write(msgbuf,'(a)') ' '
247 call print_message( msgbuf, standardmessageunit,
248 & SQUEEZE_RIGHT , mythid)
249 write(msgbuf,'(a,a)')
250 & ' cost_CTDT: no contribution of CTD temperature ',
251 & ' to cost function.'
252 call print_message( msgbuf, standardmessageunit,
253 & SQUEEZE_RIGHT , mythid)
254 write(msgbuf,'(a,a,i9.8)')
255 & ' cost_CTDT: number of records that would have',
256 & ' been processed: ',nrec
257 call print_message( msgbuf, standardmessageunit,
258 & SQUEEZE_RIGHT , mythid)
259 write(msgbuf,'(a)') ' '
260 call print_message( msgbuf, standardmessageunit,
261 & SQUEEZE_RIGHT , mythid)
262 _END_MASTER( mythid )
263 #endif
264
265 return
266 end

  ViewVC Help
Powered by ViewVC 1.1.22