Skip to content

Commit

Permalink
feature/coldstart
Browse files Browse the repository at this point in the history
Merge branch 'develop' into feature/coldstart

Issue #9
  • Loading branch information
GeorgeGayno-NOAA committed Nov 5, 2020
2 parents 4f77bdb + 8a73766 commit 0871b16
Show file tree
Hide file tree
Showing 40 changed files with 3,578 additions and 778 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build and Test
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-20.04
env:
FC: gfortran-9
CC: gcc-9

steps:
- name: install-dependencies
run: |
sudo apt-get update
sudo apt-get install libmpich-dev
sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config
sudo apt-get install libpng-dev
sudo apt-get install libjpeg-dev
- name: checkout-esmf
uses: actions/checkout@v2
with:
repository: esmf-org/esmf
path: esmf
ref: ESMF_8_0_1

- name: build-esmf
run: |
export ESMF_DIR=`pwd`/esmf
cd esmf
export ESMF_COMM=mpich3
export ESMF_INSTALL_BINDIR=bin
export ESMF_INSTALL_LIBDIR=lib
export ESMF_INSTALL_MODDIR=mod
export ESMF_COMPILER=gfortran
export ESMF_INSTALL_PREFIX=~
export ESMF_NETCDF=split
export ESMF_NETCDF_INCLUDE=/usr/include
export ESMF_NETCDF_LIBPATH=/usr/x86_64-linux-gnu
make -j2
make install
- name: checkout-jasper
uses: actions/checkout@v2
with:
repository: jasper-software/jasper
path: jasper
ref: version-2.0.22

- name: build-jasper
run: |
cd jasper
mkdir build-jasper && cd build-jasper
cmake .. -DCMAKE_INSTALL_PREFIX=~
make -j2
make install
- name: checkout-nceplibs
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS
path: nceplibs
ref: v1.2.0

- name: build-nceplibs
run: |
export ESMFMKFILE=~/lib/esmf.mk
cd nceplibs
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~ -DFLAT=ON
make -j2
- name: checkout-ufs-utils
uses: actions/checkout@v2
with:
path: ufs_utils

- name: build-ufs-utils
run: |
export ESMFMKFILE=~/lib/esmf.mk
cd ufs_utils
mkdir build && cd build
cmake .. -DCMAKE_PREFIX_PATH=~
make -j2



4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

26 changes: 16 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# This is the main CMake file for NCEPLIBS-ip.
#
# George Gayno
cmake_minimum_required(VERSION 3.15)

# Get the version from the VERSION file.
file(STRINGS "VERSION" pVersion)

project(
ufs_util
VERSION ${pVersion}
LANGUAGES C Fortran)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/Modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# User options.
option(OPENMP "use OpenMP threading" ON)

if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
message(STATUS "Setting build type to 'Release' as none was specified.")
Expand All @@ -17,14 +24,7 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
"MinSizeRel" "RelWithDebInfo")
endif()

if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
message(WARNING "Compiler not officially supported: ${CMAKE_C_COMPILER_ID}")
endif()

if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU)$")
message(WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}")
endif()

# Set compiler flags.
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model precise")
Expand All @@ -41,11 +41,11 @@ if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_C_FLAGS_DEBUG "-O0")
endif()

# Find packages.
find_package(NetCDF REQUIRED C Fortran)
find_package(MPI REQUIRED)
find_package(ESMF MODULE REQUIRED)

option(OPENMP "use OpenMP threading" ON)
if(OPENMP)
find_package(OpenMP REQUIRED COMPONENTS Fortran)
endif()
Expand All @@ -71,3 +71,9 @@ if(EMC_EXEC_DIR)
endif()

add_subdirectory(sorc)

