Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Compiling WRF-chem 3.6.1

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.


New member

i am trying to compile wrf chem 3.6.1 i followed the below instructions exactly

all tests are sussefull

however during the

./compile em_real

i get this error:

USE module_aerosols_sorgam, ONLY: sum_pm_sorgam
Fatal Error: Can't open module file 'module_aerosols_sorgam.mod' for reading at (1): No such file or directory
make[2]: [start_em.o] Error 1 (ignored)


USE module_input_chem_data
Fatal Error: Can't open module file 'module_input_chem_data.mod' for reading at (1): No such file or directory
make[1]: [real_em.o] Error 1 (ignored)

gfortran: error: ndown_em.o: No such file or directory
make[1]: [em_real] Error 1 (ignored)

collect2: error: ld returned 1 exit status
make[1]: [em_real] Error 1 (ignored)

gfortran: error: nup_em.o: No such file or directory
make[1]: [em_real] Error 1 (ignored)

gfortran: error: real_em.o: No such file or directory
make[1]: [em_real] Error 1 (ignored)

and after while it stops.

any idea?

thank you in advance.

ps let me know if any other information is required
I've moved this post to the WRF-Chem support section of the forum. Someone will respond soon.

Please compile with this command:

./compile em_real > log_comp.txt 2> errors_comp.txt

And attach the errors_comp.txt file. Thank you.

Iam facing same issue on compiling v4.1.5. Please find the files attached.

Secondly, I am not able install v4.2.2 in a 12gb ram device. I looked at memory usage using htop from terminal and it was using full ram and 2gb swp as well. and then the device automatically reboot.

Thanks in advance


  • compile_kpp.log
    323.1 KB · Views: 46
  • compile_wrf.log
    1.3 MB · Views: 54
  • configure.wrf
    20.3 KB · Views: 44

You are experiencing a memory error:

*** buffer overflow detected ***: terminated
make: *** [Makefile:3: crimech_Integrator.f90] Aborted (core dumped)

Are you compiling KPP separately? You should only need to compile at the top WRF directory.

Your error may be able to be addressed here:

i.e., in WRF/chem/KPP/configure_kpp, change




then ./clean -a, and recompile

Thank you for your quick response.
I still have problem building executable. Please find the attachment.


  • compile.log
    673 KB · Views: 54

Is this the entire log? And did you run " ./clean -a " prior to recompiling?


Also, I saw this in your original compile log:

configure_kpp, settings:
No libfl.a in /home/musaid/Models/Build_WRF/LIBRARIES/flex_dir/lib
check if FLEX_LIB_DIR environment variable is set correctly
(FLEX_LIB_DIR should be the complete pathname of the FLEX library libfl.a)
OR: Enter full path to flex library on your system

Can you ensure that you are correctly setting your environment variable to point to the FLEX lib directory?

This was not complete log, but copied from terminal to the file. I didn't save to a log file this time. sorry for that.
Previously the path was not given correctly in the bash, but this time i have done it properly.

I will explain the procedures i did after your last reply here.
*) reinstalled flex-2.5.3 and byacc-20210328
*) given the proper path in the bash.

#WRF Variables
export DIR=/home/musaid/Models/Build_WRF/LIBRARIES
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export NETCDF=/usr
export HDF5=/usr/lib/x86_64-linux-gnu/hdf5/serial
export LDFLAGS="-L/usr/lib/x86_64-linux-gnu/hdf5/serial/ -L/usr/lib"
export CPPFLAGS="-I/usr/include/hdf5/serial/ -I/usr/include"
export LD_LIBRARY_PATH=/usr/lib
export JASPERLIB=/home/musaid/Models/Build_WRF/LIBRARIES/grib2/lib
export JASPERINC=/home/musaid/Models/Build_WRF/LIBRARIES/grib2/include
export NETCDF_classic=1

