Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fv3-jedi and its dependencies #306

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions var/spack/repos/builtin/packages/crtm/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class Crtm(CMakePackage):
depends_on("netcdf-fortran", when="@v2.4-jedi.2")
depends_on("netcdf-fortran", when="@v2.4.1-jedi")
depends_on("netcdf-fortran", when="@v3.0.0-rc.1")
depends_on("netcdf-fortran", when="@v3.0.0-skylabv5")
depends_on("netcdf-fortran", when="@v3.0.0-skylabv5-1")
depends_on("netcdf-fortran", when="@v3.0.0-skylabv6")

depends_on("crtm-fix@2.3.0_emc", when="@2.3.0 +fix")
depends_on("crtm-fix@2.4.0_emc", when="@=2.4.0 +fix")
Expand All @@ -52,6 +55,46 @@ class Crtm(CMakePackage):
depends_on("ecbuild", type=("build"), when="@v2.4-jedi.2")
depends_on("ecbuild", type=("build"), when="@v2.4.1-jedi")
depends_on("ecbuild", type=("build"), when="@v3.0.0-rc.1")
depends_on("ecbuild", type=("build"), when="@v3.0.0-skylabv5")
depends_on("ecbuild", type=("build"), when="@v3.0.0-skylabv5-1")
depends_on("ecbuild", type=("build"), when="@v3.0.0-skylabv6")

# Spack gets confused by the different repository url, so we use direct URLs here.

# version("v3.0.0-skylabv6", commit="a31ed458fb702b235bccbe1693d2badffb241d05")
version(
"v3.0.0-skylabv6",
url="https://www.github.com/JCSDA/crtmv3/tarball/a31ed458fb702b235bccbe1693d2badffb241d05",
sha256="719b1070a2864e2ccc8334f195f276a555ebe3d3b1363f3dc6430b049080e4d6",
)

# Slightly after the Skylab 5 release to fix https://github.com/JCSDA/CRTMv3/pull/48.
# TODO: Push for a distinct tag in the CRTMv3 repository.
version(
"v3.0.0-skylabv5-1",
url="https://www.github.com/JCSDA/crtmv3/tarball/d15810f5538d4cf041e94ebfbb41b403d82bed13",
sha256="fa0f050ae29d3d7d71da4b97c5dfd74ad90c98c3645fd35340efa1410cf76cf3",
)

# The official release for Skylab 5, but it's buggy. See https://github.com/JCSDA/CRTMv3/pull/48.
version(
"v3.0.0-skylabv5",
url="https://www.github.com/JCSDA/crtmv3/tarball/74cdc9428f56a11ce0dcd3ac7ddff00097b7b61c",
sha256="033abf0dde10b29043f3cde8c4b4285a32e5886599d174ab83ef6f5a2132e3d6",
)

version(
"v2.4.1-jedi.1", sha256="94ff24051382d544c2e200a937bfe7d2047f6393a3e22f64284d5dc70e791ca6"
)
version(
"v2.4.1-jedi", sha256="fd8bf4db4f2a3b420b4186de84483ba2a36660519dffcb1e0ff14bfe8c6f6a14"
)

# Both of these have big binary file blobs
# Corrects polarization angle biases for NOAA-21 and fixes WMO satellite and sensor ids.
version("v2.4.0_emc.2", commit="50fde6ae9caeaca3f5c8c3a39aca7e594eab451a")
# Adds new NOAA-21 and ancillary files for VIIRS.
version("v2.4.0_emc.1", commit="eaf322287691d5d204167e1a929117ba6b9c2e23")

version(
"v2.4.1-jedi", sha256="fd8bf4db4f2a3b420b4186de84483ba2a36660519dffcb1e0ff14bfe8c6f6a14"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,8 @@

cmake_minimum_required( VERSION 3.3.2 FATAL_ERROR )

+find_package( ecbuild 3.6 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
+
project( fv3 VERSION 1.2.0 LANGUAGES C CXX Fortran )

set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH} )
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class GfdlAtmosCubedSphere(CMakePackage):
"""The GFDL atmos_cubed_sphere dynamical core code"""

homepage = "https://github.com/JCSDA/GFDL_atmos_cubed_sphere"
git = "https://github.com/JCSDA/GFDL_atmos_cubed_sphere.git"

maintainers = ["climbfuji"]

version("1.2.0.jcsda", commit="61450b4e3e80bb96b26c5f3808ce60b5e5cb4207")

