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