100% found this document useful (1 vote)
1K views20 pages

MEGAN Version3 - 1 B e Ta User Guide: Alex - Guenther@uci - Edu

This document provides an overview and user guide for MEGAN version 3.1, a model for estimating biogenic emissions of gases and aerosols from terrestrial ecosystems. MEGAN calculates emissions as the product of an emission factor and an environmental activity factor. It can be used for global and regional modeling at various spatial resolutions. The model estimates emissions of 201 chemical species based on how they respond to changes in land cover, weather, and atmospheric conditions. MEGAN has been continuously improved since the 1960s and is freely available online with documentation and input/output files to allow users to run the model.

Uploaded by

Euclides Martins
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views20 pages

MEGAN Version3 - 1 B e Ta User Guide: Alex - Guenther@uci - Edu

This document provides an overview and user guide for MEGAN version 3.1, a model for estimating biogenic emissions of gases and aerosols from terrestrial ecosystems. MEGAN calculates emissions as the product of an emission factor and an environmental activity factor. It can be used for global and regional modeling at various spatial resolutions. The model estimates emissions of 201 chemical species based on how they respond to changes in land cover, weather, and atmospheric conditions. MEGAN has been continuously improved since the 1960s and is freely available online with documentation and input/output files to allow users to run the model.

Uploaded by

Euclides Martins
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

MEGAN version3 .

1 be ta User Guide
Alex Guenther, University of California, Irvine ([email protected])
Ling Huang and Tejas Shaw, Ramboll
Xiaoyan Jiang, University of California, Irvine
Document Version August 31, 2019: see http://bai.ess.uci.edu/megan for updates.

CONTENTS
1. Introduction ........................................................................................................................................ 2
MEGAN Overview ................................................................................................................................ 2
MEGAN History..................................................................................................................................... 3
Getting Started with MEGAN .......................................................................................................... 4
MEGAN Software / Operating System Prerequisites............................................................. 5
Case Study .............................................................................................................................................. 5
How to use this document ............................................................................................................... 5
2. Input Data and Pre-Processor (Fortran code) ...................................................................... 6
Input Data: Weather........................................................................................................................... 6
Landcover, Emission Factor and Ozone Exposure Data....................................................... 7
Pre-processor Fortran Code ........................................................................................................... 7
3. Emisson Factor Processor (Python Code) ............................................................................ 10
Software and hardware requirements ..................................................................................... 10
Running the program ...................................................................................................................... 12
Input Files ............................................................................................................................................ 13
Program structure and modifications ....................................................................................... 15
4. Emisson Calculator (FORTRAN Code) .................................................................................... 17
Installing libraries ............................................................................................................................. 17
Building the code ............................................................................................................................... 17
Running the code............................................................................................................................... 19
5. Post Processing ............................................................................................................................... 20

1
1. INTRODUCTION

MEGAN Overview
The Model of Emissions of Gases and Aerosols from Nature (MEGAN) is designed to
quantify the emission of gases and aerosols from terrestrial ecosystems into the
atmosphere. This is usually done to generate inputs for specific chemical schemes in
chemistry and transport models used to investigate regional air quality and global climate.
MEGAN can also be used to investigate emissions of specific compounds including how
they change with specific scenarios. The vision for this open source and freely available
software is for the measurement and model user communities to contribute to this
community database, including both emissions and landcover data, to improve the future
accuracy of emission factors that will be available to all users.

Emissions of reactive gases and particles from terrestrial ecosystems, referred to here as
“biogenics” drive atmospheric distributions of several constituents relevant for air quality
and climate. Biogenic emissions tend to be highly variable and can vary more than an
order of magnitude over spatial scales of a few kilometers and time scales of less than a
day. This makes estimation of these emissions especially challenging and yet accurate
quantification and simulation of these fluxes is a necessary step towards developing
strategies for mitigating air pollution and climate change.

The MEGAN framework calculates biogenic emissions as the product of an emission


factor, that represents the capacity of a vegetation type to emit a compound, and an
emission activity factor that accounts for the response to changing environmental
conditions (see Figure 1). MEGAN is designed to be a flexible system that can be used for
both global and regional emissions modeling. Landcover data are available with global
coverage at 30 second spatial resolution (~ 1km2). Higher resolution data (e.g. 100 to 900
m2) are available for some regions. MEGAN uses simple mechanistic algorithms to
represent the response of emissions to the major controlling variables. Emissions of 201
chemical species are included in MEGAN3 and the model can output individual
compounds or categories associated with various atmospheric chemistry schemes. The
201 compounds are lumped into 20 categories based on emission responses to changes
in environmental conditions. Emission activities are estimated for the 20 categories and
then, depending on the option selected by the user, can be speciated into the 201
compounds or output in chemical categories associated with common atmospheric
chemistry schemes (e.g., CB05, CB6, CBMZ, S07, RACM, CRIv2-R5). Driving variables
include landcover, weather, and atmospheric chemical composition. The MEGAN code
and input files are available at no cost. Users Guides, code and input files are available for
download at URL bai.ess.uci.edu/megan.

