Merra2BC interpolates MERRA-2 chemical species to the WRF-Chem grid and updates:
- initial conditions (
wrfinput_d01) - time-varying boundary conditions (
wrfbdy_d01)
- Python 3
numpyscipynetCDF4- WRF/WPS outputs from your case setup:
wrfinput_d01wrfbdy_d01met_em.d01.*.nc
- MERRA-2 files covering the full simulation period and spatial domain
Install Python dependencies (pip):
python3 -m pip install -r requirements.txtOr create a Conda environment from the included file:
conda env create -f environment.yml
conda activate merra2bcDefaults are defined in src/config.py:
- species mapping (
spc_map) - file paths and filename masks
- whether to process IC/BC by default (
do_IC,do_BC)
At runtime, command-line flags can override these defaults without editing the file.
- Run
real.exewithchem_in_opt = 0to generatewrfinput_d01andwrfbdy_d01. - Download required MERRA-2 collections:
- Update
src/config.pydefaults (especiallyspc_map, paths, and masks). - Zero relevant chemistry fields before interpolation:
python3 zero_fields.py --do_IC=true --do_BC=true
- Run interpolation:
python3 main.py
- Before running
wrf.exe, innamelist.inputunder&chemset:have_bcs_chem = .true.for boundary conditionschem_in_opt = 1for initial conditions
- Run
wrf.exe.
Print all options:
python3 main.py --helpmain.py supported options:
--wrf_input_file(full path towrfinput_d01)--wrf_bdy_file(full path towrfbdy_d01)--wrf_met_files(full-path glob mask formet_emfiles)--merra2_files(full-path glob mask for MERRA2 files)--do_IC=true|false--do_BC=true|false--init_co2_ch4=true|false(defaultfalse; setsco2=400 ppmv,ch4=1.7 ppmv; for BC also setsco2/ch4tendencies to0)
Important:
- Quote glob masks passed to
--wrf_met_filesand--merra2_filesto prevent shell expansion. - Use one MERRA collection per run (
inst3_3d_aer_Nvorinst3_3d_chm_Nv) consistent with the activespc_map; do not mix both collections in one mask.
Example (explicit paths, process both IC and BC):
python3 main.py \
--wrf_input_file /path/to/wrf/run/wrfinput_d01 \
--wrf_bdy_file /path/to/wrf/run/wrfbdy_d01 \
--wrf_met_files '/path/to/wps/run/met_em.d01.2010-*' \
--merra2_files '/path/to/merra/MERRA2_*.nc4' \
--do_IC=true --do_BC=true \
--init_co2_ch4=falseExample (boundary conditions only):
python3 main.py --do_IC=false --do_BC=truezero_fields.py uses a fixed zero value (1e-16) and supports shared config overrides, including --wrf_input_file, --wrf_bdy_file, --do_IC=true|false, --do_BC=true|false. The fields zeroed should be the same WRF fields that are updated later by main.py (based on the active spc_map).
python3 zero_fields.py \
--wrf_input_file /path/to/wrf/run/wrfinput_d01 \
--do_IC=true
OR
python3 zero_fields.py \
--wrf_bdy_file /path/to/wrf/run/wrfbdy_d01 \
--do_BC=true- Interpolated values are added to existing WRF-Chem fields.
- Running
zero_fields.pybeforemain.pyis recommended to avoid double counting.
If this utility is useful in your research, please cite:
Ukhov, A., Ahmadov, R., Grell, G., and Stenchikov, G.: Improving dust simulations in WRF-Chem v4.1.3 coupled with the GOCART aerosol module, Geosci. Model Dev., 14, 473–493, https://doi.org/10.5194/gmd-14-473-2021, 2021.
