Skip to content

Commit

Permalink
Merge pull request NOAA-EMC#156 from NOAA-EMC/ejh_build_4
Browse files Browse the repository at this point in the history
Added BUILD_4 and BUILD_D options to build, removed _8 version of library
  • Loading branch information
edwardhartnett authored Jan 9, 2023
2 parents 6b293d7 + 14197c7 commit 251e36b
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 237 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/Intel.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This is a CI workflow for the NCEPLIBS-w3emc project.
#
# This workflow builds for the Intel compiler.
#
# Ed Hartnett, 1/8/23
name: Intel
on:
push:
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/Linux_options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This is a CI workflow for the NCEPLIBS-w3emc project.
#
# This workflow builds on Linux with different CMake build options.
#
# Ed Hartnett, 1/8/23
name: Linux_options
on:
push:
branches:
- develop
paths-ignore:
- README.md
pull_request:
branches:
- develop
paths-ignore:
- README.md

jobs:
Linux_options:
runs-on: ubuntu-latest
env:
FC: gfortran-11
CC: gcc-11
strategy:
matrix:
options: [-DBUILD_D=OFF, -DBUILD_4=OFF]

steps:

- name: checkout-bacio
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-bacio
path: bacio
ref: v2.5.0

- name: cache-bacio
id: cache-bacio
uses: actions/cache@v2
with:
path: ~/bacio
key: bacio-Linux_options_${{ runner.os }}-v2.5.0

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

- name: build-w3emc
run: |
cd w3emc
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=~/bacio ${{ matrix.options }} ..
make -j2
- name: test-w3emc
run: |
cd w3emc/build
ctest --output-on-failure --rerun-failed --verbose
6 changes: 6 additions & 0 deletions .github/workflows/Linux_versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# This is a CI workflow for the NCEPLIBS-w3emc project.
#
# This workflow builds on Linux with different versions of the
# dependent packages.
#
# Ed Hartnett, 1/8/23
name: Linux_versions
on:
push:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This is a CI workflow for the NCEPLIBS-w3emc project.
#
# This workflow builds for the MacOS system.
#
# Ed Hartnett, 1/8/23
name: MacOS
on:
push:
Expand Down Expand Up @@ -41,7 +46,7 @@ jobs:
run: |
cd bacio
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/bacio
cmake -DCMAKE_INSTALL_PREFIX=~/bacio ..
make -j2
make install
Expand All @@ -55,7 +60,7 @@ jobs:
cd w3emc
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=~/bacio
cmake -DCMAKE_PREFIX_PATH=~/bacio ..
make -j2
- name: test-w3emc
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# This is a CI workflow for the NCEPLIBS-w3emc project.
#
# This workflow builds with all developer options, including address
# sanitizer and code coverage.
#
# Ed Hartnett, 1/8/23
name: developer
on:
push:
Expand Down
25 changes: 20 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
# This is the main CMake file for NCEPLIBS-w3emc.
#
# Kyle Gerheiser
# Kyle Gerheiser, Ed Hartnett
cmake_minimum_required(VERSION 3.15)

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

project(
w3emc
VERSION ${pVersion}
LANGUAGES C Fortran)
# Set up CMake project.
project(w3emc VERSION ${pVersion} LANGUAGES C Fortran)

# Handle user options.
option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
option(BUILD_4 "Build the 4-byte real version of the library, libw3emc_4.a" ON)
option(BUILD_D "Build the 8-byte real version of the library, libw3emc_d.a" ON)

# Figure whether user wants a _4, a _d, or both libraries.
if(BUILD_4 AND BUILD_D)
set(kinds "4" "d")
elseif(BUILD_4 AND NOT BUILD_D)
set(kinds "4")
elseif(BUILD_D AND NOT BUILD_4)
set(kinds "d")
else()
message(FATAL_ERROR "At least one of BUILD_4 or BUILD_D must be turned on")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Set standard GNU install directories.
include(GNUInstallDirs)

# Deal with build type.
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()

# Bacio is required.
find_package(bacio 2.4.0 REQUIRED)

# The name of the bacio library changed with NCEPLIBS-bacio-2.5.0.
if(bacio_VERSION GREATER_EQUAL 2.5.0)
set(bacio_name bacio)
else()
Expand Down
48 changes: 44 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,65 @@
include("list_of_files.cmake")
# This is the CMake build file for the src directory of the
# NCEPLIBS-w3emc project.
#
# Kyle Gerheiser, Ed Hartnett

