Skip to content

Commit

Permalink
Merge branch 'main' into buildlib_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adrifoster committed Aug 21, 2023
2 parents d31de60 + f7e657e commit c4a200b
Show file tree
Hide file tree
Showing 22 changed files with 538 additions and 265 deletions.
46 changes: 46 additions & 0 deletions .github/actions/buildcdeps/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CDEPS build and cache
description: 'Build the CDEPS library'
inputs:
cdeps_version:
description: 'Tag in the CDEPS repository to use'
default: main
required: False
type: string
pio_path:
description: 'Path to the installed parallelio code root'
default: $HOME/pio
required: False
type: string
esmfmkfile:
description: 'Path to the installed ESMF library mkfile'
default: $HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk
required: False
type: string
src_root:
description: 'Path to cdeps source'
default: $GITHUB_WORKSPACE
required: False
type: string
cmake_flags:
description: 'Extra flags for cmake command'
default: -Wno-dev
required: False
type: string
install_prefix:
description: 'Install path of cdeps'
default: $HOME/cdeps
required: False
type: string
runs:
using: composite
steps:
- id : Build-CDEPS
shell: bash
run: |
mkdir build-cdeps
pushd build-cdeps
export ESMFMKFILE=${{ inputs.esmfmkfile }}
export PIO=${{ inputs.pio_path }}
cmake ${{ inputs.cmake_flags }} ${{ inputs.src_root }}
make VERBOSE=1
popd
83 changes: 29 additions & 54 deletions .github/workflows/extbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ jobs:
CPPFLAGS: "-I/usr/include -I/usr/local/include "
LDFLAGS: "-L/usr/lib/x86_64-linux-gnu "
# Versions of all dependencies can be updated here - these match tag names in the github repo
ESMF_VERSION: v8.4.0
#PNETCDF_VERSION: checkpoint.1.12.3
#NETCDF_FORTRAN_VERSION: v4.6.0
ParallelIO_VERSION: pio2_5_10
ESMF_VERSION: v8.5.0
ParallelIO_VERSION: pio2_6_0
steps:
- id: checkout-CDEPS
uses: actions/checkout@v3
Expand All @@ -37,68 +35,45 @@ jobs:
sudo apt-get install netcdf-bin libnetcdf-dev libnetcdff-dev
sudo apt-get install pnetcdf-bin libpnetcdf-dev
sudo apt-get install autotools-dev autoconf
# - id: cache-pnetcdf
# uses: actions/cache@v3
# with:
# path: ~/pnetcdf
# key: ${{ runner.os }}-${{ env.PNETCDF_VERSION}}-pnetcdf1
# - name: Build PNetCDF
# if: steps.cache-pnetcdf.outputs.cache-hit != 'true'
# uses: ./.github/actions/buildpnetcdf
# with:
# pnetcdf_version: ${{ env.PNETCDF_VERSION }}
# install_prefix: $HOME/pnetcdf
# - name: Cache netcdf-fortran
# id: cache-netcdf-fortran
# uses: actions/cache@v3
# with:
# path: ~/netcdf-fortran
# key: ${{ runner.os }}-${{ env.NETCDF_FORTRAN_VERSION }}-netcdf-fortran1
# - name: Build NetCDF Fortran
# if: steps.cache-netcdf-fortran.outputs.cache-hit != 'true'
# uses: ./.github/actions/buildnetcdff
# with:
# netcdf_fortran_version: ${{ env.NETCDF_FORTRAN_VERSION }}
# install_prefix: $HOME/netcdf-fortran
# netcdf_c_path: /usr
- name: Cache PARALLELIO
id: cache-PARALLELIO
uses: actions/cache@v3
with:
path: ~/pio
path: ${GITHUB_WORKSPACE}/pio
key: ${{ runner.os }}-${{ env.ParallelIO_VERSION }}-parallelio2
- name: Build ParallelIO
if: steps.cache-PARALLELIO.outputs.cache-hit != 'true'
uses: NCAR/ParallelIO/.github/actions/parallelio_cmake@9390e30e29d4ebbfbef0fc72162cacd9e8f25e4e
with:
parallelio_version: ${{ env.ParallelIO_VERSION }}
enable_fortran: True
install_prefix: $HOME/pio
- name: Cache ESMF
id: cache-esmf
uses: actions/cache@v3
with:
path: ~/ESMF
key: ${{ runner.os }}-${{ env.ESMF_VERSION }}-ESMF2
- name: Build ESMF
if: steps.cache-esmf.outputs.cache-hit != 'true'
uses: ./.github/actions/buildesmf
install_prefix: ${GITHUB_WORKSPACE}/pio
- name: Install ESMF
uses: esmf-org/install-esmf-action@v1
env:
ESMF_COMPILER: gfortran
ESMF_BOPT: g
ESMF_COMM: openmpi
ESMF_NETCDF: nc-config
ESMF_PNETCDF: pnetcdf-config
ESMF_INSTALL_PREFIX: ${GITHUB_WORKSPACE}/ESMF
ESMF_PIO: external
ESMF_PIO_INCLUDE: ${GITHUB_WORKSPACE}/pio/include
ESMF_PIO_LIBPATH: ${GITHUB_WORKSPACE}/pio/lib
with:
esmf_version: ${{ env.ESMF_VERSION }}
esmf_bopt: g
esmf_comm: openmpi
install_prefix: $HOME/ESMF
netcdf_c_path: /usr
netcdf_fortran_path: /usr
pnetcdf_path: /usr
parallelio_path: $HOME/pio
version: ${{ env.ESMF_VERSION }}
esmpy: false
cache: true

