Exercise 1: Using the Global emissions data (sea salt, biomass burning) emissions for your domain.


Purpose: To familiarize the user with the available global emissions data set. This data set uses a program called "prep_chem_sources" to read the emissions data and map it to the user specified simulation domain. The program is capable of mapping anthropogenic emissions, sea salt as well as biomass burning (wild fire) and volcanic ash emissions to the user domain.

The use of the prep_chem_sources program is complex and requires the user to be familiar with the simulation domain mapping information, the location of various data sets and where they are obtained as well as located on their particular system. Also, the user needs to be very familiar with the WRF-Chem registry (WRFV3/Registry/registry.chem) as the conversion process for this data that relies on the correct specification of chemistry namelist options. See the WRF-Chem Quick_start guide, the User's guide as well as the WRF-Chem FAQ web page (http://ruc.noaa.gov/wrf/wrf-chem/user-support.htm) for additional information.

This exercise demonstrates the methodology for making a WRF-Chem emissions input files. the process shown here is:

  1. Generate emissions data file for the domain and chemical mechanism of interest and write them into an intermediate file.
  2. Convert the emission into a WRF chemical emissions input file.


  1. Be sure your environmental variables are set. You don't have to compile WRFV3 if you are attending a NCAR tutorial class , but it is always a good idea to have them set. Also, remember to work in

  2. Make a global emissions directory and untar the prep_sources_chem code in your home directory

    mkdir Global_emissions

    cd Global_emissions

    tar -zxf /kumquat/wrfhelp/SOURCE_CODE/WRF-CHEM/prep_chem_sources_v1.4.tar.gz

    If you are not at NCAR, the Global Emissions data and the prep_chem_sources program are available from the WRF-Chem ftp site at:


  3. Compile (serial will work as it runs fast) the prep_sources_chem code using the directions in chapter 2 of the Emissions Guide. Be certain to change the compile options to include the path to the netCDF library as well as the compiler used on your system. Hint: at the NCAR tutorial the netCDF library is usually located in /usr/local and the Portland Group compiler, pgf90, is used.

    To compile the code cd to the main prep_chem_sources directory and then down to the bin/build directory (ie., cd ../../PREP_CHEM_SRC_1.3/bin/build). Edit the include file that is appropriate for your compiler (e.g., include.mk.opt.pgi, or include.mk.pgi for those using PGF90, include.mk.opt.intel for those using ifort). Pay close attention to the lines for the libraries (e.g., the NETCDF, HDF5 library paths) as well as if byte swapping is needed. Your include.mk.opt file should have lines that look something like:

    NCARG_DIR=$(NCARG_ROOT) .... Remember that WRF uses NCARG_ROOT as the path to your NCAR graphics libraries...


    NETCDF_LIBS=-I$(NETCDF)/include -L$(NETCDF)/lib -lnetcdf


    HDF_LIBS=-L/usr/local/hdf5-1.8.11-pgi/lib -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5 -L$(SZIP)/lib -lz

    and you need to change each one to the correct path for your system. Check each library location (don't just copy the above library paths) as an incorrect path for these libraries will result in a compile error.

    Regarding compile options such as byte swapping, look at the FORTAN compile lines from your WRFV3 compile log. Most often the basic compile options used for WRF will be needed for prep_chem_sources as well. For the NCAR tutorial this holds true as the PGI FORTRAN compiler uses the -byteswapio compile option. This needs to be added to the FORTRAN compile options in the include.mk.opt.pgi file at the F_OPTS line as follows:

    F_OPTS= $(NETCDF_LIBS) $(HDF_LIBS) -Mpreprocess -D$(CHEM) -O3 -byteswapio

    And finally, be sure to use as new of a compiler version as possible. There has been issues building the code when using old compilers. For example, at NCAR you have a choice between PGF90 version 10 or version 13. The version 10 compiler(/usr/local/pgi_10/bin/pgf90) will not be able to generate an executable, but the version 13 compiler (/usr/local/pgi-13.6/bin/pgf90) does work.

    Even with the correct default compiler version, you might need to state which compiler version needs to be used when building the code by editing the compiler lines from


    to like the following:


    What does this all look like? Compare your include.mk.opt.pgi file with the following example include.mk.opt.pgi file produced for the NCAR tutorial computers.

    Some computers have an additional compression library that needs to be added to the HDF5 library path. If you are getting an error message suggesting the sz compression library is not linked, make sure you have loaded the zlib module (only some systems require loading modules) and added libsz to your HDF_LIBS line in the include.mk. file.

    -L${HDF5}/zlib/lib -lz -lsz

    Once the settings for the compiler and library paths are correct you can compile the code with the command (assumes PGF90 compiler)

    make OPT=opt.pgi CHEM=RADM_WRF_FIM

    prep_chem_sources exectutable one directory up. You can verify by listing the executable ../prep_chem_sources_RADM_WRF_FIM.exe

    If during the compile you get a message like:

    ifort -c -I/usr/local/netcdf/include -L/usr/local/netcdf/lib -lnetcdf -L/usr/local/hdf5/lib -lmfhdf -ldf -L/usr/loal/jpeg-6b -ljpeg -L/usr/local/zlib-1.2.7 -lz -lsz -fpp -DRADM_WRF_FIM -convert big_endian -O2 -I../../aux_src/utils/include gocart_background.f90

    gocart_background.f90(132): error #7013: This module file was not generated by any release of this compiler. [NETCDF]

    use netcdf


    gocart_background.f90(213): error #6404: This name does not have a type, and must have an explicit type. [NF90_OPEN]

    call check( nf90_open(TRIM(filename(ispc)), NF90_NOWRITE, ncid) )

    You have a bad compile due to the netCDF library path being incorrect. Verify that the netCDF libraries and include file paths are correct for your compiler and that the hdf5 library was built with the netCDF library build disabled. Similar error messages can occur as well when there are problems with the other libraries so verify all settings in the include.mk. file if an error occurs.

    If you have a bad compile and need to clean the code and try again, just type:

    make OPT=opt.pgi clean

    If you get an error message suggesting that there are missing netCDF library routines then you might be missing the netcdff.a library extension. Not all systems have a netcdff.a library extension, but it should be included if it exists. To include the netcdff.a library you should add it to the NETCDF_LIBS listing for your compiler.

    NETCDF_LIBS=-I$(NETCDF)/include -L$(NETCDF)/lib -lnetcdf -lnetcdff

    Again, verify that the netCDF libraries and include file paths are correct for your compiler, clean and recompile the code.

    Confusing? There is a README file in the PREP_CHEM_SOURCES main directory that explains the whole process in more detail.

  4. edit the prep_sources_chem.inp input file settings:

    grid_type= 'lambert', !













    and the grid information


    NGRIDS = 1, ! Number of grids to run

    NNXP = 41 , ! Number of x gridpoints

    NNYP = 41 ! Number of y gridpoints

    NXTNEST = 0, ! Grid number which is the next coarser grid

    DELTAX = 100000.,

    DELTAY = 100000., ! X and Y grid spacing

    ! Nest ratios between this grid and the next coarser grid.

    NSTRATX = 1,2,3,4, ! x-direction

    NSTRATY = 1,2,3,4 ! y-direction

    ! For polar, polelat and polelon are the geographical coordinates of the point

    ! of tangency between the projection plane and the Earth surface.

    ! It will be coincide with the center of grid (nnxp/2,nnyp/2) if they are

    ! equal to centlat and centlon.

    ! For lambert, then polelat and polelon specify the grid center lat/lon

    POLELAT = 35., !

    POLELON = 25., !

    STDLAT1 = 30., !

    STDLAT2 = 40., !

    CENTLAT = 35.,

    CENTLON = 25.,

    For the tutorial, the input RETRO, EDGAR, surface and WF-ABBA data are located inside

    the Global_emissions directory. For a place to start, look under:

    Note: You will need to set all of the data file paths for each of the options. There will be more than just the three paths that needs to be set. Also, you might want to examine the emissions and surface data to confirm the paths you are setting. Review the quick_start and User's guide for additional information.

  5. run prep_chem_sources_RADM_WRF_FIM.exe. You should see the following message at the end of a successful run.

    DMS for month= 7


    writing spc=EROD 41 41 3

    writing spc=H2O2 41 41 55

    writing spc=OH 41 41 55

    writing spc=NO3 41 41 55

    (No, there is not a nice ending statement at this time.)

  6. Verify that the emissions data exists in the prep_chem_sources directory and that their size is (approximately) correct. Depending upon your system and data used the file sizes could vary by a small fraction.

    WRF-TUTORIAL-T-2010-07-14-000000-g1-gocartBG.bin ________ 1136624 bytes

    WRF-TUTORIAL-T-2010-07-14-000000-g1-bb.bin _______________ 235672 bytes

    WRF-TUTORIAL-T-2010-07-14-000000-g1-ab.bin _______________ 181816 bytes

  7. If not done already, obtain and compile the WRF-Chem code in your home directory. At NCAR, you can copy the WRF-Chem code directory to your home directory

    cd /kumquat/users/${USER}/CHEM

    cp -R /kumquat/wrfhelp/PRE_COMPILED/WRF-CHEM/WRFV3 WRFV3

    This WRF-Chem code is compiled for the organized tutorial sessions. If you are not attending an organized tutorial you need to obtain and compile the WRF-Chem code yourself. If compiling WRF-Chem is unfamiliar, A short tutorial on compiling the code is available.

  8. Link these files to the WRFV3/test/em_real directory from the prep_chem_sources/bin run directory. It might be useful to look at the quick start guide (in User's Guide) to get the linked file names as well as to follow the shown methodology.

  9. Next "cd" to WRFV3/test/em_real and set the correct options for emiss_inpt_opt, emiss_opt and chem_optm io_form_auxinput?, etc. in the namelist.input file. In this exercise we will use the simple GOCART aerosol option (chem_opt=300) with dust, sea salt, DMS, and biomass burning. No need to biogenic emissions as GOCART aerosols uses just so2 emissions. i Be sure to consider the update interval of the global emissions as well as their vertical dimensions (kemit=1 as it is only surface data). The run time for convert_emiss don't have to be very long - 12 hours or less - as the global emissions are updated once a month. In this exercise step you could set it to 3 hours. Also, be sure to set your auxiliary input file values accordingly or there will be no data read in or values assigned in the output file. Remember, in column 8 of the registry.chem file the auxiliary input port numbers are set and they have been assigned as:

    auxinput_5 -> Anthropogenic emissions

    auxinput_6 -> Biogenic emissions (BEIS, MEGAN)

    auxinput_7 -> Surface biomass burning fields

    auxinput_8 -> GOCART background fields

    auxinput_12 -> Chemistry initial fields

    auxinput_13 -> Volcanic ash emissions

    auxinput_14 -> Aircraft emissions

    auxinput_15 -> Green House Gas emissions

  10. With the updated namelist.input file you can now run convert_emiss.exe. The output files will be

    wrfchemi_d01 -> Anthropogenic emissions

    wrffirechemi_d01 -> Surface biomass burning fields

    wrfchemi_gocart_bg_d01 -> GOCART background fields

    Did you get a run time error when running convert_emiss.exe? Perhaps something like:

    PGFIO-F-219/unformatted read/unit=19/attempt to read/write past end of record.
    File name = wrf_gocart_backg unformatted, sequential access record = 2

    Or maybe

    forrtl: severe (67): input statement requires too much data, unit 19, file

    If so, then you might:

    * have a bad link,

    * a zero-size file, or

    * a missing the GOCART backgroud file.

    Or you might have incorrectly set the byteswap compile option(s) for prep_chem_sources. First make sure the file link is correct. Then verify that you used the same compile options for prep_chem_sources as was used with WRF.

  11. Use a netCDF data file viewer to examine your global emissions data. Does it look like it matches your domain (Europe), or a bunch of diagonal lines? It should look like the Mediterrainian region. Is there fire emissions over Greece? Did you remember there were bad fires in Greece back in July of 2010?

  12. If the global emissions, biomass burning, etc. files are correct, move or link the fire and GOCART emissions files to the WRF/test/em_real directory. If you need help follow what is shown in the quick start section of the User's guide.

  13. Now link the global anthropogenic emissions back so that it can be used in the simulation. This name is what one would normally use in a run.

    ln -sf wrfchemi_d01 wrfchemi_00z_d01

    The name wrfchemi_00z_d01 is normally used in a WRF run when emiss_inpt_opt=1 so it should become familiar. But note: IF you are using hourly emissions data - not daily global surface data from RETRO/EDGAR - there will be two wrfchemi files. The first, wrfchemi_00z_d01 containing data from 00 to 11 UTC and wrfchemi_12z_d01 containing data from 12 to 23 UTC. The 24 hours of emissions data will be cycled each day.

  14. Examine your namelist.input file making sure you have set the correct values for RETRO/EDGAR anthropogenic emissions, the proper vertical dimensions for global emissions (surface data only), auxiliary file update interval, etc. Be sure to turn on biomass burning, sea salt, DMS, etc. as the GOCART aerosol scheme is being used! Also be sure to have the run time of 2 days as you will be making a WRF simulation and not building global emissions from data files that vary daily or monthly.

  15. With the namelist.input file set you can now run your run real.exe to get the GOCART background fields and biomass burning emissions data input the wrfinput file. If you do not do this there will be zero fields entered for biomass burning, etc. when you run wrf.exe

    mpirun -np 4 real.exe

    Examine the wrfinput data file. Do you see the GOCART background fields in the wrfinput_d01 file? Biomass burning emissions (e.g., ebu_in_co) in the surface fields as well?

  16. With the input and boundary conditions files built you can now run wrf.exe. As the biomass burning and GOCART background fields are already in the wrfinput file you need to turn these fields off before running wrf.exe. If you forget you will get a failure reading the input data file message.

    mpirun -np 4 wrf.exe

    It will probably take approximately 5 minutes to finish the simulation on your computer.

    *** An important item to remember is that the GOCART background fields are reset for each chemistry time step. A small chemistry time step will result in an inacurate background state as it takes about 1 hour for the background fields to recover. Be sure to use a reasonable chemical time step like chem_dt = 60 when running the simple GOCART option (chem_opt=300). IF (and that is a big IF) you did not use a large time step for the simple GOCART simulation, rerun with chem_dt = 60 (minutes). But what about chem_opt=301 and 302 (GOCART + RADM2 or RACM gas chemistry)? Those options have the oxidizing chemistry updating with chemdt so the GOCART background fields are not being used for the gas-phase chemistry calculation. For those options use a reasonable chemistry timestep (chemdt = n * time_step; n=0,1,2,3,...). ***

  17. Once again, when finished you should examine results of your simulation. Verify that sea salt aerosols exist in the run. Are the SO2 and fire emissions correct?

    Can you see the fire emissions in the PM, or CO fields above the surface? Does the sea salt match the fine coarse particulate matter fields (PM10)?

    This concludes WRF-Chem emissions tutorial exercise 1.

    To compare solutions, download desired files from here.

    Return to WRF-Chem Emissions Tutorial Page