Skip to content

Commit

Permalink
Merge branch 'poisson_disk' of github.com:lanl/LaGriT into poisson_disk
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgable committed Dec 19, 2023
2 parents 896c443 + 810be70 commit 8040123
Show file tree
Hide file tree
Showing 99 changed files with 233 additions and 35,959 deletions.
55 changes: 32 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
# Default build with Exodus OFF
# Edit option below or use cmake .. -DLAGRIT_BUILD_EXODUS=ON
# for testing cmake options:
# -DCMAKE_BUILD_TYPE=Debug
# -DLAGRIT_BUILD_EXODUS=ON (detect Exodus?, default OFF)
#
# Some common cmake variables:
# https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
# -D CMAKE_FIND_DEBUG_MODE=ON
#
# Not supported yet but available:
# -D CMAKE_INSTALL_PREFIX (default /usr/local if make install)
# -D LaGriT_BUILD_STATIC=ON (default .a, use OFF for .so etc)
#
# Long version with explicit paths to build lagrit with Exodus
# This file is useful for debugging cmake with Exodus
# Note Windows is not working and is commented out
# Sep 28 2022 [email protected] lagrit.lanl.gov
# SEACAS Exodus Gregory Sjaardema [email protected]
##############################################################################

cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

# set cmake variables for version numbers and compilers
project(LaGriT VERSION 3.3.3
DESCRIPTION "LaGriT Meshing Utilities"
LANGUAGES Fortran CXX C)

# module not being used because this is not working
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
# message(STATUS "Using cmake module = ${CMAKE_MODULE_PATH}")

option(LAGRIT_BUILD_STATIC "Compile as a static (fat) executable." ON)
option(LAGRIT_BUILD_EXODUS "Build with Exodus." OFF)

Expand Down Expand Up @@ -96,7 +104,9 @@ endif()
# message(STATUS "Set Explicit Exodus ROOT: ${SEACASExodus_ROOT}")

# trick cmake to add exodus libs correctly for linking
set(TPL_LINK_LIBS "-L${EXODUS_ROOT}/lib -lexodus_for -lexodus -lnetcdf -lhdf5_hl -lhdf5 -lz -ldl -static-libgfortran -static-libgcc")
# nc-config --static should pick up all link FLAGS from netcdf
# -lcurl needed for linking netcdf libs on linux
set(TPL_LINK_LIBS "-L${EXODUS_ROOT}/lib -lexodus_for -lexodus -lnetcdf -lhdf5_hl -lcurl -lhdf5 -lz -ldl -static-libgfortran -static-libgcc")

message(STATUS "-----Done Exodus-----")

Expand Down Expand Up @@ -126,8 +136,8 @@ endif()

# message( FATAL_ERROR "Debug exit at STOP." )

# ===== Detect platform, bit-size, and compilers ==================== #
message(STATUS "Detected System:")
# ===== Detect local platform, bit-size, and compilers ==================== #
message(STATUS "Detecting LaGriT build using local cmake files:")
include("${CMAKE_SOURCE_DIR}/cmake/PlatformSettings.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/DetectBitSize.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/CompilerFlags-Fortran.cmake")
Expand All @@ -140,7 +150,7 @@ else()
set(BUILD_SHARED_LIBS TRUE)
endif()

# if not set will ignore sytem release or debug flags
# cmake variable to set DEBUG or RELEASE on command line
if (CMAKE_BUILD_TYPE)
message("LaGriT compile type set to: ${CMAKE_BUILD_TYPE}")
endif()
Expand All @@ -167,7 +177,7 @@ endif()
# )
#endif()

