H. \underline{Pseudo-Code for the Flux Coupler}

To understand the more subtle points of the coupler’s functionality, it is useful to have a basic understanding of the computer code that is the Flux Coupler. To that end, pseudo-code is shown below. If one wishes to modify the coupler source code, it is strongly recommended that one first study this section in conjunction with studying the source code file, main.f. This should provide a good overview of how the coupler works; a necessary pre-requisite for successful code modification. The actual source code is written almost entirely using standard Fortran 77.

Notice that the Flux Coupler code is configured for a particular time coordination scheme: the ocean model is forced with daily average fluxes, the atmosphere, ice, and land models resolve a diurnal cycle, and the land model is embedded within the atmosphere model. While this configuration is hard-coded within the coupler, it’s modular design facilitates code modifications to implement alternate configurations. A variety of time coordination schemes can be, and have been, implemented simply by rearranging subroutine calls at the highest level within the main program file, requiring a minimal amount of code modifications or new code.

An explanation of some pseudo-code notation:

• An overbar indicates fluxes averaged over an outer loop synchronization interval: one day. Fluxes without an overbar are fluxes averaged over an inner loop synchronization interval. If an inner loop synchronization interval happens to coincide with one model time step, then we have a degenerate case of time averaging wherein fluxes averaged over an inner loop synchronization interval are actually the time average of only one time sample.

• Subscripts indicate the grid on which a field resides: atmosphere, ice, or ocean.

• x_{a}, y_{a}, x_{i}, y_{i}, etc. are the component model grids.

• nstep is incremented once per outer-loop iteration, once per day, nspday is the number of inner loop time steps per day. Models that do not resolve a diurnal cycle (in this example, the ocean model) communicate with the coupler once per day. Models that do resolve a diurnal cycle (the ice and atmosphere/land models), communicate with the coupler nspday times per day.

• The coupler stops when nstep = nstop.

• The routines map-o2i, map-a2i, etc., map state and flux fields between the various grids. Different mapping techniques are available. For example, when mapping state variables one might want to use an interpolation routine that preserves higher order derivatives, whereas when mapping flux fields one might use a conservative mapping technique (e.g., area averaging).

• The routines mrg-atm, mrg-ocn, etc. merge the various component fluxes into complete sets of input fluxes.

• The routines flx-io, flx-ai, etc. provide the fluxes computed in the coupler between component model pairs. All fluxes that are not model output fluxes are computed by the coupler in these routines.

H-1

PROGRAM driver

initial ( )  !— read input namelist —
msg-drvc ( )  !— connect drv to msg-passing environment —
msg-atmi ( x_{a}, y_{a}, ndaya)  !— recv initial atm+lnd data: spatial & temporal grid —
msg-icei ( x_{i}, y_{i}, ndayi)  !— recv initial ice data: spatial & temporal grid —
msg-ocni ( x_{o}, y_{o}, ndayo)  !— recv initial ocn data: spatial & temporal grid —
msg-atmr ( Sa_{a}, Sl_{a}, F aia_{a},F ala_{a},F aoa_{a}) !— recv atm+lnd (initial) state & output fluxes —
msg-icer ( Si_{i}, F ioi_{i})  !— recv ice (initial) state & output fluxes —
msg-ocnr ( So_{o}, \overline{F ioo}_{o})  !— recv ocn (initial) state & output fluxes —

!— acquire drv restart data: note that initial output fluxes from models are over-written —

restart-read ( F aia_{a}, F ala_{a}, F aoa_{a}, F ioi_{i}, F ioo_{o}, \overline{F oxx}_{o})

tcheck ( )  !— verify time coordination —

DO WHILE ( nstepd < nstopd)

msg-ocns ( \overline{F oxx}_{o})  !— send daily avg fluxes to ocn —
tavg-zero ( ∑ F oxx_{o}= 0)  !— initialize daily avg partial sum —

DO n = 1, nspday

albd-ice ( Si_{i})  !— impose diurnal cycle on ice albedos —
albd-ocn ( So_{o})  !— compute ocn albedos with diurnal cycle —

!— redistribute radiation from atm based on albedo — map-i2a ( Si_{i}, Si_{a}) map-o2a ( So_{o}, So_{a})

flx-cor1 ( Si_{a}, Sl_{a}, So_{a}, F aia_{a}, F ala_{a}, F aoa_{a})

!— compute & map all atm/ice fluxes — map-a2i ( Sa_{a}, Sa_{i}) flx-ai ( Sa_{i}, Si_{i}, F aid_{i}) map-i2a ( F aid_{i}, F aid_{a}) map-a2i ( F aia_{a}, F aia_{i})

!— compute & map all atm/ocn fluxes — map-a2o ( Sa_{a}, Sa_{o}) flx-ao ( Sa_{o}, So_{o}, F aod_{o}) map-o2a ( F aod_{o}, F aod_{a}) map-a2o ( F aoa_{a}, F aoa_{o})

!— merge atm inputs & send to atm —

mrg-atm ( F aid_{a}, F all_{a}, F ald_{a}, F aod_{a}, F axx_{a})

H-2

mrg-atm ( Si_{a}, Sl_{a}, So_{a}, Sx_{a}) msg-atms ( F axx_{a}, Sx_{a})

!— compute & map all ice/ocn fluxes — map-o2i ( F ioo_{o}, F ioo_{i}) map-i2o ( F ioi_{i}, F ioi_{o}) map-o2i ( So_{o}, So_{i}) flx-io ( Si_{i}, So_{i}, F iod_{i}) map-i2o ( F iod_{i}, F iod_{o})

!— merge ice inputs & send to ice model —

mrg-ice ( F aia_{i}, F aid_{i}, \overline{F ioo}_{i}, F iod_{i}, F ixx_{i})

msg-ices ( F ixx_{i})

!— merge ocn inputs, form daily avg partial sum —

mrg-ocn ( F aoa_{o}, F aod_{o}, F ioi_{o}, F iod_{o}, F oxx_{o})

tavg-sum ( F oxx_{o}, ∑ F oxx_{o})

diagnos ( ) !— do diagnostic calculations —
history ( )  !— write a history file —
msg-atmr ( Sa_{a}, Sl_{a}, F aia_{a},F ala_{a},F aoa_{a}) !— recv atm+lnd outputs —
msg-icer ( Si_{i}, F ioi_{i})  !— recv ice outputs —

END DO

tavg-done ( ∑ F oxx_{o}, \overline{F oxx}_{o}) !— form daily avg ocn fluxes —
msg-ocnr ( So_{o}, \overline{F ioo}_{o})  !— recv ocn state & output fluxes —
nstepd = nstepd+1  !— drv has advanced one day —
tcheck ( )  !— verify time coordination —

restart-write ( F aia_{a}, F ala_{a}, F aoa_{a}, F ioi_{i},\overline{F ioo}_{o}, \overline{F oxx}_{o}) !— make drv restart data — END DO

msg-atmf ( ) !— send final msg to atm —
msg-icef ( ) !— send final msg to ice —
msg-ocnf ( ) !— send final msg to ocn —
msg-drvd ( ) !— disconnect drv from msg-passing environment —

STOP

H-3