initial upload

This commit is contained in:
2025-12-17 11:00:57 +08:00
parent 2bc7b24a71
commit a09a73537f
4614 changed files with 3478433 additions and 2 deletions

View File

@@ -0,0 +1,58 @@
# removing legacy flags like -m64
# flag -m64 may be needed for C code lg_util/opsys.h
# ======= C flags =========================================
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
MESSAGE(STATUS " C compiler: Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -m64")
execute_process(COMMAND clang --version OUTPUT_VARIABLE clang_version_output)
string(REGEX MATCH "[0-9]+" clang_version "${clang_version_output}")
if (clang_version AND clang_version GREATER_EQUAL 15)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=implicit-int")
endif()
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
MESSAGE(STATUS " C compiler: GNU GCC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -m64")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
MESSAGE(STATUS " C compiler: Intel C")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
MESSAGE(STATUS " C compiler: Microsoft Visual C")
else()
message(STATUS " C compiler not recognized: ${CMAKE_C_COMPILER_ID}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -m64")
endif()
# ======= C++ flags =======================================
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
message(STATUS " C++ compiler: Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -stdlib=libc++ -std=c++0x")
execute_process(COMMAND clang --version OUTPUT_VARIABLE clang_version_output)
string(REGEX MATCH "[0-9]+" clang_version "${clang_version_output}")
if (clang_version AND clang_version GREATER_EQUAL 15)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=implicit-int")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(STATUS " C++ compiler: GNU G++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message(STATUS " C++ compiler: Intel C++")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(STATUS " C++ compiler: Microsoft Visual C++")
else()
message(STATUS " C++ compiler not recognized: ${CMAKE_CXX_COMPILER_ID}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
endif()

View File

@@ -0,0 +1,28 @@
# if not found, try -DCMAKE_fortran_PATH="path/gfortran"
# remove unused option -m64
include(CheckFortranCompilerFlag)
# set known compiler flags
if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
message(STATUS " Fortran compiler: GNU GFORTRAN")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fdefault-integer-8 -std=legacy -fno-sign-zero -fno-range-check")
elseif ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel")
message(STATUS " Fortran compiler: Intel Fortran")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w -O -Qsafe-cray-ptr -integer-size=64 -assume:nominus0 -QRimplicit-import-")
# try using flags for unknown compiler
else()
message(STATUS " Fortran compiler: ${CMAKE_Fortran_COMPILER_ID}")
check_fortran_compiler_flag("${CMAKE_Fortran_FLAGS}" _my_flags)
if(_my_flags)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fdefault-integer-8 -std=legacy -fno-sign-zero -fno-range-check")
else()
message(STATUS " cmake/CompilerFlags-Fortran.cmake: FLAGS NOT SET")
endif()
endif()

24
cmake/DetectBitSize.cmake Normal file
View File

@@ -0,0 +1,24 @@
# === DETECT BIT SIZE ======================== #
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS " Architecture: 64-bit")
set(LAGRIT_RMAX_ALLOCATE 18446744073709551615.00)
set(LAGRIT_BYTES_PER_INT 8)
set(LAGRIT_BYTES_PER_REAL 8)
set(LAGRIT_BYTES_PER_CHAR 32)
set(LAGRIT_BYTES_PER_PTR 8)
set(LAGRIT_AD_SIZE 6)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS " Architecture: 32-bit")
set(LAGRIT_RMAX_ALLOCATE 4294967295.00)
set(LAGRIT_BYTES_PER_INT 4)
set(LAGRIT_BYTES_PER_REAL 8)
set(LAGRIT_BYTES_PER_CHAR 32)
set(LAGRIT_BYTES_PER_PTR 4)
set(LAGRIT_AD_SIZE 6)
endif()
configure_file(
"${SRC_UTIL}/mm2000.h.in"
"${SRC_UTIL}/mm2000.h"
@ONLY
)

35
cmake/Linux.md Normal file
View File

