Skip to content

Commit

Permalink
Merge pull request #175 from JCSDA/feature/btj_REL-3.1.1_shared_vs_st…
Browse files Browse the repository at this point in the history
…atic_build

Add option to build either shared or static libraries via CMake (update to CRTMv3 release/REL-3.1.1 branch)
  • Loading branch information
BenjaminTJohnson authored Aug 30, 2024
2 parents bd26208 + b953ed0 commit cee839f
Show file tree
Hide file tree
Showing 6 changed files with 1,436 additions and 237 deletions.
33 changes: 31 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,27 @@ option(OPENMP "Build crtm with OpenMP support" ON)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME})
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "default install path" )
message("CMAKE_INSTALL_PREFIX set to ${CMAKE_INSTALL_PREFIX}")

# Set the default install path to <build directory>/lib, but allow overriding

#set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "default install path")
if( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH "Install path prefix" FORCE)
endif()

# Include GNUInstallDirs to get the standard installation directory variables
include(GNUInstallDirs)

# Force the installation directory for libraries to be "lib" regardless of architecture
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}" CACHE STRING "Installation directory for libraries" FORCE)

# Set output directory for built libraries to <build directory>/lib
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# Optionally, set the runtime output directory (for executables)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)


# Function to get the current git commit hash
function(get_git_hash result)
Expand All @@ -31,6 +50,12 @@ set(GREEN "${ESCAPE}[32m")
# Output the project name, version, and hash in green text
message(STATUS "${GREEN}[${PROJECT_NAME}] (${PROJECT_VERSION}) [${PROJECT_HASH}]${RESET}")

# Output the various install/output paths
message("CMAKE_INSTALL_PREFIX set to ${CMAKE_INSTALL_PREFIX}")
message("CMAKE_INSTALL_LIBDIR set to ${CMAKE_INSTALL_LIBDIR}")
message("CMAKE_LIBRARY_OUTPUT_DIRECTORY set to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")


## Configuration options
include(${PROJECT_NAME}_compiler_flags)
include(GNUInstallDirs)
Expand Down Expand Up @@ -69,6 +94,10 @@ configure_file(
)

# Installation
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )

install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
6 changes: 3 additions & 3 deletions Get_CRTM_Binary_Files.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#https://bin.ssec.wisc.edu/pub/s4/CRTM/fix_REL-3.1.1.0.tgz (use this for jedi and stand-alone, some files have changed).
#https://bin.ssec.wisc.edu/pub/s4/CRTM/fix_REL-3.1.1.2.tgz (use this for jedi and stand-alone, some files have changed).

# This script is used to manually download the tarball of binary and netcdf coefficient files.
# The same files also download automatically during the cmake step, so you don't have to actually run this manually.

foldername="fix_REL-3.1.1.0"
foldername="fix_REL-3.1.1.2"
filename="${foldername}.tgz"
echo "$filename"
break
Expand All @@ -20,7 +20,7 @@ if test -f "$filename"; then
fi
else
#download, untar, move
echo "Downloading $filename, please wait about 5 minutes (4 GB tar file)"
echo "Downloading $filename, please wait about 7 minutes (7 GB tar file: sorry!)"
wget https://bin.ssec.wisc.edu/pub/s4/CRTM/$filename # CRTM binary files, add "-q" to suppress output.

#untar the file and move directory to fix
Expand Down
47 changes: 31 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
CRTM REL-3.1.0
CRTM REL-3.1.1
====================

