From 7008bb63352c59b5bcaa688e136ba3bf8e34fc03 Mon Sep 17 00:00:00 2001 From: "Marc T. Henry de Frahan" Date: Fri, 3 May 2024 01:58:35 -0600 Subject: [PATCH] Add rosco package (#43822) * Add rosco package * format * remove unused * Add in other versions * start adding some patches * finish adding the patches --- .../packages/rosco/intel-oneapi-29.patch | 13 ++++ .../packages/rosco/intel-oneapi-2x.patch | 13 ++++ .../repos/builtin/packages/rosco/package.py | 63 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 var/spack/repos/builtin/packages/rosco/intel-oneapi-29.patch create mode 100644 var/spack/repos/builtin/packages/rosco/intel-oneapi-2x.patch create mode 100644 var/spack/repos/builtin/packages/rosco/package.py diff --git a/var/spack/repos/builtin/packages/rosco/intel-oneapi-29.patch b/var/spack/repos/builtin/packages/rosco/intel-oneapi-29.patch new file mode 100644 index 0000000000..58d6e4bd07 --- /dev/null +++ b/var/spack/repos/builtin/packages/rosco/intel-oneapi-29.patch @@ -0,0 +1,13 @@ +diff --git a/rosco/controller/CMakeLists.txt b/rosco/controller/CMakeLists.txt +index 0d29085..46705c2 100644 +--- a/rosco/controller/CMakeLists.txt ++++ b/rosco/controller/CMakeLists.txt +@@ -11,7 +11,7 @@ endif() + message(STATUS "CMAKE_Fortran_COMPILER_ID = ${CMAKE_Fortran_COMPILER_ID}") + if(APPLE OR UNIX) + # Enable .dll export +-if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") ++if (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DIMPLICIT_DLLEXPORT -r8 -double-size 64 -cpp -no-wrap-margin") + else() + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DIMPLICIT_DLLEXPORT -ffree-line-length-0 -fdefault-real-8 -fdefault-double-8 -cpp") diff --git a/var/spack/repos/builtin/packages/rosco/intel-oneapi-2x.patch b/var/spack/repos/builtin/packages/rosco/intel-oneapi-2x.patch new file mode 100644 index 0000000000..fce7258e20 --- /dev/null +++ b/var/spack/repos/builtin/packages/rosco/intel-oneapi-2x.patch @@ -0,0 +1,13 @@ +diff --git a/ROSCO/CMakeLists.txt b/ROSCO/CMakeLists.txt +index b450a30..9506267 100644 +--- a/ROSCO/CMakeLists.txt ++++ b/ROSCO/CMakeLists.txt +@@ -11,7 +11,7 @@ endif() + message(STATUS "CMAKE_Fortran_COMPILER_ID = ${CMAKE_Fortran_COMPILER_ID}") + if(APPLE OR UNIX) + # Enable .dll export +-if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") ++if (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DIMPLICIT_DLLEXPORT -r8 -double-size 64 -cpp -no-wrap-margin") + else() + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DIMPLICIT_DLLEXPORT -ffree-line-length-0 -fdefault-real-8 -fdefault-double-8 -cpp") diff --git a/var/spack/repos/builtin/packages/rosco/package.py b/var/spack/repos/builtin/packages/rosco/package.py new file mode 100644 index 0000000000..8ef734e1fd --- /dev/null +++ b/var/spack/repos/builtin/packages/rosco/package.py @@ -0,0 +1,63 @@ +# Copyright 2013-2024 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 Rosco(CMakePackage): + """ + ROSCO controls package for OpenFAST from NREL + Note: this only builds ROSCO controls library for inclusion with OpenFAST + If the toolbox or tuning scripts are needed, please build manually + """ + + homepage = "https://rosco.readthedocs.io/en/latest/" + url = "https://github.com/NREL/ROSCO/archive/refs/tags/v2.9.0.tar.gz" + git = "https://github.com/NREL/ROSCO.git" + + maintainers("dzalkind", "ndevelder") + + version("develop", branch="develop") + version("main", branch="main") + version("2.9.0", sha256="eb7f6220207b8a07c9570fb64bab591906b0c19d73ac4c24bb8dca252722ca79") + version("2.8.0", sha256="7a2e3a7bebdf6ee73884a9e3502f904cc3a3f1aa1bf672c223ecbaa041bfc48f") + version("2.7.0", sha256="b6a2cda92680cf6a460d194901a2f16c2635710a82788576a6383a3bb189fc83") + version("2.6.0", sha256="ca1c1a6ac53e8220b107accccfb8b5299772c38b7c77cd8d2ba383e9825daeaa") + version("2.5.1", sha256="55fe7bba612321baa6e089ee1156ef4db2e3bccf1b69534829b06f3367fff05d") + + variant("shared", default=False, description="Build shared libraries") + variant("pic", default=False, description="Position independent code") + + patch("intel-oneapi-2x.patch", when="@2.5:2.8%oneapi") + patch("intel-oneapi-29.patch", when="@2.9.0:2.9.1%oneapi") + + @property + def root_cmakelists_dir(self): + if self.spec.version >= Version("2.9.0"): + return "rosco/controller" + else: + return "ROSCO" + + def cmake_args(self): + options = [] + + options.extend( + [ + self.define_from_variant("BUILD_SHARED_LIBS", "shared"), + self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"), + ] + ) + + return options + + def setup_run_environment(self, env): + env.set("ROSCO_DISCON", self.prefix.lib + "/libdiscon.so") + env.set("ROSCO_DISCON_DIR", self.prefix.lib) + + def flag_handler(self, name, flags): + if name == "fflags" and self.compiler.fc.endswith("gfortran"): + flags.extend(["-ffree-line-length-0"]) + + return (None, None, flags)