2
Figure 1. Schematic of the MEGAN3 modeling system.

MEGAN3 inputs and intermediate files are in either ASCII or netcdf format. The native
outputs are in netcdf/ioapi format. MEGAN can be run on a number of 32bit or 64bit
LINUX/Unix operating systems. Users may need to make changes in compliers and
environmental settings to get it run on their own machines.

MEGAN History
Biogenic emission models date back to 1960 when Dr. Fritz Went (director of the Missouri
Botanical Garden) made a first attempt to quantify biogenic volatile organic compound
(BVOC) emissions into the atmosphere and estimated that the global annual emissions
from monoterpene emissions alone exceeded 100 million tons (Went 1960). Soon after,
Dr. Rei Rasmussen, a student of Dr. Went, discovered surprisingly high emissions of
isoprene from certain plants and spent the next decade convincing the scientific
community of this finding (Rasmussen 1970). Dr. Rasmussen then joined the faculty at
Washington State University where he developed the first regional estimates of isoprene
and monoterpenes from North America and collaborated on measurement studies with Dr.
Hal Westberg, Dr. Brian Lamb, and Pat Zimmerman and other pioneers in efforts to
develop quantitative BVOC emission estimates (Rasmussen 1972, Zimmerman 1978,
Lamb et al. 1983). In the mid-1980s, with support from NOAA for investigating "acid rain",
Drs Lamb and Westberg worked with graduate students Alex Guenther and David Gay to
extend the earlier work of Rasmussen and Zimmerman with a higher resolution and more
detailed US biogenic emission model (Lamb et al. 1987). In 1990, USEPA scientist Tom
Pierce used this biogenic emission model as the starting point for the BEIS, the Biogenic
Emission Inventory System (Pierce and Waldruff 1991). After graduating from WSU, Dr.
Guenther joined Zimmerman at the NSF sponsored National Center for Atmospheric
Research (NCAR) and developed global scale BVOC emission estimates (Guenther et al.
1995) that were used for the Global Emissions Inventory Activity (GEIA) led by Tom
Graedel of AT&T Bell Laboratories and quickly became a standard for global modeling.
NCAR and EPA scientists, including Pierce and Chris Geron, collaborated on improving
the BEIS model in the 1990s (Geron et al. 1994, Guenther et al. 1994, Pierce et al. 1998).

3
The Model of Emissions of Gases and Aerosol from Nature (MEGAN) version 1 was
developed in 2002 as a Microsoft ACCESS Visual Basic (VB) code by Alex Guenther for
internal use. The VB code development continued in a collaboration with Greg Yarwood
and other Environ scientists as the GLOBal Biogenic Emission System (GLOBEIS). The
VB code was converted into a "stand-alone" Fortran code in a collaboration between
NCAR and WSU by graduate student Jack Chen for use in regional air quality modeling
(Guenther et al., 2006). Guenther and colleagues continued to improve the model and the
"stand-alone" Fortran code was further updated by Tanarit Sakulyanontvittaya, then a PhD
student at University of Colorado. This version of the code (MEGAN v2.04,
Sakulyanontvittaya et al. 2008) was released publicly on October 29, 2007 along with the
driving variables required to run the model. In 2012, Guenther and colleagues support
primarily by EPA and NSF integrated new findings and improved parameters and driving
variables into a revised version, called MEGAN version 2.10 (Guenther et al., 2012). This
"stand-alone" Fortran code was updated by Professor Xuemei Wang (then at Sun-Yat Sen
University) and Tan Sakulyanontvittaya (then a scientist at ENVIRON). The code was also
implemented into several chemistry and transport modeling systems including CESM/CLM
by Collette Heald (MIT), WRF by Serena Chung (WSU), GEOS-Chem by Dylan Millet (U.
Minnesota), and SOSA by Michael Boy (U. Helsinki). Single-point versions of MEGANv2.1
(useful for comparing with flux tower data) were written in spreadsheet form in Visual
Basic (within EXCEL) by Guenther and in MATLAB by Thomas Karl (U. Innsbruck).

The MEGAN3 framework was developed by Alex Guenther and the Fortran code written
by Ling Huang (Ramboll-Environ) with support from the Texas Air Quality Research
Program (AQRP). The beta version was completed in July 2017 and the final version
released in 2018. The MEGAN3_1 framework was developed by Alex Guenther and the
Fortran code written by Ling Huang (Ramboll) with support from the Texas Air Quality
Research Program (AQRP). The beta version was completed in August 2019.

Getting Started with MEGAN


