/[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.17 - (show annotations) (download)
Thu Oct 29 13:39:54 2015 UTC (8 years, 7 months ago) by gforget
Branch: MAIN
CVS Tags: HEAD
Changes since 1.16: +1 -1 lines
FILE REMOVED
- remove codes that have been replaced with generic function calls.

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_theta.F,v 1.16 2014/10/18 18:15:45 gforget Exp $
2 C $Name: $
3
4 #include "ECCO_OPTIONS.h"
5
6 subroutine cost_theta( myiter, mytime, mythid )
7
8 c ==================================================================
9 c SUBROUTINE cost_theta
10 c ==================================================================
11 c
12 c o Evaluate cost function contribution of temperature.
13 c
14 c started: Christian Eckert eckert@mit.edu 30-Jun-1999
15 c
16 c changed: Christian Eckert eckert@mit.edu 25-Feb-2000
17 c
18 c - Restructured the code in order to create a package
19 c for the MITgcmUV.
20 c
21 c changed: Patrick Heimbach heimbach@mit.edu 27-May-2000
22 c
23 c - set ladinit to .true. to initialise adtbar file
24 c
25 c ==================================================================
26 c SUBROUTINE cost_theta
27 c ==================================================================
28
29 implicit none
30
31 c == global variables ==
32
33 #ifdef ALLOW_THETA_COST_CONTRIBUTION
34 #include "EEPARAMS.h"
35 #include "SIZE.h"
36 #include "PARAMS.h"
37 #include "GRID.h"
38 #include "DYNVARS.h"
39
40 #include "cal.h"
41 #include "ecco_cost.h"
42 #include "CTRL_SIZE.h"
43 #include "ctrl.h"
44 #include "ctrl_dummy.h"
45 #include "optim.h"
46 #endif
47
48 c == routine arguments ==
49
50 integer myiter
51 _RL mytime
52 integer mythid
53
54 #ifdef ALLOW_THETA_COST_CONTRIBUTION
55 c == external functions ==
56 integer ilnblnk
57 external ilnblnk
58
59 c == local variables ==
60
61 integer bi,bj
62 integer i,j,k
63 integer itlo,ithi
64 integer jtlo,jthi
65 integer jmin,jmax
66 integer imin,imax
67 integer irec, irectmp
68 integer levmon
69 integer levoff
70 integer iltheta
71
72 _RL fctile
73 _RL fcthread
74
75 _RL cmask (1-olx:snx+olx,1-oly:sny+oly)
76 _RL spval
77 _RL spmax
78
79 character*(80) fnametheta
80
81 logical doglobalread
82 logical ladinit
83
84 character*(MAX_LEN_MBUF) msgbuf
85 #ifdef GENERIC_BAR_MONTH
86 integer mrec, nyears, iyear
87 #endif
88
89 _RL diagnosfld3d(1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy)
90
91 c == end of interface ==
92
93 jtlo = mybylo(mythid)
94 jthi = mybyhi(mythid)
95 itlo = mybxlo(mythid)
96 ithi = mybxhi(mythid)
97 jmin = 1
98 jmax = sny
99 imin = 1
100 imax = snx
101
102 spval = -1.8
103 spmax = 40.
104
105 c-- Read tiled data.
106 doglobalread = .false.
107 ladinit = .false.
108
109 if ( tdatfile.NE.' ') then
110
111 if (optimcycle .ge. 0) then
112 iltheta = ilnblnk( tbarfile )
113 write(fnametheta(1:80),'(2a,i10.10)')
114 & tbarfile(1:iltheta),'.',optimcycle
115 endif
116
117 fcthread = 0. _d 0
118
119 #ifdef GENERIC_BAR_MONTH
120 c-- Loop over month
121 do irec = 1,min(nmonsrec,12)
122 nyears=int((nmonsrec-irec)/12)+1
123 do bj = jtlo,jthi
124 do bi = itlo,ithi
125 do k = 1,nr
126 do j = jmin,jmax
127 do i = imin,imax
128 tbar_gen(i,j,k,bi,bj) = 0. _d 0
129 enddo
130 enddo
131 enddo
132 enddo
133 enddo
134 do iyear=1,nyears
135 mrec=irec+(iyear-1)*12
136 irectmp=mrec
137 c-- Read time averages and the monthly mean data.
138 call active_read_xyz( fnametheta, tbar, mrec,
139 & doglobalread, ladinit,
140 & optimcycle, mythid,
141 & xx_tbar_mean_dummy )
142 do bj = jtlo,jthi
143 do bi = itlo,ithi
144 do k = 1,nr
145 do j = jmin,jmax
146 do i = imin,imax
147 tbar_gen(i,j,k,bi,bj) =tbar_gen(i,j,k,bi,bj)
148 $ +tbar(i,j,k,bi,bj)/float(nyears)
149 enddo
150 enddo
151 enddo
152 enddo
153 enddo
154 enddo
155 #else
156 c-- Loop over records.
157 do irec = 1,nmonsrec
158
159 irectmp = irec
160 c-- Read time averages and the monthly mean data.
161 call active_read_xyz( fnametheta, tbar, irec,
162 & doglobalread, ladinit,
163 & optimcycle, mythid,
164 & xx_tbar_mean_dummy )
165 #endif
166 c-- Determine the month to be read.
167 levoff = mod(modelstartdate(1)/100,100)
168 levmon = (irectmp-1) + levoff
169 levmon = mod(levmon-1,12)+1
170
171 call mdsreadfield( tdatfile, cost_iprec, cost_yftype,
172 & nr, tdat, levmon, mythid)
173
174 do bj = jtlo,jthi
175 do bi = itlo,ithi
176
177 c-- Loop over the model layers
178 fctile = 0. _d 0
179 do k = 1,nr
180
181 c-- Determine the mask on weights
182 do j = jmin,jmax
183 do i = imin,imax
184 cmask(i,j) = cosphi(i,j,bi,bj)
185 if (tdat(i,j,k,bi,bj) .eq. 0.) then
186 cmask(i,j) = 0. _d 0
187 else if (tdat(i,j,k,bi,bj) .lt. spval) then
188 cmask(i,j) = 0. _d 0
189 else if (tdat(i,j,k,bi,bj) .gt. spmax) then
190 cmask(i,j) = 0. _d 0
191 endif
192 enddo
193 enddo
194
195 c-- Compute model data misfit and cost function term for
196 c the temperature field.
197 do j = jmin,jmax
198 do i = imin,imax
199 if ( _hFacC(i,j,k,bi,bj) .ne. 0. ) then
200 fctile = fctile +
201 & (wthetaLev(i,j,k,bi,bj)*cmask(i,j)*
202 & (tbar(i,j,k,bi,bj) - tdat(i,j,k,bi,bj))*
203 & (tbar(i,j,k,bi,bj) - tdat(i,j,k,bi,bj)) )
204 if ( wthetaLev(i,j,k,bi,bj)*cmask(i,j) .ne. 0. )
205 & num_temp(bi,bj) = num_temp(bi,bj) + 1. _d 0
206 diagnosfld3d(i,j,k,bi,bj) =
207 & (wthetaLev(i,j,k,bi,bj)*cmask(i,j)*
208 & (tbar(i,j,k,bi,bj) - tdat(i,j,k,bi,bj))*
209 & (tbar(i,j,k,bi,bj) - tdat(i,j,k,bi,bj)) )
210 else
211 diagnosfld3d(i,j,k,bi,bj) = 0.
212 endif
213 enddo
214 enddo
215
216 enddo
217 c-- End of loop over layers.
218
219 fcthread = fcthread + fctile
220 objf_temp(bi,bj) = objf_temp(bi,bj) + fctile
221
222 enddo
223 enddo
224
225 cph CALL WRITE_REC_XYZ_RL( 'DiagnosCost_ClimTheta',
226 cph & diagnosfld3d, irec, optimcycle, mythid )
227
228 enddo
229 c-- End of loop over records.
230
231 endif !if ( tdatfile.NE.' ') then
232
233 #endif /* ALLOW_THETA_COST_CONTRIBUTION */
234
235 RETURN
236 END

  ViewVC Help
Powered by ViewVC 1.1.22