I’ve been trying to compile CCTM but keep getting different errors. I’ve solved a good amount of them, but I’m stuck again.
First I’ll list off the software I’m using: I’m on Ubuntu (v22.04.3), using GCC compilers (v11.4.0). I installed NetCDF-C (v4.9.2) and NetCDF-Fortran (v4.6.1). I’m also using OpenMPI (v4.1.6) and I/O API (v3.2).
First, I configure using source config_cmaq.csh gcc 11.4.0
; the file looks like this:
#!/bin/csh -f
# ================= CMAQv5.4.X Configuration Script ================= #
# Requirements: I/O API & netCDF libraries #
# PGI, Intel, or Gnu Fortran compiler #
# MPICH for multiprocessor computing #
# Optional: Git for GitHub source code repository #
# #
# Note that this script was configured/tested on Red Hat Linux O/S #
# #
# To report problems or request help with this script/program: #
# http://www.cmascenter.org/help-desk.cfm #
# =================================================================== #
#> Critical Folder Locations
# CMAQ_HOME - this is where the config_cmaq.csh script is located. It
# is also the root directory for all the executables. It may include
# the repository if the user is building CMAQ inside the repository. It
# may, on the other hand, be outside the repository if the user has
# created a separate project directory where they wish to put build-
# and run-scripts as well as executables.
setenv CMAQ_HOME $cwd
# CMAQ_REPO - this is always the location of the CMAQ repository that
# the user will pull from to create exectuables. If the user is building
# CMAQ inside the repository then it will be equal to CMAQ_HOME. If not,
# the user must supply an alternative folder locaiton.
setenv CMAQ_REPO /home/hector/Software/CMAQ_REPO
# CMAQ_DATA - this may be where the input data are located. It may be a
# symbolic link to another location on the system, but it should be
# provided here
setenv CMAQ_DATA $CMAQ_HOME/data
if ( ! -d $CMAQ_DATA ) mkdir -p $CMAQ_DATA
cd $CMAQ_HOME
#===============================================================================
#> architecture & compiler specific settings
#===============================================================================
#> Set the compiler option
if ( $#argv == 1 ) then
#> Use the user's input to set the compiler parameter
setenv compiler $1
setenv compilerVrsn Empty
else if ( $#argv == 2 ) then
#> Compiler Name and Version have been provided
setenv compiler $1
setenv compilerVrsn $2
else if ( $#argv == 0 ) then
#> If config.cmaq is called from Bldit.cctm or run.cctm, then this
#> variable is already defined
if ( ! $?compiler ) then
echo "Error: 'compiler' should be set either in the"
echo " environment or as input to config.cmaq"
echo " Example:> ./config.cmaq [compiler]"
echo " Options: intel | gcc | pgi"
exit
else if ( ! $?compilerVrsn ) then
setenv compilerVrsn Empty
endif
else
#> More than two inputs were given. Exit this script just to
#> be on the safe side.
echo "Error: Too many inputs to config.cmaq. This script"
echo " is expecting one input (the name of the"
echo " desired compiler. In some installations, you "
echo " may also be able to specify the compiler version "
echo " as the second input, but this is not by default."
exit
endif
echo "Compiler is set to $compiler"
#> Compiler flags and settings
switch ( $compiler )
#> Intel fortran compiler......................................................
[Removed other compilers for space]
#> gfortran compiler............................................................
case gcc:
#> I/O API, netCDF Library Locations -- used in WRF-CMAQ
setenv NETCDF /usr/local/lib/libnetcdf.so.19 # netcdf_root_gcc # Note please combine netCDF-C & Fortran Libraries
setenv IOAPI /home/hector/Software/ioapi-3.2-mpi/Linux2_x86_64gfortmpi/libioapi.a # ioapi_root_gcc
setenv WRF_ARCH # [1-75]
#> I/O API, netCDF, and MPI Library Locations -- used in CMAQ
setenv IOAPI_INCL_DIR /home/hector/Software/ioapi-3.2-nocpl/ioapi/fixed_src/ #> I/O API include header files
setenv IOAPI_LIB_DIR /home/hector/Software/ioapi-3.2-mpi/Linux2_x86_64gfortmpi/
#> I/O API libraries
setenv NETCDF_LIB_DIR /usr/local/lib #> netCDF C directory path
setenv NETCDF_INCL_DIR /usr/local/include/ #> netCDF C directory path
setenv NETCDFF_LIB_DIR /usr/local/lib #> netCDF Fortran directory path
setenv NETCDFF_INCL_DIR /usr/local/include/ #> netCDF Fortran directory path
setenv MPI_INCL_DIR /usr/lib/x86_64-linux-gnu/openmpi/include #> MPI Include directory path
setenv MPI_LIB_DIR /usr/lib/x86_64-linux-gnu/openmpi/lib #> MPI Lib directory path
#setenv MPI_INCL_DIR /usr/local/bin #> MPI Include dir>
#setenv MPI_LIB_DIR /usr/local/lib/openmpi
#> Compiler Aliases and Flags
#> set the compiler flag -fopt-info-missed to generate a missed optimization report in the bldit logfile
setenv myFC mpifort
setenv myCC gcc
setenv myFSTD "-O3 -funroll-loops -finit-character=32 -Wtabs -Wsurprising -ftree-vectorize -ftree-loop-if-convert -finline-limit=512"
setenv myDBG "-Wall -O0 -g -fcheck=all -ffpe-trap=invalid,zero,overflow -fbacktrace"
setenv myFFLAGS "-fallow-argument-mismatch -ffixed-form -ffixed-line-length-132 -funroll-loops -finit-character=32"
setenv myFRFLAGS "-ffree-form -ffree-line-length-none -funroll-loops -finit-character=32"
setenv myCFLAGS "-O2"
setenv myLINK_FLAG # "-fopenmp" openMP not supported w/ CMAQ
setenv extra_lib ""
breaksw
default:
echo "*** Compiler $compiler not found"
exit(2)
breaksw
endsw
#> Apply Specific Module and Library Location Settings for those working inside EPA
# source /work/MOD3DEV/cmaq_common/cmaq_env.csh #>>> UNCOMMENT if at EPA
#> Add The Complier Version Number to the Compiler String if it's not empty
setenv compilerString ${compiler}
if ( $compilerVrsn != "Empty" ) then
setenv compilerString ${compiler}${compilerVrsn}
endif
#===============================================================================
#> I/O API, netCDF, and MPI libraries
setenv netcdf_lib "-lnetcdff -lnetcdf" #> -lnetcdff -lnetcdf for netCDF v4.2.0 and later
setenv netcdff_lib "-lnetcdff"
setenv ioapi_lib "-lioapi"
setenv pnetcdf_lib "-lpnetcdf"
setenv mpi_lib "-lmpi" #> -lmpich or -lmvapich
#> Query System Info and Current Working Directory
setenv system "`uname -m`"
setenv bld_os "`uname -s``uname -r | cut -d. -f1`"
setenv lib_basedir $CMAQ_HOME/lib
#> Generate Library Locations
setenv CMAQ_LIB ${lib_basedir}/${system}/${compilerString}
setenv MPI_DIR $CMAQ_LIB/mpi
setenv NETCDF_DIR $CMAQ_LIB/netcdf
setenv NETCDFF_DIR $CMAQ_LIB/netcdff
setenv PNETCDF_DIR $CMAQ_LIB/pnetcdf
setenv IOAPI_DIR $CMAQ_LIB/ioapi
#> Create Symbolic Links to Libraries
if ( ! -d $CMAQ_LIB ) mkdir -p $CMAQ_LIB
if ( -e $MPI_DIR ) rm -rf $MPI_DIR
mkdir $MPI_DIR
ln -s $MPI_LIB_DIR $MPI_DIR/lib
ln -s $MPI_INCL_DIR $MPI_DIR/include
if ( ! -d $NETCDF_DIR ) mkdir $NETCDF_DIR
if ( ! -e $NETCDF_DIR/lib ) ln -sfn $NETCDF_LIB_DIR $NETCDF_DIR/lib
if ( ! -e $NETCDF_DIR/include ) ln -sfn $NETCDF_INCL_DIR $NETCDF_DIR/include
if ( ! -d $NETCDFF_DIR ) mkdir $NETCDFF_DIR
if ( ! -e $NETCDFF_DIR/lib ) ln -sfn $NETCDFF_LIB_DIR $NETCDFF_DIR/lib
if ( ! -e $NETCDFF_DIR/include ) ln -sfn $NETCDFF_INCL_DIR $NETCDFF_DIR/include
if ( ! -d $IOAPI_DIR ) then
mkdir $IOAPI_DIR
ln -sfn $IOAPI_INCL_DIR $IOAPI_DIR/include_files
ln -sfn $IOAPI_LIB_DIR $IOAPI_DIR/lib
endif
#> Check for netcdf and I/O API libs/includes, error if they don't exist
# if ( ! -e $NETCDF_DIR/lib/libnetcdf.a ) then
# echo "ERROR: $NETCDF_DIR/lib/libnetcdf.a does not exist in your CMAQ_LIB directory!!! Check your installation before proceeding with CMAQ build."
# exit
endif
if ( ! -e $NETCDFF_DIR/lib/libnetcdff.a ) then
echo "ERROR: $NETCDFF_DIR/lib/libnetcdff.a does not exist in your CMAQ_LIB directory!!! Check your installation before proceeding with CMAQ build."
exit
endif
if ( ! -e $IOAPI_DIR/lib/libioapi.a ) then
echo "ERROR: $IOAPI_DIR/lib/libioapi.a does not exist in your CMAQ_LIB directory!!! Check your installation before proceeding with CMAQ build."
exit
endif
if ( ! -e $IOAPI_DIR/lib/m3utilio.mod ) then
echo "ERROR: $IOAPI_MOD_DIR/m3utilio.mod does not exist in your CMAQ_LIB directory!!! Check your installation before proceeding with CMAQ build."
exit
endif
#> Set executable id
setenv EXEC_ID ${bld_os}_${system}${compilerString}
(Note: the reason I used different libraries for i/o api and its include files is that I wasn’t able to build m3tools for the version with mpi, but I’m told that the m3tools that I built for the no-coupling mode of i/o api works fine, since it’s the same file type)
I then went onto /CMAQ_HOME/lib/x86_64/gcc11.4.0/ and created a new folder called pnetcdf, and pasted links to the lib and include files, since bldit_cctm.csh
calls for it.
cd /CCTM/scripts and
source bldit_cctm.csh gcc 11.4.0 |& tee build_cctm.log
This prints out a ton of stuff, but ends up on an error:
Compiler is set to gcc
setenv CCTM_SRC /home/hector/Software/CMAQ_REPO/CCTM/src
set GlobInc = /home/hector/Software/CMAQ_REPO/CCTM/src/ICL
set Mechs = /home/hector/Software/CMAQ_REPO/CCTM/src/MECHS
setenv REPOROOT /home/hector/Software/CMAQ_REPO/CCTM/src
set CompileBLDMAKE
set CopySrc
set ParOpt
set build_parallel_io
set make_options = -j
if ( 0 ) then
if ( 0 ) then
set VRSN = v54
[...]
396 | WRITE( XMSG,'(A,A,A,/,A,I2,A)' ), '*** Reference Aerosol Mode (',
| 1
Warning: Legacy Extension: Comma before i/o item list at (1)
AERO_EMIS.F:413:54:
413 | WRITE( XMSG,'(A,A,A,/,A,I2,A)' ), '*** Reference Aerosol Mode (',
| 1
Warning: Legacy Extension: Comma before i/o item list at (1)
sciproc.F:218:30:
218 | WRITE( XMSG, '(2x,6A)' ), 'Which is Equivalent to (UTC): ',
| 1
Warning: Legacy Extension: Comma before i/o item list at (1)
sciproc.F:224:34:
224 | WRITE( XMSG, '(2x,A,I6.6)' ), 'Time-Step Length (HHMMSS): ',TSTEP(2)
| 1
Warning: Legacy Extension: Comma before i/o item list at (1)
BDSNP_MOD.F:586:19:
586 | IF ( .NOT. FLUSH3 ( SOILOUT ) ) THEN
| 1
Error: Function ‘flush3’ at (1) has no IMPLICIT type; did you mean ‘close3’?
make: *** [Makefile:453: BDSNP_MOD.o] Error 1
make: *** Waiting for unfinished jobs....
**ERROR** while running make command
if ( ! 0 ) then
mv Makefile Makefile.gcc11.4.0
mv: 'Makefile' and 'Makefile.gcc11.4.0' are the same file
if ( -e Makefile.gcc11.4.0 && -e Makefile ) rm Makefile
rm Makefile
ln -s Makefile.gcc11.4.0 Makefile
endif
if ( 0 != 0 ) then
if ( -e /home/hector/CMAQ-5.4/CCTM/scripts/BLD_CCTM_v54_gcc11.4.0/CCTM_v54.cfg ) then
echo >>> previous CCTM_v54.cfg exists, re-naming to CCTM_v54.cfg.old <<<
>>> previous CCTM_v54.cfg exists, re-naming to CCTM_v54.cfg.old <<<
mv /home/hector/CMAQ-5.4/CCTM/scripts/BLD_CCTM_v54_gcc11.4.0/CCTM_v54.cfg /home/hector/CMAQ-5.4/CCTM/scripts/BLD_CCTM_v54_gcc11.4.0/CCTM_v54.cfg.old
endif
mv CCTM_v54.cfg.bld /home/hector/CMAQ-5.4/CCTM/scripts/BLD_CCTM_v54_gcc11.4.0/CCTM_v54.cfg
if ( 0 ) then
exit
If I had to guess, I’d say the error is caused by the way I linked the libraries and include files. I spent like 5 hours figuring out where everything was and I really made an effort to link everything correctly, but considering I’m new to linux and compiling stuff, there is a good chance I didn’t do it right. I’m not really sure how to ensure that the files I linked to are in fact the correct libraries/include files, since I didn’t even know what include files were up to like a week ago. Any pointers would be really greatly appreciated, and please consider that my knowledge about compiling is very limited. Thanks in advance!