# create lagrit.h from template lagrit.h.in
# create lagrit.h using PROJECT_VERSION_* in template lagrit.h.in
string(TIMESTAMP CMAKE_DATE_COMPILE "%Y/%m/%d")
configure_file(
${SRC_CORE}/lagrit.h.in
Expand All @@ -179,8 +189,8 @@ configure_file(
include(FortranCInterface)
FortranCInterface_VERIFY()

# Create fc_mangle.h for cpp-fortran routines to handle symbol mangling
# Names here should be same as found in src/lg_f_interface.h
# Create fc_mangle.h for c-fortran routines to handle symbol mangling
# Names here should also be declared in src/lg_f_interface.h
# More information: https://www.netlib.org/lapack/lawnspdf/lawn270.pdf
FortranCInterface_HEADER(
${SRC_CORE}/fc_mangle.h
Expand Down Expand Up @@ -225,7 +235,7 @@ file(
list(FILTER SRC_UTIL_FILES EXCLUDE REGEX ".*mm2000_header.F$")
list(FILTER SRC_CORE_FILES EXCLUDE REGEX ".*lagrit_main.f$")

message(STATUS "Compilers:")
message(STATUS "Using Compiler Settings:")
message(STATUS " FORTRAN [compiler = \"${CMAKE_Fortran_COMPILER}\"; flags = \"${CMAKE_Fortran_FLAGS}\"]")
message(STATUS " C [compiler = \"${CMAKE_C_COMPILER}\"; flags = \"${CMAKE_C_FLAGS}\"]")
message(STATUS " C++ [compiler = \"${CMAKE_CXX_COMPILER}\"; flags = \"${CMAKE_CXX_FLAGS}\"]")
Expand Down Expand Up @@ -256,27 +266,26 @@ set_target_properties(

# Compile the main LaGriT binary
add_executable(
lagrit.exe
lagrit
${SRC_CORE}/lagrit_main.f
)

set_target_properties(
lagrit.exe
lagrit
PROPERTIES
OUTPUT_NAME "lagrit"
LINKER_LANGUAGE Fortran
Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/modules/"
)

# Change from 'lagrit' (OUTPUT_NAME) to 'lagrit.exe' on Windows
# Note cmake should do this automatically so not needed?
if (WIN32)
set_target_properties(lagrit.exe PROPERTIES SUFFIX ".exe")
set_target_properties(lagrit PROPERTIES SUFFIX ".exe")
endif()

if (LAGRIT_BUILD_STATIC)
set_target_properties(lagrit.exe PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(lagrit.exe PROPERTIES LINK_SEARCH_END_STATIC 1)
set_target_properties(lagrit PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(lagrit PROPERTIES LINK_SEARCH_END_STATIC 1)

if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
Expand All @@ -289,18 +298,18 @@ endif()
# end static build options

target_include_directories(
lagrit.exe
lagrit
PUBLIC ${TPL_INCLUDE_DIRS} # includes 'exodusII.h' 'exodusII.inc'
)

target_link_libraries(lagrit.exe
target_link_libraries(lagrit
PRIVATE liblagrit # liblagrit.[dylib|so|a|dll]
PUBLIC ${TPL_LINK_LIBS} # Exodus / NetCDF / HDF5 / ZLIB
)

# this produces errors
#make[2]: *** No rule to make target '../TPLs/seacas/lib/libexoIIv2for.a', needed by 'lagrit'. Stop.
# target_link_libraries(lagrit.exe
# target_link_libraries(lagrit
# PRIVATE
# liblagrit
# "${Exodus_LIBRARIES}/libexodus.a"
Expand All @@ -312,7 +321,7 @@ target_link_libraries(lagrit.exe

# Install lagrit to ${CMAKE_INSTALL_PATH}/bin/
install(
TARGETS lagrit.exe
TARGETS lagrit
DESTINATION "bin"
)

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ $ cd LaGriT/
### Building LaGriT ###
---

#### Building LaGriT - for developers
#### Building LaGriT - long version

[Code Development with cmake](cmake/README.md)
[Building LaGriT with cmake and exodus](cmake/README.md)


#### Building LaGriT - Simple
Expand Down Expand Up @@ -103,17 +103,23 @@ To include these commands you will need to install Seacas-Exodus.

Use the Exodus Install script to Install Exodus and associated libraries. You can run the file or use the file as a guide to copy and paste commands for installation. The script provides the flags needed by LaGriT and will install seacas in the directory TPLs.


```bash
$ ./install-exodus.sh
```

Check that the following libriaries have been installed in seacas/lib:
**IF ERRORS** couldn't build NetCDF. exiting.
Read the instructions and edit files as suggested in install-exodus.sh

Check that the following libriaries should be installed in seacas/lib:

```
libexodus.a libexoIIv2for32.a libhdf5_hl.a libnetcdf.a
libexodus_for.a libhdf5.a libhdf5_tools.a libz.a
```

[For more on Building LaGriT with cmake and exodus](cmake/README.md)

For full and current Exodus Installation instructions, go to:
[Seacas ExodusII](https://github.com/sandialabs/seacas)

Expand Down
23 changes: 21 additions & 2 deletions cmake/CompilerFlags-C.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
# 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")

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 -m64 -stdlib=libc++ -std=c++0x")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -stdlib=libc++ -std=c++0x")

elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(STATUS " C++ compiler: GNU G++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -m64")
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()
26 changes: 23 additions & 3 deletions cmake/CompilerFlags-Fortran.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +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} -m64 -fcray-pointer -fdefault-integer-8 -std=legacy -fno-sign-zero -fno-range-check")
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 -Qm64 -Qsafe-cray-ptr -integer-size=64 -assume:nominus0 -QRimplicit-import-")
endif()
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()

7 changes: 5 additions & 2 deletions cmake/PlatformSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ if(UNIX)
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("OPERATING SYSTEM COULD NOT BE DETECTED")
endif()
message("cmake/PlatformSettings.cmake OPERATING SYSTEM UNDEFINED")
endif()
1 change: 1 addition & 0 deletions cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@ configure_file(
`${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.

Loading

0 comments on commit 8040123

Please sign in to comment.