Skip to content

macOS + GNU build#1

Closed
climbfuji wants to merge 2 commits into
NOAA-EMC:full-stackfrom
climbfuji:macos_gnu_build
Closed

macOS + GNU build#1
climbfuji wants to merge 2 commits into
NOAA-EMC:full-stackfrom
climbfuji:macos_gnu_build

Conversation

@climbfuji
Copy link
Copy Markdown
Contributor

@climbfuji climbfuji commented Nov 19, 2019

This PR and associated PRs for the submodules of NCEPLIBS (listed below) add the necessary modifications to build the entire set of NCEPlibs on macOS using the gcc+gfortran or clang+gfortran compilers.

They also allow the user to specify pre-installed versions of the HDF5, netCDF and JasPER libraries instead of building them as part of the umbrella build.

These changes were tested on macOS 10.14.6 (Mojave) using LLVM clang 9.0.0 and GNU gfortran 9.2.0, installed via homebrew. The following libraries (and any necessary dependencies) were installed manually in /usr/local with these compilers:

  • mpich 3.3.1
  • hdf5-1.8.21
  • netCDF 4.6.1
  • netCDF-Fortran 4.4.4
  • JasPER 2.0.16

The environment variables for clang/gfortran were set to

export PATH="/usr/local/opt/llvm/bin:$PATH"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
export LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

The NCEPlibs were built as follows:

mkdir build
cd build

CC=clang \
FC=gfortran \
CXX=clang++ \
cmake \
-DOPENMP=OFF \
-DCMAKE_INSTALL_PREFIX=$PWD/install \
-DHDF5_ROOT=/usr/local \
-DNETCDF=/usr/local \
-DJASPER=/usr/local .. 2>&1 | tee log.cmake

make VERBOSE=1 2>&1 | tee log.make

These NCEPLIBS were then used instead of the known-to-work NCAR NCEPLIBS umbrella build (https://github.com/NCAR/NCEPLIBS) to compile and run the ufs-weather-model. The results were identical to those using the NCAR version of NCEPLIBS, which means that at least for the NCEPLIBS used by the ufs-weather-model we can be confident that the build is ok:

# from ufs-weather-model/modulefiles/macosx.gnu/fv3
export NEMSIO_INC=${NCEPLIBS_DIR}/include
export BACIO_LIB4=${NCEPLIBS_DIR}/lib/libbacio_v2.1.0_4.a
export SP_LIBd=${NCEPLIBS_DIR}/lib/libsp_v2.0.2_d.a
export W3EMC_LIBd=${NCEPLIBS_DIR}/lib/libw3emc_v2.2.0_d.a
export W3NCO_LIBd=${NCEPLIBS_DIR}/lib/libw3nco_v2.0.6_d.a
export NEMSIO_LIB=${NCEPLIBS_DIR}/lib/libnemsio_v2.2.3.a

Note 1. Since macOS Mojave there are problems with OpenMP with both clang and gcc, hence OpenMP was disabled. This may have been already or may be fixed soon.

Note 2. While adding/correcting the compiler flags for clang/gcc+gfortran, I removed empty configuration entries for the PGI compiler to avoid it failing silently. The build system will now throw an error "unknown compiler" if the respective NCEPLIBS component has not been configured for PGI.

Note 3. I am not an expert on cmake. My workaround to create a stub netCDF-Fortran external project to avoid changing several tens of lines of code further down in the top-level CMakeLists.txt may not be ideal.

Note 4. Someone should test those changes with the full end-to-end system on a machine for which the build system previously worked (e.g. hera + intel).

@climbfuji
Copy link
Copy Markdown
Contributor Author

@mark-a-potts this PR has gone stale. Is it still needed/useful? Or did you make those changes separately? I am going to test the ufs_public_release_v1.0 branch on my macOS now with a few different scenarios (only compiler+mpi library installed, everything installed except esmf and nceplibs, only nceplibs missing). Thanks!

@climbfuji
Copy link
Copy Markdown
Contributor Author

I am closing this PR, since it is no longer up to date and will be replaced soon with a new version.

@climbfuji climbfuji closed this Dec 18, 2019
kgerheiser added a commit that referenced this pull request Jan 30, 2020
Bugfix in CMakeLists.txt: do not assume everything was built/installeby NCEPLIBS-external
climbfuji added a commit that referenced this pull request Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant