Upper Ocean 1-D Seasonal Models
File last modified 16 November 1998
19.3c Adding Gases to the Model: Running the Model
Like we said before, let's get on with it. Below are the m-files constituting the gas-enabled pwp model, which we've called pwpg.m. It contains most of the same m-files as the original, non-gas version of pwp, but some of the m-files are different, although they have the same name. Thus you must make a new directory separate from the original pwp directory to put these in. Do NOT mix the two sets of m-files or data sources. We will tell you a bit about the implementation so you have a basic understanding of how the model works. Bear in mind that the model runs take about 20 minutes per year (of model time) on a 100 MHz Pentium, so a full 3-4 year run would take in excess of an hour. We cannot predict how long it would take on Athena.
The component m-files and data sources are
Whew! That's getting complicated, but the basic code looks simple:
some code here to set Kz, and strengths of air injection, fc/fp and stochastic forcing strength
inifctr; % Initialize useful factors inihydro; % initialize water column profile inigas; % initialize water column gases % % Main time step loop % for it=1:nt T(1)=T(1)+thf(it); % add sensible + latent heat flux
S(1)=S(1)-FWFlux(it); % flux fresh water (latent/precip) T=T+rhf(it)*dRdz; % add radiant heat to profile dostins; % do static instability adjustment addmom; % add wind stress induced momentum dobrino; % do bulk Ri No Adjustment gasexch; % exchange gases dogrino; % do gradient Ri No Adjustment advdif; % advect and diffuse dooutg; % if time, save data end
The comments tell you what is going on.
One note: you'll find that we've done something slightly sleazy in computing the Schmidt numbers, solubilities and various other gas related factors. The actual, full precision calculations are multiparameter semi-thermodynamic formulae which involve logs and exponents. These are computationally very expensive, so we have done some simple quadratic/cubic polynomial fits of the appropriate parameters over the temperature range of interest (18-30 C), which fit the data to more than adequate precision. There is some fancy footwork in inigas.m to load the coefficients in from .mat files (so that we retain full precision) and the polynomial evaluation/expansion is done "on the fly" in gasexch.m using the MATLAB function polyval. This makes things a little obscure at the expense of some faster calculations, and sometimes you'll have to do this kind of thing.
GoTo Next Section