# Trying to compile CCTM, but I get an error message relating to the Makefile

**URL:** <https://forum.cmascenter.org/t/trying-to-compile-cctm-but-i-get-an-error-message-relating-to-the-makefile/4481>\
**Category:** Compiling\
**Created:** [October 13, 2023, 1:27am UTC](https://forum.cmascenter.org/t/trying-to-compile-cctm-but-i-get-an-error-message-relating-to-the-makefile/4481 "2023-10-13T01:27:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HectorVG](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.cmascenter.org/hectorvg/32/3545_2.png) [@HectorVG](https://forum.cmascenter.org/u/HectorVG)\
**Post date:** [October 13, 2023, 1:27am UTC](https://forum.cmascenter.org/t/trying-to-compile-cctm-but-i-get-an-error-message-relating-to-the-makefile/4481/1 "2023-10-13T01:27:28Z")

</div>

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:

```auto
#!/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

```auto
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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![HectorVG](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.cmascenter.org/hectorvg/32/3545_2.png) [@HectorVG](https://forum.cmascenter.org/u/HectorVG)\
**Post date:** [October 13, 2023, 1:32am UTC](https://forum.cmascenter.org/t/trying-to-compile-cctm-but-i-get-an-error-message-relating-to-the-makefile/4481/2 "2023-10-13T01:32:18Z")

</div>

`bldit_cctm.csh` was too big and didn’t fit in the original post, but if it helps, here it is:

```auto
#!/bin/csh -f

# ======================= CCTMv5.4.X Build Script ========================= 
# Usage: bldit.cctm >&! bldit.cctm.log                                   
# Requirements: I/O API & netCDF libraries, a Fortran compiler,               
# and MPI for multiprocessor computing                     
#
# To report problems or request help with this script/program:           
# http://www.cmascenter.org
# ======================================================================= 

#> Set Compiler Identity by User Input: Options -> intel | pgi | gcc
 if ( $#argv == 1 ) then
    setenv compiler $argv[1]
    setenv compilerVrsn Empty
 else if ( $#argv == 2 ) then
    #> Compiler Name and Version have been provided
    setenv compiler $1
    setenv compilerVrsn $2
 else
    echo "usage: $0 <compiler>"
    echo " where <compiler> is intel, pgi or gcc"
    exit(2)
 endif
 
#> Source the config.cmaq file to set the build environment
 cd ../..
 source ./config_cmaq.csh

 set echo

# =======================================================================
#> Begin User Input Section
# =======================================================================

#> Source Code Locations
 setenv CCTM_SRC ${CMAQ_REPO}/CCTM/src #> location of the CCTM source code
 set GlobInc = $CCTM_SRC/ICL #> location of the global include files
 set Mechs = $CCTM_SRC/MECHS #> location of the chemistry mechanism include files
 setenv REPOROOT $CCTM_SRC

#> Controls for managing the source code and MPI compilation
set CompileBLDMAKE #> Recompile the BLDMAKE utility from source
                                       #> comment out to use an existing BLDMAKE executable
set CopySrc #> copy the source files into the build directory
#set CopySrcTree #> copy the source files and directory tree into the build directory
#set MakeFileOnly #> uncomment to build a Makefile, but do not compile; 
                                       #> comment out to compile the model (default if not set)
#set build_mech #> uncomment to build mechanism source code files using the 
                                       #> chemmech utility.

#> Below are chemmech options for revising the mechanism definitions file. The option needs information on the
#> composition of each chemistry. See UTIL/chemmech/README.md for more information.
#> Uncomment to use.
#> Rewrite reactions by appending them with changes in tracked atoms or elements from reactants to products
      #setenv COMPUTE_DELTA_ATOMS F
#> The species namelist contains the composition information as comments at the end of lines defining species.
#> Note that if a defining line does not have an ending comment, the species is taken to have none of the tacked atoms.
#> If NAMELISTS_LIST_ATOMS equals F, an additional ASCII file contains the information.
      #setenv NAMELISTS_LIST_ATOMS T

#set clobber_mech #> when commented, the bldit_mech.csh script will halt if 
                                       #> newly created mechanism files are attempting replace
                                       #> existing ones. When uncommented, the existing files
                                       #> will be overwritten.
set ParOpt #> uncomment to build a multiple processor (MPI) executable; 
                                       #> comment out for a single processor (serial) executable
#set DistrEnv #> uncomment to distribute environmental variables to multiple machines
                                       #> comment out for a single processor (serial) executable (MPI only)
set build_parallel_io #> uncomment to build with parallel I/O (pnetcdf); 
                                       #> comment out to use standard netCDF I/O
#set Debug_CCTM #> uncomment to compile CCTM with debug option equal to TRUE
                                       #> comment out to use standard, optimized compile process
set make_options = "-j" #> additional options for make command if MakeFileOnly is not set
                                       #> comment out if no additional options are wanted.

[removed ISAM for space]

#> Potential vorticity free-troposphere O3 scaling
#set potvortO3

#> Working directory and Version IDs
 if ( $?ISAM_CCTM ) then
     set VRSN = v54_ISAM #> model configuration ID for CMAQ_ISAM
 else if ( $?DDM3D_CCTM ) then
     set VRSN = v54_DDM3D #> model configuration ID for CMAQ_DDM
 else
     set VRSN = v54 #> model configuration ID for CMAQ
 endif
 
 set EXEC = CCTM_${VRSN}.exe #> executable name
 set CFG = CCTM_${VRSN}.cfg #> configuration file name

 if ( $?build_twoway ) then # WRF Version used for WRF-CMAQ Model (must be v4.4+)
    set WRF_VRSN = v4.4
 endif   

#========================================================================
#> CCTM Science Modules
#========================================================================
#> NOTE: For the modules with multiple options, a note is 
#> provided on where to look in the CCTM source code 
#> archive for a list of the possible settings. Users 
#> may also refer to the CMAQ documentation.

 set ModGrid = grid/cartesian #> grid configuration module 
 
 set DepMod = m3dry #> m3dry or stage
#set DepMod = stage
 set ModAdv = wrf_cons #> 3-D Advection Scheme [Options: wrf_cons (default), local_cons]
 set ModHdiff = hdiff/multiscale #> horizontal diffusion module
 set ModVdiff = vdiff/acm2_${DepMod} #> vertical diffusion module (see $CMAQ_MODEL/CCTM/src/vdiff)
 set ModDepv = depv/${DepMod} #> deposition velocity calculation module 
                                            #> (see $CMAQ_MODEL/CCTM/src/depv)
 set ModEmis = emis/emis #> in-line emissions module
 set ModBiog = biog/beis4 #> BEIS4 in-line emissions module 

 set ModMegBiog = biog/megan3 #> MEGAN3 in-line emissions module

 set ModPlmrs = plrise/smoke #> in-line emissions plume rise
 set ModCgrds = spcs/cgrid_spcs_nml #> chemistry species configuration module 
                                            #> (see $CMAQ_MODEL/CCTM/src/spcs)
 set ModPhot = phot/inline #> photolysis calculation module 
                                            #> (see $CMAQ_MODEL/CCTM/src/phot)

 setenv Mechanism cb6r5_ae7_aq #> chemical mechanism (see $CMAQ_MODEL/CCTM/src/MECHS) 
 set ModMech = MECHS/${Mechanism}

 if ( ${Mechanism} =~ *ae7* ) then #> ae7 family of aero and cloud chem
     set ModAero = aero/aero7 # > aerosol chemistry module (see $CMAQ_MODEL/CCTM/src/aero)
     set ModCloud = cloud/acm_ae7 # > cloud chemistry module (see $CMAQ_MODEL/CCTM/src/cloud)
 else if ( ${Mechanism} =~ *ae6* ) then #> ae6 family of aero and cloud chem
     set ModAero = aero/aero6 # > aerosol chemistry module (see $CMAQ_MODEL/CCTM/src/aero)
     set ModCloud = cloud/acm_ae6 # > cloud chemistry module (see $CMAQ_MODEL/CCTM/src/cloud)
 else if ( ${Mechanism} =~ *cracmm* ) then #> CRACMM family of aero and cloud chem
     set ModAero = aero/cracmm # > aerosol chemistry module (see $CMAQ_MODEL/CCTM/src/aero)
     set ModCloud = cloud/acm_cracmm # > cloud chemistry module (see $CMAQ_MODEL/CCTM/src/cloud)
 endif

 # Special cloud modules for kmt versions
 if( ${Mechanism} == cb6r5_ae7_aqkmt2 ) then
     set ModCloud = cloud/acm_ae7_kmt2
 else if( ${Mechanism} == saprc07tic_ae7i_aqkmt2 ) then
     set ModCloud = cloud/acm_ae7_kmt2
 endif

 # Gas chem solver
 if ( ${Mechanism} == cb6r5m_ae7_aq ) then #> Gas-phase chemistry solver options ($CMAQ_MODEL/CCTM/src/gas)
     setenv ChemSolver ros3 #> ros3 (or smvgear) are system independent
 else                                      
     setenv ChemSolver ebi #> [default for most mechanisms: ebi]
 endif
                                         
 if ( $ChemSolver == ebi ) then             
    set ModGas = gas/${ChemSolver}_${Mechanism}
                                            
 else
    set ModGas = gas/${ChemSolver}
 endif
    
 set ModUtil = util/util #> CCTM utility modules
 set ModDiag = diag #> CCTM diagnostic modules
 set Tracer = trac0 #> tracer configuration directory under 
                                            #> $CMAQ_MODEL/CCTM/src/MECHS [default: no tracer species]
 set ModPa = procan/pa #> CCTM process analysis
 set ModPvO3 = pv_o3 #> potential vorticity from the free troposphere
 set ModISAM = isam #> CCTM Integrated Source Apportionment Method
 set ModDDM3D = ddm3d #> Decoupled Direct Method in 3D
 set ModDegrade = reactive_tracers #> Linear Chemical Loss for a fixed set of species treated as reactive tracers

#============================================================================================
#> Computing System Configuration:
#> Most of these settings are done in config.cmaq
#============================================================================================

 setenv FC ${myFC} #> path of Fortan compiler; set in config.cmaq
 set FP = $FC #> path of Fortan preprocessor; set in config.cmaq
 set CC = ${myCC} #> path of C compiler; set in config.cmaq
 setenv BLDER ${CMAQ_HOME}/UTIL/bldmake/bldmake_${compilerString}.exe #> name of model builder executable

#> Libraries/include files
#set LIOAPI = "${IOAPI_DIR}/lib ${ioapi_lib}" #> I/O API library directory
#set IOAPIMOD = "${IOAPI_DIR}/include" #> I/O API module directory
 set NETCDF = "${NETCDF_DIR}/lib ${netcdf_lib}" #> netCDF C library directory
 set NETCDFF = "${NETCDFF_DIR}/lib ${netcdff_lib}" #> netCDF Fortran library directory
 set PNETCDF = "${PNETCDF_DIR}/lib ${pnetcdf_lib}" #> Parallel netCDF library directory
#set PIO_INC = "${IOAPI_DIR}/src"

#> Compiler flags set in config.cmaq
 set FSTD = "${myFSTD}"
 set DBG = "${myDBG}"
 setenv F_FLAGS "${myFFLAGS}" #> F77 flags
 set F90_FLAGS = "${myFRFLAGS}" #> F90 flags
 set CPP_FLAGS = "" #> Fortran preprocessor flags
 set C_FLAGS = "${myCFLAGS} -DFLDMN -I" #> C flags
 set LINK_FLAGS = "${myLINK_FLAG}" # Link flags

#============================================================================================
#> Implement User Input
#============================================================================================

#> Check for CMAQ_REPO and CMAQ_LIB settings:
 if ( ! -e $CMAQ_REPO || ! -e $CMAQ_LIB ) then
    echo " $CMAQ_REPO or $CMAQ_LIB directory not found"
    exit 1
 endif
 echo " Model repository base path: $CMAQ_REPO"
 echo " library path: $CMAQ_LIB"

#> If $CMAQ_MODEL is not set, default to $CMAQ_REPO
 if ( $?CMAQ_MODEL ) then
    echo " Model repository path: $CMAQ_MODEL"
 else
    setenv CMAQ_MODEL $CMAQ_REPO
    echo " default Model repository path: $CMAQ_MODEL"
 endif

#> This script was written for Linux hosts only. If
#> the host system is not Linux, produce an error and stop
 set BLD_OS = `uname -s`       
 if ($BLD_OS != 'Linux') then
    echo " $BLD_OS -> wrong bldit script for host!"
    exit 1
 endif

#> If the two-way, coupled WRF-CMAQ model is being built,
#> then just generate the Makefile. Don't compile.
 if ( $?build_twoway ) then
    set MakeFileOnly   
    set ModTwoway = twoway
 endif

#> If parallel-io is selected, then make sure the multiprocessor
#> option is also set.
 if ( $?build_parallel_io ) then
    if ( ! $?ParOpt ) then
       echo "*** ParOpt is not set: required for the build_parallel_io option"
       exit 1
    endif
    set PIO = ( -Dparallel_io )
 else
    set PIO = ""
 endif

 if ($DepMod == m3dry) then
    set cpp_depmod = '-Dm3dry_opt'
 else if ($DepMod == stage) then
    set cpp_depmod = '-Dstage_opt'
 endif

#> Set variables needed for multiprocessor and serial builds
 if ( $?ParOpt ) then    
    #Multiprocessor system configuration
    echo " Parallel; set MPI flags"
    set ModStenex = STENEX/se
    set ModPario = PARIO
    set ModPar = par/mpi
    set PARIO = ${CMAQ_MODEL}/PARIO
    set STENEX = ${CMAQ_MODEL}/STENEX
    # MPI_INC is set in config.cmaq
    # set PIO_INC = "${IOAPI_DIR}/src/fixed_src"
    set PAR = ( -Dparallel )
    set Popt = SE
    set seL = se_snl
    set LIB2 = "${ioapi_lib}"
    set LIB3 = "${mpi_lib} ${extra_lib}"
    set Str1 = (// Parallel / Include message passing definitions)
    set Str2 = (include SUBST_MPI mpif.h;)
    # Distribute Environment to different machines if not done automatically 
    if ( $?DistrEnv ) then
      set PAR = ($PAR -Dcluster) 
    endif
 else
    #Serial system configuration
    echo " Not Parallel; set Serial (no-op) flags"
    set ModStenex = STENEX/noop
    set ModPar = par/par_noop
    set PARIO = "."
    set STENEX = ${CMAQ_MODEL}/STENEX/noop
    set MPI_INC = "."
    # set PIO_INC = "."
    set PAR = ""
    set Popt = NOOP
    set seL = sef90_noop
    set LIB2 = "${ioapi_lib} ${extra_lib}"
    set Str1 =
    set Str2 =
 endif 

#> if DDM-3D is set, add the pre-processor flag for it.
 if ( $?DDM3D_CCTM ) then
    set SENS = ( -Dsens )
 else
    set SENS = ""
 endif
 
#> Build Mechanism Files and instruct build-make to look
#> in the CHEMMECH output folder for the files
 if ( $?build_mech ) then

    # Because the bldit_cctm script is executing the bldit_mech
    # processor, we will assume that the source location for the new 
    # mechanism files is in the CMAQ repo. There will also be an 
    # error check for overwriting an existing mechanism that can be
    # disabled using the mech_clobber variable above.
    setenv MECH_SRC ${CMAQ_REPO}/CCTM/src/${ModMech}
    setenv TRAC_NML ${CMAQ_REPO}/CCTM/src/MECHS/trac0/Species_Table_TR_0.nml
    setenv MECH_OUT ${CMAQ_REPO}/CCTM/src/${ModMech}
    setenv EBI_SOLVER_OUT ${CMAQ_REPO}/CCTM/src/${ModGas}
    if ( $?clobber_mech ) then
      setenv CLOBBER_MECH TRUE
    else
      setenv CLOBBER_MECH FALSE
    endif

    cd ${CMAQ_HOME}/CCTM/scripts
    ./bldit_mech.csh ${compiler} ${compilerVrsn}
    if ( $? != 0 ) then
      echo ""
      echo "bldit_mech did not finish correctly --> Build Process Halted"
      exit 1
    endif
 endif

#> Tracer configuration files
 set ModTrac = MECHS/$Tracer

#> free trop. O3 potential vorticity scaling
 if ( $?potvortO3 ) then 
    set POT = ( -Dpotvorto3 )
 else
    set POT = ""
 endif 

#> Set and create the "BLD" directory for checking out and compiling 
#> source code. Move current directory to that build directory.
 if ( $?Debug_CCTM ) then
    set Bld = $CMAQ_HOME/CCTM/scripts/BLD_CCTM_${VRSN}_${compilerString}_debug
 else
    set Bld = $CMAQ_HOME/CCTM/scripts/BLD_CCTM_${VRSN}_${compilerString}
 endif

 if ( ! -e "$Bld" ) then
    mkdir $Bld
 else
    if ( ! -d "$Bld" ) then
       echo " ***target exists, but not a directory***"
       exit 1
    endif
 endif
 cd $Bld

#> Set locations for the include files of various modules
 set ICL_PAR = $GlobInc/fixed/mpi         
 set ICL_CONST = $GlobInc/fixed/const       
 set ICL_FILES = $GlobInc/fixed/filenames
 set ICL_EMCTL = $GlobInc/fixed/emctrl
#set ICL_PA = $GlobInc/procan/$PAOpt

 #Test with xlib commented out
 if ( $?ParOpt ) then
    set ICL_MPI = . #$xLib_Base/$xLib_3
 endif

#> If the source code is being copied to the build directory,
#> then move the include files as well and direct the Makefile
#> to the current directory.
 if ( $?CopySrc ) then
    /bin/cp -fp ${ICL_PAR}/* ${Bld}
    /bin/cp -fp ${ICL_CONST}/* ${Bld}
    /bin/cp -fp ${ICL_FILES}/* ${Bld}
    /bin/cp -fp ${ICL_EMCTL}/* ${Bld}
    #/bin/cp -fp ${ICL_PA}/* ${Bld}
    if ( $?ParOpt ) then
       /bin/cp -fp ${ICL_MPI}/mpif.h ${Bld}
    endif

    set ICL_PAR = .
    set ICL_CONST = .
    set ICL_FILES = .
    set ICL_EMCTL = .
    #set ICL_PA = .
    if ( $?ParOpt ) then
       set ICL_MPI = .
    endif
 endif

 set STX1 = ( -DSUBST_BARRIER=${Popt}_BARRIER\
              -DSUBST_GLOBAL_MAX=${Popt}_GLOBAL_MAX\
              -DSUBST_GLOBAL_MIN=${Popt}_GLOBAL_MIN\
              -DSUBST_GLOBAL_MIN_DATA=${Popt}_GLOBAL_MIN_DATA\
              -DSUBST_GLOBAL_TO_LOCAL_COORD=${Popt}_GLOBAL_TO_LOCAL_COORD\
              -DSUBST_GLOBAL_SUM=${Popt}_GLOBAL_SUM\
              -DSUBST_GLOBAL_LOGICAL=${Popt}_GLOBAL_LOGICAL\
              -DSUBST_GLOBAL_GATHER=${Popt}_GLOBAL_GATHER\
              -DSUBST_GLOBAL_BCAST=${Popt}_GLOBAL_BCAST\
              -DSUBST_LOOP_INDEX=${Popt}_LOOP_INDEX\
              -DSUBST_SUBGRID_INDEX=${Popt}_SUBGRID_INDEX )
 set STX2 = ( -DSUBST_HI_LO_BND_PE=${Popt}_HI_LO_BND_PE\
              -DSUBST_SUM_CHK=${Popt}_SUM_CHK\
              -DSUBST_SE_INIT=${Popt}_INIT\
              -DSUBST_INIT_ARRAY=${Popt}_INIT_ARRAY\
              -DSUBST_COMM=${Popt}_COMM\
              -DSUBST_MY_REGION=${Popt}_MY_REGION\
              -DSUBST_SLICE=${Popt}_SLICE\
              -DSUBST_GATHER=${Popt}_GATHER\
              -DSUBST_DATA_COPY=${Popt}_DATA_COPY\
              -DSUBST_IN_SYN=${Popt}_IN_SYN )

#> 3-D Advection Options
 if ( $ModAdv == wrf_cons ) then
    set ModCpl = couple/gencoor_wrf_cons #> unit conversion and concentration coupling module 
                                               #> (see $CMAQ_MODEL/CCTM/src/couple)
    set ModHadv = hadv/ppm #> horizontal advection module   
    set ModVadv = vadv/wrf_cons #> Vertical advection module                             
 else if ($ModAdv == local_cons) then
    set ModCpl = couple/gencoor_local_cons #> unit conversion and concentration coupling module 
                                               #> (see $CMAQ_MODEL/CCTM/src/couple)
    set ModHadv = hadv/ppm #> horizontal advection module
    set ModVadv = vadv/local_cons #> Vertical advection module
 endif

 # Retrieve git repository sha ID for this source code version
 set shaID = `git --git-dir=${CMAQ_REPO}/.git rev-parse --short=10 HEAD`
 if ( $? != 0 ) then
    set shaID = "not_a_repo"
 endif

#
#> Create Config File 
# 

set Cfile = ${Bld}/${CFG}.bld # Config Filename
 set quote = '"'

 echo > $Cfile
 if ( $?make_options ) then
    echo "make_options $quote$make_options$quote;" >> $Cfile
    
[Removed echos]

 if ( $?ParOpt ) then
    echo "$Str1" >> $Cfile
    echo "include SUBST_MPI ./mpif.h;" >> $Cfile
 endif
 echo >> $Cfile

 set text = "stenex or se_noop"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModStenex};" >> $Cfile
 if ( $?ParOpt ) then
    set text = "// parallel executable; stenex and pario included"
    echo $text >> $Cfile
    echo "Module ${ModPario};" >> $Cfile
 else
    set text = "serial executable; noop stenex"
    echo $text >> $Cfile
 endif
 echo >> $Cfile

 set text = "par, par_nodistr and par_noop"
 echo "// options are" $text >> $Cfile
 if ( $?ParOpt ) then
    echo "Module ${ModPar};" >> $Cfile
 endif
 echo >> $Cfile

 if ( $?build_twoway ) then
    echo "// option set for WRF-CMAQ twoway" >> $Cfile
    echo "Module ${ModTwoway};" >> $Cfile
    echo >> $Cfile
 endif

 set text = "driver"
 echo "// options are" $text >> $Cfile
 echo "Module driver;" >> $Cfile
 echo >> $Cfile

 set text = "cartesian"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModGrid};" >> $Cfile
 echo >> $Cfile

 set text = "Init"
 echo "// options are" $text >> $Cfile
 echo "Module init;" >> $Cfile
 echo >> $Cfile

 set text = "gencoor_wrf_cons and gencoor_local_cons"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModCpl};" >> $Cfile
 echo >> $Cfile

 set text = "ppm"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModHadv};" >> $Cfile
 echo >> $Cfile

 set text = "wrf_cons and local_cons"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModVadv};" >> $Cfile
 echo >> $Cfile

 set text = "multiscale"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModHdiff};" >> $Cfile
 echo >> $Cfile

 set text = "acm2_m3dry or acm2_stage"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModVdiff};" >> $Cfile
 echo >> $Cfile

 set text = "m3dry or stage"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModDepv};" >> $Cfile
 echo >> $Cfile

 set text = "emis"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModEmis};" >> $Cfile
 echo >> $Cfile

 set text = "beis4"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModBiog};" >> $Cfile
 echo >> $Cfile

 set text = "megan3"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModMegBiog};" >> $Cfile
 echo  

 set text = "smoke"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModPlmrs};" >> $Cfile
 echo >> $Cfile

 set text = "cgrid_spcs_nml and cgrid_spcs_icl"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModCgrds};" >> $Cfile
 echo >> $Cfile

 set text = "inline and table"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModPhot};" >> $Cfile
 echo >> $Cfile

 set text = "degrade"
 echo "// reactive_tracer options are" $text >> $Cfile
 echo "Module ${ModDegrade};" >> $Cfile
 echo >> $Cfile

 set text = "gas chemistry solvers"
 echo "// " $text >> $Cfile
 set text = "smvgear, ros3, and ebi; see 'gas chemistry mechanisms' for <mech>"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModGas};" >> $Cfile
 echo >> $Cfile

 set MechList = "cb6r5hap_ae7_aq, cb6r3_ae7_aq, cb6r5_ae7_aq, cb6r5_ae7_aqkmt2, cb6r5m_ae7_aq, racm2_ae6_aq, saprc07tc_ae6_aq, saprc07tic_ae7i_aq, saprc07tic_ae7i_aqkmt2"

 set text = "gas chemistry mechanisms"
 echo "// " $text >> $Cfile
 set text = "$MechList"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModMech};" >> $Cfile
 echo >> $Cfile

 set text = "tracer modules"
 echo "// " $text >> $Cfile
 echo "// options are trac0, trac1" >> $Cfile
 echo "Module ${ModTrac};" >> $Cfile
 echo 

 if ( $?potvortO3 ) then
    set text = "use potential vorticity free-troposphere O3 scaling"
    echo "// options are" $text >> $Cfile
    echo "Module ${ModPvO3};" >> $Cfile
    echo >> $Cfile
 endif

 set text = "aero6"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModAero};" >> $Cfile
 echo >> $Cfile

 set text = "acm_ae6, acm_ae6_kmt, acm_ae7_kmt2, acm_ae6_mp, acm_ae7"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModCloud};" >> $Cfile
 echo >> $Cfile

 set text = "// compile for inline process analysis"
 echo $text >> $Cfile
 echo "Module ${ModPa};" >> $Cfile
 echo >> $Cfile

 set text = "// compile for integrated source apportionment method"
 echo $text >> $Cfile
 echo "Module ${ModISAM};" >> $Cfile
 echo >> $Cfile

 if ( $?DDM3D_CCTM ) then
   set text = "// compile for decoupled direct method in 3d"
   echo $text >> $Cfile
   echo "Module ${ModDDM3D};" >> $Cfile
   echo >> $Cfile
 endif

 set text = "util"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModUtil};" >> $Cfile
 echo >> $Cfile

 set text = "diag"
 echo "// options are" $text >> $Cfile
 echo "Module ${ModDiag};" >> $Cfile
 echo >> $Cfile

 set text = "stm"
 echo "// options are" $text >> $Cfile
 echo "Module stm;" >> $Cfile
 echo >> $Cfile

 set text = "cio"
 echo "// options are" $text >> $Cfile
 echo "Module cio;" >> $Cfile
 echo >> $Cfile

 if ( $?ModMisc ) then
    echo "Module ${ModMisc};" >> $Cfile
    echo >> $Cfile
 endif

# ============================================================================
#> Create Makefile and Model Executable
# ============================================================================
 unalias mv rm

#> Recompile BLDMAKE from source if requested or if it does not exist
 if ( $?CompileBLDMAKE || ! -f $BLDER ) then
   cd ${CMAQ_REPO}/UTIL/bldmake/scripts
   ./bldit_bldmake.csh
 endif

#> Relocate to the BLD_* directory 
 cd $Bld

#> Set multiprocessor/serial options for BLDMAKE execution
 if ( $?ParOpt ) then
    set Blder = "$BLDER -verbose"
 else
    set Blder = "$BLDER -serial -verbose"
 endif

#> Run BLDMAKE Utility
 set bld_flags = ""
 if ( $?MakeFileOnly ) then # Do not compile the Model
    set bld_flags = "${bld_flags} -makefo"
 endif

 if ( $?CopySrc ) then
    set bld_flags = "${bld_flags}"
 else if ( $?CopySrcTree ) then   
    set bld_flags = "${bld_flags} -co"
 else 
    set bld_flags = "{bld_flags} -git_local" # Run BLDMAKE with source code in 
                                              # version-controlled git repo
                                              # $Cfile = ${CFG}.bld
 endif

 if ( $?Debug_CCTM ) then
    set bld_flags = "${bld_flags} -debug_cctm"
 endif

 if ( $?ISAM_CCTM ) then
    set bld_flags = "${bld_flags} -isam_cctm"
 endif

 if ( $?build_twoway ) then
   set bld_flags = "${bld_flags} -twoway"
 endif

#> Run BLDMAKE with source code in build directory
 $Blder $bld_flags $Cfile   

#> Rename Makefile to specify compiler option and link back to Makefile
 if ( ! $?build_twoway ) then
    mv Makefile Makefile.$compilerString
    if ( -e Makefile.$compilerString && -e Makefile ) rm Makefile
    ln -s Makefile.$compilerString Makefile
 endif

#> Alert user of error in BLDMAKE if it ocurred
 if ( $status != 0 ) then
    echo " ***failure in $Blder***"
    exit 1
 endif

#> Preserve old Config file, if it exists, before moving new one to 
#> build directory.
 if ( -e "$Bld/${CFG}" ) then
    echo " >>> previous ${CFG} exists, re-naming to ${CFG}.old <<<"
    mv $Bld/${CFG} $Bld/${CFG}.old
 endif
 mv ${CFG}.bld $Bld/${CFG}

#> If Building WRF-CMAQ, download WRF, download auxillary files and build
#> model
 if ( $?build_twoway ) then

#> Check if the user has git installed on their system
  git --version >& /dev/null
  
  if ($? == 0) then
   set git_check
  endif
 
  if ($?git_check) then

    cd $CMAQ_HOME/CCTM/scripts
  
    # Downlad WRF repository from GitHub and put CMAQv5.4 into it
    set WRF_BLD = BLD_WRF${WRF_VRSN}_CCTM_${VRSN}_${compilerString}
    setenv wrf_path ${CMAQ_HOME}/CCTM/scripts/${WRF_BLD}
    setenv WRF_CMAQ 1

    if ( ! -d $WRF_BLD ) then 
      git clone --branch ${WRF_VRSN} https://github.com/wrf-model/WRF.git ./$WRF_BLD >& /dev/null
      cd $wrf_path
      mv $Bld ./cmaq
  
      # Configure WRF
        ./configure <<EOF
        ${WRF_ARCH}
        1
EOF

    else
      # Clean-up 
      rm -r $Bld
      cd $wrf_path
    endif

     # Compile WRF-CMAQ
     ./compile em_real |& tee -a wrf-cmaq_buildlog.log

     cd ${CMAQ_HOME}/CCTM/scripts

   endif

 endif 

exit

```

---

<div class="post-metadata">

**Author:** ![cjcoats](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@cjcoats](https://forum.cmascenter.org/u/cjcoats)\
**Post date:** [October 16, 2023, 7:23pm UTC](https://forum.cmascenter.org/t/trying-to-compile-cctm-but-i-get-an-error-message-relating-to-the-makefile/4481/3 "2023-10-16T19:23:58Z")

</div>

No, this is a combination between being the compiler’s flag, and the author of _bldit_ not making the right allowances: for version 10 and later, the _gfortran_ compiler-authors are choosing a stuffy and idiosyncratic interpretation. You either need to fix this code to match what they want (probably not what you want to do yourself) or else you need to add `-std=legacy` to the Fortran compile-flags.

---

<div class="post-metadata">

**Author:** ![HectorVG](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.cmascenter.org/hectorvg/32/3545_2.png) [@HectorVG](https://forum.cmascenter.org/u/HectorVG)\
**Post date:** [October 17, 2023, 4:59am UTC](https://forum.cmascenter.org/t/trying-to-compile-cctm-but-i-get-an-error-message-relating-to-the-makefile/4481/4 "2023-10-17T04:59:43Z")

</div>

Thanks a lot for your reply! I added `-std=legacy` to `myFSTD`, `myDBG`, `myFFLAGS ` and `myFRFLAGS` in `config_cmaq.csh` (I added it to all just to be sure). I also added it to `CPP_FLAGS` in `bldit_cctm.csh`, re-ran `config_cmaq.csh` then

```auto
cd /CCTM/scripts/
source bldit_cctm.csh gcc 11.4.0 |& tee build_cctm-log

```

It runs fine until it creates the makefile, then this happens:

```auto
Makefile generated
mpifort -c -ffixed-form -ffixed-line-length-132 -funroll-loops -finit-character=32 -std=legacy -fallow-argument-mismatch -O3 -funroll-loops -finit-character=32 -Wtabs -Wsurprising -ftree-vectorize -ftree-loop-if-convert -finline-limit=512 -std=legacy -I /home/hector/CMAQ-5.4/lib/x86_64/gcc11.4.0/ioapi/lib -I /home/hector/CMAQ-5.4/lib/x86_64/gcc11.4.0/ioapi/include_files -I /home/hector/CMAQ-5.4/lib/x86_64/gcc11.4.0/mpi -I. -std=legacy -Dparallel -Dparallel_io -Dm3dry_opt -DSUBST_BARRIER=SE_BARRIER -DSUBST_GLOBAL_MAX=SE_GLOBAL_MAX -DSUBST_GLOBAL_MIN=SE_GLOBAL_MIN -DSUBST_GLOBAL_MIN_DATA=SE_GLOBAL_MIN_DATA -DSUBST_GLOBAL_TO_LOCAL_COORD=SE_GLOBAL_TO_LOCAL_COORD -DSUBST_GLOBAL_SUM=SE_GLOBAL_SUM -DSUBST_GLOBAL_LOGICAL=SE_GLOBAL_LOGICAL -DSUBST_GLOBAL_GATHER=SE_GLOBAL_GATHER -DSUBST_GLOBAL_BCAST=SE_GLOBAL_BCAST -DSUBST_LOOP_INDEX=SE_LOOP_INDEX -DSUBST_SUBGRID_INDEX=SE_SUBGRID_INDEX -DSUBST_HI_LO_BND_PE=SE_HI_LO_BND_PE -DSUBST_SUM_CHK=SE_SUM_CHK -DSUBST_SE_INIT=SE_INIT -DSUBST_INIT_ARRAY=SE_INIT_ARRAY -DSUBST_COMM=SE_COMM -DSUBST_MY_REGION=SE_MY_REGION -DSUBST_SLICE=SE_SLICE -DSUBST_GATHER=SE_GATHER -DSUBST_DATA_COPY=SE_DATA_COPY -DSUBST_IN_SYN=SE_IN_SYN -DSUBST_PE_COMM=\"./PE_COMM.EXT\" -DSUBST_CONST=\"./CONST.EXT\" -DSUBST_FILES_ID=\"./FILES_CTM.EXT\" -DSUBST_EMISPRM=\"./EMISPRM.EXT\" -DSUBST_MPI=\"/home/hector/CMAQ-5.4/lib/x86_64/gcc11.4.0/mpi/include/mpif.h\" BDSNP_MOD.F
f951: Warning: Nonconforming tab character in column 1 of line 1135 [-Wtabs]
f951: Warning: Nonconforming tab character in column 1 of line 1140 [-Wtabs]
f951: Warning: Nonconforming tab character in column 1 of line 1145 [-Wtabs]
BDSNP_MOD.F:399:47:

  399 | EMPOL = SOILNOX * 3600.0 * 10.0**-9![ng N/m2/s] * s/hr * g/ng
      | 1
Warning: Extension: Unary operator following arithmetic operator (use parentheses) at (1)
BDSNP_MOD.F:405:39:

  405 | & * 3600.0 * 10.0**-9 ![ng N/m2/s] * s/hr * g/ng
      | 1
Warning: Extension: Unary operator following arithmetic operator (use parentheses) at (1)
BDSNP_MOD.F:408:39:

  408 | & * 3600.0 * 10.0**-9 ![ng N/m2/s] * s/hr * g/ng
      | 1
Warning: Extension: Unary operator following arithmetic operator (use parentheses) at (1)
BDSNP_MOD.F:412:39:

  412 | & * 3600.0 * 10.0**-9 ![ng N/m2/s] * s/hr * g/ng
      | 1
Warning: Extension: Unary operator following arithmetic operator (use parentheses) 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:454: BDSNP_MOD.o] Error 1
**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

```

I experimented with removing `-std=legacy` from `myDBG`, `myFFLAGS`, and `myFRFLAGS` but got the same result. Same for removing it from `CPP_FLAGS`. I might be missing the right combination of where to put it and where not to though. If anyone could clarify where this flags is needed it would be a huge help.

I also looked for errors regarding “flush3” but only found this post, so that seems like a dead end too.

Maybe it would take less time in the end if I recompiled everything (NetCDF-C, NetCDF-FORTRAN, I/O API) from the beginning with a different compiler? GCC has been a little bit of a headache up until now. But maybe I’m so close that I might as well stick to it? Advice regarding this would also be appreciated.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![cjcoats](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@cjcoats](https://forum.cmascenter.org/u/cjcoats)\
**Post date:** [October 17, 2023, 11:35am UTC](https://forum.cmascenter.org/t/trying-to-compile-cctm-but-i-get-an-error-message-relating-to-the-makefile/4481/5 "2023-10-17T11:35:01Z")

</div>

These are different errors now (and at least one of them is an error which any good compiler should find):  
The `3600.0 * 10.0**-9` is really stupid and betrays a lack of competence on the part of the code’s author: this should have been `3600.0E-9` or `3.600E-6`.  
The code should not need the `FLUSH3` call, and if it did, it should have a declaration earlier in the code:

> ```
> `LOGICAL, EXTERNAL :: FLUSH3`
> 
> ```

By the way, this is not really a “_gcc_” model-build – it is a “_gfortran_” build; that is also a malapropism on the part of the _bldit_-system authors.

– Carlie J. Coats, Jr., Ph.D.  
I/O API Author/Maintainer

---

<div class="post-metadata">

**Author:** ![HectorVG](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.cmascenter.org/hectorvg/32/3545_2.png) [@HectorVG](https://forum.cmascenter.org/u/HectorVG)\
**Post date:** [October 18, 2023, 9:16pm UTC](https://forum.cmascenter.org/t/trying-to-compile-cctm-but-i-get-an-error-message-relating-to-the-makefile/4481/6 "2023-10-18T21:16:38Z")

</div>

Thank you for all your help Dr. Coats. I think I’m going to go ahead and restart compiling CMAQ, now with Intel compilers to see if I fare better. I appreciate the support!
