Skip to content

Diagnostic routines to quantify the drivers of air-sea CO2 fluxes in an ocean biogeochemistry model

License

Notifications You must be signed in to change notification settings

seamanticscience/Lauderdale_etal_2016_GBC

Repository files navigation

CO2 Flux diagnostic routines from Lauderdale_etal_2016_GBC

DOI GitHub release (latest by date) GitHub release date GitHub License Link to paper at http://doi.org/10.1002/2016GB005400

Calculate CO2 flux diagnostics from a steady-state model following the paper "Quantifying the drivers of ocean-atmosphere CO2 fluxes" by Jonathan Lauderdale, Stephanie Dutkiewicz, Ric Williams and Mick Follows in Global Biogeochemical Cycles. Please cite this paper (link in the badge) if you find these tools of use in your research.

The framework evaluates the interplay between:

  1. Surface heat and freshwater fluxes that influence the potential saturated carbon concentration, which depends on changes in sea surface temperature, salinity and alkalinity,
  2. A residual, disequilibrium flux influenced by upwelling and entrainment of remineralized carbon- and nutrient-rich waters from the ocean interior, as well as rapid subduction of surface waters,
  3. Carbon uptake and export by biological activity as both soft tissue and carbonate, and
  4. The effect on surface carbon concentrations due to freshwater precipitation or evaporation.

In a steady state simulation of a coarse-resolution ocean circulation and biogeochemistry model, the sum of the individually determined components is close to the known total flux of the simulation.

Any questions or comments, please get in contact!

NEW: PYTHON Code (for v3.7)

See demonstrations in the Jupyter Notebooks CO2_Flux_Drivers_Online.ipynb and CO2_Flux_Drivers_Offline.ipynb!

Offline fluxes are calculated using the routines in the folder python-fortran-interface. Compile them with f2py to generate a python module:

>>f2py -c -m offline_flux_routines --verbose python-fortran-interface/offline_routines_python.F

MATLAB Code

Run cflux_diags.m to process the supplied model output, in turn co2_flux_steadystate.m is called to calculate the different components and plot budgets and fluxes.

There are a few options that can be changed in the cflux_diags driver routine, use mitgcm_fluxes and set vertmix to blank to reproduce the "online" fluxes (blue line in Figure 1d and the majority of the other plots in our paper). Use mitgcm_monthly and set vertmix to diffusion to calculate the "offline" flux (yellow line in Figure 1d). Vary kave to change the depth of vertical integration.

The model fields in model_kpp are 12x monthly averages of a 3 degree configuration of MITgcm - see our paper for more details.

There are two external dependencies:

  1. nc_isvar for checking variables in netcdf files, which is part of the mexcdf/snctools toolbox
  2. CO2SYS for solving the carbon system, which can be obtained from CDIAC

The MEX files, which enable interaction between MATLAB and FORTRAN routines for speedy calculation (in the folder matlab-fortran-interface), should be compiled for your system. They can then be called just like regular MATLAB functions (see the examples below). Note that faults caused by these routines can cause MATLAB to crash without notice. I tried to minimize this risk, but just dont run them if you have thesis data that you have spent a long time processing. They are compatible with 32- or 64-bit array sizes, which defaults to different settings depending on your version of MATLAB (groan). There are several checks that are run, including setting NaNs to zero in masked regions. However, if you are experiencing problems, you can compile the routines with the "-DDEBUG_MESSAGES" flag to get a whole load of verbose output.

Installing MEX components

Check your mex installation and compiler (see this Gist for help)

>> mex -v -setup FORTRAN
  • Offline advective flux code.
Usage: [uflux,vflux,wflux]=mit_advect_flux(advscheme,timestep,dx,dy,dz,rax,ray,rac,mask,uvel,vvel,wvel,field);
>> mex advection_flux.F
  • Offline explicit (GM) diffusive flux code.
Usage: [udiff,vdiff,wediff]=diffusion_flux(dx,dy,dz,umask,vmask,cmask,rax,ray,rac,kux,kuz,kvy,kvz,kwx,kwy,field);
>> mex diffusion_flux.F
  • Offline implicit diffusive flux code.
Usage: widiff=implicit_diffusion_flux(timestep,iterations,rac,dzf,dzc,cmask,diffkz,field);
>> mex implicit_diffusion_flux.F 
  • Routine to calculate vertically-integrated flux divergence.
Usage: [horz_div,vert_div]=calc_divergence(dz,vol,kave,mask,uflux,vflux,wflux);
>> mex calc_divergence.F
  • Routine to calculate vertically-integrated flux divergence using a larger footprint.
Usage: [horz_div,vert_div]=calc_smooth_divergence(dz,vol,kave,mask,uflux,vflux,wflux);
>> mex calc_smooth_divergence.F
  • Routine to integrate other properties vertically.
Usage: [integral_field]=integrate_vertically(dz,kave,mask,field);
>> mex integrate_vertically.F