Open platipodium opened 1 year ago
make -f Core/CMakeFiles/core.dir/build.make Core/CMakeFiles/core.dir/build
make[3]: Entering directory '/Users/Lemmen/devel/schism/schism/build'
/opt/conda/envs/schism/bin/cmake -E cmake_copy_f90_mod include/schism_glbl.mod Core/CMakeFiles/core.dir/schism_glbl.mod.stamp GNU
Error copying Fortran module "include/schism_glbl.mod". Tried "include/SCHISM_GLBL.mod" and "include/schism_glbl.mod".
m
Hi @platipodium,
I'm willing to take a shot at this problem.
This may sound like a silly question (you may have a reason) but this is so I can understand better your context.
Is there any reason why you are invoking
make -f Core/CMakeFiles/core.dir/build.make Core/CMakeFiles/core.dir/build
Instead of invoking something like this:
mkdir build
cd build
cmake ../src # any other cmake opts here
make
Thanks @jreniel. I did exactly that. The VERBOSE option of make then isolates the culprit line (within the regular make schism
), which is
cmake -E cmake_copy_f90_mod include/schism_glbl.mod Core/CMakeFiles/core.dir/schism_glbl.mod.stamp GNU
Googling that, I saw a lot of reports on this with older cmake versions, but I am at 3.27 where this issue should be fixed.
Another idea was that it might be related to erroneous preprocessing options (which is poorly handled by cmake in mixed gfortran-clang environments, but following up some stack overflow ideas on PREPROCESS_OPTIONS didn't help. I also tried the -J and -M options to place mod files, but to no avail.
To reproduce, this is my conda configuration
conda install gfortran clang mpi netcdf-fortran parmetis
Thanks for the clarification, I'll try to reproduce the problem and let you know what I find soon.
Could you please share the cmake flags you are using to configure cmake?
After installing the dependencies you specified (by adding -c conda-forge
), and running cmake ../src
without any configuration flags, I noticed that cmake is able to pick up by default the clang compiler. Then CMake tries to build the parmetis on the SCHISM directory (rather than using the one installed through conda) using clang. However it tries to add some flags that clang compiler does not recognize and fails. So knowing which configuration flags you were applying to cmake would be helpful.
Additionally, I have a 2016 Mac, but it doesn't have an M1 processor, so I might not be able to replicate the error. However, I would argue that given the correct configuration and environment it should compile. Then again, if I'm not mistaken, the M1 processors are ARM processors and I have never seen SCHISM being compiled on ARM architechture.
Compiler problems are always fun to debug, but more importantly, I'd like to see this compiled on ARM architechture, that would be cool.
Oh.. it's been working on Mac M1 for at least a year. On my local laptop through macports. But I have now switched to a conda toolchain.
Here's my CMAKE command:
cmake -S ../src -DCMAKE_Fortran_COMPILER=${CONDA_PREFIX}/bin/mpifort -DCMAKE_C_COMPILER=${CONDA_PREFIX}/bin/mpicc -DPARMETIS_HOME=${CONDA_PREFIX}
Can you reproduce the error (on linux/conda or Mac/conda)?
Just a side note, M1/arm64/gfortran toolchain via macports continues to work:
$> cat ../cmake/SCHISM.local.macports
set(CMAKE_Fortran_COMPILER /opt/local/bin/gfortran CACHE PATH "Path to serial Fortran compiler")
set(CMAKE_C_COMPILER /opt/local/bin/gcc CACHE PATH "Path to serial C compiler")
set(NetCDF_FORTRAN_DIR /opt/local CACHE PATH "Path to NetCDF Fortran library")
set(NetCDF_C_DIR /opt/local CACHE PATH "Path to NetCDF C library")
The major difference is that there is gfortran/gcc (macports) versus gfortran/clang (conda). And the mix of fortran/c with cmake has been having issues with PREPROCESS_FLAGS (--preprocess versus -cpp) ... but how to connect this to the above error I am not sure. Neither how to fix :=)
Thanks for adding more context to the problem statement, that does help rule out some possibilities and hone in on potential solutions.
Hi All. Just to say that I have the same problem on my (old) Mac trying to compile the latest version of SCHISM. I am also using conda
.
Error persists. An update to my previous command for reproducing this is the STANDALONE cmake flag that is now necessary
conda install gfortran clang mpi netcdf-fortran parmetis
cmake -S ../src -DCMAKE_Fortran_COMPILER=${CONDA_PREFIX}/bin/mpifort -DCMAKE_C_COMPILER=${CONDA_PREFIX}/bin/mpicc -DPARMETIS_HOME=${CONDA_PREFIX} -DBLD_STANDALONE=ON
make schism
Hi, I am novice here, but have a fairly clean M2 system and am actively working on this (since I need to use it :)), so I can test configs as long as I get reasonable instructions.
I am running macOS 14, but no Conda. I installed the pre-reqs via home-brew, fortran, mai, NetCDF-fortran. I was using gcc/clang from apple as default, and went through the make options in the documentation. I was about to install a home-brew gcc (12) and switch to trying the older make.
any suggestions?
Hi, I am novice here, but have a fairly clean M2 system and am actively working on this (since I need to use it :)),
Help is greatly appreciated. Most important advise: keep your system clean and document / be able to retrace your steps. Both homebrew and conda install mixed gfortran/clang environments that seem to create difficulties; macports has both gfortran/gcc and gfortran/clang available. Please report how you fare ...
I think I further along, but not sure. I have switched to attempting the make build instead of cmake.
I got past the include/schism_glbl.mod error, but now get a series of these:
Core/schism_msgp.F90:1669:19:
1669 | call mpi_irecv(iegsend_2t(1,i),nesend_2t(i),itype,nbrrank_2t(i),16,comm,rrqst(i),ierr) | 1 ...... 4095 | call mpi_irecv(e3d_2t_data,1,e3d_2t_tr_recv_type(i),nbrrank_2t(i),18,comm,e3d_2t_tr_recv_rqst(i),ierr) | 2 Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/REAL(8)).
If these are no longer related to this thread I will search somewhere else, or post to the mailing list. Thanks!
@fred116 this has been discussed elsewhere and is a consequence of your direct use of make
instead of cmake
and mpich upstream problems. You need to provide -fallow-argument-mismatch
to proceed.
Just $0.02 here -- I finally got what I think is a successful build on Sonoma/M2.
I installed: gfortran gcc-13 netcdf/netcdf-fortran/netcdf-cxx open-mai
via homebrew. In my SCHISM.local.myown I included gcc-13
I then followed the cmake instructions; then 'make pschism'
resulting binary gave me:
epictetus:bin gbsmith$ sudo ./pschism_mac_epictetus_TVD-VL -v
schism v5.11.1 git hash e2bf5bd1 epictetus:bin gbsmith$
@fred116 How did you achieve mpich to use gcc? For me brew continues to use clang:
❯ which mpicc && mpicc --version
/opt/homebrew/bin/mpicc
clang version 16.0.6
... and then run into the mixed gfortran/clang trap. Please check which mpich you're using, and post your SCHISM.local.myown
epictetus:bin gbsmith$ sudo ./pschism_mac_epictetus_TVD-VL -v
@fred116 you should not have to run pschism
with sudo
. On the other hand, you show how much you trust us :=)
OK, I got it.
❯ brew install -cc=gcc open-mpi
❯ cmake -S ../src -DCMAKE_Fortran_COMPILER=/opt/homebrew/bin/mpifort -DBLD_STANDALONE=ON -DCMAKE_C_COMPILER=/opt/homebrew/bin/mpicc -DCMAKE_CXX_COMPILER=/opt/homebrew/bin/mpicxx
❯ make pschism
So we do have it working on gcc/gfortran toolchain, but still not clang/gfortran :=(
I will post the info tomorrow; sorry I missed the post today…
On Mar 5, 2024, at 1:29 AM, Carsten Lemmen @.***> wrote:
@fred116 How did you achieve mpich to use gcc? For me brew continues to use clang: ❯ which mpicc && mpicc --version /opt/homebrew/bin/mpicc clang version 16.0.6
... and then run into the mixed gfortran/clang trap. Please check which epic you're using, and post your SCHISM.local.myown — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
I would rather not run as sudo, but I am forced to work in a managed environment, and I haven’t gotten the permissions right somewhere in my build chain, so the end binary gives a macOS permissions error, even though the binary has wide open permissions (chmod a+rwx)…
:(
On Mar 5, 2024, at 4:32 AM, Carsten Lemmen @.***> wrote:
epictetus:bin gbsmith$ sudo ./pschism_mac_epictetus_TVD-VL -v @fred116 you should not have to run pschism with sudo. On the other hand, you show how much you trust us :=) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Post your SCHISM.local.myown
I added the homebrew cmake recipe as ./cmake/SCHISM.homebrew.gcc-openmpi
with commit fefb7aaa3c2d5f, use with
cmake ../src -C ../cmake/SCHISM.homebrew.gcc-openmpi
Hi All. I finally had some time to work on this and it turns out it's the preprocessing. Removing it from the CMakeLists
files did the trick. I was able to compile and build a conda
package as expected.
@platipodium see if it works for you as well.
I have encoded the change into the build.sh
file of the recipe as
#Fix OSX issue with preprocessing
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i -e "s|add_compile_options(\${C_PREPROCESS_FLAG})|#add_compile_options(\${C_PREPROCESS_FLAG})|g" src/CMakeLists.txt
sed -i -e "s|add_definitions(\${C_PREPROCESS_FLAG})|#add_definitions(\${C_PREPROCESS_FLAG})|g" src/Utility/Combining_Scripts/CMakeLists.txt
sed -i -e "s|add_definitions(\${C_PREPROCESS_FLAG})|#add_definitions(\${C_PREPROCESS_FLAG})|g" src/Utility/Post-Processing-Fortran/CMakeLists.txt
fi
There might also be a way to fix that by passing the right argument. In ccmake
the way it is now, the flag takes the value --preprocessing
which brakes the flow. It should be -E -P -ccp
or something similar. I don't know cmake
well enough to test that.
I have tried with several options to change the option in schism/cmake/SCHISMCompile.cmake
file but nothing was accepted. It seems that clang
does its own preprocessing automatically and all these flags fail.
So another way to achieve the same as above (thanks @pmav99) is the following:
❯ git diff ../cmake/SCHISMCompile.cmake
diff --git a/cmake/SCHISMCompile.cmake b/cmake/SCHISMCompile.cmake
index 72c558a6..e388d1fd 100644
--- a/cmake/SCHISMCompile.cmake
+++ b/cmake/SCHISMCompile.cmake
@@ -16,7 +16,7 @@ if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel")
set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -debug inline_debug_info ${SCHISM_INTEL_OPTIONS}")
set( C_PREPROCESS_FLAG CACHE STRING "C Preprocessor Flag")
endif()
-
+
endif()
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "IntelLLVM")
@@ -39,9 +39,9 @@ if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g ${SCHISM_GFORTRAN_OPTIONS}")
unset( C_PREPROCESS_FLAG CACHE)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
- set( C_PREPROCESS_FLAG "--preprocess" CACHE STRING "C Preprocessor Flag")
+ set( C_PREPROCESS_FLAG "" CACHE STRING "C Preprocessor Flag")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
- set( C_PREPROCESS_FLAG "--preprocess" CACHE STRING "C Preprocessor Flag")
+ set( C_PREPROCESS_FLAG "" CACHE STRING "C Preprocessor Flag")
else()
set( C_PREPROCESS_FLAG "-cpp" CACHE STRING "C Preprocessor Flag")
endif()
Thanks @brey for suggesting this. I have not tried yet, but this approach does not seem to resolve the issue within the CMake strutter unmixed gfortran/clang, or depends on build.sh
(which I would like not not use). But I'll investigate your suggestions more and report
Just to clarify, there is no homebrew
involved. Just changing the /cmake/SCHISMCompile.cmake
file above you can build locally with cmake
and conda
. The build.sh
referenced above is the one in the conda.recipe
used to build the package.
My conda
env is:
name: schism-openmpi-dev
channels:
- conda-forge
dependencies:
- python=3
- gfortran_osx-64
- openmpi-mpicxx
- openmpi-mpifort
- netcdf-fortran=4.5.3=mpi_openmpi_*
- cmake
- parmetis
- metis
My
conda
env is:dependencies:
- openmpi-mpicxx
- openmpi-mpifort
Great! can you tell me the outcome of your mpicc --version
and mpifort --version
? I only had the problem when they pointed to different compilers (gfortran and clang).
❯ mpicc --version
clang version 16.0.6
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /Users/brey/mambaforge/envs/schism-openmpi-dev/bin
❯ mpifort --version
GNU Fortran (GCC) 12.3.0
Copyright (C) 2022 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.
❯ which mpifort
/Users/brey/mambaforge/envs/schism-openmpi-dev/bin/mpifort
On Mac M1 in a conda environment (gfortran-clang) my build fails with
Any ideas?