Skip to content

Commit

Permalink
Merge pull request #21 from kgerheiser/master
Browse files Browse the repository at this point in the history
Release 2.6.0
  • Loading branch information
kgerheiser authored Jun 26, 2020
2 parents 304f818 + 544e146 commit da27f98
Show file tree
Hide file tree
Showing 119 changed files with 32,153 additions and 352 deletions.
143 changes: 143 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
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-netcdf
run: |
sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config
- name: install-mpi
run: |
sudo apt-get install libmpich-dev
- name: checkout-pfunit
uses: actions/checkout@v2
with:
repository: Goddard-Fortran-Ecosystem/pFUnit
path: pfunit

- name: cache-pfunit
id: cache-pfunit
uses: actions/cache@v2
with:
path: ~/pfunit
key: pfunit-${{ runner.os }}-${{ hashFiles('pfunit/VERSION') }}

- name: build-pfunit
if: steps.cache-pfunit.outputs.cache-hit != 'true'
run: |
cd pfunit
mkdir build
cd build
cmake .. -DSKIP_MPI=YES -DSKIP_ESMF=YES -DSKIP_FHAMCREST=YES -DCMAKE_INSTALL_PREFIX=~/pfunit
make -j2
make install
- name: checkout-bacio
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-bacio
path: bacio
ref: develop

- name: build-bacio
run: |
cd bacio
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/bacio
make -j2
make install
- name: checkout-w3nco
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-w3nco
path: w3nco
ref: develop

- name: cache-w3nco
id: cache-w3nco
uses: actions/cache@v2
with:
path: ~/w3nco
key: w3nco-${{ runner.os }}-${{ hashFiles('w3nco/VERSION') }}

- name: build-w3nco
if: steps.cache-w3nco.outputs.cache-hit != 'true'
run: |
cd w3nco
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/w3nco
make -j2
make install
- name: checkout-sigio
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-sigio
path: sigio
ref: develop

- name: cache-sigio
id: cache-sigio
uses: actions/cache@v2
with:
path: ~/sigio
key: sigio-${{ runner.os }}-${{ hashFiles('sigio/VERSION') }}

- name: build-sigio
if: steps.cache-sigio.outputs.cache-hit != 'true'
run: |
cd sigio
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/sigio
make -j2
make install
- name: checkout-nemsio
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-nemsio
path: nemsio
ref: develop

- name: build-nemsio
if: steps.cache-nemsio.outputs.cache-hit != 'true'
run: |
cd nemsio
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/nemsio -DCMAKE_PREFIX_PATH=~
make -j2
make install
- name: checkout-w3emc
uses: actions/checkout@v2
with:
path: w3emc
submodules: true

- name: build-w3emc
run: |
cd w3emc
mkdir build
cd build
cmake .. -DENABLE_TESTS=ON -DCMAKE_PREFIX_PATH="~/pfunit;~/"
make -j2
- name: test-w3emc
run: |
cd $GITHUB_WORKSPACE/w3emc/build
make test
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build/
install/

*.[ao]
*.mod
*.so

*.swp
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "cmake"]
path = cmake
path = CMakeModules
url = https://github.com/NOAA-EMC/CMakeModules.git
branch = release/public-v1
93 changes: 24 additions & 69 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,83 +1,38 @@
cmake_minimum_required(VERSION 3.15)
project(w3emc VERSION 2.2.0)
enable_language (Fortran)

if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: PRODUCTION Debug Release."
FORCE)
endif()
file(STRINGS "VERSION" pVersion)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(IntelComp true )
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU*" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang*")
set(GNUComp true )
elseif(CMAKE_CXX_COMPILER_ID MATCHES "pgc*")
set(PGIComp true )
endif()
project(
w3emc
VERSION ${pVersion}
LANGUAGES Fortran)

STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RelWithDebInfo" BUILD_RELEASE)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "DEBUG" BUILD_DEBUG)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/Modules")

if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) )
if(IntelComp)
set(shared_fortran_flags "-O2" "-g" "-traceback" "-fixed")
set(fortran_d_flags "-r8")
set(fortran_8_flags "-r8" "-i8")
set(fortran_4_flags)
elseif(GNUComp)
set(shared_fortran_flags "-fno-range-check" "-O2" "-g" "-fbacktrace"
"-ffixed-form" "-ggdb" "-funroll-loops")
set(fortran_d_flags "-fdefault-real-8")
set(fortran_8_flags "-fdefault-integer-8" "-fdefault-real-8")
set(CMAKE_Fortran_4_FLAGS)
else()
message("unknown compiler!")
exit()
endif()
endif()
include(GNUInstallDirs)

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG true)
if(NOT TARGET nemsio)
find_package(nemsio REQUIRED)
endif()
option(ENABLE_TESTS "Build pfunit tests?" OFF)

if(NOT TARGET sigio)
find_package(sigio REQUIRED)
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

file(GLOB fortran_src ${CMAKE_CURRENT_SOURCE_DIR}/src/*.f90 ${CMAKE_CURRENT_SOURCE_DIR}/src/*.F ${CMAKE_CURRENT_SOURCE_DIR}/src/*.f)

set(kinds "4" "8" "d")
foreach(kind ${kinds})
set(lib_name ${PROJECT_NAME}_${kind})
set(versioned_lib_name ${PROJECT_NAME}_v${PROJECT_VERSION}_${kind})
add_library(${lib_name} STATIC ${fortran_src})

set_target_properties(${lib_name} PROPERTIES OUTPUT_NAME "${versioned_lib_name}")

target_compile_options(${lib_name} PRIVATE "${shared_fortran_flags};${fortran_${kind}_flags}")

set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_${kind}")
set_target_properties(${lib_name} PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}")

target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${module_dir}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include_${kind}>)

target_link_libraries(${lib_name} nemsio sigio)
if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
message(WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}")
endif()

install(TARGETS ${lib_name}
EXPORT ${PROJECT_NAME}-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})
endforeach()
find_package(nemsio CONFIG REQUIRED)
find_package(sigio CONFIG REQUIRED)

install(EXPORT ${PROJECT_NAME}-config DESTINATION ${CMAKE_INSTALL_PREFIX})
find_package(NetCDF REQUIRED Fortran)

add_subdirectory(src)

if (ENABLE_TESTS)
find_package(PFUNIT REQUIRED)
enable_testing()
add_subdirectory(tests)
endif()

1 change: 1 addition & 0 deletions CMakeModules
Submodule CMakeModules added at ff93c2
Loading

0 comments on commit da27f98

Please sign in to comment.