depends_on("ecbuild", type=("build"))
depends_on("ecbuild@3.3.2:", type=("build"), when="@1.7.0:")
depends_on("fms@release-jcsda")
depends_on("jedi-cmake", type=("build"))
depends_on("llvm-openmp", when="%apple-clang", type=("build", "run"))
depends_on("mpi")
depends_on("netcdf-c")
depends_on("netcdf-fortran")

# find_package(ecbuild REQUIRED) is needed when using ecbuild.
patch("CMakeLists.txt.patch", when="@1.2.0.jcsda")
12 changes: 12 additions & 0 deletions var/spack/repos/jcsda-emc/packages/femps/CMakeLists.txt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,8 @@

cmake_minimum_required( VERSION 3.3.2 FATAL_ERROR )

+find_package( ecbuild 3.6 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
+
project( femps VERSION 1.2.0 LANGUAGES Fortran )

set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})

30 changes: 30 additions & 0 deletions var/spack/repos/jcsda-emc/packages/femps/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class Femps(CMakePackage):
"""Finite Element Mesh Poisson Solver"""

homepage = "https://github.com/JCSDA/femps"
git = "https://github.com/JCSDA/femps.git"

maintainers = ["climbfuji"]

version("1.2.0", commit="a22e458c1742695479db9011ddb6bcbf31de39fe")

depends_on("ecbuild", type=("build"))
depends_on("ecbuild@3.3.2:", type=("build"), when="@1.7.0:")
depends_on("jedi-cmake", type=("build"))
depends_on("llvm-openmp", when="%apple-clang", type=("build", "run"))
depends_on("mpi")
depends_on("netcdf-c")
depends_on("netcdf-fortran")

