35 |
#ifdef ALLOW_EBM |
#ifdef ALLOW_EBM |
36 |
# include "EBM.h" |
# include "EBM.h" |
37 |
#endif |
#endif |
38 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
39 |
|
# include "tamc.h" |
40 |
|
# include "tamc_keys.h" |
41 |
|
#endif |
42 |
|
|
43 |
C === Routine arguments === |
C === Routine arguments === |
44 |
C myThid - Instance number for this innvocation of CALC_FORCING |
C myThid - Instance number for this innvocation of CALC_FORCING |
55 |
INTEGER bi, bj |
INTEGER bi, bj |
56 |
INTEGER i, j |
INTEGER i, j |
57 |
INTEGER no_so |
INTEGER no_so |
58 |
|
INTEGER iebmkey |
59 |
LOGICAL TOP_LAYER |
LOGICAL TOP_LAYER |
60 |
|
|
61 |
C-- Top layer only |
C-- Top layer only |
66 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
67 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
68 |
|
|
69 |
DO j=1,sNy |
#ifdef ALLOW_AUTODIFF_TAMC |
70 |
S(j,bj) = 0.0 |
act1 = bi - myBxLo(myThid) |
71 |
P2(j,bj) = 0.0 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
72 |
P4(j,bj) = 0.0 |
act2 = bj - myByLo(myThid) |
73 |
|
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
74 |
|
act3 = myThid - 1 |
75 |
|
max3 = nTx*nTy |
76 |
|
act4 = ikey_dynamics - 1 |
77 |
|
iebmkey = (act1 + 1) + act2*max1 |
78 |
|
& + act3*max1*max2 |
79 |
|
& + act4*max1*max2*max3 |
80 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
81 |
|
|
82 |
|
DO j=1-oLy,sNy+oLy |
83 |
|
DO i=1-oLx,sNx+oLx |
84 |
|
S(i,j,bj) = 0.0 |
85 |
|
P2(i,j,bj) = 0.0 |
86 |
|
P4(i,j,bj) = 0.0 |
87 |
|
ENDDO |
88 |
SW(j,bj) = 0.0 |
SW(j,bj) = 0.0 |
89 |
LW(j,bj) = 0.0 |
LW(j,bj) = 0.0 |
90 |
Hd(j,bj) = 0.0 |
Hd(j,bj) = 0.0 |
112 |
ReCountX(j,bj) = CountX(j,bj) + 1.0 |
ReCountX(j,bj) = CountX(j,bj) + 1.0 |
113 |
ENDIF |
ENDIF |
114 |
ENDDO |
ENDDO |
115 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
116 |
|
CADJ STORE ReCountX(:,bj) = comlev1_bibj, key=iebmkey, byte=isbyte |
117 |
|
#endif |
118 |
|
|
119 |
c===================================================== |
c===================================================== |
120 |
c Fit area-weighed averaged SST north/south of 34 |
c Fit area-weighed averaged SST north/south of 34 |
124 |
T_var(2) = SIN(lat(3)*deg2rad) - SIN(lat(2)*deg2rad) |
T_var(2) = SIN(lat(3)*deg2rad) - SIN(lat(2)*deg2rad) |
125 |
T_var(3) = SIN(lat(2)*deg2rad)**3. - SIN(lat(1)*deg2rad)**3. |
T_var(3) = SIN(lat(2)*deg2rad)**3. - SIN(lat(1)*deg2rad)**3. |
126 |
T_var(4) = SIN(lat(3)*deg2rad)**3. - SIN(lat(2)*deg2rad)**3. |
T_var(4) = SIN(lat(3)*deg2rad)**3. - SIN(lat(2)*deg2rad)**3. |
127 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
128 |
|
CADJ STORE T_var(:) = comlev1_bibj, key=iebmkey, byte=isbyte |
129 |
|
#endif |
130 |
|
|
131 |
c---------------------------------------- |
c---------------------------------------- |
132 |
c Southern hemisphere: |
c Southern hemisphere: |
159 |
c Magnitude of the heat and moisture transport at 35 N/S |
c Magnitude of the heat and moisture transport at 35 N/S |
160 |
c----------------------------------------------------------- |
c----------------------------------------------------------- |
161 |
|
|
162 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
163 |
|
CADJ STORE T35(:) = comlev1_bibj, key=iebmkey, byte=isbyte |
164 |
|
CADJ STORE DTDy35(:) = comlev1_bibj, key=iebmkey, byte=isbyte |
165 |
|
#endif |
166 |
|
|
167 |
DO no_so = 1, 2 |
DO no_so = 1, 2 |
168 |
gamma = -T35(no_so)*beta*Hw*Nw*Nw/ |
gamma = -T35(no_so)*beta*Hw*Nw*Nw/ |
198 |
c |
c |
199 |
DO j=1,sNy |
DO j=1,sNy |
200 |
DO i=1,sNx |
DO i=1,sNx |
201 |
|
C sin(lat) |
202 |
|
S(i,j,bj) = sin(yC(i,j,bi,bj)*deg2rad) |
203 |
|
C setup Legendre polynomials and derivatives |
204 |
|
P2(i,j,bj) = 0.5*(3.*S(i,j,bj)**2 - 1.) |
205 |
|
P4(i,j,bj) = 0.12*(35.*S(i,j,bj)**4 - 30.*S(i,j,bj)**2 + 3.) |
206 |
|
ENDDO |
207 |
|
ENDDO |
208 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
209 |
|
CADJ STORE S(:,:,bj) = comlev1_bibj, key=iebmkey, byte=isbyte |
210 |
|
CADJ STORE P2(:,:,bj) = comlev1_bibj, key=iebmkey, byte=isbyte |
211 |
|
CADJ STORE P4(:,:,bj) = comlev1_bibj, key=iebmkey, byte=isbyte |
212 |
|
#endif |
213 |
|
c |
214 |
|
DO j=1,sNy |
215 |
|
DO i=1,sNx |
216 |
|
|
217 |
IF (yC(i,j,bi,bj) .LT. 0.) THEN |
IF (yC(i,j,bi,bj) .LT. 0.) THEN |
218 |
no_so = 1 |
no_so = 1 |
219 |
ELSE |
ELSE |
220 |
no_so = 2 |
no_so = 2 |
221 |
ENDIF |
ENDIF |
|
C sin(lat) |
|
|
S(j,bj) = sin(yC(i,j,bi,bj)*deg2rad) |
|
|
C setup Legendre polynomials and derivatives |
|
|
P2(j,bj) = 0.5*(3.*S(j,bj)**2 - 1.) |
|
|
P4(j,bj) = 0.12*(35.*S(j,bj)**4 - 30.*S(j,bj)**2 + 3.) |
|
222 |
c net shortwave |
c net shortwave |
223 |
SW(j,bj) = 0.25*Q0*(1 + Q2*P2(j,bj))* |
SW(j,bj) = 0.25*Q0*(1 + Q2*P2(i,j,bj))* |
224 |
< (1 - A0 - A2*P2(j,bj) - A4*P4(j,bj) ) |
< (1 - A0 - A2*P2(i,j,bj) - A4*P4(i,j,bj) ) |
225 |
c temperature |
c temperature |
226 |
T(j,bj) = T0(no_so) + T2(no_so)*P2(j,bj) |
T(j,bj) = T0(no_so) + T2(no_so)*P2(i,j,bj) |
227 |
c net longwave |
c net longwave |
228 |
LW(j,bj) = LW0 + LW1*(T(j,bj)-t_mlt) |
LW(j,bj) = LW0 + LW1*(T(j,bj)-t_mlt) |
229 |
c climate change run, the parameter to change is DLW |
c climate change run, the parameter to change is DLW |
232 |
< (myTime-startTime)*3.215e-8*DLW |
< (myTime-startTime)*3.215e-8*DLW |
233 |
c < - 6.0 |
c < - 6.0 |
234 |
c < *75.0*0.0474* |
c < *75.0*0.0474* |
235 |
c < (-2.62*S(j,bj)**8 + 0.73*S(j,bj)**7 + |
c < (-2.62*S(i,j,bj)**8 + 0.73*S(i,j,bj)**7 + |
236 |
c < 4.82*S(j,bj)**6 - |
c < 4.82*S(i,j,bj)**6 - |
237 |
c < 1.12*S(j,bj)**5 - 2.69*S(j,bj)**4 + 0.47*S(j,bj)**3 + |
c < 1.12*S(i,j,bj)**5 - 2.69*S(i,j,bj)**4 + 0.47*S(i,j,bj)**3 + |
238 |
c < 0.51*S(j,bj)**2 - 0.05*S(j,bj)**1 + 0.17) |
c < 0.51*S(i,j,bj)**2 - 0.05*S(i,j,bj)**1 + 0.17) |
239 |
#endif |
#endif |
240 |
c fluxes at ocean/atmosphere interface |
c fluxes at ocean/atmosphere interface |
241 |
c Heat Flux = -Div(atmospheric heat transport) + SW - LW |
c Heat Flux = -Div(atmospheric heat transport) + SW - LW |
242 |
#ifdef EBM_VERSION_1BASIN |
#ifdef EBM_VERSION_1BASIN |
243 |
Qnet(i,j,bi,bj) = -1.0*( SW(j,bj) - LW(j,bj) - |
Qnet(i,j,bi,bj) = -1.0*( SW(j,bj) - LW(j,bj) - |
244 |
< Hd35(no_so)*( |
< Hd35(no_so)*( |
245 |
< 0.000728e4 - 0.00678e4*S(j,bj) + |
< 0.000728e4 - 0.00678e4*S(i,j,bj) + |
246 |
< 0.0955e4*S(j,bj)**2 + 0.0769e4*S(j,bj)**3 - |
< 0.0955e4*S(i,j,bj)**2 + 0.0769e4*S(i,j,bj)**3 - |
247 |
< 0.8508e4*S(j,bj)**4 - 0.3581e4*S(j,bj)**5 + |
< 0.8508e4*S(i,j,bj)**4 - 0.3581e4*S(i,j,bj)**5 + |
248 |
< 2.9240e4*S(j,bj)**6 + 0.8311e4*S(j,bj)**7 - |
< 2.9240e4*S(i,j,bj)**6 + 0.8311e4*S(i,j,bj)**7 - |
249 |
< 4.9548e4*S(j,bj)**8 - 0.8808e4*S(j,bj)**9 + |
< 4.9548e4*S(i,j,bj)**8 - 0.8808e4*S(i,j,bj)**9 + |
250 |
< 4.0644e4*S(j,bj)**10 +0.3409e4*S(j,bj)**11 - |
< 4.0644e4*S(i,j,bj)**10 +0.3409e4*S(i,j,bj)**11 - |
251 |
< 1.2893e4*S(j,bj)**12 ) |
< 1.2893e4*S(i,j,bj)**12 ) |
252 |
< /(2*PI*rSphere*rSphere*25.0) ) |
< /(2*PI*rSphere*rSphere*25.0) ) |
253 |
c Qnet(i,j,bi,bj) = -1.0*( SW(j,bj) - LW(j,bj) - |
c Qnet(i,j,bi,bj) = -1.0*( SW(j,bj) - LW(j,bj) - |
254 |
c < 0.5*Hd35(no_so)*(3.054e1 - 3.763e1*S(j,bj) + |
c < 0.5*Hd35(no_so)*(3.054e1 - 3.763e1*S(i,j,bj) + |
255 |
c < 1.892e2*S(j,bj)**2 + 3.041e2*S(j,bj)**3 - |
c < 1.892e2*S(i,j,bj)**2 + 3.041e2*S(i,j,bj)**3 - |
256 |
c < 1.540e3*S(j,bj)**4 - 9.586e2*S(j,bj)**5 + |
c < 1.540e3*S(i,j,bj)**4 - 9.586e2*S(i,j,bj)**5 + |
257 |
c < 2.939e3*S(j,bj)**6 + 1.219e3*S(j,bj)**7 - |
c < 2.939e3*S(i,j,bj)**6 + 1.219e3*S(i,j,bj)**7 - |
258 |
c < 2.550e3*S(j,bj)**8 - 5.396e2*S(j,bj)**9 + |
c < 2.550e3*S(i,j,bj)**8 - 5.396e2*S(i,j,bj)**9 + |
259 |
c < 8.119e2*S(j,bj)**10) |
c < 8.119e2*S(i,j,bj)**10) |
260 |
c < /(2*PI*rSphere*rSphere*22.3) ) |
c < /(2*PI*rSphere*rSphere*22.3) ) |
261 |
#else |
#else |
262 |
IF (ReCountX(j,bj) .GT. 0.) THEN |
IF (ReCountX(j,bj) .GT. 0.) THEN |
263 |
Qnet(i,j,bi,bj) = (-90./ReCountX(j,bj))* |
Qnet(i,j,bi,bj) = (-90./ReCountX(j,bj))* |
264 |
< ( SW(j,bj) - LW(j,bj) - |
< ( SW(j,bj) - LW(j,bj) - |
265 |
< Hd35(no_so)*(3.054e1 - 3.763e1*S(j,bj) + |
< Hd35(no_so)*(3.054e1 - 3.763e1*S(i,j,bj) + |
266 |
< 1.892e2*S(j,bj)**2 + 3.041e2*S(j,bj)**3 - |
< 1.892e2*S(i,j,bj)**2 + 3.041e2*S(i,j,bj)**3 - |
267 |
< 1.540e3*S(j,bj)**4 - 9.586e2*S(j,bj)**5 + |
< 1.540e3*S(i,j,bj)**4 - 9.586e2*S(i,j,bj)**5 + |
268 |
< 2.939e3*S(j,bj)**6 + 1.219e3*S(j,bj)**7 - |
< 2.939e3*S(i,j,bj)**6 + 1.219e3*S(i,j,bj)**7 - |
269 |
< 2.550e3*S(j,bj)**8 - 5.396e2*S(j,bj)**9 + |
< 2.550e3*S(i,j,bj)**8 - 5.396e2*S(i,j,bj)**9 + |
270 |
< 8.119e2*S(j,bj)**10) |
< 8.119e2*S(i,j,bj)**10) |
271 |
< /(2*PI*rSphere*rSphere*22.3) ) |
< /(2*PI*rSphere*rSphere*22.3) ) |
272 |
ELSE |
ELSE |
273 |
Qnet(i,j,bi,bj) = 0. |
Qnet(i,j,bi,bj) = 0. |
277 |
c--- conversion of E-P from kg/(s m^2) -> m/s -> psu/s: 1e-3*35/delZ(1) |
c--- conversion of E-P from kg/(s m^2) -> m/s -> psu/s: 1e-3*35/delZ(1) |
278 |
#ifdef EBM_VERSION_1BASIN |
#ifdef EBM_VERSION_1BASIN |
279 |
EmPmR(i,j,bi,bj) = -1.e-3*Fw35(no_so) |
EmPmR(i,j,bi,bj) = -1.e-3*Fw35(no_so) |
280 |
< *(-0.8454e5*S(j,bj)**14 + 0.5367e5*S(j,bj)**13 |
< *(-0.8454e5*S(i,j,bj)**14 + 0.5367e5*S(i,j,bj)**13 |
281 |
< +3.3173e5*S(j,bj)**12 - 1.8965e5*S(j,bj)**11 |
< +3.3173e5*S(i,j,bj)**12 - 1.8965e5*S(i,j,bj)**11 |
282 |
< -5.1701e5*S(j,bj)**10 |
< -5.1701e5*S(i,j,bj)**10 |
283 |
< +2.6240e5*S(j,bj)**9 + 4.077e5*S(j,bj)**8 - 1.791e5*S(j,bj)**7 |
< +2.6240e5*S(i,j,bj)**9 + 4.077e5*S(i,j,bj)**8 |
284 |
< -1.7231e5*S(j,bj)**6 + 0.6229e5*S(j,bj)**5 |
< -1.791e5*S(i,j,bj)**7 |
285 |
< +0.3824e5*S(j,bj)**4 |
< -1.7231e5*S(i,j,bj)**6 + 0.6229e5*S(i,j,bj)**5 |
286 |
< -0.1017e5*S(j,bj)**3 - 0.0387e5*S(j,bj)**2 |
< +0.3824e5*S(i,j,bj)**4 |
287 |
< +0.00562e5*S(j,bj) + 0.0007743e5) |
< -0.1017e5*S(i,j,bj)**3 - 0.0387e5*S(i,j,bj)**2 |
288 |
|
< +0.00562e5*S(i,j,bj) + 0.0007743e5) |
289 |
< /(2.0*12.0*PI*rSphere*rSphere) |
< /(2.0*12.0*PI*rSphere*rSphere) |
290 |
c EmPmR(i,j,bi,bj) = 1.e-3*Fw35(no_so) |
c EmPmR(i,j,bi,bj) = 1.e-3*Fw35(no_so) |
291 |
c < *(50.0 + 228.0*S(j,bj) -1.593e3*S(j,bj)**2 |
c < *(50.0 + 228.0*S(i,j,bj) -1.593e3*S(i,j,bj)**2 |
292 |
c < - 2.127e3*S(j,bj)**3 + 7.3e3*S(j,bj)**4 |
c < - 2.127e3*S(i,j,bj)**3 + 7.3e3*S(i,j,bj)**4 |
293 |
c < + 5.799e3*S(j,bj)**5 - 1.232e4*S(j,bj)**6 |
c < + 5.799e3*S(i,j,bj)**5 - 1.232e4*S(i,j,bj)**6 |
294 |
c < - 6.389e3*S(j,bj)**7 + 9.123e3*S(j,bj)**8 |
c < - 6.389e3*S(i,j,bj)**7 + 9.123e3*S(i,j,bj)**8 |
295 |
c < + 2.495e3*S(j,bj)**9 - 2.567e3*S(j,bj)**10) |
c < + 2.495e3*S(i,j,bj)**9 - 2.567e3*S(i,j,bj)**10) |
296 |
c < /(2*PI*rSphere*rSphere*15.0) |
c < /(2*PI*rSphere*rSphere*15.0) |
297 |
#else |
#else |
298 |
IF (yC(i,j,bi,bj) .LT. -40.) THEN |
IF (yC(i,j,bi,bj) .LT. -40.) THEN |
299 |
c-- Southern Hemisphere |
c-- Southern Hemisphere |
300 |
EmPmR(i,j,bi,bj) = -1.e-3*(Fw35(no_so)* |
EmPmR(i,j,bi,bj) = -1.e-3*(Fw35(no_so)* |
301 |
< (-6.5 + 35.3 + 71.7*S(j,bj) |
< (-6.5 + 35.3 + 71.7*S(i,j,bj) |
302 |
< - 1336.3*S(j,bj)**2 - 425.8*S(j,bj)**3 |
< - 1336.3*S(i,j,bj)**2 - 425.8*S(i,j,bj)**3 |
303 |
< + 5434.8*S(j,bj)**4 + 707.9*S(j,bj)**5 |
< + 5434.8*S(i,j,bj)**4 + 707.9*S(i,j,bj)**5 |
304 |
< - 6987.7*S(j,bj)**6 - 360.4*S(j,bj)**7 |
< - 6987.7*S(i,j,bj)**6 - 360.4*S(i,j,bj)**7 |
305 |
< + 2855.0*S(j,bj)**8) |
< + 2855.0*S(i,j,bj)**8) |
306 |
< /(2*PI*rSphere*rSphere*18.0)) |
< /(2*PI*rSphere*rSphere*18.0)) |
307 |
ELSE |
ELSE |
308 |
c-- Atlantic |
c-- Atlantic |
309 |
IF (xC(i,j,bi,bj) .GT. 284. |
IF (xC(i,j,bi,bj) .GT. 284. |
310 |
< .OR. xC(i,j,bi,bj) .LT. 28.) THEN |
< .OR. xC(i,j,bi,bj) .LT. 28.) THEN |
311 |
EmPmR(i,j,bi,bj) = -1.e-3*(Fw35(no_so)* |
EmPmR(i,j,bi,bj) = -1.e-3*(Fw35(no_so)* |
312 |
< (-6.5 -2.878 + 3.157e2*S(j,bj) - |
< (-6.5 -2.878 + 3.157e2*S(i,j,bj) - |
313 |
< 2.388e3*S(j,bj)**2 - 4.101e3*S(j,bj)**3 + |
< 2.388e3*S(i,j,bj)**2 - 4.101e3*S(i,j,bj)**3 + |
314 |
< 1.963e4*S(j,bj)**4 + 1.534e4*S(j,bj)**5 - |
< 1.963e4*S(i,j,bj)**4 + 1.534e4*S(i,j,bj)**5 - |
315 |
< 6.556e4*S(j,bj)**6 - 2.478e4*S(j,bj)**7 + |
< 6.556e4*S(i,j,bj)**6 - 2.478e4*S(i,j,bj)**7 + |
316 |
< 1.083e5*S(j,bj)**8 + 1.85e4*S(j,bj)**9 - |
< 1.083e5*S(i,j,bj)**8 + 1.85e4*S(i,j,bj)**9 - |
317 |
< 8.703e4*S(j,bj)**10 - 5.276e3*S(j,bj)**11 + |
< 8.703e4*S(i,j,bj)**10 - 5.276e3*S(i,j,bj)**11 + |
318 |
< 2.703e4*S(j,bj)**12) |
< 2.703e4*S(i,j,bj)**12) |
319 |
< /(2*PI*rSphere*rSphere*12.0)) |
< /(2*PI*rSphere*rSphere*12.0)) |
320 |
ELSE |
ELSE |
321 |
c-- Pacific |
c-- Pacific |
322 |
EmPmR(i,j,bi,bj) = -1.e-3*(Fw35(no_so) |
EmPmR(i,j,bi,bj) = -1.e-3*(Fw35(no_so) |
323 |
< *(-6.5 +51.89 + 4.916e2*S(j,bj) - |
< *(-6.5 +51.89 + 4.916e2*S(i,j,bj) - |
324 |
< 1.041e3*S(j,bj)**2 - 7.546e3*S(j,bj)**3 + |
< 1.041e3*S(i,j,bj)**2 - 7.546e3*S(i,j,bj)**3 + |
325 |
< 2.335e3*S(j,bj)**4 + 3.449e4*S(j,bj)**5 + |
< 2.335e3*S(i,j,bj)**4 + 3.449e4*S(i,j,bj)**5 + |
326 |
< 6.702e3*S(j,bj)**6 - 6.601e4*S(j,bj)**7 - |
< 6.702e3*S(i,j,bj)**6 - 6.601e4*S(i,j,bj)**7 - |
327 |
< 2.594e4*S(j,bj)**8 + 5.652e4*S(j,bj)**9 + |
< 2.594e4*S(i,j,bj)**8 + 5.652e4*S(i,j,bj)**9 + |
328 |
< 2.738e4*S(j,bj)**10 - 1.795e4*S(j,bj)**11 - |
< 2.738e4*S(i,j,bj)**10 - 1.795e4*S(i,j,bj)**11 - |
329 |
< 9.486e3*S(j,bj)**12) |
< 9.486e3*S(i,j,bj)**12) |
330 |
< /(2*PI*rSphere*rSphere*12.0)) |
< /(2*PI*rSphere*rSphere*12.0)) |
331 |
ENDIF |
ENDIF |
332 |
ENDIF |
ENDIF |