Skip to content

Commit

Permalink
Restore BUILD_8 (NOAA-EMC#190)
Browse files Browse the repository at this point in the history
* readded _8 build

* readded _8 build

* added _8 include file again

* added _8 include file again

* added _8 again

* readding _8

* readding _8

* readding _8

* Add build_8, incl. testing, and reorganize test flags

* Update test_earth_radius.F90

* Update developer.yml

---------

Co-authored-by: Edward Hartnett <[email protected]>
Co-authored-by: Edward Hartnett <[email protected]>
  • Loading branch information
3 people authored Aug 29, 2023
1 parent dac7990 commit 726ca56
Show file tree
Hide file tree
Showing 21 changed files with 530 additions and 230 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/Intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
cd sp
mkdir build
cd build
${{ matrix.compilers }} cmake -DCMAKE_INSTALL_PREFIX=~/sp -DOPENMP=${{ matrix.openmp}} ..
${{ matrix.compilers }} cmake -DCMAKE_INSTALL_PREFIX=~/sp -DOPENMP=${{ matrix.openmp}} -DBUILD_8=ON ..
make -j2
make install
Expand All @@ -75,7 +75,7 @@ jobs:
cd ip
mkdir build
cd build
${{ matrix.compilers }} cmake -DOPENMP=${{ matrix.openmp }} -DBUILD_SHARED_LIBS=OFF -DCMAKE_PREFIX_PATH="~/sp" ..
${{ matrix.compilers }} cmake -DOPENMP=${{ matrix.openmp }} -DBUILD_SHARED_LIBS=OFF -DCMAKE_PREFIX_PATH="~/sp" -DBUILD_8=ON ..
make -j2 VERBOSE=1
- name: test
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
openmp: [ ON, OFF ]
options: [ -DBUILD_D=OFF, -DBUILD_4=OFF ]
options: [ -DBUILD_D=OFF, -DBUILD_4=OFF, -DBUILD_8=ON ]

steps:

Expand All @@ -31,7 +31,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/sp
key: sp-${{ runner.os }}-Linux-${{ matrix.openmp }}-2.3.3
key: sp-${{ runner.os }}-Linux-${{ matrix.openmp }}-2.3.3-1

- name: checkout-sp
if: steps.cache-sp.outputs.cache-hit != 'true'
Expand All @@ -47,7 +47,7 @@ jobs:
cd sp
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=~/sp -DOPENMP=${{ matrix.openmp }} ..
cmake -DCMAKE_INSTALL_PREFIX=~/sp -DOPENMP=${{ matrix.openmp }} ${{ matrix.options }} ..
make -j2
make install
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/sp
key: sp-${{ matrix.openmp }}-MacOS-2.3.3
key: sp-${{ matrix.openmp }}-MacOS-2.3.3-1

- name: checkout-sp
if: steps.cache-sp.outputs.cache-hit != 'true'
Expand All @@ -46,7 +46,7 @@ jobs:
cd sp
mkdir build
cd build
cmake -DOPENMP=${{ matrix.openmp }} -DCMAKE_INSTALL_PREFIX=~/sp -DBUILD_SHARED_LIBS=${{ matrix.sharedlibs }} ..
cmake -DOPENMP=${{ matrix.openmp }} -DCMAKE_INSTALL_PREFIX=~/sp -DBUILD_SHARED_LIBS=${{ matrix.sharedlibs }} -DBUILD_8=ON ..
make -j2
make install
ls -l ~/sp
Expand All @@ -62,7 +62,7 @@ jobs:
cd ip
mkdir build
cd build
cmake -DOPENMP=${{ matrix.openmp }} -DCMAKE_PREFIX_PATH="~/sp" -DBUILD_SHARED_LIBS=${{ matrix.sharedlibs }} -DCMAKE_INSTALL_PREFIX=~/install ..
cmake -DOPENMP=${{ matrix.openmp }} -DCMAKE_PREFIX_PATH="~/sp" -DBUILD_SHARED_LIBS=${{ matrix.sharedlibs }} -DCMAKE_INSTALL_PREFIX=~/install -DBUILD_8=ON ..
make -j2 VERBOSE=2
make install
ls -l ~/install
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
developer:
runs-on: ubuntu-latest
env:
FC: gfortran-9
CC: gcc-9
FC: gfortran-11
CC: gcc-11

steps:

Expand All @@ -39,7 +39,7 @@ jobs:
cd sp
mkdir build
cd build
cmake -DOPENMP=ON -DCMAKE_INSTALL_PREFIX=~/sp ..
cmake -DOPENMP=ON -DCMAKE_INSTALL_PREFIX=~/sp -DBUILD_8=ON ..
make -j2
make install
Expand All @@ -53,13 +53,13 @@ jobs:
cd ip
mkdir build
cd build
cmake -DENABLE_DOCS=YES -DCMAKE_PREFIX_PATH="~/" -DOPENMP=ON -DCMAKE_Fortran_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -fsanitize=address -Werror -Wno-unused-dummy-argument" -DCMAKE_C_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -fsanitize=address" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON ..
cmake -DENABLE_DOCS=YES -DCMAKE_PREFIX_PATH="~/" -DOPENMP=ON -DCMAKE_Fortran_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -fsanitize=address" -DCMAKE_C_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -fsanitize=address" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DBUILD_8=ON ..
make -j2 VERBOSE=1
- name: test
run: |
cd $GITHUB_WORKSPACE/ip/build
ctest --verbose --output-on-failure --rerun-failed
ctest -j2 --verbose --output-on-failure --rerun-failed
- name: run-gcovr
run: |
Expand Down
23 changes: 15 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@ option(OPENMP "Use OpenMP threading" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_4 "Build the 4-byte real version of the library, libip_4.a" ON)
option(BUILD_D "Build the 8-byte real version of the library, libip_d.a" ON)
option(BUILD_8 "Build the 8-byte integer version of the library, libsp_8.a" OFF)
option(BUILD_TESTING "Build tests of the library" 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)
# Figure whether user wants a _4, a _d, and/or _8.
if(BUILD_4)
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()
if(BUILD_D)
set(kinds ${kinds} "d")
endif()
if(BUILD_8)
set(kinds ${kinds} "8")
endif()
if(NOT BUILD_4 AND NOT BUILD_D AND NOT BUILD_8)
message(FATAL_ERROR "At least one of BUILD_4, BUILD_D, and BUILD_8 must be turned on")
endif()
message(STATUS "Library kinds that will be build: ${kinds}")

# Set the build type.
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
Expand All @@ -55,10 +60,12 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -check nouninit ")
endif()
set(fortran_d_flags "-r8")
set(fortran_8_flags "-i8 -r8")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "-g -fbacktrace -cpp -fimplicit-none ${CMAKE_Fortran_FLAGS}")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -Wno-unused-dummy-argument -Wsurprising -Wextra -fcheck=all")
set(fortran_d_flags "-fdefault-real-8")
set(fortran_8_flags "-fdefault-integer-8 -fdefault-real-8")
endif()