# find_package(ecbuild REQUIRED) is needed when using ecbuild.
patch("CMakeLists.txt.patch", when="@1.2.0")
# femps needs to install its Fortran modules.
patch("src.femps.CMakeLists.txt.patch", when="@1.2.0")
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- a/src/femps/CMakeLists.txt
+++ b/src/femps/CMakeLists.txt
@@ -25,3 +25,12 @@ ecbuild_add_library( TARGET femps

target_include_directories( femps INTERFACE $<BUILD_INTERFACE:${CMAKE_Fortran_MODULE_DIRECTORY}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+
+# Fortran module output directory for build and install interfaces
+set( MODULE_DIR module/${PROJECT_NAME}/${CMAKE_Fortran_COMPILER_ID}/${CMAKE_Fortran_COMPILER_VERSION} )
+set_target_properties( ${PROJECT_NAME} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/${MODULE_DIR} )
+install( DIRECTORY ${CMAKE_BINARY_DIR}/${MODULE_DIR}/ DESTINATION ${MODULE_DIR} )
+target_include_directories( femps INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/${MODULE_DIR}>
+ $<INSTALL_INTERFACE:${MODULE_DIR}> )
+

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt 2023-10-12 11:02:44
+++ b/CMakeLists.txt 2023-10-12 11:03:11
@@ -15,6 +15,8 @@

set( CMAKE_DIRECTORY_LABELS "fv3-jedi-lm" )

+find_package( ecbuild 3.6 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
+
set( ECBUILD_DEFAULT_BUILD_TYPE Release )
set( ENABLE_OS_TESTS OFF CACHE BOOL "Disable OS tests" FORCE )
set( ENABLE_LARGE_FILE_SUPPORT OFF CACHE BOOL "Disable testing of large file support" FORCE )
71 changes: 71 additions & 0 deletions var/spack/repos/jcsda-emc/packages/fv3-jedi-linearmodel/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class Fv3JediLinearmodel(CMakePackage):
"""Tangent linear and adjoint versions of FV3 dynamical core and GEOS physics"""

homepage = "https://github.com/JCSDA/fv3-jedi-linearmodel"
git = "https://github.com/JCSDA/fv3-jedi-linearmodel.git"

maintainers = ["climbfuji"]

version("1.3.0", commit="9758fbd44166fc1e1d745ca9ab7e9e5e6071955f")
version("1.2.0", commit="d47cea97c659e8a11e9e64c23092bef06227ebde")
version("develop", branch="develop", no_cache=True)

variant(
"forecast_model",
default="FV3CORE",
description="fv3 forecast model",
values=("FV3CORE", "GEOS", "UFS"),
)
# Note that the options for mkl, mpi, and openmp are lazily written in fv3-jedi-linearmodel.
# These options just turn on a find_package call. If a package is already found, for example by
# one of the package dependencies, then that component is silently used even if the user
# toggles it off. This is a bug and should be fixed eventually.
variant("mkl", default=False, description="Use MKL for LAPACK implementation (if available)")
variant("mpi", default=True, description="Support for MPI distributed parallelism")
variant("openmp", default=True, description="Build with OpenMP support")

conflicts("forecast_model=GEOS", msg="FV3-JEDI-LINEARMODEL: GEOS to be implemented.")
conflicts("forecast_model=UFS", msg="FV3-JEDI-LINEARMODEL: UFS to be implemented.")

depends_on("ecbuild", type=("build"))
depends_on("ecbuild@3.3.2:", type=("build"), when="@1.7.0:")
depends_on("fms@release-jcsda", when="forecast_model=FV3CORE")
depends_on("fms@release-jcsda", when="forecast_model=UFS")
depends_on("jedi-cmake", type=("build"))
depends_on("lapack", when="~mkl")
depends_on("llvm-openmp", when="+openmp %apple-clang", type=("build", "run"))
depends_on("mkl", when="+mkl")
depends_on("mpi", when="+mpi")
depends_on("netcdf-fortran")
depends_on("netcdf-c~mpi", when="~mpi")
depends_on("netcdf-c+mpi", when="+mpi")

# Future: GEOS needs
# - MAPL (underway at GMAO)
# - GEOSgcm
# - fms r8 or r4

# Future: UFS needs
# - stochastic_physics
# - ccpp
# - ccppphys
# - fv3atm
# - ufs
# - FMS::fms_r8

def cmake_args(self):
res = [self.define_from_variant("FV3_FORECAST_MODEL", "forecast_model")]
return res

# find_package(ecbuild REQUIRED) is needed when using ecbuild.
patch("CMakeLists.txt.patch", when="@1.2:1.3")
# fv3-jedi-linearmodel needs to install its Fortran modules.
patch("src.CMakeLists.txt.patch", when="@1.2:1.3")
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,3 +37,12 @@ target_include_directories( fv3jedilm INTERFACE $<BUILD_INTERFACE:${CMAKE_Fortra
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
target_compile_options(fv3jedilm PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:-fallow-argument-mismatch>)
endif()
+
+# Fortran module output directory for build and install interfaces
+set( MODULE_DIR module/${PROJECT_NAME}/${CMAKE_Fortran_COMPILER_ID}/${CMAKE_Fortran_COMPILER_VERSION} )
+set_target_properties( ${PROJECT_NAME} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/${MODULE_DIR} )
+install( DIRECTORY ${CMAKE_BINARY_DIR}/${MODULE_DIR}/ DESTINATION ${MODULE_DIR} )
+target_include_directories( fv3jedilm INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/${MODULE_DIR}>
+ $<INSTALL_INTERFACE:${MODULE_DIR}> )
+

11 changes: 11 additions & 0 deletions var/spack/repos/jcsda-emc/packages/fv3-jedi/CMakeLists.txt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt 2023-10-12 11:36:48
+++ b/CMakeLists.txt 2023-10-12 11:37:13
@@ -17,6 +17,8 @@

set( CMAKE_DIRECTORY_LABELS "fv3-jedi" )

+find_package( ecbuild 3.6 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
+
set( ECBUILD_DEFAULT_BUILD_TYPE Release )
set( ENABLE_OS_TESTS OFF CACHE BOOL "Disable OS tests" FORCE )
set( ENABLE_LARGE_FILE_SUPPORT OFF CACHE BOOL "Disable testing of large file support" FORCE )
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--- a/cmake/fv3jedi_extra_macros.cmake
+++ b/cmake/fv3jedi_extra_macros.cmake
@@ -21,6 +21,24 @@ macro( LINK_FILES_DIR filelist dst_dir )
endforeach(FILENAME)
endmacro()

+# macro to create a symlink from src to dst
+function(CREATE_SYMLINK src dst)
+ foreach (FILENAME ${ARGN})
+ execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink
+ ${src}/${FILENAME}
+ ${dst}/${FILENAME} )
+ endforeach(FILENAME)
+endfunction(CREATE_SYMLINK)
+
+# macro to create a symlink from src to dst with just filename
+function(CREATE_SYMLINK_FILENAME src dst)
+ foreach (FILENAME ${ARGN})
+ get_filename_component(filename ${FILENAME} NAME )
+ execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink
+ ${src}/${FILENAME}
+ ${dst}/${filename} )
+ endforeach(FILENAME)
+endfunction(CREATE_SYMLINK_FILENAME)

# Macro to include GFS restart files in testing
macro( GFS_FILES_BKG path date )
95 changes: 95 additions & 0 deletions var/spack/repos/jcsda-emc/packages/fv3-jedi/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class Fv3Jedi(CMakePackage):
"""Interface between JEDI and FV3 based models"""

homepage = "https://github.com/JCSDA/fv3-jedi"
git = "https://github.com/JCSDA/fv3-jedi.git"

maintainers = ["climbfuji"]

version("develop", branch="develop", no_cache=True)
version("1.7.0", commit="75fa0544ae7c6b5446460bef8cb7663f3fe1acad")
version("1.6.0", commit="3c20ebd2657d4b8df35103207a1e83535b67469c")

variant(
"forecast_model",
default="FV3CORE",
description="fv3 forecast model",
values=("FV3CORE", "GEOS", "UFS"),
)
variant("geos-aero", default=False, description="Enable usage of geos-aero")
variant("gsibec", default=True, description="FV3-SABER block GSI")
# Note that the option for openmp is lazily written in fv3-jedi.
# It just enables a find_package call. If a package is already found, for example by
# one of the package dependencies, then that component is silently used even if the user
# toggles it off. This is a bug and should be fixed eventually.
variant("openmp", default=True, description="Build with OpenMP support")
variant("ropp", default=False, description="Enable usage of ropp")
variant("sp", default=True, description="Enable usage of ncep-sp")

conflicts("forecast_model=GEOS", msg="FV3-JEDI: GEOS to be implemented.")
conflicts("forecast_model=UFS", msg="FV3-JEDI: UFS to be implemented.")
conflicts("+geos-aero", msg="FV3-JEDI: geos-aero to be implemented.")
# Note: the ropp code needs a JCSDA-internal repository.
conflicts("+ropp", msg="FV3-JEDI: ropp to be implemented.")

# Required components
depends_on("crtm")
depends_on("crtm@2.2.3:", when="@:1.5.0")
depends_on("crtm@v3.0.0-skylabv5-1", when="@1.6.0")
depends_on("crtm@v3.0.0-skylabv6", when="@1.7.0")
depends_on("ecbuild", type=("build"))
depends_on("ecbuild@3.3.2:", type=("build"), when="@1.6.0")
depends_on("ecmwf-atlas")
depends_on("ecmwf-atlas@0.33.0", when="@1.6.0")
depends_on("femps@1.0.0:")
depends_on("jedi-cmake", type=("build"))
depends_on("mpi")
# fv3-jedi depends on netcdf-fortran, which always depends on netcdf-c. However, netcdf-c
# has the mpi options, and netcdf-fortran does not.
depends_on("netcdf-fortran")
depends_on("netcdf-c+mpi")
depends_on("oops")
depends_on("oops@1.7.0", when="@1.6.0")
depends_on("oops@1.8.0", when="@1.7.0")
depends_on("saber")
depends_on("saber@1.7.0", when="@1.6.0")
depends_on("saber@1.8.0", when="@1.7.0")
depends_on("ufo")
depends_on("ufo@1.7.0", when="@1.6.0")
depends_on("ufo@1.8.0", when="@1.7.0")
depends_on("vader")
depends_on("vader@1.4.0", when="@1.6.0")
depends_on("vader@1.5.0", when="@1.7.0")

depends_on("fms", when="forecast_model=FV3CORE")
depends_on("fv3-jedi-linearmodel@1.0.0:", when="forecast_model=FV3CORE")

# Optional components
depends_on("GFDL_atmos_cubed_sphere", when="forecast_model=FV3CORE")
depends_on("gsibec", when="+gsibec")
depends_on("gsibec@1.1.2:", when="@1.6:1.7 +gsibec")
depends_on("llvm-openmp", when="+openmp %apple-clang", type=("build", "run"))
depends_on("sp", when="+sp")

def cmake_args(self):
res = [
self.define_from_variant("FV3_FORECAST_MODEL", "forecast_model"),
self.define_from_variant("OPENMP", "openmp"),
]
return res

# find_package(ecbuild REQUIRED) is needed when using ecbuild.
patch("CMakeLists.txt.patch", when="@1.6:1.7")
# fv3-jedi is improperly including git_functions.cmake via an environment variable.
# It should instead use the jedicmake_FUNCTIONS variable, which is exported by jedi-cmake.
patch("test.CMakeLists.txt.patch", when="@1.6:1.7")
# fv3-jedi depends on these macros that are defined (and not exported) in ufo.
patch("cmake.fv3jedi_extra_macros.cmake.patch", when="@1.6:1.7")
Loading