Running the MEGAN3.1 modeling system consists of three main steps:

 STEP1: Obtain input data and use the pre-processor code to generate landcover
and environmental conditions inputs for the desired spatial domain and time period
that you want to run the MEGAN code. A “preprocessor” FORTRAN code can be
used to regrid base data to generate values for each location and time.
Alternatively, you could use other approaches (e.g., ARCGIS) to regrid and prepare
these input data.
 STEP2: Use the Emission Factor Processor (EFP) to generate emission factor and
light dependence fractions (the fraction of the BVOC emission that follows the light
dependent response behavior) distributions for the desired spatial domain. This step
enables the user to input customized landcover and emissions data and select
which data to use. This is accomplished with CSV input files, a PYTHON code and
a SQLite database. See bai.ess.uci.edu/megan and the “MEGAN3-beta EFP Users
Guide” for guidance on obtaining input data and generating emission factor and light
dependence fraction distributions. The MEGAN3 EFP also outputs vegetation
specific emission factors and light dependence factors that can be used to show the
emission factors used for each plant type which can be used to determine which
plant species dominate the emissions within a region.
 STEP3: Run the MEGAN3 emission rate estimator. The landcover and
environmental conditions and emission factor distribution generated in steps 1 and
2 are used as inputs to a FORTRAN code that calculates and outputs emissions for
each location and time. This document is the “MEGAN3-beta Users Guide” and

4
provides guidance on running the emission estimator. Updates can be found from
bai.ess.uci.edu/megan.

MEGAN Software / Operating System Prerequisites


It should be noted that running the MEGAN Preprocessor and Emission Calculator Fortran
codes requires both access to and knowledge of a LINUX/UNIX operating system and
working knowledge of Fortran. Users who have never been exposed to Unix-type
operating systems (i.e., if you are only familiar with Windows) unfortunately will find it
difficult to run MEGAN. Although you do not need to be a computer programmer to run the
model, you should have a basic understanding of computer programming and Unix (i.e.,
you should know how to unzip/untar files and other basic commands in Unix, install
libraries and link files within Unix, and know basic Fortan commands such as how to
invoke a code). In summary, you should have a working knowledge of Unix and Fortran
before attempting to use MEGAN. The following are the system and software
requirements for installing and running MEGAN:

 LINUX/UNIX operating system


 csh/sh scripting language
 FORTRAN 90 compiler, i.e. pgi
 It can only be run on a single processor, no MPI support
 Netcdf 3.6.0 or greater
 ioapi 3.1
 MCIP 3.6

It has been successfully tested on GNU/Linux x86_64 machine with PGI compiler. The
provided test case was also created on GNU/Linux x86_64 machine.

Case Study
A folder with inputs and outputs for a test case can be used by users can use to test their
implementation of MEGAN.

How to use this document

This guide instructs users on building and running MEGAN3 for climate and air quality
applications. If you are a new user, we recommend that the introductory sections be read
before moving onto other sections. This document is written so that individual sections
stand on their own and the user’s guide can be scanned and sections read in a relatively
ad hoc order.

Throughout the document, this presentation style indicates shell commands and options,
fragments of code, namelist variables, etc. Where examples from an interactive shell
session are presented, lines starting with ">" indicate the shell prompt.

5
2. INPUT DATA AND PRE-PROCESSOR (FORTRAN CODE)
The starting point for running the MEGAN model is to access the required input data and
process these data to get the on the correct grid and format. MEGAN input and output
data for a simple case study is provided as a test case. This document also describes the
pre-processor that can be used to regrid MEGAN base data to a user defined domain.

Input Data: Weather


The weather data used to drive MEGAN can be obtained by running a model such as
WRF or MM5. The variables include PAR (photosynthetically active radiation),
temperature, humidity, wind speed, and soil moisture. MEGAN can also use the soil type
data from WRF.

Using weather data from WRF/MM5 model simulations


Installing the MCIP
Untar mcip_v3.6.tar.gz downloaded from http://www.cmascenter.org/ Go to src directory
to make changes in Makefile to include correct paths for

NETCDF
IOAPI_ROOT FC
LIBS

Type “make” to compile all the programs. After a successful compilation, you should see a
file named “mcip.exe”.

Obtaining MCIP weather input files


MCIP input meteorology files can be from WRF or MM5 output. You need to run WRF or
MM5 to generate some input files.

Running the MCIP


Go to /MCIP3.6/, and make changes in run.mcipto include your meteorology files
generated by WRF or MM5. WRF output files include wrfout* and geo_em_d01.nc(Terrain
information). MM5 output files include MMOUT_DOMAIN* and TERRAIN_DOMAIN*

Using weather data from other sources


Weather data from other sources could also be used to run MEGAN but you will need to
develop your own preprocessor to convert your data into the format required for MEGAN.
For example, some MEGAN users have used RAMS weather model output to generate
weather inputs for MEGAN. Other data, including observations, could also be used to run
MEGAN.

