H. 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 co- ordination 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: o 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. o Subscripts indicate the grid on which a field resides: atmosphere, ice, or ocean. o xa ; ya ; xi; yi, etc. are the component model grids. o 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. o The coupler stops when nstep = nstop. o 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). o The routines mrg-atm, mrg-ocn, etc. merge the various component fluxes into complete sets of input fluxes. o 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 ( xa , ya , ndaya) !_ recv initial atm+lnd data: spatial & temporal grid _ msg-icei ( xi, yi, ndayi) !_ recv initial ice data: spatial & temporal grid _ msg-ocni ( xo , yo , ndayo) !_ recv initial ocn data: spatial & temporal grid _ msg-atmr ( Saa , Sla , F aiaa ,F alaa ,F aoaa ) !_ recv atm+lnd (initial) state & output fluxes _ msg-icer ( Sii, F_ioii)__ !_ recv ice (initial) state & output fluxes _ msg-ocnr ( Soo , 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 aiaa , F alaa , F aoaa , F ioii, F iooo , F oxx o ) tcheck ( ) !_ verify time coordination _ DO WHILE ( nstepd < nstopd) _________ msg-ocns ( F oxx o ) !_ send daily avg fluxes to ocn _ P tavg-zero ( F oxx o = 0) !_ initialize daily avg partial sum _ DO n = 1; nspday albd-ice ( Sii) !_ impose diurnal cycle on ice albedos _ albd-ocn ( Soo ) !_ compute ocn albedos with diurnal cycle _ !_ redistribute radiation from atm based on albedo _ map-i2a ( Sii, Sia ) map-o2a ( Soo , Soa ) flx-cor1 ( Sia , Sla , Soa , F aiaa , F alaa , F aoaa ) !_ compute & map all atm/ice fluxes _ map-a2i ( Saa , Sai) flx-ai ( Sai, Sii, F aidi) map-i2a ( F aidi, F aida ) map-a2i ( F aiaa , F aiai) !_ compute & map all atm/ocn fluxes _ map-a2o ( Saa , Sao ) flx-ao ( Sao , Soo , F aodo ) map-o2a ( F aodo , F aoda ) map-a2o ( F aoaa , F aoao ) !_ merge atm inputs & send to atm _ mrg-atm ( F aida , F alla , F alda , F aoda , F axxa ) H-2 mrg-atm ( Sia , Sla , Soa , Sxa ) msg-atms ( F axxa , Sxa ) !_ compute & map all ice/ocn fluxes _ map-o2i ( F iooo , F iooi) map-i2o ( F ioii, F ioio ) map-o2i ( Soo , Soi) flx-io ( Sii, Soi, F iodi) map-i2o ( F iodi, F iodo ) !_ merge ice inputs & send_to_ice_model _ mrg-ice ( F aiai, F aidi, F ioo i, F iodi, F ixxi) msg-ices ( F ixxi) !_ merge ocn inputs, form daily avg partial sum _ mrg-ocn ( F aoao , FPaodo , F ioio , F iodo , F oxxo ) tavg-sum ( F oxxo , F oxx o ) diagnos ( ) !_ do diagnostic calculations _ history ( ) !_ write a history file _ msg-atmr ( Saa , Sla , F aiaa ,F alaa ,F aoaa ) !_ recv atm+lnd outputs _ msg-icer ( Sii, F ioii) !_ recv ice outputs _ END DO P _________ tavg-done ( F oxx o , F oxx o ) !_ form daily avg ocn fluxes _ ________ msg-ocnr ( Soo , F ioo o ) !_ recv ocn state & output fluxes _ nstepd = nstepd+1 !_ drv has advanced one day _ tcheck ( ) !_ verify time coordination _ ________ _________ restart-write ( F aiaa , F alaa , F aoaa , F ioii,F ioo o , 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