WRF 4.7.1 and 4.6.1 fails to build with netcdf4 enabled on MacOS with GNU from homebrew.

William.Hatheway

Well-known member
Bash:
*****************************************************************************
workhorses-Mac:WRF-4.7.1 workhorse$ ./clean -a
workhorses-Mac:WRF-4.7.1 workhorse$ ./configure
checking for perl5... no
checking for perl... found /usr/bin/perl (perl)
Will use NETCDF in dir: /Users/workhorse/WRF/Libs/NETCDF
Will use PNETCDF in dir: /Users/workhorse/WRF/Libs/grib2
ADIOS2 not set in environment. Will configure WRF for use without.
Will use HDF5 in dir: /Users/workhorse/WRF/Libs/grib2
Will use PHDF5 in dir: /Users/workhorse/WRF/Libs/grib2
Will use 'time' to report timing information


If you REALLY want Grib2 output from WRF, modify the arch/Config.pl script.
Right now you are not getting the Jasper lib, from the environment, compiled into WRF.

------------------------------------------------------------------------
Please select from among the following Darwin ARCH options:

  1. (serial)   2. (smpar)   3. (dmpar)   4. (dm+sm)   PGI (pgf90/pgcc)
  5. (serial)   6. (smpar)   7. (dmpar)   8. (dm+sm)   INTEL (ifort/icc)
  9. (serial)  10. (smpar)  11. (dmpar)  12. (dm+sm)   INTEL (ifort/clang)
 13. (serial)               14. (dmpar)                GNU (g95/gcc)
 15. (serial)  16. (smpar)  17. (dmpar)  18. (dm+sm)   GNU (gfortran/gcc)
 19. (serial)  20. (smpar)  21. (dmpar)  22. (dm+sm)   GNU (gfortran/clang)
 23. (serial)               24. (dmpar)                IBM (xlf90_r/cc)
 25. (serial)  26. (smpar)  27. (dmpar)  28. (dm+sm)   PGI (pgf90/pgcc): -f90=pgf90
 29. (serial)  30. (smpar)  31. (dmpar)  32. (dm+sm)   INTEL (ifort/icc): Open MPI
 33. (serial)  34. (smpar)  35. (dmpar)  36. (dm+sm)   GNU (gfortran/gcc): Open MPI

Enter selection [1-36] : 17
------------------------------------------------------------------------
Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: 1

Configuration successful!
------------------------------------------------------------------------
testing for fseeko and fseeko64
fseeko is supported and handles 64 bit offsets
------------------------------------------------------------------------

# Settings for    Darwin x86_64 arm64, (MACOS) gfortran with gcc  (dmpar)
#
DESCRIPTION     =       GNU ($SFC/$SCC)
DMPARALLEL      =        1
OMPCPP          =       # -D_OPENMP
OMP             =       # -fopenmp
OMPCC           =       # -fopenmp
SFC             =       gfortran
SCC             =       gcc
CCOMP           =       gcc
DM_FC           =       mpif90 -f90=$(SFC)
DM_CC           =       mpicc -cc=$(SCC)
FC              =       time $(DM_FC)
CC              =       $(DM_CC) -DFSEEKO_OK
LD              =       $(FC)
RWORDSIZE       =       4
PROMOTION       =       #-fdefault-real-8
ARCH_LOCAL      =       -DNONSTANDARD_SYSTEM_SUBR -DMACOS  -DWRF_USE_CLM $(NETCDF4_IO_OPTS)
CFLAGS_LOCAL    =       -w -O3 -c  -DMACOS # -DRSL0_ONLY
LDFLAGS_LOCAL   =
CPLUSPLUSLIB    =       
ESMF_LDFLAG     =       $(CPLUSPLUSLIB)
FCOPTIM         =       -O2 -ftree-vectorize -funroll-loops
FCREDUCEDOPT    =       $(FCOPTIM)
FCNOOPT         =       -O0
FCDEBUG         =       # -g $(FCNOOPT) # -fbacktrace -ggdb -fcheck=bounds,do,mem,pointer -ffpe-trap=invalid,zero,overflow
FORMAT_FIXED    =       -ffixed-form
FORMAT_FREE     =       -ffree-form -ffree-line-length-none
FCSUFFIX        =       
FCCOMPAT        =       
BYTESWAPIO      =       -fconvert=big-endian -frecord-marker=4
FCBASEOPTS_NO_G =       -w $(FORMAT_FREE) $(BYTESWAPIO) $(FCCOMPAT)
FCBASEOPTS      =       $(FCBASEOPTS_NO_G) $(FCDEBUG)
MODULE_SRCH_FLAG =
TRADFLAG        =      -traditional-cpp $(NETCDF4_IO_OPTS)
CPP             =      cpp -P -nostdinc -xassembler-with-cpp
AR              =      ar
ARFLAGS         =      ru
M4              =      m4 -B 14000
RANLIB          =      ranlib
RLFLAGS        =    -c
CC_TOOLS        =      $(SCC)