@@ -0,0 +1,35 @@
# Linux Helps and Hints
Versions of LaGriT have been developed and tested on our local Linux Ubuntu servers using GNU compilers for many years.
This platform is very stable and should not require any special changes to cmake or associated files.
### LaGriT build without Exodus
No known issues.
### LaGriT V3.3.3 build with Exodus
**install-exodus.sh**
Modifications for Exodus install, cmake, build were suggested by Greg at Seacas.
```
# FIX TPL/netcdf/runcmake.sh and cmake-exodus as described above
sed -i '69i \ -DENABLE_PLUGINS:BOOL=OFF \\\n -DENABLE_MULTIFILTERS:BOOL=NO \\\n -DENABLE_NCZARR_FILTERS:BOOL=OFF \\\n -DENABLE_TESTS:BOOL=OFF \\' TPL/netcdf/runcmake.sh
sed -ie 's/DSeacas_EXTRA_LINK_FLAGS=z;dl/DSeacas_EXTRA_LINK_FLAGS=curl;z;dl/g' cmake-exodus
```
**CMakeLists.txt**
Exodus for LaGriT requires Exodus Fortran libraries, not always installed on systems.
For this reason we recommend installing Exodus in the local directory "TPLs".
CMakeLists.txt will look for needed libraries locally rather than system versions that may not work.
```
set(EXODUS_ROOT "${CMAKE_SOURCE_DIR}/TPLs/seacas")
set(Exodus_INCLUDE_DIR "${EXODUS_ROOT}/include")
set(Exodus_LIBRARIES "${EXODUS_ROOT}/lib")
```
See detailed instructions at https://github.com/sandialabs/seacas
Seacas Contact Gregory Sjaardema gsjaardema@gmail.com

View File

@@ -0,0 +1,27 @@
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/How-To-Write-Platform-Checks#platform-variables
if(UNIX)
if(APPLE)
message(STATUS " Operating System: macOS")
add_definitions(-Dmacx64)
elseif(CYGWIN)
message(STATUS " Operating System: Windows (Cygwin)")
add_definitions(-Dwin64)
else()
message(STATUS " Operating System: Linux")
add_definitions(-Dlinx64)
endif()
set(LaGriT_STATIC_LINKER_FLAGS "-static-libgcc -static-libstdc++")
elseif(WIN32)
message(STATUS " Operating System: Windows")
add_definitions(-Dwin64)
elseif(MINGW)
message(STATUS " Operating System: Windows (MinGW)")
add_definitions(-Dwin64)
else()
message("cmake/PlatformSettings.cmake OPERATING SYSTEM UNDEFINED")
endif()

312
cmake/README.md Normal file
View File

