1 |
C $Header: $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_CPPOPTIONS.h" |
5 |
|
6 |
|
7 |
subroutine cost_atlantic( |
8 |
I mytime, |
9 |
I myiter, |
10 |
I mythid |
11 |
& ) |
12 |
|
13 |
c ================================================================== |
14 |
c SUBROUTINE cost_atlantic |
15 |
c ================================================================== |
16 |
c |
17 |
c o Compute meridional heat transport. The counters |
18 |
c are explicitly calculated instead of being incremented. This |
19 |
c reduces dependencies. The latter is useful for the adjoint code |
20 |
c generation. |
21 |
c |
22 |
c started: Armin Koehl akoehl@ucsd.edu 22-Sep-2000 |
23 |
c |
24 |
c ================================================================== |
25 |
c SUBROUTINE cost_atlantic |
26 |
c ================================================================== |
27 |
|
28 |
implicit none |
29 |
|
30 |
c == global variables == |
31 |
#ifdef ALLOW_COST_ATLANTIC |
32 |
|
33 |
#include "EEPARAMS.h" |
34 |
#include "SIZE.h" |
35 |
#include "GRID.h" |
36 |
#include "DYNVARS.h" |
37 |
#include "PARAMS.h" |
38 |
#include "CG2D.h" |
39 |
|
40 |
#include "optim.h" |
41 |
#include "cost.h" |
42 |
#include "ecco_cost.h" |
43 |
#include "ctrl_dummy.h" |
44 |
|
45 |
#endif |
46 |
|
47 |
c == routine arguments == |
48 |
|
49 |
_RL mytime |
50 |
integer myiter |
51 |
integer mythid |
52 |
|
53 |
#ifdef ALLOW_COST_ATLANTIC |
54 |
|
55 |
c == local variables == |
56 |
|
57 |
integer bi,bj |
58 |
integer i,j,k |
59 |
integer itlo,ithi |
60 |
integer jtlo,jthi |
61 |
integer jmin,jmax |
62 |
integer imin,imax |
63 |
|
64 |
logical first |
65 |
logical startofday |
66 |
logical startofmonth |
67 |
logical startofyear |
68 |
logical inday |
69 |
logical inmonth |
70 |
logical inyear |
71 |
logical last |
72 |
logical endofday |
73 |
logical endofmonth |
74 |
logical endofyear |
75 |
|
76 |
_RL p5 |
77 |
parameter( p5 = 0.5 ) |
78 |
|
79 |
_RL del_y |
80 |
_RL tv |
81 |
_RL ylat,beglon,endlon |
82 |
_RL ylat2,beglon2,endlon2 |
83 |
_RL ylat3,beglon3,endlon3 |
84 |
c parameter(ylat= 29., beglon=-42., endlon =-2.) |
85 |
c parameter(ylat= 29., beglon=282., endlon =352.) |
86 |
c parameter(ylat= 29., beglon=-82., endlon =-2.) |
87 |
parameter(ylat= 66.75,beglon=-34.5,endlon =-22.5) |
88 |
parameter(ylat2= 63.8,beglon2=-20,endlon2 =-5.) |
89 |
parameter(ylat3= 63.8,beglon3=-98.5,endlon3 =-80.0) |
90 |
c == external functions == |
91 |
|
92 |
integer ilnblnk |
93 |
external ilnblnk |
94 |
|
95 |
c == end of interface == |
96 |
|
97 |
jtlo = mybylo(mythid) |
98 |
jthi = mybyhi(mythid) |
99 |
itlo = mybxlo(mythid) |
100 |
ithi = mybxhi(mythid) |
101 |
jmin = 1 |
102 |
jmax = sny |
103 |
imin = 1 |
104 |
imax = snx |
105 |
|
106 |
|
107 |
|
108 |
c-- Get the time flags and record numbers for the time averaging. |
109 |
|
110 |
call cost_AveragesFlags( |
111 |
I myiter, mytime, mythid, |
112 |
O first, last, |
113 |
O startofday, startofmonth, startofyear, |
114 |
O inday, inmonth, inyear, |
115 |
O endofday, endofmonth, endofyear, |
116 |
O sum1day, dayrec, |
117 |
O sum1mon, monrec, |
118 |
O sum1year, yearrec |
119 |
& ) |
120 |
|
121 |
ce print*,' cost_AveragesFields: myiter = ', myiter |
122 |
ce print*,' cost_AveragesFields: mytime = ', mytime |
123 |
ce print*,' cost_AveragesFields: first = ', first |
124 |
ce print*,' cost_AveragesFields: startofday = ', startofday |
125 |
ce print*,' cost_AveragesFields: startofmonth = ', startofmonth |
126 |
ce print*,' cost_AveragesFields: inday = ', inday |
127 |
ce print*,' cost_AveragesFields: inmonth = ', inmonth |
128 |
ce print*,' cost_AveragesFields: last = ', last |
129 |
ce print*,' cost_AveragesFields: endofday = ', endofday |
130 |
ce print*,' cost_AveragesFields: endofmonth = ', endofmonth |
131 |
ce print*,' cost_AveragesFields: sum1day = ', sum1day |
132 |
ce print*,' cost_AveragesFields: dayrec = ', dayrec |
133 |
ce print*,' cost_AveragesFields: sum1mon = ', sum1mon |
134 |
ce print*,' cost_AveragesFields: monrec = ', monrec |
135 |
|
136 |
ce stop '... cost_AveragesFields stopped after ecco_TimeAverageFlags.' |
137 |
|
138 |
c-- Next, do the monthly average for temperature. |
139 |
if (first) then |
140 |
c-- Assign the first value to the array holding the average. |
141 |
do bj = jtlo,jthi |
142 |
do bi = itlo,ithi |
143 |
tv=0.0 |
144 |
do k = 1,nr |
145 |
do j = jmin,jmax |
146 |
do i = imin,imax |
147 |
del_y=yc(i,j,bi,bj)-yc(i,j-1,bi,bj) |
148 |
if(yc(i,j,bi,bj) .ge.ylat .and. |
149 |
$ yc(i,j,bi,bj).lt.ylat+del_y.and. |
150 |
$ xc(i,j,bi,bj).ge.beglon.and. |
151 |
$ xc(i,j,bi,bj).le.endlon.or. |
152 |
$ (yc(i,j,bi,bj) .ge.ylat2 .and. |
153 |
$ yc(i,j,bi,bj).lt.ylat2+del_y.and. |
154 |
$ xc(i,j,bi,bj).ge.beglon2.and. |
155 |
$ xc(i,j,bi,bj).le.endlon2).or. |
156 |
$ (yc(i,j,bi,bj) .ge.ylat3 .and. |
157 |
$ yc(i,j,bi,bj).lt.ylat3+del_y.and. |
158 |
$ xc(i,j,bi,bj).ge.beglon3.and. |
159 |
$ xc(i,j,bi,bj).le.endlon3)) then |
160 |
tv = tv+p5*(theta(i,j,k,bi,bj) |
161 |
$ + theta(i,j-1,k,bi,bj))*vVel(i,j,k,bi,bj) |
162 |
$ * _dxG(i,j,bi,bj) |
163 |
& * drF(k)*_hFacS(i,j,k,bi,bj) |
164 |
$ *HeatCapacity_Cp*rhoNil |
165 |
endif |
166 |
enddo |
167 |
enddo |
168 |
enddo |
169 |
objf_atl(bi,bj) = tv |
170 |
enddo |
171 |
enddo |
172 |
else if (last ) then |
173 |
print*,"cost_atlantic last" |
174 |
c-- Add the last value and devide by the number of accumulated |
175 |
c-- records. |
176 |
do bj = jtlo,jthi |
177 |
do bi = itlo,ithi |
178 |
objf_atl(bi,bj) = (objf_atl(bi,bj) |
179 |
& )/float(nTimeSteps) |
180 |
enddo |
181 |
enddo |
182 |
else |
183 |
c-- Accumulate the array holding the average. |
184 |
do bj = jtlo,jthi |
185 |
do bi = itlo,ithi |
186 |
tv=0 |
187 |
do k = 1,nr |
188 |
do j = jmin,jmax |
189 |
do i = imin,imax |
190 |
del_y=yc(i,j,bi,bj)-yc(i,j-1,bi,bj) |
191 |
if(yc(i,j,bi,bj) .ge.ylat .and. |
192 |
$ yc(i,j,bi,bj).lt.ylat+del_y.and. |
193 |
$ xc(i,j,bi,bj).ge.beglon.and. |
194 |
$ xc(i,j,bi,bj).le.endlon.or. |
195 |
$ (yc(i,j,bi,bj) .ge.ylat2 .and. |
196 |
$ yc(i,j,bi,bj).lt.ylat2+del_y.and. |
197 |
$ xc(i,j,bi,bj).ge.beglon2.and. |
198 |
$ xc(i,j,bi,bj).le.endlon2).or. |
199 |
$ (yc(i,j,bi,bj) .ge.ylat3 .and. |
200 |
$ yc(i,j,bi,bj).lt.ylat3+del_y.and. |
201 |
$ xc(i,j,bi,bj).ge.beglon3.and. |
202 |
$ xc(i,j,bi,bj).le.endlon3)) then |
203 |
tv = tv |
204 |
$ +p5*(theta(i,j,k,bi,bj) |
205 |
$ + theta(i,j-1,k,bi,bj))*vVel(i,j,k,bi,bj) |
206 |
$ * _dxG(i,j,bi,bj) |
207 |
& * drF(k)*_hFacS(i,j,k,bi,bj) |
208 |
$ *HeatCapacity_Cp*rhoNil |
209 |
endif |
210 |
enddo |
211 |
enddo |
212 |
enddo |
213 |
objf_atl(bi,bj) = objf_atl(bi,bj) +tv |
214 |
enddo |
215 |
enddo |
216 |
endif |
217 |
|
218 |
#endif |
219 |
|
220 |
end |