###########################################################
######################
# POSTAMBLE

FGREP = fgrep -iq
### Used throughout the build system to inform promotion to double precision
DOUBLE_PRECISION =

ARCHFLAGS       =    $(COREDEFS) -DIWORDSIZE=$(IWORDSIZE) -DDWORDSIZE=$(DWORDSIZE) -DRWORDSIZE=$(RWORDSIZE) -DLWORDSIZE=$(LWORDSIZE)  \
                     $(ARCH_LOCAL) \
                     $(DA_ARCHFLAGS) \
                      -DDM_PARALLEL \
                       \
                      -DNETCDF \
                       \
                      -DPNETCDF \
                       \
                       \
                       \
                       \
                       \
                      -DHDF5 \
                       \
                       \
                       -DLANDREAD_STUB=1 \
                       \
                       \
                      -DUSE_ALLOCATABLES \
                      -Dwrfmodel \
                      -DGRIB1 \
                      -DINTIO \
                      -DKEEP_INT_AROUND \
                      -DLIMIT_ARGS \
                      -DBUILD_RRTMG_FAST=0 \
                      -DBUILD_RRTMK=0 \
                      -DBUILD_SBM_FAST=1 \
                      -DSHOW_ALL_VARS_USED=0 \
                      -DCONFIG_BUF_LEN=$(CONFIG_BUF_LEN) \
                      -DMAX_DOMAINS_F=$(MAX_DOMAINS) \
                      -DMAX_HISTORY=$(MAX_HISTORY) \
              -DNMM_NEST=$(WRF_NMM_NEST)
CFLAGS          =    $(CFLAGS_LOCAL) -DDM_PARALLEL  \
                      -DLANDREAD_STUB=1 \
                      -DMAX_HISTORY=$(MAX_HISTORY) -DNMM_CORE=$(WRF_NMM_CORE)
FCFLAGS         =    $(FCOPTIM) $(FCBASEOPTS)
ESMF_LIB_FLAGS  =   
# ESMF 5 -- these are defined in esmf.mk, included above
 ESMF_IO_LIB     =    -L$(WRF_SRC_ROOT_DIR)/external/esmf_time_f90 -lesmf_time
ESMF_IO_LIB_EXT =    -L$(WRF_SRC_ROOT_DIR)/external/esmf_time_f90 -lesmf_time
INCLUDE_MODULES =    $(MODULE_SRCH_FLAG) \
                     $(ESMF_MOD_INC) $(ESMF_LIB_FLAGS) \
                      -I$(WRF_SRC_ROOT_DIR)/main \
                      -I$(WRF_SRC_ROOT_DIR)/external/io_netcdf \
                      -I$(WRF_SRC_ROOT_DIR)/external/io_int \
                      -I$(WRF_SRC_ROOT_DIR)/frame \
                      -I$(WRF_SRC_ROOT_DIR)/share \
                      -I$(WRF_SRC_ROOT_DIR)/phys \
                      -I$(WRF_SRC_ROOT_DIR)/wrftladj \
                      -I$(WRF_SRC_ROOT_DIR)/chem -I$(WRF_SRC_ROOT_DIR)/inc \
                      -I$(NETCDFPATH)/include \
                      
REGISTRY        =    Registry
CC_TOOLS_CFLAGS = -DNMM_CORE=$(WRF_NMM_CORE)

LIB             =    $(LIB_BUNDLED) $(LIB_EXTERNAL) $(LIB_LOCAL) $(LIB_WRF_HYDRO)  $(NETCDF4_DEP_LIB)
LDFLAGS         =    $(OMP) $(FCFLAGS) $(LDFLAGS_LOCAL)
ENVCOMPDEFS     =   
WRF_CHEM    =    0
CPPFLAGS        =    $(ARCHFLAGS) $(ENVCOMPDEFS) -I$(LIBINCLUDE) $(TRADFLAG)
NETCDFPATH      =    /Users/workhorse/WRF/Libs/NETCDF
HDF5PATH        =    /Users/workhorse/WRF/Libs/grib2
WRFPLUSPATH     =   
RTTOVPATH       =   
PNETCDFPATH     =    /Users/workhorse/WRF/Libs/grib2
ADIOS2PATH      =   
NETCDFPAR_BUILD    =    echo SKIPPING


