From a432bfb6c653c47c1678be1303b31ace38896f16 Mon Sep 17 00:00:00 2001 From: Alex Richert Date: Thu, 6 Jun 2024 09:16:51 -0700 Subject: [PATCH] Deprecate unused code (#229) * remove args_mod.f (already disabled) * Deprecate various subroutines and add BUILD_DEPRECATED CMake option * remove aea test --- .github/workflows/Linux_options.yml | 2 +- .github/workflows/Spack.yml | 2 +- CMakeLists.txt | 3 +- spack/package.py | 7 +++ src/CMakeLists.txt | 84 ++++++++++++++++++----------- src/args_mod.f | 34 ------------ tests/CMakeLists.txt | 1 - tests/test_aea.F90 | 22 -------- 8 files changed, 64 insertions(+), 91 deletions(-) delete mode 100644 src/args_mod.f delete mode 100644 tests/test_aea.F90 diff --git a/.github/workflows/Linux_options.yml b/.github/workflows/Linux_options.yml index 00c4b90c..1135ed6b 100644 --- a/.github/workflows/Linux_options.yml +++ b/.github/workflows/Linux_options.yml @@ -20,7 +20,7 @@ jobs: CC: gcc-11 strategy: matrix: - options: ['-DBUILD_D=OFF -DBUILD_WITH_BUFR=ON', '-DBUILD_4=OFF -DBUILD_WITH_BUFR=ON', '-DBUILD_SHARED_LIBS=ON'] + options: ['-DBUILD_D=OFF', '-DBUILD_4=OFF -DBUILD_DEPRECATED=ON -DBUILD_WITH_BUFR=ON', '-DBUILD_SHARED_LIBS=ON'] steps: diff --git a/.github/workflows/Spack.yml b/.github/workflows/Spack.yml index e933368b..75f06e21 100644 --- a/.github/workflows/Spack.yml +++ b/.github/workflows/Spack.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - variants: ["+pic +shared +bufr precision=d", "~pic ~shared ~bufr precision=4", "+pic ~shared ~bufr precision=8"] + variants: ["+pic +shared precision=d", "~pic ~shared precision=4", "+pic ~shared precision=8"] runs-on: ${{ matrix.os }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e040078..2b65f3df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,8 @@ option(BUILD_SHARED_LIBS "Build shared libraries" 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) option(BUILD_8 "Build the 8-byte integer version of the library, libsp_8.a" OFF) -option(BUILD_WITH_BUFR "Build w3emc with subprograms which call NCEPLIBS-bufr" OFF) +option(BUILD_DEPRECATED "Build deprecated routines" OFF) +option(BUILD_WITH_BUFR "Build deprecated routines that call NCEPLIBS-bufr" OFF) # Figure whether user wants _4, _d, _8 kinds of library. if(BUILD_4) diff --git a/spack/package.py b/spack/package.py index e8af0c3b..338e873f 100644 --- a/spack/package.py +++ b/spack/package.py @@ -44,6 +44,12 @@ class W3emc(CMakePackage): description="Build w3emc with subprograms which call unknown dependencies", when="@2.10:2.11", ) + variant( + "build_deprecated", + default=False, + description="Build deprecated subroutines", + when="@develop", + ) conflicts("+shared +extradeps", msg="Shared library cannot be built with unknown dependencies") conflicts("+shared ~pic", msg="Shared library requires PIC") @@ -80,6 +86,7 @@ def cmake_args(self): self.define("BUILD_8", self.spec.satisfies("precision=8")), self.define_from_variant("BUILD_SHARED_LIBS", "shared"), self.define_from_variant("BUILD_WITH_EXTRA_DEPS", "extradeps"), + self.define_from_variant("BUILD_DEPRECATED", "build_deprecated"), ] return args diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed78c332..da3e306c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,39 +1,61 @@ # This is the CMake build file for the src directory of the # NCEPLIBS-w3emc project. # -# Kyle Gerheiser, Ed Hartnett +# Alex Richert, Kyle Gerheiser, Ed Hartnett # This is the Fortran source code. -set(fortran_src 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 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 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 -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 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 w3utcdat.f w3valdat.f w3ymdh4.f xmovex.f xstore.f w3tagb.f -makgds.f90) - -# These functions call NCEPLIBS-bufr. -if(BUILD_WITH_BUFR) - set(fortran_src ${fortran_src} w3miscan.f iw3unp29.f w3unpk77.f) +set(fortran_src + errexit.f errmsg.f fparsei.f fparser.f + gbyte.f gbytec.f gbytes.f gbytesc.f + getbit.f getgb.f getgb1.f getgb1r.f getgb1re.f getgb1s.f getgbe.f getgbeh.f + getgbem.f getgbemh.f getgbemn.f getgbemp.f getgbens.f getgbep.f getgbex.f + getgbexm.f getgbh.f getgbm.f getgbmh.f getgbmp.f getgbp.f getgi.f getgir.f + gtbits.f idsdef.f instrument.f isrchne.f iw3jdn.f iw3mat.f iw3pds.f ixgb.f + lengds.f makgds.f90 makwmo.f mersenne_twister.f mkfldsep.f mova2i.f orders.f + pdsens.f pdseup.f + putgb.f putgbe.f putgben.f putgbens.f putgbex.f putgbn.f + r63w72.f + sbyte.f sbytec.f sbytes.f sbytesc.f + skgb.f + w3ai15.f w3ai19.f w3ai24.f w3ai39.f + w3as00.f w3difdat.f w3doxdat.f + w3fa03.f w3fa09.f + w3fb05.f w3fb06.f w3fb07.f w3fb08.f w3fb09.f w3fb10.f w3fb11.f w3fb12.f + w3fc05.f w3fc06.f w3fc07.f + w3fi01.f w3fi04.f w3fi58.f w3fi59.f w3fi62.f w3fi63.f w3fi68.f w3fi69.f + w3fi71.f w3fi72.f w3fi73.f w3fi74.f w3fi75.f w3fi76.f w3fi82.f w3fi83.f + w3fp11.f + w3fs13.f w3fs15.f w3fs21.f w3fs26.f + w3ft01.f w3ft16.f w3ft17.f w3ft26.f + w3kind.f w3locdat.f w3movdat.f w3pradat.f w3reddat.f w3tagb.f w3trnarg.f + w3utcdat.f w3valdat.f + xmovex.f xstore.f +) + +if(BUILD_DEPRECATED) + set(fortran_src ${fortran_src} + aea.f q9ie32.f + w3ai00.f w3ai01.f w3ai08.f w3ai18.f w3ai38.f w3ai40.f w3ai41.f + w3aq15.f w3ctzdat.f + w3fa01.f w3fa03v.f w3fa04.f w3fa06.f w3fa11.f w3fa12.f w3fa13.f + w3fb00.f w3fb01.f w3fb02.f w3fb03.f w3fb04.f + w3fc02.f w3fc08.f + w3fi02.f w3fi03.f w3fi18.f w3fi19.f w3fi20.f w3fi32.f w3fi47.f w3fi48.f + w3fi61.f w3fi64.f w3fi65.f w3fi66.f w3fi67.f w3fi70.f w3fi78.f + w3fi85.f w3fi88.f w3fi92.f + w3fm07.f w3fm08.f + w3fp04.f w3fp05.f w3fp06.f w3fp10.f w3fp12.f w3fp13.f + w3ft00.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 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 + w3ft32.f w3ft33.f w3ft38.f w3ft39.f w3ft40.f w3ft41.f w3ft43v.f + w3log.f w3nogds.f w3ymdh4.f xdopen.f + ) + # These functions call NCEPLIBS-bufr. + if(BUILD_WITH_BUFR) + set(fortran_src ${fortran_src} iw3unp29.f w3miscan.f w3unpk77.f) + endif() endif() # This is the C source code. diff --git a/src/args_mod.f b/src/args_mod.f deleted file mode 100644 index d98ccb71..00000000 --- a/src/args_mod.f +++ /dev/null @@ -1,34 +0,0 @@ -C> @file -C> @brief Wrapper for routines iargc and getarg. -C> @author Mark Iredell @date 1998-11-DD - -C> This Fortran Module acts as a wrapper to the system -C> routines IARGC and GETARG. Use of this module allows IARGC and -C> GETARG to work properly with 4-byte or 8-byte integer arguments. -C> -C> @author Mark Iredell @date 1998-11-DD - module args_mod - interface iargc - module procedure iargc_8 - end interface - interface getarg - subroutine getarg(k,c) - integer(4) k - character*(*) c - end subroutine getarg - module procedure getarg_8 - end interface - contains - integer(8) function iargc_8() - integer(4) iargc - external iargc - iargc_8=iargc() - end function iargc_8 - subroutine getarg_8(k,c) - integer(8) k - character*(*) c - integer(4) k4 - k4=k - call getarg(k4,c) - end subroutine getarg_8 - end module args_mod diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b68dff03..385b433b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,7 +37,6 @@ foreach(kind ${kinds}) # create_test(test_w3fi72 ${kind}) create_test(test_w3fi73 ${kind}) create_test(test_w3fi74 ${kind}) - create_test(test_aea ${kind}) create_test(test_fparsei ${kind}) create_test(test_fparser ${kind}) create_test(test_gbyte ${kind}) diff --git a/tests/test_aea.F90 b/tests/test_aea.F90 deleted file mode 100644 index 600605f6..00000000 --- a/tests/test_aea.F90 +++ /dev/null @@ -1,22 +0,0 @@ -program test_aea - integer, parameter :: nchar=4 - character*1 :: ia(nchar), ie(nchar), ie_ref(nchar) - integer nc - nc = -nchar - ia(1) = 'a' - ia(2) = 'A' - ia(3) = 'b' - ia(4) = 'B' - call aea(ia, ie, nc) -!! Uncomment to regenerate baseline data: -! open(12, file='data/baseline/aea',access='direct',recl=nchar) -! write(12, rec=1) ie -! close(12) - open(11, file='data/baseline/aea', access='direct',recl=nchar) - read(11, rec=1) ie_ref - close(11) - if (any(ie.ne.ie_ref)) stop 1 - nc = nchar - call aea(ia, ie, nc) - if (ia(1).ne.'a' .or. ia(2).ne.'A' .or. ia(3).ne.'b' .or. ia(4).ne.'B') stop 2 -end program