From 726ca5697fdd5f3285a38934abc5488190e47b53 Mon Sep 17 00:00:00 2001 From: Alex Richert <82525672+AlexanderRichert-NOAA@users.noreply.github.com> Date: Tue, 29 Aug 2023 12:38:16 -0400 Subject: [PATCH] Restore BUILD_8 (#190) * 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 Co-authored-by: Edward Hartnett <38856240+edwardhartnett@users.noreply.github.com> --- .github/workflows/Intel.yml | 4 +- .github/workflows/Linux.yml | 6 +- .github/workflows/MacOS.yml | 6 +- .github/workflows/developer.yml | 10 +- CMakeLists.txt | 23 ++-- cmake/PackageConfig.cmake.in | 1 + src/CMakeLists.txt | 5 +- src/gdswzd_c.F90 | 38 +++++-- src/ip2lib_8.h | 193 ++++++++++++++++++++++++++++++++ src/iplib_8.h | 35 ++++++ src/ipolates.F90 | 84 ++++++++++---- src/ipolatev.F90 | 90 ++++++++++----- tests/CMakeLists.txt | 13 ++- tests/input_data_mod_grib1.F90 | 12 +- tests/input_data_mod_grib2.F90 | 12 +- tests/interp_mod_grib1.F90 | 52 ++++----- tests/interp_mod_grib2.F90 | 64 +++++------ tests/test_earth_radius.F90 | 10 +- tests/test_ipxwafs.F90 | 41 ++++--- tests/tst_gdswzd_grib1.c | 29 +++-- tests/tst_gdswzd_grib2.c | 32 +++--- 21 files changed, 530 insertions(+), 230 deletions(-) create mode 100644 src/ip2lib_8.h create mode 100644 src/iplib_8.h diff --git a/.github/workflows/Intel.yml b/.github/workflows/Intel.yml index 26ff2c3a..36afb0fc 100644 --- a/.github/workflows/Intel.yml +++ b/.github/workflows/Intel.yml @@ -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 @@ -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 diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index 331bf461..f3206ca5 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -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: @@ -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' @@ -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 diff --git a/.github/workflows/MacOS.yml b/.github/workflows/MacOS.yml index 79be9813..dc722c1c 100644 --- a/.github/workflows/MacOS.yml +++ b/.github/workflows/MacOS.yml @@ -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' @@ -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 @@ -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 diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index bae8ccc6..6f234f54 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -17,8 +17,8 @@ jobs: developer: runs-on: ubuntu-latest env: - FC: gfortran-9 - CC: gcc-9 + FC: gfortran-11 + CC: gcc-11 steps: @@ -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 @@ -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: | diff --git a/CMakeLists.txt b/CMakeLists.txt index e9960f4f..8ebc68b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)$") @@ -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. diff --git a/cmake/PackageConfig.cmake.in b/cmake/PackageConfig.cmake.in index 29df1840..86eed6e7 100644 --- a/cmake/PackageConfig.cmake.in +++ b/cmake/PackageConfig.cmake.in @@ -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@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b96766d6..d2122615 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/gdswzd_c.F90 b/src/gdswzd_c.F90 index 204b367d..4a900f3a 100644 --- a/src/gdswzd_c.F90 +++ b/src/gdswzd_c.F90 @@ -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, & @@ -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, & diff --git a/src/ip2lib_8.h b/src/ip2lib_8.h new file mode 100644 index 00000000..b28c9186 --- /dev/null +++ b/src/ip2lib_8.h @@ -0,0 +1,193 @@ +/** @file + * @brief C interface to gdswzd() and gdswzd_grib1() functions for '8' + * library build. + * @author Jovic @date 2016 + * @author NOAA Programmer + */ + +#ifndef IPLIB +#define IPLIB + +/** + * gdswzd() interface for C for _8 build of library. + * + * @param igdtnum grid definition template number. Corresponds + * to the gfld%igdtnum component of the ncep g2 library gridmod data + * structure. + * - 00 equidistant cylindrical + * - 01 rotated equidistant cylindrical. "e" and non-"e" staggered + * - 10 mercator cyclindrical + * - 20 polar stereographic azimuthal + * - 30 lambert conformal conical + * - 40 gaussian equidistant cyclindrical + * @param igdtmpl (igdtlen) grid definition template array. + * corresponds to the gfld%igdtmpl component of the ncep g2 library + * gridmod data structure for section three. + * all projections: + * - 1 shape of earth, octet 15 + * - 2 scale factor of spherical earth radius, octet 16 + * - 3 scaled value of radius of spherical earth, octets 17-20 + * - 4 scale factor of major axis of elliptical earth, octet 21 + * - 5 scaled value of major axis of elliptical earth, octets 22-25 + * - 6 scale factor of minor axis of elliptical earth, octet 26 + * - 7 scaled value of minor axis of elliptical earth, octets 27-30 + * equidistant cyclindrical: + * - 8 number of points along a parallel, octs 31-34 + * - 9 number of points along a meridian, octs 35-38 + * - 10 basic angle of initial production domain, octets 39-42. + * - 11 subdivisions of basic angle, octets 43-46 + * - 12 latitude of first grid point, octets 47-50 + * - 13 longitude of first grid point, octets 51-54 + * - 14 resolution and component flags, octet 55 + * - 15 latitude of last grid point, octets 56-59 + * - 16 longitude of last grid point, octets 60-63 + * - 17 i-direction increment, octets 64-67 + * - 18 j-direction increment, octets 68-71 + * - 19 scanning mode, octet 72 + * mercator cyclindrical: + * - 8 number of points along a parallel, octs 31-34 + * - 9 number of points along a meridian, octs 35-38 + * - 10 latitude of first point, octets 39-42 + * - 11 longitude of first point, octets 43-46 + * - 12 resolution and component flags, octet 47 + * - 13 tangent latitude, octets 48-51 + * - 14 latitude of last point, octets 52-55 + * - 15 longitude of last point, octets 56-59 + * - 16 scanning mode flags, octet 60 + * - 17 orientation of grid, octets 61-64 + * - 18 longitudinal grid length, octets 65-68 + * - 19 latitudinal grid length, octets 69-72 + * Lambert conformal conical: + * - 8 number of points along x-axis, octs 31-34 + * - 9 number of points along y-axis, octs 35-38 + * - 10 latitude of first point, octets 39-42 + * - 11 longitude of first point, octets 43-46 + * - 12 resolution of component flag, octet 47 + * - 13 latitude where grid lengths specified, octets 48-51 + * - 14 longitude of meridian that is parallel to y-axis, octets 52-55 + * - 15 x-direction grid length, octets 56-59 + * - 16 y-direction grid length, octets 60-63 + * - 17 projection center flag, octet 64 + * - 18 scanning mode, octet 65 + * - 19 first tangent latitude from pole, octets 66-69 + * - 20 second tangent latitude from pole, octets 70-73 + * - 21 latitude of south pole of projection, octets 74-77 + * - 22 longitude of south pole of projection, octets 78-81 + * gaussian cylindrical: + * - 8 number of points along a parallel, octs 31-34 + * - 9 number of points along a meridian, octs 35-38 + * - 10 basic angle of initial production domain, octets 39-42 + * - 11 subdivisions of basic angle, octets 43-46 + * - 12 latitude of first grid point, octets 47-50 + * - 13 longitude of first grid point, octets 51-54 + * - 14 resolution and component flags, octet 55 + * - 15 latitude of last grid point, octets 56-59 + * - 16 longitude of last grid point, octets 60-63 + * - 17 i-direction increment, octets 64-67 + * - 18 number of parallels between pole and equator, octets 68-71 + * - 19 scanning mode, octet 72 + * polar stereographic azimuthal: + * - 8 number of points along x-axis, octets 31-34 + * - 9 number of points along y-axis, octets 35-38 + * - 10 latitude of first grid point, octets 39-42 + * - 11 longitude of first grid point, octets 43-46 + * - 12 resolution and component flags, octet 47 + * - 13 true latitude, octets 48-51 + * - 14 orientation longitude, octets 52-55 + * - 15 x-direction grid length, octets 56-59 + * - 16 y-direction grid length, octets 60-63 + * - 17 projection center flag, octet 64 + * - 18 scanning mode flags, octet 65 + * rotated equidistant cyclindrical: + * - 8 number of points along a parallel, octs 31-34 + * - 9 number of points along a meridian, octs 35-38 + * - 10 basic angle of initial production domain, octets 39-42 + * - 11 subdivisions of basic angle, octets 43-46 + * - 12 latitude of first grid point, octets 47-50 + * - 13 longitude of first grid point, octets 51-54 + * - 14 resolution and component flags, octet 55 + * - 15 latitude of last grid point, octets 56-59 + * - 16 longitude of last grid point, octets 60-63 + * - 17 i-direction increment, octets 64-67 + * - 18 j-direction increment, octets 68-71 + * - 19 scanning mode, octet 72 + * - 20 latitude of southern pole of projection, octets 73-76 + * - 21 longitude of southern pole of projection, octets 77-80 + * - 22 angle of rotation of projection, octs 81-84 + * @param igdtlen number of elements of the grid definition + * template array. Corresponds to the gfld%igdtlen component of the + * ncep g2 library gridmod data structure. + * @param iopt option flag + * - 0 to compute earth coords of all the grid points + * - 1 to compute earth coords of selected grid coords + * - -1 to compute grid coords of selected earth coords + * @param npts integer maximum number of coordinates + * @param fill real fill value to set invalid output data (must + * be impossible value; suggested value: -9999.) + * @param xpts real (npts) grid x point coordinates if iopt>0 + * @param ypts real (npts) grid y point coordinates if iopt>0 + * @param rlon real (npts) earth longitudes in degrees e if + * iopt<0 (acceptable range: -360. to 360.) + * @param rlat real (npts) earth latitudes in degrees n if + * iopt<0 (acceptable range: -90. to 90.) + * @param nret number of valid points computed (-1 if + * projection unrecognized) + * @param crot (npts) clockwise vector rotation cosines + * @param srot (npts) clockwise vector rotation sines + * (ugrid=crot*uearth-srot*vearth, vgrid=srot*uearth+crot*vearth) + * @param xlon (npts) dx/dlon in 1/degrees + * @param xlat (npts) dx/dlat in 1/degrees + * @param ylon (npts) dy/dlon in 1/degrees + * @param ylat (npts) dy/dlat in 1/degrees + * @param area (npts) area weights in m**2 (Proportional to the + * square of the map factor in the case of conformal projections.) + * + * @author Jovic @date 2016 + */ +void gdswzd(long igdtnum, long *igdtmpl, long igdtlen, long iopt, + long npts, double fill, double *xpts, double *ypts, + double *rlon, double *rlat, long *nret, + double *crot, double *srot, double *xlon, double *xlat, + double *ylon, double *ylat, double *area); + +/** + * gdswzd_grib1() interface for C for _8 build of the library. + * + * This is a C prototype to call the Fortran module subroutine + * gdswzd_c_grib1() for the _4 version of the library. + * + * @param kgds (200) gds parameters as decoded by + * [w3fi63](https://noaa-emc.github.io/NCEPLIBS-w3emc/w3fi63_8f.html). + * @param iopt option flag + * - 0 to compute earth coords of all the grid points + * - 1 to compute earth coords of selected grid coords + * - -1 to compute grid coords of selected earth coords + * @param npts maximum number of coordinates + * @param fill fill value to set invalid output data (must be + * impossible value; suggested value: -9999.) + * @param xpts (npts) grid x point coordinates if iopt>0 + * @param ypts (npts) grid y point coordinates if iopt>0 + * @param rlon (npts) earth longitudes in degrees e if iopt<0 + * (acceptable range: -360. to 360.) + * @param rlat (npts) earth latitudes in degrees n if iopt<0 + * (acceptable range: -90. to 90.) + * @param nret number of valid points computed (-1 if + * projection unrecognized) + * @param crot (npts) clockwise vector rotation cosines + * @param srot (npts) clockwise vector rotation sines + * (ugrid=crot*uearth-srot*vearth; vgrid=srot*uearth+crot*vearth) + * @param xlon (npts) dx/dlon in 1/degrees + * @param xlat (npts) dx/dlat in 1/degrees + * @param ylon (npts) dy/dlon in 1/degrees + * @param ylat (npts) dy/dlat in 1/degrees + * @param area (npts) area weights in m**2 (proportional to the + * square of the map factor in the case of conformal projections.) + * + * @author Jovic @date 2016 + */ +void gdswzd_grib1(long kgds, long iopt, long npts, + double *fill, double *xpts, + double *ypts, double *rlon, double *rlat, int nret, double *crot, + double *srot, double *xlon, double *xlat, double *ylon, + double *ylat, double *area); +#endif diff --git a/src/iplib_8.h b/src/iplib_8.h new file mode 100644 index 00000000..058176de --- /dev/null +++ b/src/iplib_8.h @@ -0,0 +1,35 @@ +/** @file + * @brief C interface to gdswzd() function for '8' library build. + * @author NOAA Programmer + */ + +#ifndef IPLIB +#define IPLIB + +/** + GDSWZD_grib1 in C. + + @param kgds + @param iopt + @param npts + @param *fill + @param *xpts + @param *ypts + @param *rlon + @param *rlat + @param nret + @param *crot + @param *srot + @param *xlon + @param *xlat + @param *ylon + @param *ylat + @param *area + */ +void gdswzd(long *kgds, long iopt, long npts, double fill, + double *xpts, double *ypts, double *rlon, double *rlat, + long *nret, + double *crot, double *srot, double *xlon, double *xlat, + double *ylon, double *ylat, double *area); + +#endif diff --git a/src/ipolates.F90 b/src/ipolates.F90 index 3096a4d7..8c5ff38f 100644 --- a/src/ipolates.F90 +++ b/src/ipolates.F90 @@ -158,23 +158,30 @@ end subroutine ipolates_grid subroutine ipolates_grib1_single_field(ip,ipopt,kgdsi,kgdso,mi,mo,km,ibi,li,gi, & no,rlat,rlon,ibo,lo,go,iret) bind(c) ! - USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL + USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL, C_LONG +#if (LSIZE==8) + INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO + INTEGER(C_LONG), INTENT(IN ) :: IBI, KGDSI(200), KGDSO(200) + INTEGER(C_LONG), INTENT(INOUT) :: NO + INTEGER(C_LONG), INTENT( OUT) :: IRET, IBO +#else INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO INTEGER(C_INT), INTENT(IN ) :: IBI, KGDSI(200), KGDSO(200) INTEGER(C_INT), INTENT(INOUT) :: NO INTEGER(C_INT), INTENT( OUT) :: IRET, IBO +#endif ! LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI) LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO) ! -#if (LSIZE==D) - REAL(C_DOUBLE), INTENT(IN ) :: GI(MI) - REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) - REAL(C_DOUBLE), INTENT( OUT) :: GO(MO) -#elif (LSIZE==4) +#if (LSIZE==4) REAL(C_FLOAT), INTENT(IN ) :: GI(MI) REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO) REAL(C_FLOAT), INTENT( OUT) :: GO(MO) +#else + REAL(C_DOUBLE), INTENT(IN ) :: GI(MI) + REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) + REAL(C_DOUBLE), INTENT( OUT) :: GO(MO) #endif ! @@ -286,23 +293,30 @@ END SUBROUTINE IPOLATES_grib1_single_field subroutine ipolates_grib1(ip,ipopt,kgdsi,kgdso,mi,mo,km,ibi,li,gi, & no,rlat,rlon,ibo,lo,go,iret) bind(c) ! - USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL + USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL, C_LONG +#if (LSIZE==8) + INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO + INTEGER(C_LONG), INTENT(IN ) :: IBI(KM), KGDSI(200), KGDSO(200) + INTEGER(C_LONG), INTENT(INOUT) :: NO + INTEGER(C_LONG), INTENT( OUT) :: IRET, IBO(KM) +#else INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO INTEGER(C_INT), INTENT(IN ) :: IBI(KM), KGDSI(200), KGDSO(200) INTEGER(C_INT), INTENT(INOUT) :: NO INTEGER(C_INT), INTENT( OUT) :: IRET, IBO(KM) +#endif ! LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI,KM) LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO,KM) ! -#if (LSIZE==D) - REAL(C_DOUBLE), INTENT(IN ) :: GI(MI,KM) - REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) - REAL(C_DOUBLE), INTENT( OUT) :: GO(MO,KM) -#elif (LSIZE==4) +#if (LSIZE==4) REAL(C_FLOAT), INTENT(IN ) :: GI(MI,KM) REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO) REAL(C_FLOAT), INTENT( OUT) :: GO(MO,KM) +#else + REAL(C_DOUBLE), INTENT(IN ) :: GI(MI,KM) + REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) + REAL(C_DOUBLE), INTENT( OUT) :: GO(MO,KM) #endif ! @@ -574,7 +588,17 @@ SUBROUTINE IPOLATES_grib2(IP,IPOPT,IGDTNUMI,IGDTMPLI,IGDTLENI, & IGDTNUMO,IGDTMPLO,IGDTLENO, & MI,MO,KM,IBI,LI,GI, & NO,RLAT,RLON,IBO,LO,GO,IRET) bind(C) - USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL + USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL, C_LONG +#if (LSIZE==8) + INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO + INTEGER(C_LONG), INTENT(IN ) :: IBI(KM) + INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMI, IGDTLENI + INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLI(IGDTLENI) + INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMO, IGDTLENO + INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLO(IGDTLENO) + INTEGER(C_LONG), INTENT( OUT) :: NO + INTEGER(C_LONG), INTENT( OUT) :: IRET, IBO(KM) +#else INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO INTEGER(C_INT), INTENT(IN ) :: IBI(KM) INTEGER(C_INT), INTENT(IN ) :: IGDTNUMI, IGDTLENI @@ -583,18 +607,19 @@ SUBROUTINE IPOLATES_grib2(IP,IPOPT,IGDTNUMI,IGDTMPLI,IGDTLENI, & INTEGER(C_INT), INTENT(IN ) :: IGDTMPLO(IGDTLENO) INTEGER(C_INT), INTENT( OUT) :: NO INTEGER(C_INT), INTENT( OUT) :: IRET, IBO(KM) +#endif ! LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI,KM) LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO,KM) ! -#if (LSIZE==D) - REAL(C_DOUBLE), INTENT(IN ) :: GI(MI,KM) - REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) - REAL(C_DOUBLE), INTENT( OUT) :: GO(MO,KM) -#elif (LSIZE==4) +#if (LSIZE==4) REAL(C_FLOAT), INTENT(IN ) :: GI(MI,KM) REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO) REAL(C_FLOAT), INTENT( OUT) :: GO(MO,KM) +#else + REAL(C_DOUBLE), INTENT(IN ) :: GI(MI,KM) + REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) + REAL(C_DOUBLE), INTENT( OUT) :: GO(MO,KM) #endif type(grib2_descriptor) :: desc_in, desc_out @@ -784,7 +809,17 @@ SUBROUTINE IPOLATES_GRIB2_SINGLE_FIELD(IP,IPOPT,IGDTNUMI,IGDTMPLI,IGDTLENI, & IGDTNUMO,IGDTMPLO,IGDTLENO, & MI,MO,KM,IBI,LI,GI, & NO,RLAT,RLON,IBO,LO,GO,IRET) bind(C) - USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL + USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL, C_LONG +#if (LSIZE==8) + INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO + INTEGER(C_LONG), INTENT(IN ) :: IBI + INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMI, IGDTLENI + INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLI(IGDTLENI) + INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMO, IGDTLENO + INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLO(IGDTLENO) + INTEGER(C_LONG), INTENT( OUT) :: NO + INTEGER(C_LONG), INTENT( OUT) :: IRET, IBO +#else INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO INTEGER(C_INT), INTENT(IN ) :: IBI INTEGER(C_INT), INTENT(IN ) :: IGDTNUMI, IGDTLENI @@ -793,18 +828,19 @@ SUBROUTINE IPOLATES_GRIB2_SINGLE_FIELD(IP,IPOPT,IGDTNUMI,IGDTMPLI,IGDTLENI, & INTEGER(C_INT), INTENT(IN ) :: IGDTMPLO(IGDTLENO) INTEGER(C_INT), INTENT( OUT) :: NO INTEGER(C_INT), INTENT( OUT) :: IRET, IBO +#endif ! LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI) LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO) ! -#if (LSIZE==D) - REAL(C_DOUBLE), INTENT(IN ) :: GI(MI) - REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) - REAL(C_DOUBLE), INTENT( OUT) :: GO(MO) -#elif (LSIZE==4) +#if (LSIZE==4) REAL(C_FLOAT), INTENT(IN ) :: GI(MI) REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO) REAL(C_FLOAT), INTENT( OUT) :: GO(MO) +#else + REAL(C_DOUBLE), INTENT(IN ) :: GI(MI) + REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) + REAL(C_DOUBLE), INTENT( OUT) :: GO(MO) #endif type(grib2_descriptor) :: desc_in, desc_out diff --git a/src/ipolatev.F90 b/src/ipolatev.F90 index 5d4b23a0..9e7433e2 100644 --- a/src/ipolatev.F90 +++ b/src/ipolatev.F90 @@ -383,7 +383,16 @@ subroutine ipolatev_grib2(ip,ipopt,igdtnumi,igdtmpli,igdtleni, & igdtnumo,igdtmplo,igdtleno, & mi,mo,km,ibi,li,ui,vi, & no,rlat,rlon,crot,srot,ibo,lo,uo,vo,iret) bind(c) - USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL + USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL, C_LONG +#if (LSIZE==8) + INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), IBI(KM) + INTEGER(C_LONG), INTENT(IN ) :: KM, MI, MO + INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMI, IGDTLENI + INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLI(IGDTLENI) + INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMO, IGDTLENO + INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLO(IGDTLENO) + INTEGER(C_LONG), INTENT( OUT) :: IBO(KM), IRET, NO +#else INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), IBI(KM) INTEGER(C_INT), INTENT(IN ) :: KM, MI, MO INTEGER(C_INT), INTENT(IN ) :: IGDTNUMI, IGDTLENI @@ -391,20 +400,21 @@ subroutine ipolatev_grib2(ip,ipopt,igdtnumi,igdtmpli,igdtleni, & INTEGER(C_INT), INTENT(IN ) :: IGDTNUMO, IGDTLENO INTEGER(C_INT), INTENT(IN ) :: IGDTMPLO(IGDTLENO) INTEGER(C_INT), INTENT( OUT) :: IBO(KM), IRET, NO +#endif ! LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI,KM) LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO,KM) ! -#if (LSIZE==D) - REAL(C_DOUBLE), INTENT(IN ) :: UI(MI,KM),VI(MI,KM) - REAL(C_DOUBLE), INTENT(INOUT) :: CROT(MO),SROT(MO) - REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) - REAL(C_DOUBLE), INTENT( OUT) :: UO(MO,KM),VO(MO,KM) -#elif (LSIZE==4) +#if (LSIZE==4) REAL(C_FLOAT), INTENT(IN ) :: UI(MI,KM),VI(MI,KM) REAL(C_FLOAT), INTENT(INOUT) :: CROT(MO),SROT(MO) REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO) REAL(C_FLOAT), INTENT( OUT) :: UO(MO,KM),VO(MO,KM) +#else + REAL(C_DOUBLE), INTENT(IN ) :: UI(MI,KM),VI(MI,KM) + REAL(C_DOUBLE), INTENT(INOUT) :: CROT(MO),SROT(MO) + REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) + REAL(C_DOUBLE), INTENT( OUT) :: UO(MO,KM),VO(MO,KM) #endif ! @@ -554,27 +564,34 @@ end subroutine ipolatev_grib2 !> @author Kyle Gerheiser subroutine ipolatev_grib1(ip,ipopt,kgdsi,kgdso,mi,mo,km,ibi,li,ui,vi, & no,rlat,rlon,crot,srot,ibo,lo,uo,vo,iret) bind(c) - USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL + USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL, C_LONG IMPLICIT NONE ! +#if (LSIZE==8) + INTEGER(C_LONG), INTENT(IN ):: IP, IPOPT(20), IBI(KM) + INTEGER(C_LONG), INTENT(IN ):: KM, MI, MO + INTEGER(C_LONG), INTENT(INOUT):: KGDSI(200), KGDSO(200) + INTEGER(C_LONG), INTENT( OUT):: IBO(KM), IRET, NO +#else INTEGER(C_INT), INTENT(IN ):: IP, IPOPT(20), IBI(KM) INTEGER(C_INT), INTENT(IN ):: KM, MI, MO INTEGER(C_INT), INTENT(INOUT):: KGDSI(200), KGDSO(200) INTEGER(C_INT), INTENT( OUT):: IBO(KM), IRET, NO +#endif ! LOGICAL(C_BOOL), INTENT(IN ):: LI(MI,KM) LOGICAL(C_BOOL), INTENT( OUT):: LO(MO,KM) ! -#if (LSIZE==D) - REAL(C_DOUBLE), INTENT(IN ):: UI(MI,KM),VI(MI,KM) - REAL(C_DOUBLE), INTENT(INOUT):: CROT(MO),SROT(MO) - REAL(C_DOUBLE), INTENT(INOUT):: RLAT(MO),RLON(MO) - REAL(C_DOUBLE), INTENT( OUT):: UO(MO,KM),VO(MO,KM) -#elif (LSIZE==4) +#if (LSIZE==4) REAL(C_FLOAT), INTENT(IN ):: UI(MI,KM),VI(MI,KM) REAL(C_FLOAT), INTENT(INOUT):: CROT(MO),SROT(MO) REAL(C_FLOAT), INTENT(INOUT):: RLAT(MO),RLON(MO) REAL(C_FLOAT), INTENT( OUT):: UO(MO,KM),VO(MO,KM) +#else + REAL(C_DOUBLE), INTENT(IN ):: UI(MI,KM),VI(MI,KM) + REAL(C_DOUBLE), INTENT(INOUT):: CROT(MO),SROT(MO) + REAL(C_DOUBLE), INTENT(INOUT):: RLAT(MO),RLON(MO) + REAL(C_DOUBLE), INTENT( OUT):: UO(MO,KM),VO(MO,KM) #endif ! INTEGER :: KGDSI11, KGDSO11 @@ -662,27 +679,34 @@ END SUBROUTINE IPOLATEV_grib1 !> @author Kyle Gerheiser subroutine ipolatev_grib1_single_field(ip,ipopt,kgdsi,kgdso,mi,mo,km,ibi,li,ui,vi, & no,rlat,rlon,crot,srot,ibo,lo,uo,vo,iret) bind(c) - USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL + USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL, C_LONG IMPLICIT NONE ! +#if (LSIZE==8) + INTEGER(C_LONG), INTENT(IN ):: IP, IPOPT(20), IBI + INTEGER(C_LONG), INTENT(IN ):: KM, MI, MO + INTEGER(C_LONG), INTENT(INOUT):: KGDSI(200), KGDSO(200) + INTEGER(C_LONG), INTENT( OUT):: IBO, IRET, NO +#else INTEGER(C_INT), INTENT(IN ):: IP, IPOPT(20), IBI INTEGER(C_INT), INTENT(IN ):: KM, MI, MO INTEGER(C_INT), INTENT(INOUT):: KGDSI(200), KGDSO(200) INTEGER(C_INT), INTENT( OUT):: IBO, IRET, NO +#endif ! LOGICAL(C_BOOL), INTENT(IN ):: LI(MI) LOGICAL(C_BOOL), INTENT( OUT):: LO(MO) ! -#if (LSIZE==D) - REAL(C_DOUBLE), INTENT(IN ):: UI(MI),VI(MI) - REAL(C_DOUBLE), INTENT(INOUT):: CROT(MO),SROT(MO) - REAL(C_DOUBLE), INTENT(INOUT):: RLAT(MO),RLON(MO) - REAL(C_DOUBLE), INTENT( OUT):: UO(MO),VO(MO) -#elif (LSIZE==4) +#if (LSIZE==4) REAL(C_FLOAT), INTENT(IN ):: UI(MI),VI(MI) REAL(C_FLOAT), INTENT(INOUT):: CROT(MO),SROT(MO) REAL(C_FLOAT), INTENT(INOUT):: RLAT(MO),RLON(MO) REAL(C_FLOAT), INTENT( OUT):: UO(MO),VO(MO) +#else + REAL(C_DOUBLE), INTENT(IN ):: UI(MI),VI(MI) + REAL(C_DOUBLE), INTENT(INOUT):: CROT(MO),SROT(MO) + REAL(C_DOUBLE), INTENT(INOUT):: RLAT(MO),RLON(MO) + REAL(C_DOUBLE), INTENT( OUT):: UO(MO),VO(MO) #endif ! INTEGER :: KGDSI11, KGDSO11 @@ -809,7 +833,16 @@ subroutine ipolatev_grib2_single_field(ip,ipopt,igdtnumi,igdtmpli,igdtleni, & igdtnumo,igdtmplo,igdtleno, & mi,mo,km,ibi,li,ui,vi, & no,rlat,rlon,crot,srot,ibo,lo,uo,vo,iret) bind(c) - USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL + USE ISO_C_BINDING, ONLY: C_INT, C_FLOAT, C_DOUBLE, C_BOOL, C_LONG +#if (LSIZE==8) + INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), IBI + INTEGER(C_LONG), INTENT(IN ) :: KM, MI, MO + INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMI, IGDTLENI + INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLI(IGDTLENI) + INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMO, IGDTLENO + INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLO(IGDTLENO) + INTEGER(C_LONG), INTENT( OUT) :: IBO, IRET, NO +#else INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), IBI INTEGER(C_INT), INTENT(IN ) :: KM, MI, MO INTEGER(C_INT), INTENT(IN ) :: IGDTNUMI, IGDTLENI @@ -817,20 +850,21 @@ subroutine ipolatev_grib2_single_field(ip,ipopt,igdtnumi,igdtmpli,igdtleni, & INTEGER(C_INT), INTENT(IN ) :: IGDTNUMO, IGDTLENO INTEGER(C_INT), INTENT(IN ) :: IGDTMPLO(IGDTLENO) INTEGER(C_INT), INTENT( OUT) :: IBO, IRET, NO +#endif ! LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI) LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO) ! -#if (LSIZE==d) - REAL(C_DOUBLE), INTENT(IN ) :: UI(MI),VI(MI) - REAL(C_DOUBLE), INTENT(INOUT) :: CROT(MO),SROT(MO) - REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) - REAL(C_DOUBLE), INTENT( OUT) :: UO(MO),VO(MO) -#elif (LSIZE==4) +#if (LSIZE==4) REAL(C_FLOAT), INTENT(IN ) :: UI(MI),VI(MI) REAL(C_FLOAT), INTENT(INOUT) :: CROT(MO),SROT(MO) REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO) REAL(C_FLOAT), INTENT( OUT) :: UO(MO),VO(MO) +#else + REAL(C_DOUBLE), INTENT(IN ) :: UI(MI),VI(MI) + REAL(C_DOUBLE), INTENT(INOUT) :: CROT(MO),SROT(MO) + REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO) + REAL(C_DOUBLE), INTENT( OUT) :: UO(MO),VO(MO) #endif ! diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 117271ab..6bd06865 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,10 +11,8 @@ execute_process(COMMAND cmake -E create_symlink # Set compiler flags. set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_DEBUG}") if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$") - set(CMAKE_Fortran_FLAGS "-r8 -heap-arrays ${CMAKE_Fortran_FLAGS}") + set(CMAKE_Fortran_FLAGS " -heap-arrays ${CMAKE_Fortran_FLAGS}") set(CMAKE_C_FLAGS "-std=c99") -elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") - set(CMAKE_Fortran_FLAGS "-fdefault-real-8 ${CMAKE_Fortran_FLAGS}") endif() # Set compiler flags for GNU. @@ -23,6 +21,7 @@ if(${CMAKE_Fortran_COMPILER_ID} MATCHES "^(GNU)$" AND ${CMAKE_Fortran_COMPILER_V endif() foreach(kind ${kinds}) + set(BUILD_FLAGS "${fortran_${kind}_flags}") string(TOUPPER ${kind} kind_definition) # Test ipxwafs routines @@ -30,6 +29,7 @@ foreach(kind ${kinds}) target_link_libraries(test_ipxwafs_${kind} PUBLIC ip::ip_${kind}) target_link_libraries(test_ipxwafs_${kind} PUBLIC sp::sp_${kind}) target_compile_definitions(test_ipxwafs_${kind} PRIVATE "LSIZE=${kind_definition}") + set_target_properties(test_ipxwafs_${kind} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}") add_test(test_ipxwafs_${kind} test_ipxwafs_${kind}) # Test earth_radius_mod. @@ -37,6 +37,7 @@ foreach(kind ${kinds}) target_link_libraries(test_earth_radius_${kind} PUBLIC ip::ip_${kind}) target_link_libraries(test_earth_radius_${kind} PUBLIC sp::sp_${kind}) target_compile_definitions(test_earth_radius_${kind} PRIVATE "LSIZE=${kind_definition}") + set_target_properties(test_earth_radius_${kind} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}") add_test(test_earth_radius_${kind} test_earth_radius_${kind}) # grib-2 tests @@ -44,6 +45,7 @@ foreach(kind ${kinds}) target_link_libraries(test_library_grib2_${kind} PUBLIC ip::ip_${kind}) target_link_libraries(test_library_grib2_${kind} PUBLIC sp::sp_${kind}) target_compile_definitions(test_library_grib2_${kind} PRIVATE "LSIZE=${kind_definition}") + set_target_properties(test_library_grib2_${kind} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}") add_executable(tst_gdswzd_grib2_${kind} tst_gdswzd_grib2.c) set_target_properties(tst_gdswzd_grib2_${kind} PROPERTIES LINKER_LANGUAGE C) @@ -56,6 +58,8 @@ foreach(kind ${kinds}) target_link_libraries(test_vector_grib2_${kind} PRIVATE test_library_grib2_${kind}) target_compile_definitions(test_scalar_grib2_${kind} PRIVATE "LSIZE=${kind_definition}") target_compile_definitions(test_vector_grib2_${kind} PRIVATE "LSIZE=${kind_definition}") + set_target_properties(test_scalar_grib2_${kind} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}") + set_target_properties(test_vector_grib2_${kind} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}") add_test(tst_gdswzd_c_grib2_${kind} tst_gdswzd_grib2_${kind}) @@ -98,12 +102,15 @@ foreach(kind ${kinds}) target_link_libraries(test_library_grib1_${kind} PUBLIC ip::ip_${kind}) target_link_libraries(test_library_grib1_${kind} PUBLIC sp::sp_${kind}) target_compile_definitions(test_library_grib1_${kind} PRIVATE "LSIZE=${kind_definition}") + set_target_properties(test_library_grib1_${kind} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}") add_executable(tst_gdswzd_grib1_${kind} tst_gdswzd_grib1.c) set_target_properties(tst_gdswzd_grib1_${kind} PROPERTIES LINKER_LANGUAGE C) target_compile_definitions(tst_gdswzd_grib1_${kind} PRIVATE "LSIZE=${kind_definition}") add_executable(test_scalar_grib1_${kind} test_scalar_grib1.F90) add_executable(test_vector_grib1_${kind} test_vector_grib1.F90) + set_target_properties(test_scalar_grib1_${kind} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}") + set_target_properties(test_vector_grib1_${kind} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}") target_link_libraries(test_scalar_grib1_${kind} PRIVATE test_library_grib1_${kind}) target_link_libraries(test_vector_grib1_${kind} PRIVATE test_library_grib1_${kind}) diff --git a/tests/input_data_mod_grib1.F90 b/tests/input_data_mod_grib1.F90 index 8b236d85..1499f51e 100644 --- a/tests/input_data_mod_grib1.F90 +++ b/tests/input_data_mod_grib1.F90 @@ -5,12 +5,6 @@ ! ! Kyle Gerheiser June, 2021 -#if (LSIZE==D) -#define REALSIZE 8 -#elif (LSIZE==4) -#define REALSIZE 4 -#endif - module input_data_mod_grib1 implicit none @@ -32,9 +26,9 @@ module input_data_mod_grib1 ! integer, parameter :: missing=b'11111111111111111111111111111111' - real(KIND=REALSIZE), allocatable, public :: input_data(:,:) - real(KIND=REALSIZE), allocatable, public :: input_u_data(:,:) - real(KIND=REALSIZE), allocatable, public :: input_v_data(:,:) + real, allocatable, public :: input_data(:,:) + real, allocatable, public :: input_u_data(:,:) + real, allocatable, public :: input_v_data(:,:) logical*1, allocatable, public :: input_bitmap(:,:) diff --git a/tests/input_data_mod_grib2.F90 b/tests/input_data_mod_grib2.F90 index dca345cc..2b145cac 100644 --- a/tests/input_data_mod_grib2.F90 +++ b/tests/input_data_mod_grib2.F90 @@ -5,12 +5,6 @@ ! ! Kyle Gerheiser June, 2021 -#if (LSIZE==D) -#define REALSIZE 8 -#elif (LSIZE==4) -#define REALSIZE 4 -#endif - module input_data_mod_grib2 implicit none @@ -29,9 +23,9 @@ module input_data_mod_grib2 integer, parameter :: missing=huge(1) - real(KIND=REALSIZE), allocatable, public :: input_data(:,:) - real(KIND=REALSIZE), allocatable, public :: input_u_data(:,:) - real(KIND=REALSIZE), allocatable, public :: input_v_data(:,:) + real, allocatable, public :: input_data(:,:) + real, allocatable, public :: input_u_data(:,:) + real, allocatable, public :: input_v_data(:,:) logical*1, allocatable, public :: input_bitmap(:,:) diff --git a/tests/interp_mod_grib1.F90 b/tests/interp_mod_grib1.F90 index 713baa2d..6ea320d1 100644 --- a/tests/interp_mod_grib1.F90 +++ b/tests/interp_mod_grib1.F90 @@ -2,14 +2,6 @@ ! ! Kyle Gerheiser June, 2021 -#if (LSIZE==D) -#define REALSIZE 8 -#define REALSIZESTR "8" -#elif (LSIZE==4) -#define REALSIZE 4 -#define REALSIZESTR "4" -#endif - module interp_mod_grib1 use ip_mod implicit none @@ -59,15 +51,15 @@ subroutine interp(grid, interp_opt) character*100 :: baseline_file - integer :: ip, ipopt(20), output_kgds(200) - integer :: km, ibi(1), mi, iret, i, j, ibi_scalar=0 - integer :: i_output, j_output, mo, no, ibo(1), ibo_scalar + integer :: ip, ipopt(20), output_kgds(200) + integer :: km, ibi(1), mi, iret, i, j, ibi_scalar=0 + integer :: i_output, j_output, mo, no, ibo(1), ibo_scalar integer :: num_pts_diff, which_func, ntol logical*1, allocatable :: output_bitmap(:,:) - real(KIND=REALSIZE), allocatable :: output_rlat(:), output_rlon(:) - real(KIND=REALSIZE), allocatable :: output_data(:,:) + real, allocatable :: output_rlat(:), output_rlon(:) + real, allocatable :: output_data(:,:) real(kind=4), allocatable :: baseline_data(:,:) real :: avgdiff, maxdiff real(kind=4) :: output_data4 @@ -101,12 +93,12 @@ subroutine interp(grid, interp_opt) data grd218 /3, 614, 428, 12190, -133459, 8, -95000, & 12191, 12191, 0, 64, 25000, 25000, 0, 0, 0, 0, 0, 0, 255, 180*0/ -#if (LSIZE==D) - abstol=0.0001 - ntol = 0 -#elif (LSIZE==4) +#if (LSIZE==4) abstol=0.05 ntol = 10 +#else + abstol=0.0001 + ntol = 0 #endif select case (trim(grid)) @@ -208,7 +200,7 @@ subroutine interp(grid, interp_opt) endif ! Uncomment to generate new baseline file: -! open (13, file="grid"//trim(grid)//".opt"//trim(interp_opt)//".bin_"//REALSIZESTR, access="direct", recl=mo*4) +! open (13, file="grid"//trim(grid)//".opt"//trim(interp_opt)//".bin_"//"LSIZE", access="direct", recl=mo*4) ! write (13, rec=1) real(output_data, kind=4) ! close (13) @@ -334,17 +326,17 @@ subroutine interp_vector(grid, interp_opt) character*100 :: baseline_file - integer :: ip, ipopt(20), output_kgds(200) - integer :: km, ibi(1), mi, iret, i, j, which_func - integer :: i_output, j_output, mo, no, ibo(1) - integer :: ibi_scalar=0, ibo_scalar + integer :: ip, ipopt(20), output_kgds(200) + integer :: km, ibi(1), mi, iret, i, j, which_func + integer :: i_output, j_output, mo, no, ibo(1) + integer :: ibi_scalar=0, ibo_scalar integer :: num_upts_diff, num_vpts_diff, ntol logical*1, allocatable :: output_bitmap(:,:) - real(KIND=REALSIZE), allocatable :: output_rlat(:), output_rlon(:) - real(KIND=REALSIZE), allocatable :: output_crot(:), output_srot(:) - real(KIND=REALSIZE), allocatable :: output_u_data(:,:), output_v_data(:,:) + real, allocatable :: output_rlat(:), output_rlon(:) + real, allocatable :: output_crot(:), output_srot(:) + real, allocatable :: output_u_data(:,:), output_v_data(:,:) real :: avg_u_diff, avg_v_diff real :: max_u_diff, max_v_diff real(kind=4) :: output_data4 @@ -380,12 +372,12 @@ subroutine interp_vector(grid, interp_opt) data grd218 /3, 614, 428, 12190, -133459, 8, -95000, & 12191, 12191, 0, 64, 25000, 25000, 0, 0, 0, 0, 0, 0, 255, 180*0/ -#if (LSIZE==D) - abstol=0.0001 - ntol = 0 -#elif (LSIZE==4) +#if (LSIZE==4) abstol=0.05 ntol = 10 +#else + abstol=0.0001 + ntol = 0 #endif select case (trim(grid)) @@ -491,7 +483,7 @@ subroutine interp_vector(grid, interp_opt) endif ! Uncomment to generate new baseline file: -! open (13, file="grid"//trim(grid)//".opt"//trim(interp_opt)//".bin_"//REALSIZESTR, access="direct", recl=mo*4) +! open (13, file="grid"//trim(grid)//".opt"//trim(interp_opt)//".bin_"//"LSIZE", access="direct", recl=mo*4) ! write (13, rec=1) real(output_u_data, kind=4) ! write (13, rec=2) real(output_v_data, kind=4) ! close (13) diff --git a/tests/interp_mod_grib2.F90 b/tests/interp_mod_grib2.F90 index 2c589732..4457b5e1 100644 --- a/tests/interp_mod_grib2.F90 +++ b/tests/interp_mod_grib2.F90 @@ -2,14 +2,6 @@ ! ! Kyle Gerheiser June, 2021 -#if (LSIZE==D) -#define REALSIZE 8 -#define REALSIZESTR "8" -#elif (LSIZE==4) -#define REALSIZE 4 -#define REALSIZESTR "4" -#endif - module interp_mod_grib2 use ip_mod implicit none @@ -63,17 +55,17 @@ subroutine interp(grid, interp_opt) character*100 :: baseline_file integer, allocatable :: output_gdtmpl(:) - integer :: ip, ipopt(20), output_gdtlen, output_gdtnum - integer :: km, ibi(1), mi, iret, i, j - integer :: i_output=-1, j_output=-1, mo, no, ibo(1) - integer :: ibi_scalar=0, ibo_scalar + integer :: ip, ipopt(20), output_gdtlen, output_gdtnum + integer :: km, ibi(1), mi, iret, i, j + integer :: i_output=-1, j_output=-1, mo, no, ibo(1) + integer :: ibi_scalar=0, ibo_scalar integer :: num_pts_diff, which_func, ntol integer , parameter :: missing=huge(0) logical*1, allocatable :: output_bitmap(:,:) - real(KIND=REALSIZE), allocatable :: output_rlat(:), output_rlon(:) - real(KIND=REALSIZE), allocatable :: output_data(:,:) + real, allocatable :: output_rlat(:), output_rlon(:) + real, allocatable :: output_data(:,:) real :: station_ref_output(4) real(kind=4), allocatable :: baseline_data(:,:) real :: avgdiff, maxdiff @@ -121,12 +113,12 @@ subroutine interp(grid, interp_opt) 12190000, 226541000, 56, 25000000, 265000000, & 12191000, 12191000, 0, 64, 25000000, 25000000, -90000000, 0/ -#if (LSIZE==D) - abstol=0.0001 - ntol = 0 -#elif (LSIZE==4) +#if (LSIZE==4) abstol=0.05 ntol = 10 +#else + abstol=0.0001 + ntol = 0 #endif select case (trim(grid)) @@ -249,8 +241,8 @@ subroutine interp(grid, interp_opt) allocate (baseline_data(i_output,j_output)) if (trim(grid) .eq. '-1') then - output_rlat = REAL((/ 45.0, 35.0, 40.0, 35.0 /), KIND=REALSIZE) - output_rlon = REAL((/ -100.0, -100.0, -90.0, -120.0 /), KIND=REALSIZE) + output_rlat = REAL((/ 45.0, 35.0, 40.0, 35.0 /)) + output_rlon = REAL((/ -100.0, -100.0, -90.0, -120.0 /)) endif do which_func=1,2 @@ -267,7 +259,7 @@ subroutine interp(grid, interp_opt) endif ! Uncomment to generate new baseline file: -! open (13, file="grid"//trim(grid)//".opt"//trim(interp_opt)//".bin_"//REALSIZESTR, access="direct", recl=mo*4) +! open (13, file="grid"//trim(grid)//".opt"//trim(interp_opt)//".bin_"//"LSIZE", access="direct", recl=mo*4) ! write (13, rec=1) real(output_data, kind=4) ! close (13) @@ -417,18 +409,18 @@ subroutine interp_vector(grid, interp_opt) character*100 :: baseline_file integer, allocatable :: output_gdtmpl(:) - integer :: ip, ipopt(20), output_gdtlen, output_gdtnum - integer :: which_func - integer :: km, ibi(1), mi, iret, i, j - integer :: ibi_scalar = 0, ibo_scalar - integer :: i_output, j_output, mo, no, ibo(1) + integer :: ip, ipopt(20), output_gdtlen, output_gdtnum + integer :: which_func + integer :: km, ibi(1), mi, iret, i, j + integer :: ibi_scalar = 0, ibo_scalar + integer :: i_output, j_output, mo, no, ibo(1) integer :: num_upts_diff, num_vpts_diff, ntol integer, parameter :: missing=huge(0) logical*1, allocatable :: output_bitmap(:,:) - real(KIND=REALSIZE), allocatable :: output_rlat(:), output_rlon(:) - real(KIND=REALSIZE), allocatable :: output_crot(:), output_srot(:) - real(KIND=REALSIZE), allocatable :: output_u_data(:,:), output_v_data(:,:) + real, allocatable :: output_rlat(:), output_rlon(:) + real, allocatable :: output_crot(:), output_srot(:) + real, allocatable :: output_u_data(:,:), output_v_data(:,:) real :: avg_u_diff, avg_v_diff real :: max_u_diff, max_v_diff real(kind=4) :: output_data4 @@ -478,12 +470,12 @@ subroutine interp_vector(grid, interp_opt) 12190000, 226541000, 56, 25000000, 265000000, & 12191000, 12191000, 0, 64, 25000000, 25000000, -90000000, 0/ -#if (LSIZE==D) - abstol=0.0001 - ntol = 0 -#elif (LSIZE==4) +#if (LSIZE==4) abstol=0.05 ntol = 10 +#else + abstol=0.0001 + ntol = 0 #endif select case (trim(grid)) @@ -607,8 +599,8 @@ subroutine interp_vector(grid, interp_opt) allocate (output_bitmap(i_output,j_output)) if (trim(grid) .eq. '-1') then - output_rlat = REAL((/ 45.0, 35.0, 40.0, 90.0 /), KIND=REALSIZE) - output_rlon = REAL((/ -100.0, -100.0, -90.0, 10.0 /), KIND=REALSIZE) + output_rlat = REAL((/ 45.0, 35.0, 40.0, 90.0 /)) + output_rlon = REAL((/ -100.0, -100.0, -90.0, 10.0 /)) output_srot = 0.0 ! no turning of wind output_crot = 1.0 ! no turning of wind endif @@ -633,7 +625,7 @@ subroutine interp_vector(grid, interp_opt) endif ! Uncomment to generate new baseline file: -! open (13, file="grid"//trim(grid)//".opt"//trim(interp_opt)//".bin_"//REALSIZESTR, access="direct", recl=mo*4) +! open (13, file="grid"//trim(grid)//".opt"//trim(interp_opt)//".bin_"//"LSIZE", access="direct", recl=mo*4) ! write (13, rec=1) real(output_u_data, kind=4) ! write (13, rec=2) real(output_v_data, kind=4) ! close (13) diff --git a/tests/test_earth_radius.F90 b/tests/test_earth_radius.F90 index 916593fe..249802a2 100644 --- a/tests/test_earth_radius.F90 +++ b/tests/test_earth_radius.F90 @@ -1,9 +1,3 @@ -#if (LSIZE==D) -#define REALSIZE 8 -#elif (LSIZE==4) -#define REALSIZE 4 -#endif - program test_earth_radius use earth_radius_mod implicit none @@ -11,8 +5,8 @@ program test_earth_radius integer :: igdtlen parameter(igdtlen = 7) integer :: igdtmpl(igdtlen) - real(KIND=REALSIZE) :: eccen_squared - real(KIND=REALSIZE) :: radius + real :: eccen_squared + real :: radius print *,'Testing earth_radius_mod...' diff --git a/tests/test_ipxwafs.F90 b/tests/test_ipxwafs.F90 index a608dde0..86dbcccb 100644 --- a/tests/test_ipxwafs.F90 +++ b/tests/test_ipxwafs.F90 @@ -2,11 +2,6 @@ ! ! Alex Richert, June 2023 -#if (LSIZE==D) -#define REALSIZE 8 -#elif (LSIZE==4) -#define REALSIZE 4 -#endif program test_ipxwafs implicit none @@ -15,15 +10,17 @@ program test_ipxwafs integer :: igdtmpl_thin(19)=0 integer :: igdtmpl_full(19) integer :: ib_thin(1)=0, ib_full(1) - integer :: iret, i, which_func + integer :: iret + integer :: idir=1, km=1, num_opt=73, igdtlen=19 + integer :: i, which_func integer, parameter :: nthin = 3447, nfull = 5329 ! logical(kind=1) :: bitmap_thin(nthin,1)=.true. logical(kind=1) :: bitmap_full(nfull,1) ! - real(KIND=REALSIZE) :: data_thin(nthin,1) - real(KIND=REALSIZE) :: data_thin_contract(nthin,1) - real(KIND=REALSIZE) :: data_full(nfull,1) + real :: data_thin(nthin,1) + real :: data_thin_contract(nthin,1) + real :: data_full(nfull,1) real :: ref_data(10) real, parameter :: abstol=1e-6 @@ -41,20 +38,20 @@ program test_ipxwafs igdtmpl_thin(19) = 64 do i=1,nthin - data_thin(i,1) = real(i,KIND=REALSIZE)/nthin + data_thin(i,1) = real(i)/nthin enddo if (which_func .eq. 1) then - call ipxwafs(1, 3447, 5329, 1, 73, opt_pts, & - 19, igdtmpl_thin, data_thin, & + call ipxwafs(idir, nthin, nfull, km, num_opt, opt_pts, & + igdtlen, igdtmpl_thin, data_thin, & igdtmpl_full, data_full, iret) elseif (which_func .eq. 2) then - call ipxwafs2(1, 3447, 5329, 1, 73, opt_pts, & - 19, igdtmpl_thin, data_thin, ib_thin, bitmap_thin, & + call ipxwafs2(idir, nthin, nfull, km, num_opt, opt_pts, & + igdtlen, igdtmpl_thin, data_thin, ib_thin, bitmap_thin, & igdtmpl_full, data_full, ib_full, bitmap_full, iret) elseif (which_func .eq. 3) then - call ipxwafs3(1, 3447, 5329, 1, 73, opt_pts, & - 19, igdtmpl_thin, data_thin, ib_thin, bitmap_thin, & + call ipxwafs3(idir, nthin, nfull, km, num_opt, opt_pts, & + igdtlen, igdtmpl_thin, data_thin, ib_thin, bitmap_thin, & igdtmpl_full, data_full, ib_full, bitmap_full, iret) endif @@ -74,16 +71,16 @@ program test_ipxwafs igdtmpl_full(9)=73 igdtmpl_full(17)=1250000 if (which_func .eq. 1) then - call ipxwafs(-1, 3447, 5329, 1, 73, opt_pts, & - 19, igdtmpl_thin, data_thin_contract, & + call ipxwafs(-idir, nthin, nfull, km, num_opt, opt_pts, & + igdtlen, igdtmpl_thin, data_thin_contract, & igdtmpl_full, data_full, iret) elseif (which_func .eq. 2) then - call ipxwafs2(-1, 3447, 5329, 1, 73, opt_pts, & - 19, igdtmpl_thin, data_thin_contract, ib_thin, bitmap_thin, & + call ipxwafs2(-idir, nthin, nfull, km, num_opt, opt_pts, & + igdtlen, igdtmpl_thin, data_thin_contract, ib_thin, bitmap_thin, & igdtmpl_full, data_full, ib_full, bitmap_full, iret) elseif (which_func .eq. 3) then - call ipxwafs3(-1, 3447, 5329, 1, 73, opt_pts, & - 19, igdtmpl_thin, data_thin_contract, ib_thin, bitmap_thin, & + call ipxwafs3(-idir, nthin, nfull, km, num_opt, opt_pts, & + igdtlen, igdtmpl_thin, data_thin_contract, ib_thin, bitmap_thin, & igdtmpl_full, data_full, ib_full, bitmap_full, iret) endif if (.not. all(abs(data_thin-data_thin_contract) -#include - -#include "iplib.h" - /************************************************************** Unit test to ensure the 'c' wrapper routine for gdswzd is working. @@ -12,20 +7,30 @@ Tests the mixed precision version of gdswzd. **************************************************************/ -#if(LSIZE==D) -#define REALTYPE double -#elif(LSIZE==4) +#include +#include + +#include "iplib.h" + +#if(LSIZE==4) #define REALTYPE float +#else +#define REALTYPE double +#endif +#if(LSIZE==8) +#define INTTYPE long +#else +#define INTTYPE int #endif -void gdswzd_grib1(int *, int, int, REALTYPE, - REALTYPE *, REALTYPE *, REALTYPE *, REALTYPE *, int *, +void gdswzd_grib1(INTTYPE *, INTTYPE, INTTYPE, REALTYPE, + REALTYPE *, REALTYPE *, REALTYPE *, REALTYPE *, INTTYPE *, REALTYPE *, REALTYPE *, REALTYPE *, REALTYPE *, REALTYPE *, REALTYPE *, REALTYPE *); int main() { - int kgds[200]; - int iopt, npts, nret; + INTTYPE kgds[200]; + INTTYPE iopt, npts, nret; REALTYPE fill; REALTYPE *xpts, *ypts, *rlon, *rlat; REALTYPE *crot, *srot, *xlon, *xlat, *ylon, *ylat, *area; diff --git a/tests/tst_gdswzd_grib2.c b/tests/tst_gdswzd_grib2.c index 27b019ee..5082fb0f 100644 --- a/tests/tst_gdswzd_grib2.c +++ b/tests/tst_gdswzd_grib2.c @@ -1,8 +1,3 @@ -#include -#include - -#include "ip2lib.h" - /************************************************************** Unit test to ensure the 'c' wrapper routine for gdswzd is working. @@ -12,16 +7,27 @@ Tests the mixed precision version of gdswzd. **************************************************************/ +#include +#include -int main() -{ - int *igdtmpl; - int igdtnum, igdtlen, iopt, npts, nret; -#if(LSIZE==D) -#define REALTYPE double -#elif(LSIZE==4) +#include "ip2lib.h" + +#if(LSIZE==4) #define REALTYPE float +#else +#define REALTYPE double +#endif +#if(LSIZE==8) +#define INTTYPE long +#else +#define INTTYPE int #endif + + +int main() +{ + INTTYPE *igdtmpl; + INTTYPE igdtnum, igdtlen, iopt, npts, nret; REALTYPE fill; REALTYPE *xpts, *ypts, *rlon, *rlat; REALTYPE *crot, *srot, *xlon, *xlat, *ylon, *ylat, *area; @@ -32,7 +38,7 @@ int main() igdtnum = 1; igdtlen = 22; - igdtmpl = (int *) malloc(igdtlen * sizeof(int)); + igdtmpl = (INTTYPE *) malloc(igdtlen * sizeof(INTTYPE)); igdtmpl[0] = 6; igdtmpl[1] = 255;