bundled:  io_only
external: io_only $(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite $(ESMF_TARGET)
io_only:  esmf_time wrfio_nf  wrfio_pnf   \
      wrf_ioapi_includes wrfio_grib_share wrfio_grib1 wrfio_int fftpack


######################
------------------------------------------------------------------------
Settings listed above are written to configure.wrf.
If you wish to change settings, please edit that file.
If you wish to change the default options, edit the file:
     arch/configure.defaults
NetCDF users note:
 This installation of NetCDF supports large file support.  To DISABLE large file
 support in NetCDF, set the environment variable WRFIO_NCD_NO_LARGE_FILE_SUPPORT
 to 1 and run configure again. Set to any other value to avoid this message.
 

Testing for NetCDF, C and Fortran compiler

This installation of NetCDF is 64-bit
                 C compiler is 64-bit
           Fortran compiler is 64-bit
              It will build in 64-bit
 
NetCDF version: 4.9.3
Enabled NetCDF-4/HDF-5: yes
NetCDF built with PnetCDF: yes
 

************************** W A R N I N G ************************************
NETCDF4 IO features are requested, but this installation of NetCDF           
  /Users/workhorse/WRF/Libs/NETCDF
DOES NOT support these IO features.                                         

Please make sure NETCDF version is 4.1.3 or later and was built with         
--enable-netcdf4                                                             

OR set NETCDF_classic variable                                               
   bash/ksh : export NETCDF_classic=1                                       
        csh : setenv NETCDF_classic 1                                       

Then re-run this configure script                                           

!!! configure.wrf has been REMOVED !!!

*****************************************************************************
 
Bash:
workhorses-Mac:WRF-4.7.1 workhorse$ nc-config --all



This netCDF 4.9.3 has been built with the following features:



  --cc                -> /Users/workhorse/WRF/Libs/MPICH/bin/mpicc

  --cflags            -> -I/Users/workhorse/WRF/Libs/NETCDF/include -I/Users/workhorse/WRF/Libs/grib2/include

  --libs              -> -L/Users/workhorse/WRF/Libs/NETCDF/lib -lnetcdf

  --static            -> -lpnetcdf -lm -lbz2 -lxml2 -lhdf5_hl -lhdf5 -lz -lcurl -lgfortran -lgcc -lm -ldl -lpnetcdf

  --has-dap           -> no

  --has-dap2          -> no

  --has-dap4          -> no

  --has-nc2           -> yes

  --has-nc4           -> yes

  --has-hdf5          -> yes

  --has-hdf4          -> no

  --has-logging       -> yes

  --has-pnetcdf       -> yes

  --has-szlib         -> no

  --has-cdf5          -> yes

  --has-parallel4     -> yes

  --has-parallel      -> yes

  --has-nczarr        -> yes

  --has-zstd          -> no

  --has-benchmarks    -> no

  --has-multifilters  -> yes

  --has-stdfilters    -> bz2 deflate

  --has-quantize      -> yes



  --prefix            -> /Users/workhorse/WRF/Libs/NETCDF

  --includedir        -> /Users/workhorse/WRF/Libs/NETCDF/include

  --libdir            -> /Users/workhorse/WRF/Libs/NETCDF/lib

  --plugindir         -> /Users/workhorse/WRF/Libs/NETCDF/hdf5/lib/plugin

  --plugin-searchpath -> /Users/workhorse/WRF/Libs/NETCDF/hdf5/lib/plugin:/usr/local/hdf5/lib/plugin

  --version           -> netCDF 4.9.3

  --build-system      -> autotools
[/CODE]
 
Bash:
workhorses-Mac:WRF-4.7.1 workhorse$ which /usr/local/bin/gcc-15
/usr/local/bin/gcc-15
workhorses-Mac:WRF-4.7.1 workhorse$ /usr/local/bin/gcc-15 --version
gcc-15 (Homebrew GCC 15.1.0) 15.1.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

workhorses-Mac:WRF-4.7.1 workhorse$ /usr/local/bin/g++-15 --version
g++-15 (Homebrew GCC 15.1.0) 15.1.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

workhorses-Mac:WRF-4.7.1 workhorse$ /usr/local/bin/gfortran-15 --version
GNU Fortran (Homebrew GCC 15.1.0) 15.1.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


All compiler and environment tests passed
 
After configuring, can you post the tools/nc4_test.log created?
Code:
if [ -z "0" ] || [ 0 -eq 0 ] ; then \
     ( cd tools ; /bin/rm -f nc4_test.{exe,nc,o} ; gcc -o nc4_test.exe nc4_test.c -I/Users/workhorse/WRF/Libs/NETCDF/include -L/Users/workhorse/WRF/Libs/NETCDF/lib -lnetcdf -L/Users/workhorse/WRF/Libs/NETCDF/lib -lnetcdff -L/Users/workhorse/WRF/Libs/NETCDF/lib -L/Users/workhorse/WRF/Libs/grib2/lib -Wl,-rpath,/Users/workhorse/WRF/Libs/NETCDF/lib -Wl,-rpath,/Users/workhorse/WRF/Libs/grib2/lib -lnetcdf -lm -lnetcdf -lpnetcdf -lcurl -lhdf5_hl -lhdf5 -lz -lm -ldl -lgcc -lgfortran ; cd .. ) ; \
    else \
     ( cd tools ; /bin/rm -f nc4_test.{exe,nc,o} ; mpicc -cc=gcc -o nc4_test.exe nc4_test.c -I/Users/workhorse/WRF/Libs/NETCDF/include -L/Users/workhorse/WRF/Libs/NETCDF/lib -lnetcdf -L/Users/workhorse/WRF/Libs/NETCDF/lib -lnetcdff -L/Users/workhorse/WRF/Libs/NETCDF/lib -L/Users/workhorse/WRF/Libs/grib2/lib -Wl,-rpath,/Users/workhorse/WRF/Libs/NETCDF/lib -Wl,-rpath,/Users/workhorse/WRF/Libs/grib2/lib -lnetcdf -lm -lnetcdf -lpnetcdf -lcurl -lhdf5_hl -lhdf5 -lz -lm -ldl -lgcc -lgfortran ; cd ..  ) ; \
    fi
ld: library not found for -lgcc
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Code:
   C function called by Fortran
   Values are xx =  2.00 and ii = 1
 SUCCESS test 1 fortran + c + netcdf


   C function called by Fortran
   Values are xx =  2.00 and ii = 1
 status =            2
 SUCCESS test 2 fortran + c + netcdf + mpi


 SUCCESS test 1 fortran only fixed format


 Assume Fortran 2003: has FLUSH, ALLOCATABLE derived type, and ISO C Binding
 SUCCESS test 2 fortran only free format
 
 
 SUCCESS test 3 C only


   C function called by Fortran
   Values are xx =  2.00 and ii = 1
 SUCCESS test 4 fortran calling c
 
Code:
workhorses-Mac:WRF-4.6.1 workhorse$ which $CC
/usr/local/bin/gcc-15

workhorses-Mac:WRF-4.6.1 workhorse$ which $CXX
/usr/local/bin/g++-15

workhorses-Mac:WRF-4.6.1 workhorse$ which $FC
/usr/local/bin/gfortran-15

workhorses-Mac:WRF-4.6.1 workhorse$ which $F77
/usr/local/bin/gfortran-15

workhorses-Mac:WRF-4.6.1 workhorse$ which $MPICC
/Users/workhorse/WRFHYDRO_STANDALONE/Libs/MPICH/bin/mpicc

workhorses-Mac:WRF-4.6.1 workhorse$ which $MPIFC
/Users/workhorse/WRFHYDRO_STANDALONE/Libs/MPICH/bin/mpifort

workhorses-Mac:WRF-4.6.1 workhorse$ which $MPIF77
/Users/workhorse/WRFHYDRO_STANDALONE/Libs/MPICH/bin/mpifort

workhorses-Mac:WRF-4.6.1 workhorse$ which $MPICXX
/Users/workhorse/WRFHYDRO_STANDALONE/Libs/MPICH/bin/mpicxx

workhorses-Mac:WRF-4.6.1 workhorse$ which gcc
/usr/bin/gcc

workhorses-Mac:WRF-4.6.1 workhorse$ gcc --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

workhorses-Mac:WRF-4.6.1 workhorse$ /usr/local/bin/gcc-15 --version
gcc-15 (Homebrew GCC 15.2.0) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
This seems to not be a failure of WRF compiling directly, but an issue in your environment. -lgcc is coming from your netCDF library dependencies, though I'm not sure why it is using the values of nc-config --static instead of nc-config --libs.
 
This seems to not be a failure of WRF compiling directly, but an issue in your environment. -lgcc is coming from your netCDF library dependencies, though I'm not sure why it is using the values of nc-config --static instead of nc-config --libs.
i figured it out or at least a work around, it needed to symlink the hombrew gcc in /usr/local/bin to the master clang gcc in /usr/bin

not really a great solution but it at least got it to install...
 
Back
Top