@@ -0,0 +1,312 @@
# LaGriT and ExodusII with cmake
The CMake build system is a way of enabling LaGriT to be cross-platform, cross-architecture, and cross-compiler. This page is a verbose description of building LaGriT and includes instructions for building the optional library for ExodusII.
The CMake build is controlled by CMakeLists.txt and files in directory /cmake
The ExodusII libraries can be built using install-exodus.sh or MAC_install-exodus.sh
For additional help on ExodusII, see instructions at https://github.com/sandialabs/seacas
**Note for Exodus with LaGriT, FORTRAN must be set to YES**
There's a really good tutorial-overview on CMake here, it covers how to handle multiple build configurations: https://cliutils.gitlab.io/modern-cmake/
## Download LaGriT
Download the repo as shown under the Code button on git.
For developers, be sure to use SSH version to clone.
```
$ git clone git@github.com:lanl/LaGriT.git
$ cd LaGriT/
```
If SSH Key needed, generate a key for your machine.
[See GitHub Docs for SSH Key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
```
Generate a SSH key (NOT RSA) in your .ssh directory.
ssh-keygen -t ed25519 -C "email.lanl.gov"
Copy contents of id_ed25519.pub into your SSH Keys on github (under settings).
```
## Build With ExodusII (optional)
From the top directory run: ```./install-exodus.sh``` or for a mac use: ```./MAC_install-exodus.sh```
The script will take some time to clone, configure, and build the necessary lib and include files.
Read comments in the script for hints if things go wrong.
For additional help on ExodusII, see instructions at https://github.com/sandialabs/seacas
LaGriT requires the following:
```
/seacas/lib/ libexodus.a libexodus_for.a libexoIIv2for32.a
/seacas/include/ exodus_config.h exodusII.h exodusII.inc exodusII_int.h exodusII_par.h
```
Once the ExodusII is successful, build LaGriT as usual using the EXODUS flag:
```
mkdir build/ && cd build/
cmake .. -DLAGRIT_BUILD_EXODUS=ON
make
```
## Build Without ExodusII
If you do not need to write an Exodus formatted file, you can build LaGriT without the ExodusII libraries.
Create a directory for your lagrit executable, then use cmake to create the configuration files and directories.
From the top directory in LaGriT:
```
mkdir build
cd build
cmake ..
```
Cmake will use settings defined in LaGriT/CMakeLists.txt and should look something like this:
```
-- ==========================================
-- ============Configuring LaGriT============
-- ===================v3.3.3=================
-- Compile LaGriT as a static binary = ON
-- Compile LaGriT with ExodusII = OFF
LaGriT Compiling without ExodusII support.
To include Exodus, use -DLAGRIT_BUILD_EXODUS=ON
-- Detecting LaGriT build using local cmake files:
-- Operating System: Linux
-- Architecture: 64-bit
-- Fortran compiler: GNU GFORTRAN
-- C compiler: GNU GCC
-- C++ compiler: GNU G++
-- Configuring done
-- Generating done
-- Build files have been written to: /project/eesdev/tam/clone/LaGriT/build
```
Once cmake has configured the directory files, type *make* to compile the lagrit executable:
```
make
```
This directory will create the **lagrit** executable using the files created by cmake.
```
Scanning dependencies of target liblagrit
[ 0%] Building Fortran object CMakeFiles/liblagrit.dir/src/ColoredGraphModule.f90.o
...
[100%] Built target liblagrit
Scanning dependencies of target lagrit
[100%] Building Fortran object CMakeFiles/lagrit.dir/src/lagrit_main.f.o
[100%] Linking Fortran executable lagrit
[100%] Built target lagrit
```
## Run LaGriT Test Suite
Go to LaGriT/test and run the test script. See the README file for further instructions.
```
$ cd test
$ python runtests.py
```
## Create your build directory:
By default, most the scripts will expect the lagrit executable to be in the "build" directory. But you build in directories with other names.
You can build as Debug (-g) or as Release with the CMake flag "-D CMAKE_BUILD_TYPE=[Debug|Release]".
There's two stages in CMake; the 'configure' stage (where you run 'cmake ..') and the build stage (where you run 'make' using the Makefile created by cmake)
The build type can only be set in the configure stage (with cmake) and will apply to all files in your build directory. If you make a change to cmake, you will need to run in a new directory, or remove all the files and directories created with your previous cmake configuration.
Setup a work directory for dev and debug work (example using name "debug").
Use cmake to create Makefiles and build files. You will do this only once.
Compile the lagrit executable using 'make' or 'make VERBOSE=1'
```
mkdir debug && cd debug
cmake .. -D CMAKE_BUILD_TYPE=Debug
make
```
Run ./lagrit and type command **test** which creates hex mesh and reports expected values.
For debugging the build process, set cmake and make to show verbose screen reporting. These are run from your build directory with the following options:
```
cmake -D CMAKE_FIND_DEBUG_MODE=ON ..
make VERBOSE=1
```
## Modify code and update **lagrit** executable
Modify code by working with lagrit source files in LaGriT/src
Do not add any non-code develpment files in the /src directory, they may be detected and attempted to use during compile time.
When you want to compile, do not run cmake again, it already created your makefiles, .o, and other dependencies.
Go to LaGriT/*your_build_name* directory and type
```
make
```
**lagrit** will be built in LaGriT/*your_build_name* directory.
*If you add new files to /src you will need to run cmake again. This will detect all files in src/ and create a new set of Makefiles.*
### Example Directory structure for developers:
```
LaGriT/
|
└── build/
└── lagrit executable, Makefiles built by cmake, cmake files
└── src/
└── file.cpp, file.f, file.c, lagrit.h, etc
|
├── CMakeLists.txt
└── cmake/
└── CompilerFlags-C.cmake, CompilerFlags-Fortran.cmake, DetectBitSize.cmake, PlatformSettings.cmake
```
### Example Screen Output for cmake .. -DLAGRIT_BUILD_EXODUS=ON
```
-- The Fortran compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- The C compiler identification is GNU 7.5.0
-- ==========================================
-- ============Configuring LaGriT============
-- ===================v3.3.3=================
-- Compile LaGriT as a static binary = ON
-- Compile LaGriT with ExodusII = ON
-- ExodusII libraries : /project/eesdev/tam/LaGriT/TPLs/seacas/lib
-- ExodusII include : /project/eesdev/tam/LaGriT/TPLs/seacas/include
-- Detected System:
-- Operating System: Linux
-- Architecture: 64-bit
-- Fortran compiler: GNU GFORTRAN
-- C compiler: GNU GCC
-- C++ compiler: GNU G++
-- Using Third Party Libraries.
-- TPL libs: /project/eesdev/tam/LaGriT/TPLs/seacas/lib
-- TPL include: /project/eesdev/tam/LaGriT/TPLs/seacas/include
-- Detecting Fortran/C Interface - Found GLOBAL and MODULE mangling
-- Verifying Fortran/C Compiler Compatibility - Success
-- Compilers:
-- FORTRAN [compiler = "/usr/bin/f95"; flags = " -m64 -fcray-pointer -fdefault-integer-8 -std=legacy -fno-sign-zero -fno-range-check"]
-- C [compiler = "/usr/bin/cc"; flags = " -w -m64"]
-- C++ [compiler = "/usr/bin/c++"; flags = " -w -m64"]
-- Configuring done
-- Generating done
-- Build files have been written to: /project/eesdev/tam/LaGriT/build
```
### Example Screen Output for make VERBOSE=1
```
[ 2%] Building C object CMakeFiles/liblagrit.dir/lg_util/src/gmvwrite.c.o
/usr/bin/cc -DLAGRIT_INCLUDE_EXODUSII -Dlinx64 -I/project/eesdev/tam/LaGriT/TPLs/seacas/include -w -m64 -MD -MT CMakeFiles/liblagrit.dir/lg_util/src/gmvwrite.c.o -MF CMakeFiles/liblagrit.dir/lg_util/src/gmvwrite.c.o.d -o CMakeFiles/liblagrit.dir/lg_util/src/gmvwrite.c.o -c /project/eesdev/tam/LaGriT/lg_util/src/gmvwrite.c
[ 36%] Building Fortran object CMakeFiles/liblagrit.dir/src/dumpexodusII.f.o
/usr/bin/f95 -DLAGRIT_INCLUDE_EXODUSII -Dlinx64 -I/project/eesdev/tam/LaGriT/TPLs/seacas/include -m64 -fcray-pointer -fdefault-integer-8 -std=legacy -fno-sign-zero -fno-range-check -cpp -c /project/eesdev/tam/LaGriT/src/dumpexodusII.f -o CMakeFiles/liblagrit.dir/src/dumpexodusII.f.o
[ 70%] Building CXX object CMakeFiles/liblagrit.dir/src/poi_helperFunctions.cpp.o
/usr/bin/c++ -DLAGRIT_INCLUDE_EXODUSII -Dlinx64 -I/project/eesdev/tam/LaGriT/TPLs/seacas/include -w -m64 -MD -MT CMakeFiles/liblagrit.dir/src/poi_helperFunctions.cpp.o -MF CMakeFiles/liblagrit.dir/src/poi_helperFunctions.cpp.o.d -o CMakeFiles/liblagrit.dir/src/poi_helperFunctions.cpp.o -c /project/eesdev/tam/LaGriT/src/poi_helperFunctions.cpp
[100%] Linking CXX static library liblagrit.a
/n/swdev/packages/Ubuntu-18.04-x86_64/cmake/cmake-3.22.1/bin/cmake -P CMakeFiles/liblagrit.dir/cmake_clean_target.cmake
/n/swdev/packages/Ubuntu-18.04-x86_64/cmake/cmake-3.22.1/bin/cmake -E cmake_link_script CMakeFiles/liblagrit.dir/link.txt
/usr/bin/ranlib liblagrit.a
make[2]: Leaving directory '/project/eesdev/tam/LaGriT/build'
[100%] Built target liblagrit
[100%] Linking Fortran executable lagrit
/n/swdev/packages/Ubuntu-18.04-x86_64/cmake/cmake-3.22.1/bin/cmake -E cmake_link_script CMakeFiles/lagrit.exe.dir/link.txt
/usr/bin/f95 -static-libgcc -static-libstdc++ -m64 -fcray-pointer -fdefault-integer-8 -std=legacy -fno-sign-zero -fno-range-check CMakeFiles/lagrit.exe.dir/src/lagrit_main.f.o -o lagrit liblagrit.a -L/project/eesdev/tam/LaGriT/TPLs/seacas/lib -lexodus_for -lexodus -lnetcdf -lhdf5_hl -lhdf5 -lz -ldl -static-libgfortran -static-libgcc -lstdc++
[100%] Built target lagrit
```
## Automatic Configurations
This is work performed by cmake and is usually not modified. Cmake is used to do some automatic file edits that depend on the machine or platform you are using.
### Header File configuration
CMake automatically configures two header files:
- `lg_util/src/mm2000.h`
- `src/lagrit.h`
The original files have the same name, but ending with `.in`.
CMake configures the files as following. Consider a line from `lagrit.h.in`:
```fortran
parameter (v_major=@PROJECT_VERSION_MAJOR@)
```
Here, `@PROJECT_VERSION_MAJOR@` is a CMake variable which will be replaced by CMake.
Here is how CMake configures the file:
```cmake
configure_file(
${SRC_CORE}/lagrit.h.in
${SRC_CORE}/lagrit.h
@ONLY
)
```
`${SRC_CORE}/lagrit.h.in` is the 'template' file, and `${SRC_CORE}/lagrit.h` is the output file. The `@ONLY` line means to **only** replace variables between the `@` symbol.
The variable above - `@PROJECT_VERSION_MAJOR@` is an instrinsic CMake variable. You can define your own. For example, CMake code within `SetBitSize.cmake` configures the `lg_util/src/mm2000.h.in` file.
### C-Fortran Compatibility
LaGriT codes include both Fortran and C/C++ code files. The driver routines are Fortran, the C/C++ files use wrapper functions and definitions set by cmake before code is compiled. These are set during the configuration and should not need to be modified unless new routines are added.
cmake writes fc_mangle.h for c-fortran routines. This file handles the symbol mangling for routines declared in src/lg_f_interface.h include file. For more information on this method visit https://www.netlib.org/lapack/lawnspdf/lawn270.pdf
The C++ wrapper routines need to be listed in CMakeLists.txt:
```
FortranCInterface_HEADER(
${SRC_CORE}/fc_mangle.h
SYMBOLS
INITLAGRIT # syntax: <subroutine>
DOTASK
CMO_GET_NAME
CMO_GET_INFO
CMO_GET_INTINFO
FC_CMO_GET_INT
FC_CMO_GET_VINT
FC_CMO_GET_DOUBLE
FC_CMO_GET_VDOUBLE
FPASS_TYPES
INSIDE_TET
LINESEG_TRI)
```
### LaGriT command TEST
The following commands have been added as tests during execution. These are especially useful in testing and to debug the c-fortran codes on various machines.
```
test (no second word) - easy test using createpts to check executable
test list - list available options
cpp - call dotask and c-fortran wrappers using get_info calls to get pointers from fortran
fortran - call dotask and get_info pointers used by cpp
dotask - call dotask_test which avoids global commands and just tests dotask parameters
```

36
cmake/Windows.md Normal file
View File

@@ -0,0 +1,36 @@
# Windows Helps and Hints
LaGriT V3.3.3 was not tested on Windows.
Earlier versions of LaGriT worked on Windows using CYGWIN.
## LaGrit V3.3.3 Windows 10 with gcc/gfortran
From User cean wang ceanwang@gmail.com Dec 11 2023
Cean compiled LaGriT under WIndows 10 with gcc/gfortran.
Cean followed instructions at https://lanl.github.io/LaGriT/pages/docs/build.html
and copied the example driver function into adrivgen.f and had a successful compile.
Cean noticed an error message suggesting to add a '' at the end of a function name, that is: initlagrit to initlagrit. This is normal for C & Fortran mixed programing.
## LaGriT V3.2 with C++ main on Windows with Microsoft Visual Studio
GOLDER Project has a forked version of LaGriT V3.2 that builds on Windows and includes instructions for their work: See repo at https://github.com/daniellivingston/LaGriT-Windows
Daniel Livingston developed a branch working on windows that is an update to the Golder project. See https://github.com/lanl/LaGriT/tree/windows
The code on the windows branch uses C++ as main calling LaGriT fortran and c codes. The branch has not been merged with master because of compile failures on Linux and Mac systems.
## ERROR: Undefined references to srand48() and drand48()
Complaint using WIndows 10 with gcc/gfortran edit src/metis_lg.c
Functions srand48() and drand48() are Linux or some flavor of Windows with MinGW as compiler system.
Solution at https://stackoverflow.com/questions/74274179/i-cant-use-drand48-and-srand48-in-c
Note metis codes are no longer used and will be updated or removed.
*Check LaGriT Github Issues for help and hints for Windows systems.*

246
cmake/macOS.md Normal file
View File

@@ -0,0 +1,246 @@
# MacOS Helps and Hints
LaGriT has been developed and used on MacOS machines for many years, using both Clang and GNU compilers.
For MacOS compilers and systems newer than those used in 2019, there may be issues finding the correct compilers.
See below for known issues.
LaGriT V3.3.3 builds with and without Exodus on MacOS Intel and M1 machines on Monterey, Ventura, and Sonoma.
LaGriT builds without Exodus are usually successful and recommended before building a version with Exodus.
See **LaGriT/MAC-install-exodus.sh** which works for brew as well as macports. This script finds and sets compiler paths due to location and naming changes between homebrew and macports.
See also **LaGriT/MAC_EnvironmentalVar.sh** for setting your compilers.
### Compiler Errors
LaGriT uses C, C++, and Fortran compilers. You may have to set the correct compilers for your build environment. The build may fail for newer models due to differences in naming conventions for both file structure and compilers.
Find or install your preferred compilers and set your environment, for example:
```
export CC=/opt/local/bin/gcc-mp-12
export CXX=/opt/local/bin/g++-mp-12
export FC=/opt/local/bin/gfortran-mp-12
```
On newer machines, the problem is that mac / osx has stolen the name gcc and g++ for the Apple clang compiler. And they don't provide fortran.
There are quite a few ways to work around this issue, but in any given case you have to be careful to make sure things are self-consistent.
Below are instructions for installing a set of compilers using MacPorts (Homebrew also works).
## Fortran Compiler Not Found or Incompatible with C compilers (macports example)
For LaGriT V3.3.3 on MacOS the Builds for LaGriT and Exodus were successful on Ventura and Sonoma using MacPorts and Homebrew. This example uses macports.
To use Macports you will need to install XCode command line tools.
Go to:https://developer.apple.com/download/all/ and select Sonoma Xcode 15.1, Ventura Xcode 14.3, or Early macOS 13.2.
Download and install macports:https://www.macports.org/install.php
Once Downloaded, Check to see if port command is found:
```
% port version
Version: 2.8.1
```
If port not found, set path. This should be in your appropriate login file such as .bash_profile.
```
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
```
selfupdate with verbose will take some time:
```sudo -E port -v selfupdate```
Use macports, Install CMake, GNU make, GNU compilers, (and wget for Exodus). Use the -E option to preserve environment varables such as your Proxies.
```
sudo -E port install cmake
sudo -E port install gmake
sudo -E port install gcc12
sudo -E port install wget
```
When done should have:
```
cmake version 3.24.4
gmake version 4.4.1
gcc version Apple Clang version 14.0.3
g++ version Apple Clang version 14.0.3
gfortran version 12.2.0
wget version 1.21.4
```
Make sure Cmake configurations for LaGriT and Exodus are using these tools and compilers.
## Exodus Build Fails with CommandLineTools Error (macports example)
Usually these strange permission errors are related to XCode resource management and parallel builds. In the older XCode (14.x) these were all resolved with the gnu tools (particularly gmake) coming from macports.
```
[ 93%] Built target h5dump
[ 93%] Built target h5watch
[ 93%] Built target h5perf_serial
make[1]: /Library/Developer/CommandLineTools/usr/bin/make: Permission denied
```
Switch MacPort installed gmake to 4.4 release.
See also: https://trac.macports.org/wiki/howto/InstallingOlderPort
```
git clone --single-branch https://github.com/macports/macports-ports.git
cd macports-ports
find . -name gmake
```
Now either in a web browser or from the command line identify the hash of the version you want.
Then checkout that commit, the commands below will checkout version 4.4
```
git checkout 4423959
cd devel/gmake
sudo -E port install
```
The tail end of the output shows that the newer version is deactivated and replaced with the older version:
```
---> Building gmake
---> Staging gmake into destroot
---> Installing gmake @4.4_0
---> Deactivating gmake @4.4.1_0
---> Cleaning gmake
---> Activating gmake @4.4_0
---> Cleaning gmake
---> Scanning binaries for linking errors
---> No broken files found.
---> No broken ports found.
```
If you experience a weird permission error, and you have admin permissions set. You still might not have access to the files you just installed.
```
Error: Unable to execute port: Could not open file: /Users/l113691/macports/macports-ports/devel/gmake/Portfile
```
Suggested fix, move the directory away from root and inherited permissions:
See suggestion at: https://superuser.com/questions/598824/previous-version-of-cgal-with-macports-error-unable-to-execute-port-could-no
```
cd macports-ports/devel
sudo mv gmake /private/tmp
cd /private/tmp
sudo -E port install
```
```
gmake --version
GNU Make 4.4
```
This solution worked on MacOS Intel and M1, Ventura and Sonoma for building LaGriT and Exodus.
## Exodus Build Fails with a make error that mentions an "sdk"
The error looks like this using macports:
```
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:90,
from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/wchar.h:67,
from /opt/local/include/gcc14/c++/cwchar:44,
from /opt/local/include/gcc14/c++/bits/postypes.h:40,
from /opt/local/include/gcc14/c++/bits/char_traits.h:42,
from /opt/local/include/gcc14/c++/string:42,
from /Users/elm/packages/amanzi/repos/amanzi-1.5.1/src/error_handling/exceptions.hh:13,
from /Users/elm/packages/amanzi/repos/amanzi-1.5.1/src/error_handling/dbc.hh:13,
from /Users/elm/packages/amanzi/repos/amanzi-1.5.1/src/error_handling/dbc.cc:10:
/opt/local/lib/gcc14/gcc/aarch64-apple-darwin23/14.2.0/include-fixed/stdio.h:83:8: error: 'FILE' does not name a type
83 | extern FILE *__stdinp;
| ^~~~
```
or this using brew:
```
Building CXX object CMakeFiles/cmTC_c85e6.dir/testCXXCompiler.cxx.o
/Library/Developer/CommandLineTools/usr/bin/g++ “-I/opt/homebrew/opt/llvm/include” -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk -mmacosx-version-min=14.7 -MD -MT CMakeFiles/cmTC_c85e6.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_c85e6.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_c85e6.dir/testCXXCompiler.cxx.o -c /Users/jhyman/src/LaGriT/TPLs/seacas/TPL/netcdf/netcdf-c/build/CMakeFiles/CMakeScratch/TryCompile-sEGBRU/testCXXCompiler.cxx
clang++: error: no such file or directory: '“-I/opt/homebrew/opt/llvm/include”'
gmake[1]: *** [CMakeFiles/cmTC_c85e6.dir/build.make:79: CMakeFiles/cmTC_c85e6.dir/testCXXCompiler.cxx.o] Error 1
gmake[1]: Leaving directory '/Users/jhyman/src/LaGriT/TPLs/seacas/TPL/netcdf/netcdf-c/build/CMakeFiles/CMakeScratch/TryCompile-sEGBRU'
gmake: *** [Makefile:127: cmTC_c85e6/fast] Error 2
```
**This error happens because newer Mac's require a newer version of x-code Command Line Tools to be installed. These tools don't work nicely with gcc-14. The sdk's for the newer tools are incompatible.**
To fix the error:
1. Verify that you have an older MacOSX14.sdk installation
```
ls /Library/Developer/CommandLineTools/SDKs
```
2. export older sds:
```
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/
```
## New Compilers show precision error for very small numbers
The XCode 15.0 compilers are showing a precision error for very small numbers.
This does not alter the meshing results but can show differences in how diagonals are crossed and reporting statistics.
This issue was observed using the following:
```
Cmake 3.24.4
Gmake 3.81
gcc 15.0.0
gcc-mp-13
g++-mp-13
gfortran-mp-13
```
The MacPorts compilers shown above do not have this precision issue.
## Compilers using Homebrew
Prior to installing compilers, you must have a working git, https://github.com/git-guides/install-git, and homebrew, https://github.com/homebrew, install.
```
brew install cmake
brew install make
brew install gcc
brew install wget
```
It may be necessary to export your compiler path as MACs like to use Clang whenever possible
```
export PATH=/usr/local/bin:$PATH
```
It some cases, creating an alias also helps:
```
alias gcc="gcc-13"
alias g++="g++-13"
alias cc="cc-13"
alias c++="c++-13"
```
When you run
```
gcc version
```
it should now list homebrew rather than clang.
## Clang and Implicit-int error
Newer versions of Clang have moved away from implicit-int and have begun reporting it as an error rather then a warning. It may be necessary to use the flag
```
-Wno-error=implicit-int
```

View File

@@ -0,0 +1,27 @@
#
# Find the Exodus finite element data model library from Sandia
#
# EXODUS_FOUND - System has Exodus
# EXODUS_INCLUDE_DIR - The LibXml2 include directory
# EXODUS_LIBRARIES - The libraries needed to use LibXml2
#
# Original author: https://gitlab.kitware.com/xdmf/xdmf/blob/master/CMake/FindExodus.cmake
#FIND_PACKAGE(NetCDF REQUIRED)
# Original lagrit build line: -L$(EXO_LIB_DIR) -lexodus_for -lexodus -lnetcdf -lhdf5_hl -lhdf5 -lz -ldl
FIND_PATH(Exodus_INCLUDE_DIR NAMES exodusII.h)
#FIND_LIBRARY(EXODUS_LIBRARIES NAMES exodusii exodusIIv2c exodus_for exodus)
FIND_LIBRARY(Exodus_LIBRARIES
NAMES exodus_for exodus
)
INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set EXODUS_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Exodus DEFAULT_MSG Exodus_LIBRARIES Exodus_INCLUDE_DIR)
MARK_AS_ADVANCED(Exodus_INCLUDE_DIR Exodus_LIBRARIES)

View File

@@ -0,0 +1,30 @@
#
# Find NetCDF include directories and libraries
#
# NetCDF_FOUND - System has NetCDF
# NetCDF_INCLUDE_DIR - The NetCDF include directory
# NetCDF_LIBRARIES - The libraries needed to use NetCDF
FIND_PATH(NetCDF_INCLUDE_DIR netcdf.h)
FIND_LIBRARY(NetCDF_LIBRARIES
NAMES netcdf
${NetCDF_PREFIX}
${NetCDF_PREFIX}/lib64
${NetCDF_PREFIX}/lib
/usr/local/lib64
/usr/lib64
/usr/lib64/netcdf-3
/usr/local/lib
/usr/lib
/usr/lib/netcdf-3
)
INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set EXODUS_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NetCDF DEFAULT_MSG NetCDF_INCLUDE_DIR NetCDF_LIBRARIES)
MARK_AS_ADVANCED(NetCDF_INCLUDE_DIR NetCDF_LIBRARIES)