6
Landcover, Emission Factor and Ozone Exposure Data

The landcover data such as Leaf Area Index (LAI) and growth form fraction (GFF) inputs
for MEGAN are typically based on satellite and ground observations or dynamic model
output and are processed by the pre-processor described in this section. Emission Factor
and Light Dependence Factor distributions required to run MEGAN3 are generated using
the Emission Factor Processor described in section 3. MEGAN3 has optional algorithms to
account for the impact of soil moisture and ozone on biogenic emissions. If the user
selects to use this algorithm then it is necessary to input the distribution of ozone exposure
(W126). See bai.ess.uci.edu/megan for guidance on obtaining input data and generating
emission factor and light dependence fraction distributions.

Soil climate and type, fertilizer, atmospheric N deposition

The BDSNP soil NO algorithm requires four additional input datasets. Preprocessor
Fortran codes have been written to regrid these data sets: prepmegan4cmaq_arid.f90

1) Input data: soil_climate_arid.nc


a) prepmegan4cmaq_non_arid.f90

2) Input data: soil_climate_non_arid.nc


b) prepmegan4cmaq_fert.f90

3) Input data: soil_fert_001.nc, soil_fert_002.nc, …, soil_fert_366.nc (daily


fertilizer data, in mg/m3)
c) prepmegan4cmaq_landtype.f90

4) Input data: soil_landtype_01.nc, soil_landtype_02.nc, …,


soil_landtype_24.nc (24 land types)
d) prepmegan4cmaq_nitrogen.f90

5) Input data: soil_nitrogen_mon01.nc, soil_nitrogen_mon02.nc, …,


soil_nitrogen_mon12.nc (monthly nitrogen deposition data, in kg/m2/s)

See bai.ess.uci.edu/megan for guidance on obtaining input data.

Pre-processor Fortran Code


Users can use the preprocessor FORTRAN code to re-grid base data (e.g., 30 seconds
latitude by 30 seconds longitude) to fit with the domain definition of their model simulation.

Software Requirements
Running the pre-processor will need to following system and software requirements:
 LINUX/UNIX operating system
 csh/sh scripting language
 FORTRAN90 compiler, i.e. pgi
 Netcdf 3.6.0 or greater
7
Data Requirements
The required input data include landcover (3 types: LAIv, growth forms, and ecotype) and
weather (output from WRF model or other source) data. Optional data includes ozone
exposure data (W126) and soil moisture.

Landcover data
(1) LAIv data: Leaf Area Index averaged over vegetation covered surfaces.

(2) Growth form data: growth form data for trees, shrubs, grasses, and crops. Two
additional files are used to differentiate broadleaf vs needleleaf trees and
tropical vs temperate trees.

(3) Ecotype data: ecotype data.


Ozone exposure
(4) W126 data (This input is optional and is only used if the user selects to
implement the ozone stress response):

Weather inputs
(5) wrfinput_d<nn> or wrfoutput_d<nn>: Initial condition file or output file from
WRF; <nn> represents an two-digit integer number, indicating the WRF
domain. This file is simply used for grid definition.
(6) a namelist file: see prepmegan4cmaq.inp as an example. This namelist file
defines the subdomain of WRF on which to run MEGAN and other variables
related to directory settings.

Program operation
(1) Compilation
- Modify the file make_util under /src to set user’s own FORTRAN compiler
and NetCDF library path

- Run the following commands to compile the code. Note that while the file
name is prepmegan4cmaq, it will also work for CAMx and othe models:
>make_util prepmegan4cmaq_lai.x
>make_util prepmegan4cmaq_grwform.x
>make_util prepmegan4cmaq_ecotype.x
>make_util prepmegan4cmaq_cantype.x
>make_util prepmegan4cmaq_w126.x

(2) Modifying namelist file (prepmegan4cmaq.inp)

(3) Running the pre-processor

>./prepmegan4cmaq_lai.x < prepmegan4cmaq.inp > lai.log


>./prepmegan4cmaq_grwform.x < prepmegan4cmaq.inp > grwform.log
>./prepmegan4cmaq_ecotype.x < prepmegan4cmaq.inp > ecotype.log
>./prepmegan4cmaq_cantype.x < prepmegan4cmaq.inp > cantype.log
>./prepmegan4cmaq_w126.x < prepmegan4cmaq.inp > w126.log

8
Output files: all output files are in csv format. Note that regridded growth form and ecotype
files are needed as inputs for the MEGAN3 Emission Factor Processor.

