From 10ccd65ac9fbf8b8f4bb35d991c4f3d6d08c1115 Mon Sep 17 00:00:00 2001 From: Kyle Gerheiser <3209794+kgerheiser@users.noreply.github.com> Date: Wed, 8 Sep 2021 15:22:49 -0400 Subject: [PATCH 1/4] Create Findwgrib2.cmake to handle stock (non-CMake) build of wgrib2 FindWgrib2.cmake uses the target wgrib2::wgrib2 instead of wgrib2::wgrib2_lib and wgrib2::wgrib2_api --- .../workflows/debug-docs-test_coverage.yml | 12 ++++-- .github/workflows/intel.yml | 22 ++++++---- .github/workflows/linux-mac-nceplibs-mpi.yml | 23 +++++++---- .github/workflows/netcdf-versions.yml | 22 ++++++---- cmake/Findwgrib2.cmake | 41 +++++++++++++++++++ sorc/chgres_cube.fd/CMakeLists.txt | 3 +- 6 files changed, 93 insertions(+), 30 deletions(-) create mode 100644 cmake/Findwgrib2.cmake diff --git a/.github/workflows/debug-docs-test_coverage.yml b/.github/workflows/debug-docs-test_coverage.yml index 6e481a8dc..0f920f471 100644 --- a/.github/workflows/debug-docs-test_coverage.yml +++ b/.github/workflows/debug-docs-test_coverage.yml @@ -26,7 +26,7 @@ jobs: uses: actions/cache@v2 with: path: ~/esmf - key: esmf-8.0.1-${{ runner.os }} + key: esmf-8.0.1-${{ runner.os }}3 - name: build-esmf if: steps.cache-esmf.outputs.cache-hit != 'true' @@ -53,7 +53,7 @@ jobs: uses: actions/cache@v2 with: path: ~/jasper - key: jasper-2.0.25-${{ runner.os }} + key: jasper-2.0.25-${{ runner.os }}3 - name: build-jasper if: steps.cache-jasper.outputs.cache-hit != 'true' @@ -62,7 +62,7 @@ jobs: tar zxf version-2.0.25.tar.gz cd jasper-version-2.0.25 mkdir build-jasper && cd build-jasper - cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper + cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper -DJAS_ENABLE_SHARED=OFF make -j2 make install @@ -71,7 +71,7 @@ jobs: uses: actions/cache@v2 with: path: ~/nceplibs - key: nceplibs-1.3.0-${{ runner.os }} + key: nceplibs-1.3.0-${{ runner.os }}3 - name: build-nceplibs if: steps.cache-nceplibs.outputs.cache-hit != 'true' @@ -97,6 +97,10 @@ jobs: export CC=mpicc export CXX=mpicxx export FC=mpifort + # Findwgrib2 in module form does not search -version + # as NCEPLIBS installs it + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:~/jasper/lib;~/jasper/lib64" + export wgrib2_ROOT=`find ~/nceplibs -type d -maxdepth 1 -iname "wgrib2*"` cmake .. -DCMAKE_PREFIX_PATH='~/jasper;~/nceplibs' -DCMAKE_BUILD_TYPE=Debug -DENABLE_DOCS=On -DCMAKE_Fortran_FLAGS="-g -fprofile-arcs -ftest-coverage -O0" make -j2 diff --git a/.github/workflows/intel.yml b/.github/workflows/intel.yml index e4266dc6d..cb0231749 100644 --- a/.github/workflows/intel.yml +++ b/.github/workflows/intel.yml @@ -37,7 +37,7 @@ jobs: uses: actions/cache@v2 with: path: ~/netcdf - key: netcdf-c-$4.7.4-{{ runner.os }}-intel + key: netcdf-c-$4.7.4-{{ runner.os }}-intel3 - name: build-hdf5 if: steps.cache-netcdf.outputs.cache-hit != 'true' @@ -46,7 +46,7 @@ jobs: wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.7/src/hdf5-1.10.7.tar.gz &> /dev/null tar -xzf hdf5-1.10.7.tar.gz pushd hdf5-1.10.7 - ./configure --prefix=${HOME}/netcdf --enable-parallel --disable-tools --disable-fortran --disable-cxx --enable-parallel-tests + ./configure --prefix=${HOME}/netcdf --enable-parallel --disable-tools --disable-fortran --disable-cxx --enable-parallel-tests --disable-shared --disable-shared --enable-static make -j2 make install @@ -59,7 +59,7 @@ jobs: wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-c-4.7.4.tar.gz &> /dev/null tar -xzf netcdf-c-4.7.4.tar.gz pushd netcdf-c-4.7.4 - ./configure --prefix=${HOME}/netcdf --disable-dap --disable-utilities + ./configure --prefix=${HOME}/netcdf --disable-dap --disable-utilities --disable-shared make -j2 make install @@ -72,10 +72,11 @@ jobs: export FC=mpiifort export CPPFLAGS=-I${HOME}/netcdf/include export LDFLAGS=-L${HOME}/netcdf/lib + export LIBS=`nc-config --libs` wget https://github.com/Unidata/netcdf-fortran/archive/v4.5.3.tar.gz &> /dev/null tar -xzf v4.5.3.tar.gz pushd netcdf-fortran-4.5.3 - ./configure --prefix=${HOME}/netcdf + ./configure --prefix=${HOME}/netcdf --disable-shared make -j2 make install @@ -84,7 +85,7 @@ jobs: uses: actions/cache@v2 with: path: ~/esmf - key: esmf-8.0.1-${{ runner.os }}-intel + key: esmf-8.0.1-${{ runner.os }}-intel3 - name: build-esmf if: steps.cache-esmf.outputs.cache-hit != 'true' @@ -103,6 +104,7 @@ jobs: export ESMF_NETCDF=split export ESMF_NETCDF_INCLUDE=${HOME}/netcdf/include export ESMF_NETCDF_LIBPATH=${HOME}/netcdf/lib + export ESMF_NETCDF_LIBS="-lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz" make -j2 make install @@ -111,7 +113,7 @@ jobs: uses: actions/cache@v2 with: path: ~/jasper - key: jasper-2.0.25-${{ runner.os }}-intel + key: jasper-2.0.25-${{ runner.os }}-intel3 - name: build-jasper if: steps.cache-jasper.outputs.cache-hit != 'true' @@ -120,7 +122,7 @@ jobs: tar zxf version-2.0.25.tar.gz cd jasper-version-2.0.25 mkdir build-jasper && cd build-jasper - cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper + cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper -DJAS_ENABLE_SHARED=OFF make -j2 make install @@ -135,7 +137,7 @@ jobs: uses: actions/cache@v2 with: path: ~/nceplibs - key: nceplibs-1.3.0-${{ runner.os }}-intel + key: nceplibs-1.3.0-${{ runner.os }}-intel3 - name: build-nceplibs if: steps.cache-nceplibs.outputs.cache-hit != 'true' @@ -158,6 +160,10 @@ jobs: export ESMFMKFILE=~/esmf/lib/esmf.mk cd ufs_utils mkdir build && cd build + # Findwgrib2 in module form does not search -version + # as NCEPLIBS installs it + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:~/jasper/lib;~/jasper/lib64" + export wgrib2_ROOT=`find ~/nceplibs -type d -maxdepth 1 -iname "wgrib2*"` cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH='~;~/jasper;~/nceplibs;~/netcdf' make -j2 diff --git a/.github/workflows/linux-mac-nceplibs-mpi.yml b/.github/workflows/linux-mac-nceplibs-mpi.yml index e0f29b610..4776bec3b 100644 --- a/.github/workflows/linux-mac-nceplibs-mpi.yml +++ b/.github/workflows/linux-mac-nceplibs-mpi.yml @@ -75,7 +75,7 @@ jobs: uses: actions/cache@v2 with: path: ~/netcdf - key: netcdf-c-${{ matrix.netcdf_version }}-${{ runner.os }}-${{ matrix.mpi_type }} + key: netcdf-c-${{ matrix.netcdf_version }}-${{ runner.os }}-${{ matrix.mpi_type }}3 - name: build-hdf5 if: steps.cache-netcdf.outputs.cache-hit != 'true' @@ -84,7 +84,7 @@ jobs: wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.7/src/hdf5-1.10.7.tar.gz &> /dev/null tar -xzf hdf5-1.10.7.tar.gz pushd hdf5-1.10.7 - ./configure --prefix=${HOME}/netcdf --enable-parallel --disable-tools --disable-fortran --disable-cxx --enable-parallel-tests + ./configure --prefix=${HOME}/netcdf --enable-parallel --disable-tools --disable-fortran --disable-cxx --enable-parallel-tests --disable-shared --enable-static make -j2 make install @@ -97,7 +97,7 @@ jobs: wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-c-${{ matrix.netcdf_version }}.tar.gz &> /dev/null tar -xzf netcdf-c-${{ matrix.netcdf_version }}.tar.gz cd netcdf-c-${{ matrix.netcdf_version }} - ./configure --prefix=${HOME}/netcdf --disable-dap --disable-utilities + ./configure --prefix=${HOME}/netcdf --disable-dap --disable-utilities --disable-shared make -j2 make install @@ -110,10 +110,11 @@ jobs: export FC=mpifort export CPPFLAGS=-I${HOME}/netcdf/include export LDFLAGS=-L${HOME}/netcdf/lib + export LIBS=`nc-config --libs` wget https://github.com/Unidata/netcdf-fortran/archive/v4.5.3.tar.gz &> /dev/null tar -xzf v4.5.3.tar.gz pushd netcdf-fortran-4.5.3 - ./configure --prefix=${HOME}/netcdf + ./configure --prefix=${HOME}/netcdf --disable-shared make -j2 make install @@ -122,7 +123,7 @@ jobs: uses: actions/cache@v2 with: path: ~/esmf - key: esmf--8.0.1-${{ runner.os }}-${{ matrix.mpi_type }}-netcdf-${{ matrix.netcdf_version }} + key: esmf--8.0.1-${{ runner.os }}-${{ matrix.mpi_type }}-netcdf-${{ matrix.netcdf_version }}3 - name: build-esmf if: steps.cache-esmf.outputs.cache-hit != 'true' @@ -146,6 +147,7 @@ jobs: export ESMF_NETCDF=split export ESMF_NETCDF_INCLUDE=${HOME}/netcdf/include export ESMF_NETCDF_LIBPATH=${HOME}/netcdf/lib + export ESMF_NETCDF_LIBS="-lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz" make -j2 make install @@ -154,7 +156,7 @@ jobs: uses: actions/cache@v2 with: path: ~/jasper - key: jasper-2.0.25-${{ runner.os }} + key: jasper-2.0.25-${{ runner.os }}3 - name: build-jasper if: steps.cache-jasper.outputs.cache-hit != 'true' @@ -165,7 +167,7 @@ jobs: tar zxf version-2.0.25.tar.gz cd jasper-version-2.0.25 mkdir build-jasper && cd build-jasper - cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper + cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper -DJAS_ENABLE_SHARED=OFF make -j2 make install @@ -187,7 +189,7 @@ jobs: uses: actions/cache@v2 with: path: ~/nceplibs - key: nceplibs-${{ matrix.nceplibs_version }}-${{ runner.os }}-${{ matrix.mpi_type }}-${{ hashFiles('nceplibs/hash.txt') }} + key: nceplibs-${{ matrix.nceplibs_version }}-${{ runner.os }}-${{ matrix.mpi_type }}-${{ hashFiles('nceplibs/hash.txt') }}3 - name: build-nceplibs if: steps.cache-nceplibs.outputs.cache-hit != 'true' @@ -212,6 +214,11 @@ jobs: export CC=mpicc export CXX=mpicxx export FC=mpifort + # Findwgrib2 in module form does not search -version + # as NCEPLIBS installs it + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:~/jasper/lib;~/jasper/lib64" + export DYLD_LIBRARY_PATH="${LD_LIBRARY_PATH}:~/jasper/lib;~/jasper/lib64" + export wgrib2_ROOT=`find ~/nceplibs -type d -maxdepth 1 -iname "wgrib2*"` cmake .. -DCMAKE_PREFIX_PATH='~/jasper;~/nceplibs;~/netcdf' make -j2 diff --git a/.github/workflows/netcdf-versions.yml b/.github/workflows/netcdf-versions.yml index 53cad1f20..c286011a7 100644 --- a/.github/workflows/netcdf-versions.yml +++ b/.github/workflows/netcdf-versions.yml @@ -28,7 +28,7 @@ jobs: uses: actions/cache@v2 with: path: ~/netcdf - key: netcdf-c-${{ matrix.netcdf_version }}-${{ runner.os }} + key: netcdf-c-${{ matrix.netcdf_version }}-${{ runner.os }}3 - name: build-hdf5 if: steps.cache-netcdf.outputs.cache-hit != 'true' @@ -37,7 +37,7 @@ jobs: wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.7/src/hdf5-1.10.7.tar.gz &> /dev/null tar -xzf hdf5-1.10.7.tar.gz pushd hdf5-1.10.7 - ./configure --prefix=${HOME}/netcdf --enable-parallel --disable-tools --disable-fortran --disable-cxx --enable-parallel-tests + ./configure --prefix=${HOME}/netcdf --enable-parallel --disable-tools --disable-fortran --disable-cxx --enable-parallel-tests --disable-shared --enable-static make -j2 make install @@ -50,7 +50,7 @@ jobs: wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-c-${{ matrix.netcdf_version }}.tar.gz &> /dev/null tar -xzf netcdf-c-${{ matrix.netcdf_version }}.tar.gz cd netcdf-c-${{ matrix.netcdf_version }} - ./configure --prefix=${HOME}/netcdf --disable-dap --disable-utilities + ./configure --prefix=${HOME}/netcdf --disable-dap --disable-utilities --disable-shared make -j2 make install @@ -63,10 +63,11 @@ jobs: export FC=mpifort export CPPFLAGS=-I${HOME}/netcdf/include export LDFLAGS=-L${HOME}/netcdf/lib + export LIBS=`nc-config --libs` wget https://github.com/Unidata/netcdf-fortran/archive/v4.5.3.tar.gz &> /dev/null tar -xzf v4.5.3.tar.gz pushd netcdf-fortran-4.5.3 - ./configure --prefix=${HOME}/netcdf + ./configure --prefix=${HOME}/netcdf --disable-shared make -j2 make install @@ -75,7 +76,7 @@ jobs: uses: actions/cache@v2 with: path: ~/esmf - key: esmf-8.0.1-${{ runner.os }}-netcdf-${{ matrix.netcdf_version }} + key: esmf-8.0.1-${{ runner.os }}-netcdf-${{ matrix.netcdf_version }}3 - name: build-esmf #if: steps.cache-esmf.outputs.cache-hit != 'true' @@ -94,6 +95,7 @@ jobs: export ESMF_NETCDF=split export ESMF_NETCDF_INCLUDE=${HOME}/netcdf/include export ESMF_NETCDF_LIBPATH=${HOME}/netcdf/lib + export ESMF_NETCDF_LIBS="-lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz" make -j2 make install @@ -102,7 +104,7 @@ jobs: uses: actions/cache@v2 with: path: ~/jasper - key: jasper-2.0.25-${{ runner.os }} + key: jasper-2.0.25-${{ runner.os }}3 - name: build-jasper if: steps.cache-jasper.outputs.cache-hit != 'true' @@ -111,7 +113,7 @@ jobs: tar zxf version-2.0.25.tar.gz cd jasper-version-2.0.25 mkdir build-jasper && cd build-jasper - cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper + cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper -DJAS_ENABLE_SHARED=OFF make -j2 make install @@ -120,7 +122,7 @@ jobs: uses: actions/cache@v2 with: path: ~/nceplibs - key: nceplibs-1.3.0-${{ runner.os }}-netcdf-${{ matrix.netcdf_version }} + key: nceplibs-1.3.0-${{ runner.os }}-netcdf-${{ matrix.netcdf_version }}3 - name: build-nceplibs if: steps.cache-nceplibs.outputs.cache-hit != 'true' @@ -146,6 +148,10 @@ jobs: export CC=mpicc export CXX=mpicxx export FC=mpifort + # Findwgrib2 in module form does not search -version + # as NCEPLIBS installs it + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:~/jasper/lib;~/jasper/lib64" + export wgrib2_ROOT=`find ~/nceplibs -type d -maxdepth 1 -iname "wgrib2*"` cmake .. -DCMAKE_PREFIX_PATH='~/jasper;~/nceplibs;~/netcdf' -DCMAKE_BUILD_TYPE=Debug make -j2 diff --git a/cmake/Findwgrib2.cmake b/cmake/Findwgrib2.cmake new file mode 100644 index 000000000..431363cfb --- /dev/null +++ b/cmake/Findwgrib2.cmake @@ -0,0 +1,41 @@ +# This module produces the target wgrib2::wgrib2 + +find_path(WGRIB2_INCLUDES wgrib2api.mod) +find_library(WGRIB2_LIB libwgrib2.a) +find_library(WGRIB2_API_LIB libwgrib2_api.a) + +add_library(wgrib2::wgrib2 UNKNOWN IMPORTED) + +# Library builds are different between CMake build and the make build. +# libwgrib2_api.a is only necessary in the CMake build and must come first when linking +if(WGRIB2_API_LIB) + # CMake build. Need both. + set(first_lib ${WGRIB2_API_LIB}) + set(second_lib ${WGRIB2_LIB}) +else() + # Makefile build. Only need libwgrib2.a + set(FIRST_LIB ${WGRIB2_LIB}) + set(second_lib "") +endif() + +set_target_properties(wgrib2::wgrib2 PROPERTIES + IMPORTED_LOCATION "${first_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${WGRIB2_INCLUDES}" + INTERFACE_LINK_LIBRARIES "${second_lib}") + +set(WGRIB2_LIBRARIES "${first_lib}" "${second_lib}") + +find_program(WGRIB2_EXE wgrib2) +execute_process(COMMAND ${WGRIB2_EXE} --version OUTPUT_VARIABLE version_str) + +# Wgrib2 changed how it output --version from "v0.x.y.z" to "vx.y.z" starting in wgrib2 3.0 +if(version_str MATCHES "^v0.*") + string(SUBSTRING "${version_str}" 3 5 version) +else() + string(SUBSTRING "${version_str}" 1 5 version) +endif() + +find_package_handle_standard_args(wgrib2 + REQUIRED_VARS WGRIB2_LIBRARIES WGRIB2_INCLUDES WGRIB2_EXE + VERSION_VAR version + ) diff --git a/sorc/chgres_cube.fd/CMakeLists.txt b/sorc/chgres_cube.fd/CMakeLists.txt index 90101ab0b..7b6ad9388 100644 --- a/sorc/chgres_cube.fd/CMakeLists.txt +++ b/sorc/chgres_cube.fd/CMakeLists.txt @@ -49,8 +49,7 @@ target_link_libraries( sp::sp_d w3nco::w3nco_d esmf - wgrib2::wgrib2_lib - wgrib2::wgrib2_api + wgrib2::wgrib2 MPI::MPI_Fortran NetCDF::NetCDF_Fortran) From 284edfbda270c629f1d009cd0d7f5d1c9a27a406 Mon Sep 17 00:00:00 2001 From: RatkoVasic-NOAA <37597874+RatkoVasic-NOAA@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:42:05 -0400 Subject: [PATCH 2/4] filter_topo - Add extrapolation of regional fields to halo points (#571) Fixes a bug when running the filter_topo program in regional mode. Several variables are allocated, but their values along the halo are never initialized. This lead to unstable results. Add a routine to extrapolate fields from the grid interior to the halo. Fixes #105. --- .../filter_topo.fd/filter_topo.F90 | 35 +++++++++++- sorc/grid_tools.fd/filter_topo.fd/utils.F90 | 36 ++++++++++++ tests/filter_topo/CMakeLists.txt | 4 ++ tests/filter_topo/ftst_fill_regional_halo.F90 | 56 +++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 tests/filter_topo/ftst_fill_regional_halo.F90 diff --git a/sorc/grid_tools.fd/filter_topo.fd/filter_topo.F90 b/sorc/grid_tools.fd/filter_topo.fd/filter_topo.F90 index b93c77edb..d4b5d672a 100644 --- a/sorc/grid_tools.fd/filter_topo.fd/filter_topo.F90 +++ b/sorc/grid_tools.fd/filter_topo.fd/filter_topo.F90 @@ -748,6 +748,9 @@ subroutine read_grid_file(regional) call fill_cubic_grid_halo(geolat_c, geolat_c, ng, 1, 1, 1, 1) if(.not. nested) call fill_bgrid_scalar_corners(geolon_c, ng, npx, npy, isd, jsd, XDir) if(.not. nested) call fill_bgrid_scalar_corners(geolat_c, ng, npx, npy, isd, jsd, YDir) + else + call fill_regional_halo(geolon_c, ng) + call fill_regional_halo(geolat_c, ng) endif !--- compute grid cell center @@ -1041,6 +1044,12 @@ subroutine read_topo_file(regional) call fill_cubic_grid_halo(mask, mask, ng, 0, 0, 1, 1) endif + if( regional ) then + call fill_regional_halo(oro, ng) + oro(:,:,:) = max(oro(:,:,:),0.) + call fill_regional_halo(mask, ng) + mask(:,:,:) = min(max(mask(:,:,:),0.),1.) + endif end subroutine read_topo_file @@ -1184,7 +1193,7 @@ subroutine FV3_zs_filter (is, ie, js, je, isd, ied, jsd, jed, npx, npy, npx_glob real, intent(IN):: sin_sg(4,isd:ied,jsd:jed,ntiles) real, intent(IN):: stretch_fac logical, intent(IN) :: nested, regional - real, intent(inout):: phis(isd:ied,jsd,jed,ntiles) + real, intent(inout):: phis(isd:ied,jsd:jed,ntiles) real:: cd2 integer mdim, n_del2, n_del4 @@ -1391,6 +1400,16 @@ subroutine two_delta_filter(is, ie, js, je, isd, ied, jsd, jed, npx, npy, ntiles a1(npx+1) = c3*q(npx,j,t) + c2*q(npx+1,j,t) + c1*q(npx+2,j,t) endif + if ( regional .and. grid_type<3 ) then + a1(0) = c1*q(-1,j,t) + c2*q(-1,j,t) + c3*q(0,j,t) + a1(2) = c3*q(1,j,t) + c2*q(2,j,t) + c1*q(3,j,t) + a1(1) = 0.5*(a1(0) + a1(2)) + + a1(npx-1) = c1*q(npx-3,j,t) + c2*q(npx-2,j,t) + c3*q(npx-1,j,t) + a1(npx+1) = c3*q(npx,j,t) + c2*q(npx+1,j,t) + c1*q(npx+2,j,t) + a1(npx) = 0.5*(a1(npx-1)+a1(npx+1)) + endif + if ( filter_type == 0 ) then do i=is-1, ie+1 if( abs(3.*(a1(i)+a1(i+1)-2.*q(i,j,t))) > abs(a1(i)-a1(i+1)) ) then @@ -1446,6 +1465,20 @@ subroutine two_delta_filter(is, ie, js, je, isd, ied, jsd, jed, npx, npy, ntiles enddo endif + if ( regional .and. grid_type<3 ) then + do i=is,ie + a2(i,0) = c1*q(i,-2,t) + c2*q(i,-1,t) + c3*q(i,0,t) + a2(i,2) = c3*q(i,1,t) + c2*q(i,2,t) + c1*q(i,3,t) + a2(i,1) = 0.5*(a2(i,0) + a2(i,2)) + enddo + + do i=is,ie + a2(i,npy-1) = c1*q(i,npy-3,t) + c2*q(i,npy-2,t) + c3*q(i,npy-1,t) + a2(i,npy+1) = c3*q(i,npy,t) + c2*q(i,npy+1,t) + c1*q(i,npy+2,t) + a2(i,npy) = 0.5*(a2(i,npy-1)+a2(i,npy+1)) + enddo + endif + if ( filter_type == 0 ) then do j=js-1,je+1 do i=is,ie diff --git a/sorc/grid_tools.fd/filter_topo.fd/utils.F90 b/sorc/grid_tools.fd/filter_topo.fd/utils.F90 index 7927e769b..1444495ae 100644 --- a/sorc/grid_tools.fd/filter_topo.fd/utils.F90 +++ b/sorc/grid_tools.fd/filter_topo.fd/utils.F90 @@ -60,6 +60,42 @@ subroutine read_namelist end subroutine read_namelist +!> This routine extrapolate geolat_c and geolon_c halo points for the +!! regional standalone grid. Halo points are needed for dxc and dyc +!! calculation. +!! +!! @param[in,out] data - field to be extrapolated +!! @param[in] halo - number of halo rows/columns +!! @author Ratko Vasic (NCEP/EMC) + subroutine fill_regional_halo(data, halo) + integer, intent(in) :: halo + real, dimension(1-halo:,1-halo:,:), intent(inout) :: data + integer :: h, i_st, i_ed, j_st, j_ed + + i_st=lbound(data,1)+halo + i_ed=ubound(data,1)-halo + j_st=lbound(data,2)+halo + j_ed=ubound(data,2)-halo + + do h = 1, halo + data(i_st:i_ed, j_st-1 , :) = 2* data(i_st:i_ed, j_st , :) - data(i_st:i_ed, j_st+1 , :)! north + data(i_st:i_ed, j_ed+1 , :) = 2* data(i_st:i_ed, j_ed , :) - data(i_st:i_ed, j_ed-1 , :)! south + data(i_st-1 , j_st:j_ed, :) = 2* data(i_st , j_st:j_ed, :) - data(i_st+1 , j_st:j_ed, :)! east + data(i_ed+1 , j_st:j_ed, :) = 2* data(i_ed , j_st:j_ed, :) - data(i_ed-1 , j_st:j_ed, :)! west + + data(i_st-1, j_st-1, :) = (data(i_st-1, j_st, :) + data(i_st, j_st-1, :))*0.5 !NW Corner + data(i_ed+1, j_st-1, :) = (data(i_ed+1, j_st, :) + data(i_ed, j_st-1, :))*0.5 !NE Corner + data(i_st-1, j_ed+1, :) = (data(i_st-1, j_ed, :) + data(i_st, j_ed+1, :))*0.5 !SW Corner + data(i_ed+1, j_ed+1, :) = (data(i_ed+1, j_ed, :) + data(i_ed, j_ed+1, :))*0.5 !SE Corner + + i_st=i_st-1 + i_ed=i_ed+1 + j_st=j_st-1 + j_ed=j_ed+1 + enddo + + end subroutine fill_regional_halo + !> Prints an error message to standard output, !! then halts program execution with a !! bad status. diff --git a/tests/filter_topo/CMakeLists.txt b/tests/filter_topo/CMakeLists.txt index 9c4501438..0928b3e24 100644 --- a/tests/filter_topo/CMakeLists.txt +++ b/tests/filter_topo/CMakeLists.txt @@ -21,3 +21,7 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E copy add_executable(ftst_read_filter_topo_nml ftst_readnml.F90) add_test(NAME filter_topo-ftst_read_namelist COMMAND ftst_read_filter_topo_nml) target_link_libraries(ftst_read_filter_topo_nml filter_topo_lib) + +add_executable(ftst_fill_regional_halo ftst_fill_regional_halo.F90) +add_test(NAME filter_topo-ftst_fill_regional_halo COMMAND ftst_fill_regional_halo) +target_link_libraries(ftst_fill_regional_halo filter_topo_lib) diff --git a/tests/filter_topo/ftst_fill_regional_halo.F90 b/tests/filter_topo/ftst_fill_regional_halo.F90 new file mode 100644 index 000000000..de57b6b00 --- /dev/null +++ b/tests/filter_topo/ftst_fill_regional_halo.F90 @@ -0,0 +1,56 @@ +! Unit test for filter_topo routine "fill_regional_halo". +! +! Author Ratko Vasic + + program fill_halo + + use utils + + implicit none + + integer :: halo,ix,jx,i,j + + real, allocatable :: testdata(:,:,:) + + print*, "Starting test of filter_topo routine fill_regional_halo" + + halo = 3 + ix=6 + jx=9 + + allocate(testdata(1-halo:ix+halo,1-halo:jx+halo,1)) + +! Initialize whole domain (including halo points) to zero + testdata(:,:,:)=0. + +! Initialize inner domain + do j=1,jx + do i=1,ix + testdata(i,j,1)=10*i+j + enddo + enddo + +!!! do j=1-halo,jx+halo +!!! write(0,101) testdata(1-halo:ix+halo,j,1) +!!! enddo +!!!101 format(12(f9.5,x)) + +! Fill halo points + call fill_regional_halo(testdata, halo) + +!!! print* +!!! do j=1-halo,jx+halo +!!! write(0,101) testdata(1-halo:ix+halo,j,1) +!!! enddo + + if(testdata(-2,-2,1)== 5.5 .and. testdata(-2,12,1)== 14.5 .and. & + testdata( 9,-2,1)== 65.5 .and. testdata( 9,12,1)== 74.5) then + print*, "OK" + print*, "SUCCESS!" + else + stop 22 + endif + + deallocate(testdata) + + end program fill_halo From 1b274c7fe1eb5cb1b0e1be6a8735dbcc8633a670 Mon Sep 17 00:00:00 2001 From: Kyle Gerheiser <3209794+kgerheiser@users.noreply.github.com> Date: Thu, 30 Sep 2021 15:25:01 -0400 Subject: [PATCH 3/4] Use new location of libraries for WCOSS Cray --- modulefiles/build.wcoss_cray.intel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modulefiles/build.wcoss_cray.intel b/modulefiles/build.wcoss_cray.intel index c6e297d28..d8bdc424d 100644 --- a/modulefiles/build.wcoss_cray.intel +++ b/modulefiles/build.wcoss_cray.intel @@ -16,7 +16,7 @@ module load alps/5.2.4-2.0502.9822.32.1.ari module load cray-netcdf/4.3.3.1 module load cray-hdf5/1.8.14 -module use /usrx/local/nceplibs/NCEPLIBS/cmake/install/NCEPLIBS-v1.2.0/modules +module use /usrx/local/nceplibs/NCEPLIBS/cmake/install/NCEPLIBS-v1.3.0/modules module load bacio/2.4.1 module load g2/3.4.1 module load ip/3.3.3 From 9b77a821a275f6ee26aed6ef27fffbe39d990d38 Mon Sep 17 00:00:00 2001 From: kgerheiser Date: Mon, 4 Oct 2021 09:38:31 -0400 Subject: [PATCH 4/4] Fix variable name --- cmake/Findwgrib2.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Findwgrib2.cmake b/cmake/Findwgrib2.cmake index 431363cfb..68b8833c4 100644 --- a/cmake/Findwgrib2.cmake +++ b/cmake/Findwgrib2.cmake @@ -14,7 +14,7 @@ if(WGRIB2_API_LIB) set(second_lib ${WGRIB2_LIB}) else() # Makefile build. Only need libwgrib2.a - set(FIRST_LIB ${WGRIB2_LIB}) + set(first_lib ${WGRIB2_LIB}) set(second_lib "") endif()