- name: Build CDEPS
uses: ./.github/actions/buildcdeps
with:
esmfmkfile: $ESMFMKFILE
pio_path: ${GITHUB_WORKSPACE}/pio
src_root: ${GITHUB_WORKSPACE}
cmake_flags: " -Wno-dev -DCMAKE_BUILD_TYPE=DEBUG -DWERROR=ON -DCMAKE_Fortran_FLAGS=\"-DCPRGNU -g -Wall \
-ffree-form -ffree-line-length-none -fallow-argument-mismatch \""
- name: Test CDEPS
run: |
export ESMFMKFILE=$HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk
export PIO=$HOME/pio
export SRC_ROOT=
mkdir build-cdeps
pushd build-cdeps
cmake -Wno-dev -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_Fortran_FLAGS="-DCPRGNU -g -Wall -ffree-form -ffree-line-length-none -fallow-argument-mismatch " -DWERROR=ON ../
cd build-cdeps
make VERBOSE=1
popd
56 changes: 35 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.10)
include(ExternalProject)
include(FetchContent)

set(DISABLE_FoX OFF CACHE BOOL "Disable FoX library to process XML files.")
message("DISABLE_FoX = ${DISABLE_FoX}")
if(DISABLE_FoX)
add_definitions(-DDISABLE_FoX)
endif()

if (DEFINED CIMEROOT)
message("Using CIME in ${CIMEROOT} with compiler ${COMPILER}")
include(${CASEROOT}/Macros.cmake)
Expand All @@ -23,7 +29,9 @@ else()
set(BLD_STANDALONE TRUE)
project(NUOPC_DATA_MODELS LANGUAGES Fortran VERSION 0.1)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(FOX_ROOT ${CMAKE_SOURCE_DIR}/fox)
if(NOT DISABLE_FoX)
set(FOX_ROOT ${CMAKE_SOURCE_DIR}/fox)
endif()
endif()
message("CMAKE_MODULE_PATH is ${CMAKE_MODULE_PATH}, CMAKE_Fortran_COMPILER is ${CMAKE_Fortran_COMPILER}")
enable_language(Fortran)
Expand Down Expand Up @@ -62,29 +70,32 @@ endif()
add_subdirectory(streams)
add_subdirectory(dshr)

if(IS_DIRECTORY "${FOX_ROOT}")
message(STATUS "FoX library is already checked out!")
message(STATUS "FoX source dir: ${FOX_ROOT}")
else()
FetchContent_Declare(fox
GIT_REPOSITORY https://github.com/ESMCI/fox.git
GIT_TAG 4.1.2.1
SOURCE_DIR ${FOX_ROOT}
BINARY_DIR ${FOX_ROOT}/..
)
FetchContent_GetProperties(fox)
if(NOT fox_POPULATED)
FetchContent_Populate(fox)
message(STATUS "FoX source dir: ${fox_SOURCE_DIR}")
message(STATUS "FoX binary dir: ${fox_BINARY_DIR}")
if(NOT DISABLE_FoX)
if(IS_DIRECTORY "${FOX_ROOT}")
message(STATUS "FoX library is already checked out!")
message(STATUS "FoX source dir: ${FOX_ROOT}")
else()
FetchContent_Declare(fox
GIT_REPOSITORY https://github.com/ESMCI/fox.git
GIT_TAG 4.1.2.1
SOURCE_DIR ${FOX_ROOT}
BINARY_DIR ${FOX_ROOT}/..
)
FetchContent_GetProperties(fox)
if(NOT fox_POPULATED)
FetchContent_Populate(fox)
message(STATUS "FoX source dir: ${fox_SOURCE_DIR}")
message(STATUS "FoX binary dir: ${fox_BINARY_DIR}")
endif()
endif()
add_subdirectory(fox)