[![Build Status](https://app.travis-ci.com/JCSDA-internal/crtm.svg?token=r6aaq9P13fHcTi8yBgdM&branch=develop)](https://app.travis-ci.com/JCSDA-internal/crtm)

Preamble
--------

CRTM v3.1.0 release (`REL-3.1.0`)
CRTM v3.1.1 release (`REL-3.1.1`)

v3.1.1 released August 12, 2024
v3.1.0 (alpha) Released October 31, 2023
v3.0.0 Released March, 2023
v2.4.1-alpha Released on April 1, 2021 (internal realease only)
Expand All @@ -17,7 +18,7 @@ This is an experimental release of CRTM v3.0, some features may not be fully fun
v3.x features will be rolled out in incremental updates.

Basic requirements:
(1) A Fortran 2003 compatible compiler
(1) A Fortran 2008 compatible compiler
(2) A netCDF4 / HDF5 library that has been built with the compiler you're going to use (module environments are helpful here)
(3) A linux, macOS, or unix-style environment. This has not been tested under any Windows Fortran environments.
(4) Bash shell is preferred.
Expand All @@ -26,7 +27,7 @@ Basic requirements:

=========================================================

**JEDI NOTE** This develop branch is also designed to work directly in a JEDI container or JEDI environment. If you're doing JEDI things, you're probably in the right spot. However, you should stop reading right now and have a look at the README_JEDI.md file.
**JEDI NOTE** This release branch is also designed to work directly in a JEDI container or JEDI environment. If you're doing JEDI things, you're probably in the right spot. However, you should stop reading right now and have a look at the README_JEDI.md file.

If you're looking for an older version of CRTM (v2.3.0 or older) you should obtain the appropriate tarball from
https://bin.ssec.wisc.edu/pub/s4/CRTM/ OR https://github.com/JCSDA/crtm (old versions).
Expand Down Expand Up @@ -55,12 +56,9 @@ Contents

Configuration, building, and testing the library
================================================
JCSDA CRTM v3.0.x Build Instructions
JCSDA CRTM v3.1.1 Build Instructions

- Development Repository Build
- Note: the development repository build differs from a release build.

The CRTM **development** repository directory structure looks like:
The CRTM repository directory structure looks (something) like:

<pre>
.
Expand Down Expand Up @@ -117,26 +115,42 @@ But after a clean clone of the development repository, none of the links to sour

Configuration
-------------
At present, the `fix/` directory is provided either through ftp or during the ctest step. We're working on a way to make the process of getting binary data equitable and easy for all users.
At present, the `fix/` directory is provided through ftp using the Get_CRTM_Binary_Files.sh script to obtain and unpack the dataset.
If this directory doesn't exist during the `cmake` step, then cmake will download and install into `build/test_data/fix_REL-3.1.1.x/fix/`...

The files therein are gzipped (*.gz extension). Use the Get_CRTM_Binary_Files.sh script to obtain and unpack the dataset.
The fix/ directory (as of v3.1.1) contains most of the netCDF SpcCoeff and TauCoeff files, as part of our ongoing effort to transition toward netCDF-only CRTM. We expect to deprecate the binary formats in v3.2.x

As of CRTM v3.0.0, we no longer support legacy build system using autotools. (i.e., configure/make). Only cmake / ecbuild (a cmake wrapper, but not required) is supported.
As of CRTM v3.0.0, we no longer support legacy build system using autotools. (i.e., configure/make). Only cmake / ecbuild (a cmake wrapper, but not required) is supported. Many standalone Makefiles, make.dependencies, etc. have been removed, but not entirely. Cleanup occurs as we work our way through the repository updating other things.

**Build Step 1**
From the top level of the CRTM directory, e.g., `CRTMv3/`
<pre>
mkdir build/
cd build/
cmake ..
cmake -D<cmake variables here, see below> ..
make clean
make -j8
make install (optional, see -DCMAKE_INSTALL_PREFIX below, default install location is `<build>/.`)
ctest -j8
</pre>

`-j8` runs 8 processes in parallel, adjust to your system.
Now we have compiled the linked source codes that reside in the `src/` directory, and the ctests are built as well.

The CMake variables of interest are:
`-DCMAKE_BUILD_TYPE = RELEASE / DEBUG / RELWITHDEBINFO` (default is `RELEASE` if not specified)
`-DCMAKE_SHARED_LIBS = ON / OFF` (build shared lib (`<build>/lib/libcrtm.so`) or static lib (`<build>/lib/libcrtm.a`) -- default is `ON` if not specified)
`-DCMAKE_INSTALL_PREFIX=<path-to-install>` (You have to run `make install` to install the libcrtm* into your desired directory `<build>/path-to-install`).


example:
```
cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./install ..
```
this would make a debug build of CRTM, static library (`libcrtm.a`) and set the optional install location to `<build>/install/.` (or something similar, search for `libcrtm.*` and `*.mod`). Custom Install only happens if you issue the `make install` command.

The first time you run `cmake`, it will check for a `fix/` directory one level above, and if it does't find it, it will download the binary files (according to `test/CMakeLists.txt` file information), and store them in `<build>/test_data/**`.

Linking to the library
----------------------

Expand All @@ -152,15 +166,16 @@ LIBS="-lcrtm ${LIBS}"

**Feedback and Contact Information**

CRTM SUPPORT EMAIL: [email protected] OR visit https://forums.jcsda.org/
CRTM SUPPORT: visit https://forums.jcsda.org/ or visit https://github.com/JCSDA/CRTMv3 and post an issue (be sure to assign someone from the team).

If you have problems building the library please include the generated "config.log" file in your email correspondence.

Known Issues
------------

(1) Any "Transmitance Coefficient" generation codes included in src/ are not functional. Contact CRTM support above for details.
(2) No testing was done on PGI, XLF, or other less commonr compilers. Feedback from users suggest that there's no major concerns though. Please contact us with specifics.
(2) No testing was done on PGI, XLF, or other less common compilers. Feedback from users suggest that there's no major concerns though. Please contact us with specifics. Tested on GCC v5 and higher, and ifort v18 and higher. Some specific compiler versions have issues, contact support if you run into problems.





Expand Down
Loading

0 comments on commit cee839f

Please sign in to comment.