9
3. EMISSON FACTOR PROCESSOR (PYTHON CODE)
The MEGAN framework calculates biogenic emissions as the product of an emission
factor, that represents the capacity of a vegetation type to emit a compound, and an
emission activity factor that accounts for the response to environmental conditions. The
task of synthesizing relevant observations and compiling emission factors is challenging,
due to the diverse measurement approaches and the immense biological and chemical
diversity, and has previously been accomplished through a relatively opaque process. The
MEGAN3EFP approach was designed to improve model estimates by enabling the
following:

 Provide a transparent approach for assigning emission factors so that model users
can determine the basis for these factors and gain some insights into the uncertainty
and the need for additional measurements
 Facilitate the integration of new measurements into the inputs used for biogenic
emission modeling
 Enable up-to-date lists of vegetation emission characteristics that could be used to
guide urban landscaping decisions.

Software and hardware requirements

The MEGAN3EFP program is built on the Python programming language and requires you
to have Python installed on your computer. This program has been tested and
successfully run with Python 2.7 on Linux (Centos 6), Mac (Mac OS 10.10) and Windows
(Windows 7, Windows 10) operating systems. The hardware requirements will depend on
the size of the domain but for most applications a recent generation computer (notebook,
desktop, workstation) will be sufficient.

If your computer does not already have Python installed, we recommend installing the
Anaconda distribution of Python via

https://www.continuum.io/downloads

Alternatively, Python can also be installed from source via

https://www.python.org/downloads

Several Python libraries and packages are required to run the MEGAN EFP program.
Most are standard Python libraries that do not require any additional installation. All other
need packages are available for download and installation via pip or conda. Included in
this folder is a requirements.txt file that can be run as instructed below to install all
additional packages

Required Python Libraries and Packages

pandas (Not included in standard Python build)

numpy

To install any packages not included in the standard Python build, users can install them
via pip or conda.

10
To install via pip run:

$ pip install -r requirements.txt

To install via conda:

$ conda install --file requirements.txt

User options
The user options that can be set in the MEGAN_EFP.py script include:

 Set scenario name: give a name to the output text file and SQLite database
describing the specific scenario used.
 Set scenario name: give a name to the output file describing the specific scenario
used.
 Set input table names and paths: Allows the user to select which input files to use
 Number of classes: This sets the number of MEGAN chemical classes to use. It is
currently set for the 20 MEGAN3 classes. Changing this will require the user to
modify the submodules which will require some python programming experience.
 J-rating: specify the lowest J-rating to use in the calculations (J=0 is lowest
confidence, J= 4 is the highest confidence). If you select 4 then only data with J-
rating of 4 will be used. If you select 0 then all data will be used.
 Set output directory: Allows the user to select the output directory

These user options are also described in Table 1.

11
Table 1. MEGAN3EFP script user options
Variable Description
scen_name Run scenario identifier/name
M3VTEF_database Output database path and name for the Vegetation EF
tables
M3GEFP_database Output database path and name for the Gridded EF
tables
M3LDF_database Output database path and file name for the vegetative
LDF tables
M3GLDF_database Output database path and file name for the gridded LDF
tables
VegDB_tables Input measurement tables and other characteristics
information input file folder
GridDB_tables gridded landcover distribution and 4 ecotype species
composition input file folder
Description_Vegetation Vegetation description file name under VegDB_tables
DB_SLA Observations of plant specific leaf area file under
VegDB_tables
DB_LDF Observations of fraction of emission that is light
dependent file under VegDB_tables
DB_emissions Observations of vegetation biogenic emissions file under
VegDB_tables
Ecotype_Crop vegetation type composition of crops in each ecotype file
under GridDB_tables
Ecotype_Herb vegetation type composition of herbs in each ecotype file
under GridDB_tables
Ecotype_Shrub vegetation type composition of shrubs in each ecotype
file under GridDB_tables
Ecotype_Tree vegetation type composition of tress in each ecotype file
under GridDB_tables
grid_ecotype Fraction of surface area covered by each ecotype file
under GridDB_tables
grid_growth_form Fraction of surface area covered by each major growth
form file under GridDB_tables
TotalClasses Total number of MEGAN3 classes
Jrating Specify lowest J-rating to use in calculations. 0 (lowest
confidence) to 4 (highest confidence)
outputs_path Output directory path

Running the program


After you set the user options in the MEGAN_EFP.py script, you can run the MEGAN3EFP
program with a call from terminal:

$ python MEGAN_EFP.py