# If doxygen documentation we enabled, build it.
if(ENABLE_DOCS)
find_package(Doxygen REQUIRED)
add_subdirectory(docs)
endif()
1 change: 0 additions & 1 deletion CMakeModules
Submodule CMakeModules deleted from 3eaddb
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,40 @@
Utilities for the NCEP models. This is part of the
[NCEPLIBS](https://github.com/NOAA-EMC/NCEPLIBS) project.

Complete documentation can be found at
https://noaa-emc.github.io/UFS_UTILS/.

## Authors

NCEP/EMC developers.

Code manager: George Gayno

## Prerequisites

This package requires the following NCEPLIBS packages:
- [NCEPLIBS-gfsio](https://github.com/NOAA-EMC/NCEPLIBS-gfsio)
- [NCEPLIBS-sfcio](https://github.com/NOAA-EMC/NCEPLIBS-sfcio)
- [NCEPLIBS-w3nco](https://github.com/NOAA-EMC/NCEPLIBS-w3nco)
- [NCEPLIBS-landsfcutil](https://github.com/NOAA-EMC/NCEPLIBS-landsfcutil)
- [NCEPLIBS-bacio](https://github.com/NOAA-EMC/NCEPLIBS-bacio)
- [NCEPLIBS-nemsio](https://github.com/NOAA-EMC/NCEPLIBS-nemsio)
- [NCEPLIBS-nemsiogfs](https://github.com/NOAA-EMC/NCEPLIBS-nemsiogfs)
- [NCEPLIBS-sigio](https://github.com/NOAA-EMC/NCEPLIBS-sigio)
- [NCEPLIBS-sp](https://github.com/NOAA-EMC/NCEPLIBS-sp)
- [NCEPLIBS-ip](https://github.com/NOAA-EMC/NCEPLIBS-ip)
- [NCEPLIBS-w3emc](https://github.com/NOAA-EMC/NCEPLIBS-w3emc)
- [NCEPLIBS-g2](https://github.com/NOAA-EMC/NCEPLIBS-g2)
- [NCEPLIBS-wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2)

This package also requires:

- [netcdf-c Library](https://github.com/Unidata/netcdf-c)
- [netcdf-fortran Library](https://github.com/Unidata/netcdf-fortran)
- [ESMF](https://github.com/esmf-org/esmf)
- [Jasper](https://github.com/jasper-software/jasper)


## Installing

```
Expand Down
16 changes: 7 additions & 9 deletions build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export MOD_PATH
if [[ "$target" == "linux.*" || "$target" == "macosx.*" ]]; then
unset -f module
set +x
source ./modulefiles/build.$target > /dev/null 2>&1
source ./modulefiles/build.$target > /dev/null 2>&1
set -x
else
set +x
Expand All @@ -20,21 +20,19 @@ else
set -x
fi

# --- Build all programs.
#

rm -fr ./build
mkdir ./build
cd ./build

CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DEMC_EXEC_DIR=ON"

if [[ "$compiler" == "intel" ]]; then
if [[ "$target" != "wcoss_cray" && "$target" != "odin" ]]; then
if [[ "$target" != "wcoss_cray" && \
"$target" != "gaea" && \
"$target" != "odin" ]]; then
CMAKE_FLAGS+=" -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_C_COMPILER=icc"
fi
fi

rm -fr ./build
mkdir ./build && cd ./build

cmake .. ${CMAKE_FLAGS}

make -j 8 VERBOSE=1
Expand Down
105 changes: 105 additions & 0 deletions cmake/FindESMF.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# - Try to find ESMF
#
# Requires setting ESMFMKFILE to the filepath of esmf.mk. If this is NOT set,
# then ESMF_FOUND will always be FALSE. If ESMFMKFILE exists, then ESMF_FOUND=TRUE
# and all ESMF makefile variables will be set in the global scope. Optionally,
# set ESMF_MKGLOBALS to a string list to filter makefile variables. For example,
# to globally scope only ESMF_LIBSDIR and ESMF_APPSDIR variables, use this CMake
# command in CMakeLists.txt:
#
# set(ESMF_MKGLOBALS "LIBSDIR" "APPSDIR")


# Add the ESMFMKFILE path to the cache if defined as system env variable
if (DEFINED ENV{ESMFMKFILE} AND NOT DEFINED ESMFMKFILE)
set(ESMFMKFILE $ENV{ESMFMKFILE} CACHE FILEPATH "Path to ESMF mk file")
endif ()

# Found the mk file and ESMF exists on the system
if (EXISTS ${ESMFMKFILE})
set(ESMF_FOUND TRUE CACHE BOOL "ESMF mk file found" FORCE)
# Did not find the ESMF mk file
else()
set(ESMF_FOUND FALSE CACHE BOOL "ESMF mk file NOT found" FORCE)
# Best to warn users that without the mk file there is no way to find ESMF
if (NOT DEFINED ESMFMKFILE)
message(FATAL_ERROR "ESMFMKFILE not defined. This is the path to esmf.mk file. \
Without this filepath, ESMF_FOUND will always be FALSE.")
endif ()
endif()

# Only parse the mk file if it is found
if (ESMF_FOUND)
# Read the mk file
file(STRINGS "${ESMFMKFILE}" esmfmkfile_contents)
# Parse each line in the mk file
foreach(str ${esmfmkfile_contents})
# Only consider uncommented lines
string(REGEX MATCH "^[^#]" def ${str})
# Line is not commented
if (def)
# Extract the variable name
string(REGEX MATCH "^[^=]+" esmf_varname ${str})
# Extract the variable's value
string(REGEX MATCH "=.+$" esmf_vardef ${str})
# Only for variables with a defined value
if (esmf_vardef)
# Get rid of the assignment string
string(SUBSTRING ${esmf_vardef} 1 -1 esmf_vardef)
# Remove whitespace
string(STRIP ${esmf_vardef} esmf_vardef)
# A string or single-valued list
if(NOT DEFINED ESMF_MKGLOBALS)
# Set in global scope
set(${esmf_varname} ${esmf_vardef})
# Don't display by default in GUI
mark_as_advanced(esmf_varname)
else() # Need to filter global promotion
foreach(m ${ESMF_MKGLOBALS})
string(FIND ${esmf_varname} ${m} match)
# Found the string
if(NOT ${match} EQUAL -1)
# Promote to global scope
set(${esmf_varname} ${esmf_vardef})
# Don't display by default in the GUI
mark_as_advanced (esmf_varname)
# No need to search for the current string filter
break()
endif()
endforeach()
endif()
endif()
endif()
endforeach()

separate_arguments(ESMF_F90COMPILEPATHS NATIVE_COMMAND ${ESMF_F90COMPILEPATHS})
foreach (ITEM ${ESMF_F90COMPILEPATHS})
string(REGEX REPLACE "^-I" "" ITEM "${ITEM}")
list(APPEND tmp ${ITEM})
endforeach()
set(ESMF_F90COMPILEPATHS ${tmp})

add_library(esmf UNKNOWN IMPORTED)
# Look for static library, if not found try dynamic library
find_library(esmf_lib NAMES libesmf.a PATHS ${ESMF_LIBSDIR})
if(esmf_lib MATCHES "esmf_lib-NOTFOUND")
message(STATUS "Static ESMF library not found, searching for dynamic library instead")
find_library(esmf_lib NAMES esmf_fullylinked PATHS ${ESMF_LIBSDIR})
if(esmf_lib MATCHES "esmf_lib-NOTFOUND")
message(FATAL_ERROR "Neither the dynamic nor the static ESMF library was found")
else()
message(STATUS "Found ESMF library: ${esmf_lib}")
endif()
set(ESMF_INTERFACE_LINK_LIBRARIES "")
else()
# When linking the static library, also need the ESMF linker flags; strip any leading/trailing whitespaces
string(STRIP "${ESMF_F90ESMFLINKRPATHS} ${ESMF_F90ESMFLINKPATHS} ${ESMF_F90LINKPATHS} ${ESMF_F90LINKLIBS} ${ESMF_F90LINKOPTS}" ESMF_INTERFACE_LINK_LIBRARIES)
message(STATUS "Found ESMF library: ${esmf_lib}")
endif()

set_target_properties(esmf PROPERTIES
IMPORTED_LOCATION ${esmf_lib}
INTERFACE_INCLUDE_DIRECTORIES "${ESMF_F90COMPILEPATHS}"
INTERFACE_LINK_LIBRARIES "${ESMF_INTERFACE_LINK_LIBRARIES}")

endif()
Loading

0 comments on commit 0871b16

Please sign in to comment.