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