# This is the Fortran source code.
set(fortran_src args_mod.f getgbens.f isrchne.f iw3mat.f
mersenne_twister.f mova2i.f orders.f putgbens.f w3ai40.f w3ai41.f
w3ctzdat.f w3fa01.f w3fa03.f w3fa03v.f w3fa04.f w3fa06.f w3fa09.f
w3fa11.f w3fa12.f w3fa13.f w3fb00.f w3fb01.f w3fb02.f w3fb03.f
w3fb04.f w3fb05.f w3fb06.f w3fb07.f w3fb08.f w3fb09.f w3fb10.f
w3fb11.f w3fb12.f w3fc02.f w3fc05.f w3fc06.f w3fc07.f w3fc08.f
w3fi02.f w3fi03.f w3fi18.f w3fi19.f w3fi20.f w3fi32.f w3fi47.f
w3fi48.f w3fi52.f w3fi61.f w3fi65.f w3fi66.f w3fi67.f w3fi70.f
w3fi78.f w3fi85.f w3fm07.f w3fm08.f w3fp04.f w3fp05.f w3fp06.f
w3fp10.f w3fq07.f w3ft00.f w3ft01.f w3ft02.f w3ft03.f w3ft05.f
w3ft05v.f w3ft06.f w3ft06v.f w3ft07.f w3ft08.f w3ft09.f w3ft10.f
w3ft11.f w3ft12.f w3ft16.f w3ft17.f w3ft201.f w3ft202.f w3ft203.f
w3ft204.f w3ft205.f w3ft206.f w3ft207.f w3ft208.f w3ft209.f w3ft210.f
w3ft211.f w3ft212.f w3ft213.f w3ft214.f w3ft21.f w3ft26.f w3ft33.f
w3ft38.f w3ft39.f w3ft40.f w3ft41.f w3ft43v.f w3log.f w3miscan.f
xdopen.f aea.f errexit.f errmsg.f fparsei.f fparser.f gbytec.f gbyte.f
gbytesc.f gbytes.f getbit.f getgb1.f getgb1re.f getgb1r.f getgb1s.f
getgbe.f getgbeh.f getgbem.f getgbemh.f getgbemn.f getgbemp.f
getgbep.f getgbex.f getgbexm.f getgb.f getgbh.f getgbm.f getgbmh.f
getgbmp.f getgbp.f getgi.f getgir.f gtbits.f idsdef.f instrument.f
iw3jdn.f iw3pds.f iw3unp29.f ixgb.f lengds.f makwmo.f mkfldsep.f
pdsens.f pdseup.f putgbe.f putgben.f putgbex.f putgb.f putgbn.f
q9ie32.f r63w72.f sbytec.f sbyte.f sbytesc.f sbytes.f skgb.f w3ai00.f
w3ai01.f w3ai08.f w3ai15.f w3ai18.f w3ai19.f w3ai24.f w3ai38.f
w3ai39.f w3aq15.f w3as00.f w3difdat.f w3doxdat.f w3fi01.f w3fi04.f
w3fi58.f w3fi59.f w3fi62.f w3fi63.f w3fi64.f w3fi68.f w3fi69.f
w3fi71.f w3fi72.f w3fi73.f w3fi74.f w3fi75.f w3fi76.f w3fi82.f
w3fi83.f w3fi88.f w3fi92.f w3fp11.f w3fp12.f w3fp13.f w3fs13.f
w3fs15.f w3fs21.f w3fs26.f w3ft32.f w3kind.f w3locdat.f w3movdat.f
w3nogds.f w3pradat.f w3reddat.f w3trnarg.f w3unpk77.f w3utcdat.f
w3valdat.f w3ymdh4.f xmovex.f xstore.f w3tagb.f makgds.f90 )

# THis is the C source code.
set(c_src summary.c)

# Set compiler flags.
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "-g -traceback ${CMAKE_Fortran_FLAGS}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(fortran_d_flags "-r8")
set(fortran_8_flags "-i8 -r8")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS
"-g -fno-range-check -fbacktrace -funroll-loops ${CMAKE_Fortran_FLAGS}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-ggdb -Wall")
set(fortran_d_flags "-fdefault-real-8")
set(fortran_8_flags "-fdefault-integer-8 -fdefault-real-8")
endif()

# Deal with argument mismatch on GNU compilers version 10 or later.
if(${CMAKE_Fortran_COMPILER_ID} MATCHES "^(GNU)$" AND ${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w -fallow-argument-mismatch -fallow-invalid-boz")
endif()

add_library(c_obj_lib OBJECT ${c_src})

set(kinds "4" "8" "d")
# We buld a _4 and a _d by default.
foreach(kind ${kinds})
set(lib_name ${PROJECT_NAME}_${kind})
set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_${kind}")
Expand All @@ -43,6 +82,7 @@ foreach(kind ${kinds})
install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})
endforeach()

# Install the library.
install(
TARGETS ${LIB_TARGETS}
EXPORT ${PROJECT_NAME}Exports
Expand Down
Loading

0 comments on commit 251e36b

Please sign in to comment.