This is just a tutorial created to assist the execution of the Model of Emissions of Gases and Aerosols from Nature (MEGAN) model. Please visit the developer site for more information: https://bai.ess.uci.edu/megan/
Reference: https://gmd.copernicus.org/articles/5/1471/2012/
The tutorial is developed for academic purposes in support of the UKM-YSD Chair in Climate Change grant (ZF-2020-001)
Download required files as provided:
Basic:
- MEGAN source code
- Tutorial input files
- Run scripts
Download Ubuntu 20.04 LTS from the Microsoft Store or https://ubuntu.com/wsl
Follow the instructions here to install the required Windows Subsytem and restart the machine, as per the instructions on
https://docs.microsoft.com/en-us/windows/wsl/install-on-server
Download MobaXTerm for Windows
Download gedit for Windows
https://gedit.en.uptodown.com/windows
Locate the Ubuntu folder in your machine (AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc)
Enter to the home directory and create a folder called "MEGAN"
Example: (replace the username according to your account)
C:\Users\Chelg\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\maggieooi\MEGAN
Move MEGANv2.10_beta.tar.gz and Tutorial1 into .../home/user
/MEGAN
Open your MobaXTerm and double-click on WSL
Type commands below and key in password when prompted
sudo apt-get update
sudo apt install ncview
sudo apt install csh
Some basic LINUX commands:
pwd - present working directory
ls - listing files in folder
ls -lah - listing files in folder with all details (a) in human readable form (h)
cd - change directory
cd MEGAN - enter MEGAN directory
chmod - change mode of access (**r**ead,**w**rite,e**x**ecute); level: 7 (rwe), 5 (r-e), 4 (r--);
user: user, group, others
chmod 700 - change mode of access to 700 (only admin can rwe)
chmod 755 - change mode of access to 755 (admin can rwe, groups and other can read and execute)
chmod 755 * - change mode recursively (applies 700 for all the files)
chmod -R 755 * - change mode recursively (applies 700 for all the files and files inside folders)
ls -lah
mv MEGANv2.10_beta.tar.gz MEGAN
mv Tutorial1.zip MEGAN
In MEGAN directory:
cd ~/MEGAN
ls
tar -zxvf MEGANv2.10_beta.tar.gz
ls -lah
ls -lah MEGANv2.10
cd ../
unzip Tutorial1.zip
ls -lah
ls -lah Tutorial1
in MEGAN/MEGANv2.10
|-bin : execution files (txt2ioapi, met2mgn, emproc, mgn2mech)
|-src : source codes
|-work : script executed (txt2ioapi, met2mgn, emproc, mgn2mech csh files)
|-Input : input files (EF, PFT, LAI csv files)
|-Output : output files
|-setcase.csh : setting the environment variables
- Correction of bin/mgn2mech link
cd bin
ls -l
ln -sf ../src/MGN2MECH/mgn2mech .
ls -l
- Copy tutorial input files into MEGANv2.10 folder
cd ~/MEGAN/Tutorial1/Input
ls
cp * ../../MEGANv2.10/Input
- Copy tutorial script files into MEGANv2.10 folder
cd ~/MEGAN/Tutorial1
ls
cp *csh ../MEGANv2.10
cd ../MEGANv2.10
ls -lah
ls -lah Input
- Setting environmental variables setcase.csh
cd MEGAN/MEGANv2.10
cat setcase.csh - printout file on screen
pwd
vi setcase.csh - edit `MGNHOME` directory
In vi/vim editor:
Enter i
for edit mode; Esc
to exit edit mode
Enter :w
to save change; ZZ
to save change and exit; :q!
to exit without saving
- txt2ioapi: Convert the text files into the I/O API files
./run.txt2ioapi.v210.csh
Input files: EF210_mSEA_d01.csv, LAI210_mSEA_d01.csv, PFT210_mSEA_d01.csv
Output files: EFMAPS.mSEA.d01.ncf, LAIS46.mSEA.d01.ncf, PFTS16.mSEA.d01.ncf
Output logfile: log.txt2ioapi.d01.txt
- met2mgn: Convert meteorological files (WRF/MCIP output) into I/O API files
./run.met2mgn.v210.2016352.csh
Input files: METCRO2D_d01_2016325, METCRO3D_d01_2016325, METDOT3D_d01_2016325
Output files: MET.MEGAN.2016325.d01.ncf
Output logfile: log.met2mgn.2016325.d01.txt
- emproc: MEGAN emission processing files
./run.emproc.v210.2016352.csh
Input files: Output files from txt2ioapi and met2mgn
Output files: ER.mSEA.2016325.d01.ncf
Logfiles: log.emproc.2016325.d01.txt
- mgn2mech: MEGAN output speciated to specified chemical mechanism
./run.mgn2mech.v210.2016352.csh
Input files: ER.mSEA.2016325.d01.ncf
Output files: MEGANv2.10.mSEA.CB05.2016325.d01.ncf
Logfiles: log.run.CB05.2016325.d01.txt