# This is the source code directiroy.
Expand Down
1 change: 1 addition & 0 deletions cmake/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@PACKAGE_INIT@

# * @PROJECT_NAME@::@PROJECT_NAME@_4 - real32 library target
# * @PROJECT_NAME@::@PROJECT_NAME@_8 - real64 library target
# * @PROJECT_NAME@::@PROJECT_NAME@_d - mixed precision library target

# Include targets file. This will create IMPORTED target @PROJECT_NAME@
Expand Down
5 changes: 2 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ ip_rot_equid_cylind_egrid_mod.F90 ip_rot_equid_cylind_grid_mod.F90
constants_mod.F90 ip_grids_mod.F90 ip_grid_factory_mod.F90
ip_interpolators_mod.F90 earth_radius_mod.F90 polfix_mod.F90)

# We build a version of the library with 4-byte reals (_4), and one
# with 8-byte reals (_d).
# Build _4, _d, and/or _8 depending on options provided to CMake
foreach(kind ${kinds})
set(lib_name ${PROJECT_NAME}_${kind})
set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_${kind}")

# Create the C header files for _4 or _d.
# Create the C header files for this kind.
configure_file(ip2lib_${kind}.h ${CMAKE_CURRENT_BINARY_DIR}/include_${kind}/ip2lib.h COPYONLY)
configure_file(iplib_${kind}.h ${CMAKE_CURRENT_BINARY_DIR}/include_${kind}/iplib.h COPYONLY)

