-
Notifications
You must be signed in to change notification settings - Fork 0
/
gosbc.F
216 lines (216 loc) · 7.28 KB
/
gosbc.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
subroutine gosbc (ncall)
c
c=======================================================================
c interpolate the ocean S.B.C. (surface boundary conditions
c which were prepared by the atmosphere) to the ocean grid
c
c inputs:
c
c ncall = number of times this routine was called
c
c author: r. c. pacanowski e-mail=> rcp@gfdl.gov
c=======================================================================
c
#ifdef coupled
# include "param.h"
# include "coord.h"
# include "csbc.h"
# include "grdvar.h"
# include "levind.h"
c
parameter (lenw=10*imt)
common /gosbci/ nc1, nc2
common /gosbcr/ work1(lenw), work2(lenw)
dimension sor(imap2,jma), res(imap2,jma)
dimension average(maxsbc)
c
call tic ('mom', 'get S.B.C. for ocean (gosbc)')
c
write (stdout,8900)
c
c-----------------------------------------------------------------------
c initialize counters to store interpolation weights
c-----------------------------------------------------------------------
c
if (ncall .eq. 1) then
nc1 = 0
nc2 = 0
c
c-----------------------------------------------------------------------
c compute initial checksums of ocean S.B.C.'s
c "n" is the S.B.C. and "m" refers to its ordering within arrays
c-----------------------------------------------------------------------
c
do n=1,numosbc
m = mapsbc(n)
cksum = checksum (sbcatm(1,1,m), imap2, jma)
write (stdout,*) sbcname(m),' S.B.C. checksum =',cksum
enddo
endif
c
c-----------------------------------------------------------------------
c prepare each ocean S.B.C. one at a time
c "n" is the S.B.C. and "m" refers to its ordering within arrays
c This assumes that the S.B.C. have been initialized, accumulated,
c and averaged in the Atmosphere model
c-----------------------------------------------------------------------
c
do n=1,numosbc
m = mapsbc(n)
c
c set cyclic conditions on the atmosphere grid
c
do j=1,jma
sbcatm(1,j,m) = sbcatm(imap2-1,j,m)
sbcatm(imap2,j,m) = sbcatm(2,j,m)
enddo
c
c compute the global mean from the heat flux at bottom of
c atmosphere before interpolating to ocean
c
if (sbcname(m) .eq. ' heat flux') then
avg = c0
anum = c0
do j=2,jma-1
cosdy = abcgcs(j)*abcgdy(j)
do i=2,imap2-1
weight = aland(i,j)*abcgdx(i)*cosdy
anum = anum + weight
avg = avg + weight*sbcatm(i,j,m)
enddo
enddo
if (anum .ne. c0) avg = avg/anum
fluxcor = avg*4.186e4
write (stdout,8400) fluxcor
endif
c
# ifdef trace_coupled_fluxes
write (stdout,*) ' ===> values on entering gosbc.F:'
call scope (sbcatm(1,1,m), imap2, imap2, jma, sbcname(m))
# endif
c
c-----------------------------------------------------------------------
c extrapolate values into land areas on the atmospheric grid
c to accomadate mismatches in ocean and atmospheric land masks
c when interpolating to ocean grid
c-----------------------------------------------------------------------
c
call extrap (sbcatm(1,1,m), aland, sor, res, imap2, jma, numpas
&, crits(m), sbcname(m), 2)
# ifdef trace_coupled_fluxes
write (stdout,*) ' ===> after extrapolating into land:'
call scope (sbcatm(1,1,m), imap2, imap2, jma, sbcname(m))
# endif
c
c-----------------------------------------------------------------------
c linearly interpolate to the ocean grid assuming the
c atmos grid is coarse relative to the ocean grid
c-----------------------------------------------------------------------
c
if (sbcname(m) .eq. ' taux ' .or.
& sbcname(m) .eq. ' tauy ') then
nc1 = nc1 + 1
call ctf (sbcatm(1,1,m), imap2, jma, abcgx, abcgy
&, sbcocn(1,1,m), imt, jmt, 2, imtm1, 2, jmt-1, xu, yu, nc1
&, work1, lenw)
else
nc2 = nc2 + 1
call ctf (sbcatm(1,1,m), imap2, jma, abcgx, abcgy
&, sbcocn(1,1,m), imt, jmt, 2, imtm1, 2, jmt-1, xt, yt, nc2
&, work2, lenw)
endif
c
do j=1,jmt
# ifdef cyclic
sbcocn(1,j,m) = sbcocn(imtm1,j,m)
sbcocn(imt,j,m) = sbcocn(2,j,m)
# else
sbcocn(1,j,m) = sbcocn(2,j,m)
sbcocn(imt,j,m) = sbcocn(imtm1,j,m)
# endif
enddo
c
do i=1,imt
sbcocn(i,jmt,m) = sbcocn(i,jmtm1,m)
sbcocn(i,1,m) = sbcocn(i,2,m)
enddo
c
# ifdef trace_coupled_fluxes
write (stdout,*) ' ===> after interpolating to "sbcocn":'
call scope (sbcocn(1,1,m), imt, imt, jmt, sbcname(m))
# endif
c
c-----------------------------------------------------------------------
c convert to units expected by ocean
c
c note: a westerly wind means taux is positive (toward the east)
c a southerly wind means tauy is positive (toward the north)
c a positive heat flux means the ocean is warming
c a positive fresh water flux means the ocean is getting
c fresher (less dense)
c-----------------------------------------------------------------------
c
do j=1,jmt
do i=1,imt
sbcocn(i,j,m) = coabc(m)*sbcocn(i,j,m)
enddo
enddo
# ifdef trace_coupled_fluxes
write (stdout,*) ' ===> after converting units:'
call scope (sbcocn(1,1,m), imt, imt, jmt, sbcname(m))
# endif
c
c-----------------------------------------------------------------------
c calculate averages of the ocean S.B.C.
c (the S.B.C. are assumed to be defined on the same grid as "kmt")
c-----------------------------------------------------------------------
c
average(m) = c0
anum = c0
do j=1,jmt
cosdy = cst(j)*dyt(j)
do i=2,imt-1
weight = min(kmt(i,j),1)*dxt(i)*cosdy
anum = anum + weight
average(m) = average(m) + weight*sbcocn(i,j,m)
enddo
enddo
if (anum .ne. c0) average(m) = average(m)/anum
c
enddo
c
c-----------------------------------------------------------------------
c show averages of the ocean boundary conditions
c-----------------------------------------------------------------------
c
write (stdout,9100)
do n=1,numosbc
m = mapsbc(n)
write (stdout,9200) m, sbcname(m), average(m), dunits(m)
if (sbcname(m) .eq. ' heat flux') then
c
c also show in units of watts/m**2
c
write (stdout,8500) average(m)*4.186e4, ' watts/m**2'
endif
if (sbcname(m) .eq. ' salt flux') then
c
c also so equivalent fresh water flux
c
write (stdout,8500) average(m)*86400.0/0.035, ' cm/day '
endif
enddo
c
write (stdout,9400)
call toc ('mom', 'get S.B.C. for ocean (gosbc)')
8400 format (1x,'Note: not removing a net imbalance of ',1pe14.7
&, 'watts/m**2',/,' from the atmospheric heat flux.')
8500 format (57x,1pe14.7,18x,a15)
8900 format (/,10x, ' ==> Getting ocean S.B.C.')
9100 format (/10x,' ==> S.B.C. averages for the ocean follow:'/)
9200 format (17x,'for S.B.C. #',i2,', the average ',a10,' is ',1pe14.7
&, 1x, ' after converting from ',a15)
9400 format (/10x,' ==> S.B.C. prepared for this ocean segment.'/)
#endif
return
end