Running this program will generate 3 SQLite databases (M3VTEF, M3 LDF, and
M3GEFP) based on the input files (Comma Separated Values, CSVs) that are described
in the following section and are located in the ./input directory. These input files are loaded
into primary tables from which queried tables are generated based on SQL queries run in
the program. The program loops through each class overwriting each database each time
while generating CSV output found in ./output/*byClass/. This output is then reloaded into
the database when each class has been run and concatenated into a single table in the
database and then that is written out as a CSV in ./output/. Two of these summary files
12
(grid_EF.csv, grid_LDF.csv) contain gridded data that are used as input for MEGAN3
FORTRAN simulations. The other two summary files (Vegtype_EF.csv, Vegtype_LDF.csv)
contain vegetation specific values. These are provided so that the user can see what
values are used for each vegetation type. These can be compared with literature values,
including both values that have already been incorporated into the database and those
that have not. This may be helpful in determining the major sources of BVOC emissions in
a region and whether additional studies are needed to improve emission factor estimates
of the major sources.

Input Files
The input files for MEGAN3EFP include 2 gridded landcover distribution and 4 ecotype
species composition files (in the ./GridDB_Tables directory) and 3 measurement database
and 5 characteristics information files (in the ./VegDB_Tables directory). A set of files is
provided with MEGAN3EFP but users may want to modify these files or develop their own
input files. This can be accomplished by either modifying the text files described below or
modifying the base netcdf files and then running the preprocessor (see preprocessor user
guide) to generate the input files for the model domain. The user can also add or delete
emission measurement data in the DB_emissions.csv file described below. The user can
make adjustments to any of the input files simply by modify the appropriate CSV file
described below.
*NOTE: The user may also change the names of the CSV files, which will aid in keeping
track of various versions of landcover and plant trait data, but will need to accordingly
update the name in MEGAN_EFP.py when choosing which input files to use for a specific
run.

Ecotype vegetation species composition files:


Ecotype_Tree_Speciation.csv: vegetation type composition of trees in each ecotype
 EcotypeID: unique number identifying each ecotype
 VegID: unique identifier of each vegetation type
 TreeSpecFrac: Fraction of the trees in specified ecotype comprised of the specified
vegetation type

Ecotype_Shrub_Speciation.csv: vegetation type composition of shrubs in each ecotype


 EcotypeID: unique number identifying each ecotype
 VegID: unique identifier of each vegetation type
 ShrubSpecFrac: Fraction of the shrubs in specified ecotype comprised of the
specified vegetation type

Ecotype_Herb_Speciation.csv: vegetation type composition of herb in each ecotype


 EcotypeID: unique number identifying each ecotype
 VegID: unique identifier of each vegetation type
 HerbSpecFrac: Fraction of the herb in specified ecotype comprised of the specified
vegetation type

Ecotype_Crop_Speciation.csv: vegetation type composition of crops in each ecotype


 EcotypeID: unique number identifying each ecotype
 VegID: unique identifier of each vegetation type
 CropSpecFrac: Fraction of the crops in specified ecotype comprised of the
specified vegetation type

13
Landcover distribution files:
grid_growth_form.csv: Fraction of surface area covered by each major growth form
 gridID: unique number identifying each location in a modeling domain
 TreeFrac: Fraction of grid covered by trees
 CropFrac: Fraction of grid covered by crops
 ShrubFrac: Fraction of grid covered by shrubs
 HerbFrac: Fraction of grid covered by herbs

grid_ecotype.csv: Fraction of surface area covered by each ecotype


 gridID: unique number identifying each grid location in a modeling domain
 EcotypeID: unique number identifying each ecotype
 EcoTypeFrac: Fraction of grid covered by specified ecotype

Characteristics files:
Description_Compounds.csv: Description of emitted compounds included in MEGAN3
 CAS (Chemical Abstracts Service) registry number: This number is currently set to
the number for the MEGAN class
 CompoundName: This is currently set to the number for the MEGAN class
 MW: Average molecular weight (grams per mole) of compounds in the class
 ClassPlusID: Unique identifier for MEGAN3 chemical classes

Description_Class.csv: Description of MEGAN3 classes


 ClassPlusID: Unique identifier for MEGAN3 chemical classes
 ClassPlusDescription: Description of MEGAN3 compound classes

Description_References.csv: contains citation and other information on publications


containing emissions and SLM (specific leaf mass) observations
 REFID: Unique identifier for each publication
 REFcode: Unique text identifier for each publication
 REFauthor: last name of first author of publication
 REFYear: year of publication
 Citation: Citation information

Description_Vegetation.csv: Information on all of the vegetation types


 VegID: unique identifier of each vegetation type
 Veg_Description: Description of vegetation type
 Common_Name: common name of vegetation type
 Genus: Genus of vegetation type ("NA" if vegetation type is not a specific species
or genus)
 Family: Family of vegetation type ("NA" if vegetation type is not a specific species
or genus)
 GrowthForm: Growth form of vegetation type (e.g., tree, shrub, vine, graminoid,
etc.)
 Lifespan: Short (annual plant), Moderate (unknown, Perennial grass, etc), Long
(woody plant)
 Specific type: 1 indicates a specific plant species; 0 indicates other type
 Comment: Additional information

14
Measurement database files:
DB_emissions.csv: Observations of vegetation biogenic emissions
 REFID: Unique text identifier for each publication (link to "Description References")
 VegID: Unique identifier for each vegetation type (link to "Description Vegetation")
 CAS (Chemical Abstracts Service) registry number: unique identifier for each
compound class (link to "Description Compounds")
 ERuggh: Emission rate in micrograms compound per gram dry weight foliage per
hour (-999 if not reported)
 ERnmm2s: Emission rate in nanomoles compound per square meter foliage area
(one sided) per second (-999 if not reported)
 J-rating: 0 (lowest confidence) to 4 (highest confidence)
 position in canopy: 1 for top of canopy, 2 middle of canopy (or mixture or
unknown), 3 for bottom of canopy
 Class Plus ID: unique identifier for each compound class
 Veg_Description: Description of vegetation type
 Approach: Measurement approach
 Platform: platform used to make measurements
 Comments: additional information
 Comments2: additional information

DB_LDF.csv: Observations of plant specific leaf area (leaf area per dry mass)
 REFID: Unique text identifier for each publication (link to "Description References")
 VegID: Unique identifier for each vegetation type (link to "Description Vegetation")
 CAS (Chemical Abstracts Service) registry number: unique identifier for each
compound class (link to "Description Compounds")
 LDfrac: Fraction of emission that is light dependent
 J-rating: 0 (lowest confidence) to 4 (highest confidence)
 Veg_Description: Description of vegetation type
 Class Plus ID: unique identifier for each compound class
 Comments: additional information
 Comments2: additional information

DB_SLA.csv: Observations of plant specific leaf area (leaf area per dry mass)
 REFID: Unique text identifier for each publication (link to "Description References")
 VegID: Unique identifier for each vegetation type (link to "Description Vegetation")
 SLAcm2g: Specific Leaf Area (square cm per gram dry weight)
 Position in canopy: 1 for top of canopy, 2 middle of canopy (or mixture or
unknown), 3 for bottom of canopy
 J-rating: 0 (lowest confidence) to 4 (highest confidence)
 Comments: additional information

Program structure and modifications


The general design of the MEGAN3EFP is illustrated in figure 2. The program can be
customized by adding or modifying SQL queries and the functions used in SQL queries.
All SQL queries are stored individually as functions within its respective sub module and
executed in consecutive order by the run_*_DB function located at the bottom of the sub
module. A number of functions are used in SQL queries to manipulate data. These are
stored in the db_functions.py sub module. Before the functions can be added to the SQL
queries, they must first be initialized in the initDB function in the db_functions.py module.
Format for initializing a function is as follows:
15
conn.create_function("functionNameInSQL", #NumberOfInputs, functionNameInPython)

Users may find it helpful to examine the original database or the user created database
directly. Beyond using SQLite command line tools, several third party programs exist to
examine SQLite databases including the DB Browser for SQLite:

http://sqlitebrowser.org/

Figure 2. General Design of MEGAN3EFP Program

16
4. EMISSON CALCULATOR (FORTRAN CODE)

The MEGAN modeling system software installation is fairly straightforward on the


supported platforms (i.e., GNU Linux). After you download the required libraries and
packages, you can refer to the steps listed below to install them. Installing MEGAN requires
you to first install NetCDF and ioapi libraries. Note that the programs should be compiled
with the same NetCDF version to limit compilation and run-time errors.

Installing libraries
Installing NetCDF
There are two ways to install NetCDF on LINUX/UNIX. One is to install the pre--‐built binary
package. If you use pre-built NetCDF, make sure you download the correct version for your
operating system. The other approach is to install it from a tar.gz file.

Once you download it, “untar” it and go to the NetCDF directory. Type the following
commands:

>./configure --prefix=/usr/bin/local
>make check install

Once the NetCDF is installed, you need to set your environmental variables to the location
where you installed it.

>setenv NETCDF path-to-netcdf-library

Please refer to the link below for the details about how to install the netcdf.
http://www.unidata.ucar.edu/software/netcdf/docs/index.html

Installing ioapi
Please refer to http://www.cmascenter.org for installing ioapi 3.1.

Building the code


 Unzip and untar the MEGAN code you downloaded from the MEGAN website,

>gunzip MEGANv3.tar.gz
> tar -xf MEGANv3.tar

it will create a MEGAN3 directory. This contains:

bin/ Directory for executable files linking to the locations where


the files are.
Input/ Directory for input files including MAP (LAI, CT, EF, LDF, and
W126 (optional)), MET (weather), and PAR (radiation).
Output/ Directory for output files.
setcase.csh Script to set up MEGAN environmental variables
src/ Directory for main routines, Makefiles, and all executables after
compilation. It includes five folders for different components of
MEGAN.
work/ Directory for running the model, modeling domain
information, and output log files.

17
 Go to MEGAN3 and make changes in setcase.csh.

>cd MEGAN3

The only thing you need to change is MGNHOME environmental variable. Reset the
location of the MEGAN model in your computer:

Change:

setenv MGNHOME /data/home/MEGAN/MEGAN3

to:

setenv MGNHOME /location-of-your-MEGAN3-model

or:

setenv MGNHOME $cwd:h


($cwd is the current path)

 Under src/, you will see eight sub-directories, which are different components of the
MEGAN model.

TXT2IOAPI/ Directory for converting comma delimited line input (LAI, CT,
EF, LDF, and W126 (optional)) to gridded netCDF-IOAPI
format.
MET2MGN/ Directory for converting IO/API files with various
meteorological variables to the format that can be read by
MEGAN
DAYMET/ Directory for calculating daily meteorological variables
that will be used by MEGVEA
MEGCAN/ Directory for converting above-canopy meteorology to
within-canopy meteorology that will be used by MEGVEA
MEGSEA/ Directory for calculating soil moisture activity factor and
soil NO emission activity factor
MEGVEA/ Directory for calculating various emission activity factors
MGN2MECH/ Directory for doing chemical speciation and MECHANISM
conversion using MEGAN output.
IOAPI2UAM/ Directory for converting IO/API output files to CAMx low-level
emission files

 Go to each of the eight sub-directories to make changes in Makefile.*.32bit/64bit to


set up new LIBS and INCLUDE locations. You may also need to change FC to the
FORTRAN you are using. The default is pgf90. You will need to know if your
machine is 32 bit or 64 bit before you go to the next step.

 Go back to src/ directory, and run the following command to build the MEGAN
model if you are using a 32 bit machine. If you are using a 64 bit machine, you need
to change 32 to 64.

> ./make_all_programs.scr 32bit

18
 After a successful compilation, you should have executables (txt2ioapi, met2mgn,
daymet, megcan, megsea, megvea, mgn2mech, and ioapi2uam) created in the eight
sub-directories listed above under /MEGANv3/src. Now you have built MEGAN3 and
are ready to run it.

Running the code


The scripts for running the MEGAN model are located under /MEGANv3/work. Before you
execute the following steps, make sure you have a GRIDDESC file located under this
directory. This file is generated by MCIP, including projection and domain information for
your input files. A sample file is provided under this directory.

You can run the model by following the steps listed below:

6) Make changes in run.txt2ioapi.v3.csh to include setcase.csh and landcover input


files generated in Section 4.
Execute the following command to convert csv format landcover data to ioapi
format
>./run.txt2ioapi.v3.csh

Preparing/converting W126 data is optional. If user does not want to enable air
quality-induced emission stress, you do not need to prepare W126 input data.

7) Make changes in run.met2mgn.v3.cshto include setcase.csh, MCIP output files,


and start and end dates of your case. You will also need to change “GDNAM3D”
variable to be consistent with your MCIP output files.
Execute the following command to convert MCIP output files to MEGAN ioapi
format.
>./run.met2mgn.v3.csh

8) Make changes as you did for 2). , and then execute the following command to
generate daily meteorological variables. You will need to specify the start date
and length of your simulation episode in the run script below.
>./run.daymet.v3.csh

9) Make changes as you did for 2)., and then execute the following command to
calculate soil moisture activity factor and soil NO emission activity factor.
>./run.megsea.v3.csh

10) Make changes as you did for 2)., and then execute the following command to
convert above-canopy meteorology to within-canopy meteorology. If you wish to
use alternative canopy model to generate within-canopy meteorology, you do
not need to run this step. But you will need to prepare input files that have all the
variables (e.g. SunleafTK, SunPPFD, etc.) that MEGAN3 needs.
>./run.megcan.v3.csh

11) Make changes as you did for 2)., and then execute the following command to
run MEGAN3. Note that the time required to run the model will depend on the
length of your simulation and the domain size. A user can specify which stress
19
factors (e.g. air quality stress, high/low temperature stress, high wind stress,
etc.) to include. Make sure you provide the necessary input files if you enable
specific stress factors.
>./run.megvea.v3.csh

12) Make changes as you did for 2), and then execute the following command to
convert MEGAN species to other speciation profiles. You can choose any one of
fourteen chemical mechanisms to convert MEGAN species to by running this
script.
>./run.mgn2mech.v3.csh

13) The following command can be used to convert 1--‐D emissions files (I/O API) to
CAMx low--‐level emissions files (UAM--‐IV).
>./run.ioapi2uam.csh

The MEGAN output files are available in the /MEGANv3/Output directory. All of the log files
for running these scripts are under /MEGANv3/work/logdir.

5. POST PROCESSING
Various techniques and tools are available for displaying MEGAN output data including
NCL, ArcGIS, and IDL. Any tools that are capable of displaying the ioapi or UAM--‐CAMx
2D emission data format can be used for this purpose.

20

You might also like