Expand Down
38 changes: 26 additions & 12 deletions src/gdswzd_c.F90
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,28 @@ SUBROUTINE GDSWZD_C(IGDTNUM,IGDTMPL,IGDTLEN,IOPT,NPTS,FILL, &

IMPLICIT NONE

#if (LSIZE==8)
INTEGER(KIND=C_LONG), INTENT(IN) :: IGDTMPL(IGDTLEN)
INTEGER(KIND=C_LONG), VALUE, INTENT(IN) :: IGDTNUM, IGDTLEN
INTEGER(KIND=C_LONG), VALUE, INTENT(IN) :: IOPT, NPTS
INTEGER(KIND=C_LONG), INTENT(OUT) :: NRET
#else
INTEGER(KIND=C_INT), INTENT(IN) :: IGDTMPL(IGDTLEN)
INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: IGDTNUM, IGDTLEN
INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: IOPT, NPTS
INTEGER(KIND=C_INT), INTENT(OUT) :: NRET
#endif

#if (LSIZE==D)
REAL(KIND=C_DOUBLE), VALUE, INTENT(IN) :: FILL
REAL(KIND=C_DOUBLE), INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS),RLON(NPTS),RLAT(NPTS)
REAL(KIND=C_DOUBLE), INTENT(OUT) :: CROT(NPTS),SROT(NPTS),XLON(NPTS),XLAT(NPTS)
REAL(KIND=C_DOUBLE), INTENT(OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
#else
#if (LSIZE==4)
REAL(KIND=C_FLOAT), VALUE, INTENT(IN) :: FILL
REAL(KIND=C_FLOAT), INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS),RLON(NPTS),RLAT(NPTS)
REAL(KIND=C_FLOAT), INTENT(OUT) :: CROT(NPTS),SROT(NPTS),XLON(NPTS),XLAT(NPTS)
REAL(KIND=C_FLOAT), INTENT(OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
#else
REAL(KIND=C_DOUBLE), VALUE, INTENT(IN) :: FILL
REAL(KIND=C_DOUBLE), INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS),RLON(NPTS),RLAT(NPTS)
REAL(KIND=C_DOUBLE), INTENT(OUT) :: CROT(NPTS),SROT(NPTS),XLON(NPTS),XLAT(NPTS)
REAL(KIND=C_DOUBLE), INTENT(OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
#endif

CALL GDSWZD(IGDTNUM,IGDTMPL,IGDTLEN,IOPT,NPTS,FILL, &
Expand Down Expand Up @@ -257,21 +264,28 @@ SUBROUTINE GDSWZD_C_grib1(KGDS,IOPT,NPTS,FILL,XPTS,YPTS,RLON,RLAT,NRET, &

IMPLICIT NONE

#if (LSIZE==8)
INTEGER(KIND=C_LONG), INTENT(IN) :: KGDS(200)
INTEGER(KIND=C_LONG), VALUE, INTENT(IN) :: IOPT
INTEGER(KIND=C_LONG), VALUE, INTENT(IN) :: NPTS
INTEGER(KIND=C_LONG), INTENT(OUT) :: NRET
#else
INTEGER(KIND=C_INT), INTENT(IN) :: KGDS(200)
INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: IOPT
INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: NPTS
INTEGER(KIND=C_INT), INTENT(OUT) :: NRET
#endif

#if (LSIZE==D)
REAL(KIND=C_DOUBLE), VALUE, INTENT(IN) :: FILL
REAL(KIND=C_DOUBLE), INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS),RLON(NPTS),RLAT(NPTS)
REAL(KIND=C_DOUBLE), INTENT(OUT) :: CROT(NPTS),SROT(NPTS),XLON(NPTS),XLAT(NPTS)
REAL(KIND=C_DOUBLE), INTENT(OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
#else
#if (LSIZE==4)
REAL(KIND=C_FLOAT), VALUE, INTENT(IN) :: FILL
REAL(KIND=C_FLOAT), INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS),RLON(NPTS),RLAT(NPTS)
REAL(KIND=C_FLOAT), INTENT(OUT) :: CROT(NPTS),SROT(NPTS),XLON(NPTS),XLAT(NPTS)
REAL(KIND=C_FLOAT), INTENT(OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
#else
REAL(KIND=C_DOUBLE), VALUE, INTENT(IN) :: FILL
REAL(KIND=C_DOUBLE), INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS),RLON(NPTS),RLAT(NPTS)
REAL(KIND=C_DOUBLE), INTENT(OUT) :: CROT(NPTS),SROT(NPTS),XLON(NPTS),XLAT(NPTS)
REAL(KIND=C_DOUBLE), INTENT(OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
#endif

CALL GDSWZD(KGDS,IOPT,NPTS,FILL,XPTS,YPTS,RLON,RLAT,NRET, &
Expand Down
Loading

0 comments on commit 726ca56

Please sign in to comment.