target_include_directories(streams PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>
$<INSTALL_INTERFACE:mod>)
target_include_directories(dshr PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>
$<INSTALL_INTERFACE:mod>)
endif()
add_subdirectory(fox)

target_include_directories(streams PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>
$<INSTALL_INTERFACE:mod>)
target_include_directories(dshr PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>
$<INSTALL_INTERFACE:mod>)
target_include_directories(dshr PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/streams>
$<INSTALL_INTERFACE:mod>)

Expand Down Expand Up @@ -112,6 +123,9 @@ foreach(COMP datm dice dlnd docn drof dwav)
endforeach(COMP)

foreach(DEPS streams dshr cdeps_share FoX_dom FoX_wxml FoX_sax FoX_common FoX_utils FoX_fsys)
if(DISABLE_FoX AND ${DEPS} MATCHES "^FoX")
continue()
endif()
if(NOT BLD_STANDALONE AND ${DEPS} STREQUAL "cdeps_share")
continue()
endif()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Community Data Models for Earth Prediction Systems

For documentation see

https://escomp.github.io/CDEPS/html/index.html
https://escomp.github.io/CDEPS/versions/master/html/index.html

## A note on github tag action

Expand Down
4 changes: 1 addition & 3 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def buildlib(bldroot, libroot, case):

logger.info("Running cmake for CDEPS")
srcpath = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
cmake_flags = get_standard_cmake_args(
case, os.path.join(sharedpath, "cdeps")
)
cmake_flags = get_standard_cmake_args(case, os.path.join(sharedpath, "cdeps"))
# base path of install to be completed by setting DESTDIR in make install
cmake_flags += " -DCMAKE_INSTALL_PREFIX:PATH=/"
cmake_flags += " -DLIBROOT={} ".format(libroot)
Expand Down
22 changes: 15 additions & 7 deletions cime_config/buildlib_comps
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,44 @@ if _CIMEROOT is None:
raise SystemExit("ERROR: must set CIMEROOT environment variable")
sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools"))

_LIBDIR = os.path.join(_CIMEROOT, "scripts", "lib")
_LIBDIR = os.path.join(_CIMEROOT, "CIME")
sys.path.append(_LIBDIR)

from standard_script_setup import *
from CIME.buildlib import parse_input
from CIME.case import Case
from CIME.utils import run_cmd, symlink_force, expect

# pragma pylint: disable=unused-argument,undefined-variable

logger = logging.getLogger(__name__)


def buildlib(bldroot, libroot, case, compname=None):
if not compname:
expect(bldroot.endswith("obj"),
"It appears that buildlib_comps is being called for the main CDEPS build\n"
"(the main CDEPS build should use buildlib, not buildlib_comps)")
compname = os.path.basename(os.path.abspath(os.path.join(bldroot,os.pardir)))
expect(
bldroot.endswith("obj"),
"It appears that buildlib_comps is being called for the main CDEPS build\n"
"(the main CDEPS build should use buildlib, not buildlib_comps)",
)
compname = os.path.basename(os.path.abspath(os.path.join(bldroot, os.pardir)))

_, o, e = run_cmd("make d{}".format(compname), from_dir=bldroot, verbose=True)
libname = "lib{}.a".format(compname)
dlibname = "libd{}.a".format(compname)
dlibpath = os.path.join(bldroot, dlibname)
if os.path.exists(dlibpath):
symlink_force(os.path.join(bldroot,dlibname), os.path.join(libroot,libname))
symlink_force(os.path.join(bldroot, dlibname), os.path.join(libroot, libname))
else:
expect(False, "ERROR in {} build {} {}".format(compname,o,e))
expect(False, "ERROR in {} build {} {}".format(compname, o, e))
logger.info(f"build successful for comp={compname}")


def _main_func(args):
caseroot, libroot, bldroot = parse_input(args)
with Case(caseroot) as case:
buildlib(bldroot, libroot, case)


if __name__ == "__main__":
_main_func(sys.argv)
Loading

0 comments on commit c4a200b

Please sign in to comment.