/[MITgcm]/MITgcm_contrib/dcarroll/highres_darwin/code/exf_getforcing2.F
ViewVC logotype

Contents of /MITgcm_contrib/dcarroll/highres_darwin/code/exf_getforcing2.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Sun Sep 22 21:23:46 2019 UTC (5 years, 10 months ago) by dcarroll
Branch: MAIN
CVS Tags: HEAD
Initial check in of high resolution Darwin simulation code

1 C $Header: /u/gcmpack/MITgcm_contrib/ecco_darwin/v4_llc270/code_darwin/exf_getforcing2.F,v 1.1 2017/12/01 19:02:11 dimitri 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 | | Check whether read fields are within assumed range
55 C | | (may capture mismatches in units)
56 C | o
57 C |
58 C |-- EXF_RADIATION
59 C | | Compute net or downwelling radiative fluxes via
60 C | | Stefan-Boltzmann law in case only one is known.
61 C |-- EXF_WIND
62 C | | Compute air-sea wind-stress from winds (or the other way)
63 C |-- EXF_BULKFORMULAE
64 C | | Compute air-sea buoyancy fluxes from atmospheric
65 C | | state following Large and Pond, JPO, 1981/82
66 C | o
67 C |
68 C |-- < add time-mean river runoff here, if available >
69 C |
70 C |-- < update tile edges here >
71 C |
72 C |-- EXF_GETSURFACEFLUXES
73 C | | If forcing and control are fluxes, then
74 C | | control vector anomalies are added here.
75 C | |--- ctrl_get_gen
76 C | o
77 C |
78 C |-- < treatment of hflux w.r.t. swflux >
79 C |
80 C |-- EXF_DIAGNOSTICS_FILL
81 C | | Do EXF-related diagnostics output here.
82 C |-- EXF_MONITOR
83 C | | Monitor EXF-forcing fields
84 C | o
85 C |
86 C |-- EXF_MAPFIELDS
87 C | | Forcing fields from exf package are mapped onto
88 C | | mitgcm forcing arrays.
89 C | | Mapping enables a runtime rescaling of fields
90 C | o
91 C
92 C \ev
93 CEOI
94
95 CBOP
96 C !ROUTINE: EXF_GETFORCING
97 C !INTERFACE:
98 SUBROUTINE EXF_GETFORCING2( myTime, myIter, myThid )
99
100 C !DESCRIPTION: \bv
101 C *=================================================================
102 C | SUBROUTINE EXF_GETFORCING
103 C *=================================================================
104 C o Get the forcing fields for the current time step. The switches
105 C for the inclusion of the individual forcing components have to
106 C be set in EXF_OPTIONS.h (or ECCO_CPPOPTIONS.h).
107 C A note on surface fluxes:
108 C The MITgcm-UV vertical coordinate z is positive upward.
109 C This implies that a positive flux is out of the ocean
110 C model. However, the wind stress forcing is not treated
111 C this way. A positive zonal wind stress accelerates the
112 C model ocean towards the east.
113 C started: eckert@mit.edu, heimbach@mit.edu, ralf@ocean.mit.edu
114 C mods for pkg/seaice: menemenlis@jpl.nasa.gov 20-Dec-2002
115 C *=================================================================
116 C | SUBROUTINE EXF_GETFORCING
117 C *=================================================================
118 C \ev
119
120 C !USES:
121 IMPLICIT NONE
122
123 C == global variables ==
124 #include "EEPARAMS.h"
125 #include "SIZE.h"
126 #include "PARAMS.h"
127 #include "GRID.h"
128
129 #include "EXF_PARAM.h"
130 #include "EXF_FIELDS.h"
131 #include "EXF_CONSTANTS.h"
132 #ifdef ALLOW_AUTODIFF_TAMC
133 # include "tamc.h"
134 #endif
135
136 C !INPUT/OUTPUT PARAMETERS:
137 C == routine arguments ==
138 _RL myTime
139 INTEGER myIter
140 INTEGER myThid
141
142 C !LOCAL VARIABLES:
143 C == local variables ==
144 INTEGER bi,bj
145 INTEGER i,j,k
146 C == end of interface ==
147 CEOP
148
149 C Get values of climatological fields.
150 CALL EXF_GETCLIM( myTime, myIter, myThid )
151
152 #ifdef ALLOW_AUTODIFF_TAMC
153 # ifdef ALLOW_ATM_TEMP
154 CADJ STORE precip0 = comlev1, key=ikey_dynamics, kind=isbyte
155 CADJ STORE precip1 = comlev1, key=ikey_dynamics, kind=isbyte
156 CADJ STORE snowprecip0 = comlev1, key=ikey_dynamics, kind=isbyte
157 CADJ STORE snowprecip1 = comlev1, key=ikey_dynamics, kind=isbyte
158 # endif
159 #endif
160 C Get the surface forcing fields.
161 CALL EXF_GETFFIELDS( myTime, myIter, myThid )
162 IF ( .NOT.useAtmWind ) THEN
163 IF ( stressIsOnCgrid .AND. ustressfile.NE.' '
164 & .AND. vstressfile.NE.' ' )
165 & CALL EXCH_UV_XY_RL( ustress, vstress, .TRUE., myThid )
166 ENDIF
167
168 #ifdef ALLOW_AUTODIFF_TAMC
169 # ifdef ALLOW_AUTODIFF_MONITOR
170 CALL EXF_ADJOINT_SNAPSHOTS( 2, myTime, myIter, myThid )
171 # endif
172 #endif
173
174 #ifdef ALLOW_DOWNWARD_RADIATION
175 C Set radiative fluxes
176 CALL EXF_RADIATION( myTime, myIter, myThid )
177 #endif
178
179 #ifdef ALLOW_AUTODIFF_TAMC
180 CADJ STORE ustress = comlev1, key=ikey_dynamics, kind=isbyte
181 CADJ STORE vstress = comlev1, key=ikey_dynamics, kind=isbyte
182 CADJ STORE uwind = comlev1, key=ikey_dynamics, kind=isbyte
183 CADJ STORE vwind = comlev1, key=ikey_dynamics, kind=isbyte
184 CADJ STORE wspeed = comlev1, key=ikey_dynamics, kind=isbyte
185 #endif
186 C Set wind fields
187 CALL EXF_WIND( myTime, myIter, myThid )
188
189 #ifdef ALLOW_ATM_TEMP
190 # ifdef ALLOW_BULKFORMULAE
191 # ifdef ALLOW_AUTODIFF_TAMC
192 CADJ STORE ustress = comlev1, key=ikey_dynamics, kind=isbyte
193 CADJ STORE vstress = comlev1, key=ikey_dynamics, kind=isbyte
194 CADJ STORE uwind = comlev1, key=ikey_dynamics, kind=isbyte
195 CADJ STORE vwind = comlev1, key=ikey_dynamics, kind=isbyte
196 CADJ STORE wspeed = comlev1, key=ikey_dynamics, kind=isbyte
197 # endif
198 C Compute turbulent fluxes (and surface stress) from bulk formulae
199 CALL EXF_BULKFORMULAE( myTime, myIter, myThid )
200 # endif /* ALLOW_BULKFORMULAE */
201 #endif /* ALLOW_ATM_TEMP */
202
203 DO bj = myByLo(myThid), myByHi(myThid)
204 DO bi = myBxLo(myThid), myBxHi(myThid)
205
206 #ifdef ALLOW_ATM_TEMP
207 C compute hflux & sflux from multiple components
208 DO j = 1,sNy
209 DO i = 1,sNx
210 C Net surface heat flux.
211 hflux(i,j,bi,bj) =
212 & - hs(i,j,bi,bj)
213 & - hl(i,j,bi,bj)
214 & + lwflux(i,j,bi,bj)
215 #ifndef SHORTWAVE_HEATING
216 & + swflux(i,j,bi,bj)
217 #endif
218 C fresh-water flux from Precipitation and Evaporation.
219 sflux(i,j,bi,bj) = evap(i,j,bi,bj) - precip(i,j,bi,bj)
220 ENDDO
221 ENDDO
222 #endif /* ALLOW_ATM_TEMP */
223
224 C Apply runoff, masks and exchanges
225 k = 1
226 DO j = 1,sNy
227 DO i = 1,sNx
228 #ifdef ALLOW_RUNOFF
229 sflux(i,j,bi,bj) = sflux(i,j,bi,bj) - runoff(i,j,bi,bj)
230 #endif
231 hflux(i,j,bi,bj) = hflux(i,j,bi,bj)*maskC(i,j,k,bi,bj)
232 sflux(i,j,bi,bj) = sflux(i,j,bi,bj)*maskC(i,j,k,bi,bj)
233 ENDDO
234 ENDDO
235
236 ENDDO
237 ENDDO
238
239 C Update the tile edges: needed for some EXF fields involved in horizontal
240 C averaging, e.g., wind-stress; fields used by main model or other pkgs
241 C are exchanged in EXF_MAPFIELDS.
242 c _EXCH_XY_RL(hflux, myThid)
243 c _EXCH_XY_RL(sflux, myThid)
244 IF ( stressIsOnCgrid ) THEN
245 CALL EXCH_UV_XY_RL( ustress, vstress, .TRUE., myThid )
246 ELSE
247 CALL EXCH_UV_AGRID_3D_RL(ustress, vstress, .TRUE., 1, myThid)
248 ENDIF
249 #ifdef SHORTWAVE_HEATING
250 c _EXCH_XY_RL(swflux, myThid)
251 #endif
252 #ifdef ATMOSPHERIC_LOADING
253 c _EXCH_XY_RL(apressure, myThid)
254 #endif
255 #ifdef EXF_SEAICE_FRACTION
256 c _EXCH_XY_RL(areamask, myThid)
257 #endif
258
259 C Get values of the surface flux anomalies.
260 CALL EXF_GETSURFACEFLUXES( myTime, myIter, myThid )
261
262 IF ( useExfCheckRange .AND.
263 & ( myIter.EQ.nIter0 .OR. exf_debugLev.GE.debLevC ) ) THEN
264 CALL EXF_CHECK_RANGE( myTime, myIter, myThid )
265 ENDIF
266
267 #ifdef ALLOW_AUTODIFF
268 # ifdef ALLOW_AUTODIFF_MONITOR
269 CALL EXF_ADJOINT_SNAPSHOTS( 1, myTime, myIter, myThid )
270 # endif
271 #endif /* ALLOW_AUTODIFF */
272
273 #ifdef ALLOW_ATM_TEMP
274 # ifdef SHORTWAVE_HEATING
275 C Treatment of qnet
276 C The location of the summation of Qnet in exf_mapfields is unfortunate:
277 C For backward compatibility issues we want it to happen after
278 C applying control variables, but before exf_diagnostics_fill.
279 C Therefore, we DO it exactly here:
280 DO bj = myByLo(myThid), myByHi(myThid)
281 DO bi = myBxLo(myThid), myBxHi(myThid)
282 DO j = 1-oLy,sNy+oLy
283 DO i = 1-oLx,sNx+oLx
284 hflux(i,j,bi,bj) = hflux(i,j,bi,bj) + swflux(i,j,bi,bj)
285 ENDDO
286 ENDDO
287 ENDDO
288 ENDDO
289 # endif /* SHORTWAVE_HEATING */
290 #endif /* ALLOW_ATM_TEMP */
291
292 C Diagnostics output
293 Cdc CALL EXF_DIAGNOSTICS_FILL( myTime, myIter, myThid )
294
295 C Monitor output
296 CALL EXF_MONITOR( myTime, myIter, myThid )
297
298 C Map the forcing fields onto the corresponding model fields.
299 CALL EXF_MAPFIELDS( myTime, myIter, myThid )
300
301 #ifdef ALLOW_AUTODIFF
302 # ifdef ALLOW_AUTODIFF_MONITOR
303 IF ( .NOT. useSEAICE )
304 & CALL EXF_ADJOINT_SNAPSHOTS( 3, myTime, myIter, myThid )
305 # endif
306 #endif /* ALLOW_AUTODIFF */
307
308 RETURN
309 END

  ViewVC Help
Powered by ViewVC 1.1.22