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 (SkyLab 8 version) #395

Open
wants to merge 10 commits into
base: spack-stack-dev
Choose a base branch
from
48 changes: 48 additions & 0 deletions var/spack/repos/builtin/packages/crtm/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ 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("netcdf-fortran", when="@v3.1.0-skylabv7")

depends_on("[email protected]_emc", when="@2.3.0 +fix")
depends_on("[email protected]_emc", when="@=2.4.0 +fix")
Expand All @@ -45,6 +49,50 @@ 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")
depends_on("ecbuild", type=("build"), when="@v3.1.0-skylabv7")

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

version(
"v3.1.0-skylabv7",
url="https://www.github.com/JCSDA/crtmv3/tarball/90d52eec1f97bb5a098c9834c4499a17de4ff35b",
sha256="0751ddad9a0304e62902a11faa1e693b84ad2b338512f8d2c1a03e5cc573a947",
)
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.
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
2 changes: 2 additions & 0 deletions var/spack/repos/builtin/packages/ecmwf-atlas/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class EcmwfAtlas(CMakePackage):

version("master", branch="master")
version("develop", branch="develop")
version("0.36.0", sha256="39bf748aa7b22df80b9791fbb6b4351ed9a9f85587b58fc3225314278a2a68f8")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to this file will no longer be needed. We merged the missing [email protected]: dependency upstream (spack#43133); spack develop already had 0.36.0. We'll bring both updates to our spack fork shortly.

version("0.35.1", sha256="7a344aaa8a1378d989a7bb883eb741852c5fa494630be6d8c88e477e4b9c5be1")
version("0.35.0", sha256="5a4f898ffb4a33c738b6f86e4e2a4c8e26dfd56d3c3399018081487374e29e97")
version("0.34.0", sha256="48536742cec0bc268695240843ac0e232e2b5142d06b19365688d9ea44dbd9ba")
Expand All @@ -29,6 +30,7 @@ class EcmwfAtlas(CMakePackage):
version("0.31.0", sha256="fa4ff8665544b8e19f79d171c540a9ca8bfc4127f52a3c4d4d618a2fe23354d7")

depends_on("ecbuild", type=("build"))
depends_on("[email protected]:", type=("build"), when="@0.36.0:")
depends_on("eckit@:1.23", when="@:0.33")
depends_on("[email protected]:", when="@0.34:")
depends_on("boost cxxstd=14 visibility=hidden", when="@0.26.0:0.33.99", type=("build", "run"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer required for Skylab v8 because of JCSDA/GFDL_atmos_cubed_sphere#3

+++ 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("[email protected]:", 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("[email protected]:", 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patches should no longer be required if we target sklyab v8

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 )
72 changes: 72 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,72 @@
# 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.4.0", commit="05cc1ae63252ca535f3db0fdca9a8a996329fc8f")
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.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are using the current fv3-jedi-linearmodel with GEOS and UFS - @shlyaeva can you comment on this?

Copy link
Author

@rhoneyager-tomorrow rhoneyager-tomorrow Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're using both, but at time of writing this PR GEOS wasn't fully buildable in Spack. Likewise, the ufs-bundle depended on JCSDA-internal, so I didn't have much insight there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can merge it as-is now, and update later as needed

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

depends_on("ecbuild", type=("build"))
depends_on("[email protected]:", 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", "link", "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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patches should no longer be required if we target sklyab v8

patch("CMakeLists.txt.patch", when="@1.2:1.4")
# fv3-jedi-linearmodel needs to install its Fortran modules.
patch("src.CMakeLists.txt.patch", when="@1.2:1.4")
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}> )
+

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,20 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,8 @@ set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})

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 )
@@ -217,7 +219,7 @@ if (FV3_FORECAST_MODEL MATCHES UFS)
endif()

add_subdirectory( src )
-add_subdirectory( test )
+#add_subdirectory( test )

if( ENABLE_FV3JEDI_DOC )
add_subdirectory( Documents )
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 )
Loading