############## Chem #######################
ulimit -s unlimited
export MALLOC_CHECK_=0
export EM_CORE=1
export NMM_CORE=0
export WRF_CHEM=1
export WRF_KPP=1
export PATH=home/musaid/Models/Build_WRF/LIBRARIES/byacc-20210328:$PATH
export PATH=home/musaid/Models/Build_WRF/LIBRARIES/flex-2.5.3/bin:$PATH
export YACC='/home/musaid/Models/Build_WRF/LIBRARIES/byacc-20210328/yacc -d'
export FLEX=/home/musaid/Models/Build_WRF/LIBRARIES/flex-2.5.3/bin/flex
export FLEX_LIB_DIR=/home/musaid/Models/Build_WRF/LIBRARIES/flex-2.5.3/flex_directory/lib
export KPP_HOME=/home/musaid/Models/Build_WRF/WRF-4.1.5/chem/KPP/kpp/kpp-2.1
export WRF_SRC_ROOT_DIR=/home/musaid/Models/Build_WRF/WRF-4.1.5
export PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
export SED=/usr/bin/sed

*) edited the CC_FLAGS="-O" in /home/musaid/Models/Build_WRF/WRF-4.1.5/chem/KPP/configure_kpp to CC_FLAGS="-O0"
*) cd /home/musaid/Models/Build_WRF/WRF-4.1.5/
*) ./clean
*) cd chem/KPP/kpp/kpp-2.1/src
*)/usr/bin/flex scan.l
*)cd /home/musaid/Models/Build_WRF/WRF-4.1.5/
configured for 34 and then 1
*)./compile em_real

for your reference, I have compiled again to generate the files, which is being attached.


  • compile_kpp.log
    357.3 KB · Views: 32
  • compile_wrf.log
    1.6 MB · Views: 40
  • configure.wrf
    20.3 KB · Views: 40

Before preceding with this debug, please do it this way. Everything up to this point is fine: "export WRFIO_NCD_LARGE_FILE_SUPPORT=1"

Please add:

export WRF_EM_CORE=1

then proceed,
cd /home/musaid/Models/Build_WRF/WRF-4.1.5/
*) ./clean Here, rather than "clean", please run "./clean -a"
*) cd chem/KPP/kpp/kpp-2.1/src. Don't do this step
*)/usr/bin/flex scan.l ..or this step

*)cd /home/musaid/Models/Build_WRF/WRF-4.1.5/
configured for 34 and then 1
*)./compile Don't do this step, you only need to issue a single compile command (i.e., ./compile em_real")
*)./compile em_real

Finally, is your NETCDF actually installed here: "/usr"

Thank you, jordanschnell, for your indeed support and help.

I used to install netcdf using sudo apt to the root folders and give path as /usr , and i dont know somehow it worked for me to install normal wrfv4.1.5 and all.

Here i dont know what was the proper error. but, what i have done is, build each library to separate LIBRARY folder and given its path to the bash.

I will add the new bash variables here:

#WRF Variables
export DIR=/home/musaid/Models/Build_WRF/LIBRARIES

#### mpich
export PATH=$DIR/mpich/bin:$PATH

#### netcdf
export PATH=$DIR/netcdf/bin:$PATH
export NETCDF=$DIR/netcdf

#### libpng

#### jasper
export PATH=$DIR/jasper/bin:$PATH

############## Chem #######################
ulimit -s unlimited
export MALLOC_CHECK_=0
export EM_CORE=1
export NMM_CORE=0
export WRF_CHEM=1
export WRF_KPP=1
export YACC='/usr/bin/yacc -d'
export FLEX=$DIR/flex_directory/bin/flex
export FLEX_LIB_DIR=$DIR/flex_directory/lib
export KPP_HOME=/home/musaid/Models/Build_WRF/WRF-4.2.2/chem/KPP/kpp/kpp-2.1
export WRF_SRC_ROOT_DIR=/home/musaid/Models/Build_WRF/WRF-4.2.2
export PATH=$KPP_HOME/bin:$PATH
export SED=/usr/bin/sed

I could observe some errors due to incompetency of some library versions, such as , flex and netcdf-fortran.

latest version, netcdf-fortran-4.5.3 was not configuring with netcdf-c-4.8.0. while doing so, unexpected errors such as "configure: error: netcdf-c version 4.7.4 or greater is required " was shown!!!!.
Anyhow, this was solved while using a lower version, netcdf-fortran-4.5.0.

Similarly, the apt-installed version of flex library was flex 2.6.4, which resulted in errors " ERROR: variable name for third body in KPP species file is expected to be M, but was not found in cbm4 species file" . For which installing version 2.5.3 solved the problem, which was already mentioned in

Anyhow, Thank you somuch for your support.If any further details is required, please feel free to ask. It is my pleasure to help regarding this.