1 |
C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_getforcing.F,v 1.38 2010/05/21 10:08:44 mlosch Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "EXF_OPTIONS.h" |
5 |
|
6 |
CBOI |
7 |
C |
8 |
C !TITLE: EXTERNAL FORCING |
9 |
C !AUTHORS: mitgcm developers ( support@mitgcm.org ) |
10 |
C !AFFILIATION: Massachussetts Institute of Technology |
11 |
C !DATE: |
12 |
C !INTRODUCTION: External forcing package |
13 |
c \bv |
14 |
c * The external forcing package, in conjunction with the |
15 |
c calendar package (cal), enables the handling of realistic forcing |
16 |
c fields of differing temporal forcing patterns. |
17 |
c * It comprises climatological restoring and relaxation |
18 |
c * Bulk formulae are implemented to convert atmospheric fields |
19 |
c to surface fluxes. |
20 |
c * An interpolation routine provides on-the-fly interpolation of |
21 |
c forcing fields an arbitrary grid onto the model grid. |
22 |
c * A list of EXF variables and units is in EXF_FIELDS.h |
23 |
c |
24 |
C !CALLING SEQUENCE: |
25 |
c ... |
26 |
c exf_getforcing (TOP LEVEL ROUTINE) |
27 |
c | |
28 |
c |-- exf_getclim (get climatological fields used e.g. for relax.) |
29 |
c | |--- exf_set_climtemp (relax. to 3-D temperature field) |
30 |
c | |--- exf_set_climsalt (relax. to 3-D salinity field) |
31 |
c | |--- exf_set_climsst (relax. to 2-D SST field) |
32 |
c | |--- exf_set_climsss (relax. to 2-D SSS field) |
33 |
c | o |
34 |
c | |
35 |
c |-- exf_getffields <- this one does almost everything |
36 |
c | | 1. reads in fields, either flux or atmos. state, |
37 |
c | | depending on CPP options (for each variable two fields |
38 |
c | | consecutive in time are read in and interpolated onto |
39 |
c | | current time step). |
40 |
c | | 2. If forcing is atmos. state and control is atmos. state, |
41 |
c | | then the control variable anomalies are read here |
42 |
c | | * ctrl_getatemp |
43 |
c | | * ctrl_getaqh |
44 |
c | | * ctrl_getuwind |
45 |
c | | * ctrl_getvwind |
46 |
c | | If forcing and control are fluxes, then |
47 |
c | | controls are added later. |
48 |
c | o |
49 |
c | |
50 |
c |-- exf_check_range |
51 |
c | | 1. Check whether read fields are within assumed range |
52 |
c | | (may capture mismatches in units) |
53 |
c | o |
54 |
c | |
55 |
c |-- exf_bulkformulae |
56 |
c | | 1. Compute net or downwelling radiative fluxes via |
57 |
c | | Stefan-Boltzmann law in case only one is known. |
58 |
c | | 2. Compute air-sea momentum and buoyancy fluxes from |
59 |
c | | atmospheric state following Large and Pond, JPO, 1981/82 |
60 |
c | o |
61 |
c | |
62 |
c |-- < add time-mean river runoff here, if available > |
63 |
c | |
64 |
c |-- < update tile edges here > |
65 |
c | |
66 |
c |-- exf_getsurfacefluxes |
67 |
c | | 1. If forcing and control are fluxes, then |
68 |
c | | controls are added here. |
69 |
c | o |
70 |
c | |
71 |
c |-- < treatment of hflux w.r.t. swflux > |
72 |
c | |
73 |
c |-- exf_diagnostics_fill |
74 |
c | | 1. Do EXF-related diagnostics output here. |
75 |
c | o |
76 |
c | |
77 |
c |-- exf_mapfields |
78 |
c | | 1. Map the EXF variables onto the core MITgcm |
79 |
c | | forcing fields. |
80 |
c | o |
81 |
c | |
82 |
c |-- exf_bulkformulae |
83 |
c | If ALLOW_BULKFORMULAE, compute fluxes via bulkformulae |
84 |
c | |
85 |
c |-- exf_getsurfacefluxes |
86 |
c | If forcing and control is flux, then the |
87 |
c | control vector anomalies are read here |
88 |
c | * ctrl_getheatflux |
89 |
c | * ctrl_getsaltflux |
90 |
c | * ctrl_getzonstress |
91 |
c | * call ctrl_getmerstress |
92 |
c | |
93 |
c |-- exf_mapfields |
94 |
c | Forcing fields from exf package are mapped onto |
95 |
c | mitgcm forcing arrays. |
96 |
c | Mapping enables a runtime rescaling of fields |
97 |
c |
98 |
c \ev |
99 |
CEOI |
100 |
|
101 |
CBOP |
102 |
C !ROUTINE: exf_getforcing |
103 |
C !INTERFACE: |
104 |
subroutine exf_getforcing( mytime, myiter, mythid ) |
105 |
|
106 |
C !DESCRIPTION: \bv |
107 |
c *================================================================= |
108 |
c | SUBROUTINE exf_getforcing |
109 |
c *================================================================= |
110 |
c o Get the forcing fields for the current time step. The switches |
111 |
c for the inclusion of the individual forcing components have to |
112 |
c be set in EXF_OPTIONS.h (or ECCO_CPPOPTIONS.h). |
113 |
c A note on surface fluxes: |
114 |
c The MITgcm-UV vertical coordinate z is positive upward. |
115 |
c This implies that a positive flux is out of the ocean |
116 |
c model. However, the wind stress forcing is not treated |
117 |
c this way. A positive zonal wind stress accelerates the |
118 |
c model ocean towards the east. |
119 |
c started: eckert@mit.edu, heimbach@mit.edu, ralf@ocean.mit.edu |
120 |
c mods for pkg/seaice: menemenlis@jpl.nasa.gov 20-Dec-2002 |
121 |
c *================================================================= |
122 |
c | SUBROUTINE exf_getforcing |
123 |
c *================================================================= |
124 |
C \ev |
125 |
|
126 |
C !USES: |
127 |
implicit none |
128 |
|
129 |
#include "EEPARAMS.h" |
130 |
#include "SIZE.h" |
131 |
#include "PARAMS.h" |
132 |
#include "GRID.h" |
133 |
|
134 |
#include "EXF_PARAM.h" |
135 |
#include "EXF_FIELDS.h" |
136 |
#include "EXF_CONSTANTS.h" |
137 |
#ifdef ALLOW_AUTODIFF_TAMC |
138 |
# include "tamc.h" |
139 |
#endif |
140 |
|
141 |
c == global variables == |
142 |
|
143 |
C !INPUT/OUTPUT PARAMETERS: |
144 |
c == routine arguments == |
145 |
integer mythid |
146 |
integer myiter |
147 |
_RL mytime |
148 |
|
149 |
C !LOCAL VARIABLES: |
150 |
c == local variables == |
151 |
|
152 |
integer bi,bj |
153 |
integer i,j,k |
154 |
character*(max_len_mbuf) msgbuf |
155 |
|
156 |
c == end of interface == |
157 |
CEOP |
158 |
|
159 |
c Get values of climatological fields. |
160 |
call exf_getclim( mytime, myiter, mythid ) |
161 |
|
162 |
c Get the surface forcing fields. |
163 |
call exf_getffields( mytime, myiter, mythid ) |
164 |
#ifndef ALLOW_ATM_WIND |
165 |
IF ( stressIsOnCgrid .AND. ustressfile.NE.' ' |
166 |
& .AND. vstressfile.NE.' ' ) |
167 |
& CALL EXCH_UV_XY_RL( ustress, vstress, .TRUE., myThid ) |
168 |
#endif |
169 |
|
170 |
#ifdef ALLOW_AUTODIFF_TAMC |
171 |
# if (defined (ALLOW_AUTODIFF_MONITOR)) |
172 |
CALL EXF_ADJOINT_SNAPSHOTS( 2, myTime, myIter, myThid ) |
173 |
# endif |
174 |
#endif |
175 |
|
176 |
#ifdef ALLOW_BULKFORMULAE |
177 |
c Set radiative fluxes |
178 |
call exf_radiation( mytime, myiter, mythid ) |
179 |
|
180 |
# ifdef ALLOW_AUTODIFF_TAMC |
181 |
# ifndef ALLOW_ATM_WIND |
182 |
CADJ STORE ustress = comlev1, key=ikey_dynamics, kind=isbyte |
183 |
CADJ STORE vstress = comlev1, key=ikey_dynamics, kind=isbyte |
184 |
# else |
185 |
CADJ STORE uwind = comlev1, key=ikey_dynamics, kind=isbyte |
186 |
CADJ STORE vwind = comlev1, key=ikey_dynamics, kind=isbyte |
187 |
# endif |
188 |
CADJ STORE wspeed = comlev1, key=ikey_dynamics, kind=isbyte |
189 |
# endif |
190 |
c Set wind fields |
191 |
call exf_wind( mytime, myiter, mythid ) |
192 |
c Compute turbulent fluxes (and surface stress) from bulk formulae |
193 |
call exf_bulkformulae( mytime, myiter, mythid ) |
194 |
#endif |
195 |
|
196 |
c Apply runoff, masks and exchanges |
197 |
do bj = mybylo(mythid),mybyhi(mythid) |
198 |
do bi = mybxlo(mythid),mybxhi(mythid) |
199 |
k = 1 |
200 |
do j = 1,sny |
201 |
do i = 1,snx |
202 |
#ifdef ALLOW_ATM_TEMP |
203 |
c Net surface heat flux. |
204 |
hflux(i,j,bi,bj) = |
205 |
& - hs(i,j,bi,bj) |
206 |
& - hl(i,j,bi,bj) |
207 |
& + lwflux(i,j,bi,bj) |
208 |
#ifndef SHORTWAVE_HEATING |
209 |
& + swflux(i,j,bi,bj) |
210 |
#endif |
211 |
c Salt flux from Precipitation and Evaporation. |
212 |
sflux(i,j,bi,bj) = evap(i,j,bi,bj) - precip(i,j,bi,bj) |
213 |
#endif /* ALLOW_ATM_TEMP */ |
214 |
#ifdef ALLOW_RUNOFF |
215 |
sflux(i,j,bi,bj) = sflux(i,j,bi,bj) - runoff(i,j,bi,bj) |
216 |
#endif |
217 |
|
218 |
hflux(i,j,bi,bj) = hflux(i,j,bi,bj)*maskC(i,j,1,bi,bj) |
219 |
sflux(i,j,bi,bj) = sflux(i,j,bi,bj)*maskC(i,j,1,bi,bj) |
220 |
enddo |
221 |
enddo |
222 |
enddo |
223 |
enddo |
224 |
|
225 |
c Update the tile edges. |
226 |
_EXCH_XY_RL(hflux, mythid) |
227 |
_EXCH_XY_RL(sflux, mythid) |
228 |
IF ( stressIsOnCgrid ) THEN |
229 |
CALL EXCH_UV_XY_RL( ustress, vstress, .TRUE., myThid ) |
230 |
ELSE |
231 |
CALL EXCH_UV_AGRID_3D_RL(ustress, vstress, .TRUE., 1, myThid) |
232 |
ENDIF |
233 |
#ifdef SHORTWAVE_HEATING |
234 |
_EXCH_XY_RL(swflux, mythid) |
235 |
#endif |
236 |
#ifdef ATMOSPHERIC_LOADING |
237 |
_EXCH_XY_RL(apressure, mythid) |
238 |
#endif |
239 |
#ifdef ALLOW_ICE_AREAMASK |
240 |
_EXCH_XY_RL(areamask, mythid) |
241 |
#endif |
242 |
|
243 |
c Get values of the surface flux anomalies. |
244 |
call exf_getsurfacefluxes( mytime, myiter, mythid ) |
245 |
|
246 |
if ( useExfCheckRange .AND. |
247 |
& ( myiter.EQ.nIter0 .OR. debugLevel.GE.debLevC ) ) then |
248 |
call exf_check_range( mytime, myiter, mythid ) |
249 |
endif |
250 |
|
251 |
#ifdef ALLOW_AUTODIFF_TAMC |
252 |
# if (defined (ALLOW_AUTODIFF_MONITOR)) |
253 |
CALL EXF_ADJOINT_SNAPSHOTS( 1, myTime, myIter, myThid ) |
254 |
# endif |
255 |
#endif |
256 |
|
257 |
#ifdef SHORTWAVE_HEATING |
258 |
c Treatment of qnet |
259 |
c The location of te summation of Qnet in exf_mapfields is unfortunate. |
260 |
c For backward compatibility issues we want it to happen after |
261 |
c applying control variables, but before exf_diagnostics_fill. |
262 |
c Therefore, we do it exactly here: |
263 |
do bj = mybylo(mythid),mybyhi(mythid) |
264 |
do bi = mybxlo(mythid),mybxhi(mythid) |
265 |
do j = 1-oLy,sNy+oLy |
266 |
do i = 1-oLx,sNx+oLx |
267 |
hflux(i,j,bi,bj) = hflux(i,j,bi,bj) + swflux(i,j,bi,bj) |
268 |
enddo |
269 |
enddo |
270 |
enddo |
271 |
enddo |
272 |
#endif |
273 |
|
274 |
c Diagnostics output |
275 |
call exf_diagnostics_fill( mytime, myiter, mythid ) |
276 |
|
277 |
c Monitor output |
278 |
call exf_monitor( mytime, myiter, mythid ) |
279 |
|
280 |
c Map the forcing fields onto the corresponding model fields. |
281 |
call exf_mapfields( mytime, myiter, mythid ) |
282 |
|
283 |
#ifdef ALLOW_AUTODIFF_TAMC |
284 |
# if (defined (ALLOW_AUTODIFF_MONITOR)) |
285 |
if ( .NOT. useSEAICE ) |
286 |
& CALL EXF_ADJOINT_SNAPSHOTS( 3, myTime, myIter, myThid ) |
287 |
# endif |
288 |
#endif |
289 |
|
290 |
end |
291 |
|