Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for bitmaps #768

Merged
merged 46 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4e7fde8
bitmap test file
AlysonStahl-NOAA Nov 5, 2024
2e9cf89
add test file
AlysonStahl-NOAA Nov 5, 2024
eef84e9
copy test data
AlysonStahl-NOAA Nov 5, 2024
77d3b41
Update test_bitmap.F90
AlysonStahl-NOAA Nov 12, 2024
43eb3db
Merge branch 'develop' into as_bitmap
AlysonStahl-NOAA Nov 13, 2024
42f1e05
Update test_bitmap.F90
AlysonStahl-NOAA Nov 13, 2024
3750879
debug memcheck
AlysonStahl-NOAA Nov 14, 2024
e24f72e
Update test_bitmap.F90
AlysonStahl-NOAA Nov 15, 2024
2b223d2
debug test coverage
AlysonStahl-NOAA Nov 15, 2024
e9ffe0e
debug workflows
AlysonStahl-NOAA Nov 15, 2024
1f2ddde
fix test coverage
AlysonStahl-NOAA Nov 15, 2024
18a986d
debug failing workflows
AlysonStahl-NOAA Nov 15, 2024
9170d2c
Update test_bitmap.F90
AlysonStahl-NOAA Nov 15, 2024
decec32
debugging
AlysonStahl-NOAA Nov 15, 2024
fe81cea
Update test_bitmap.F90
AlysonStahl-NOAA Nov 15, 2024
ae6ae36
debugging memory errors
AlysonStahl-NOAA Nov 15, 2024
96aec93
undo last change
AlysonStahl-NOAA Nov 15, 2024
556559a
debug
AlysonStahl-NOAA Nov 15, 2024
4527471
Update test_bitmap.F90
AlysonStahl-NOAA Nov 15, 2024
d718e8e
debug
AlysonStahl-NOAA Nov 15, 2024
867e553
Update test_bitmap.F90
AlysonStahl-NOAA Nov 15, 2024
da20177
remove comments
AlysonStahl-NOAA Nov 15, 2024
a594759
Update test_bitmap.F90
AlysonStahl-NOAA Nov 15, 2024
1c10014
Update test_bitmap.F90
AlysonStahl-NOAA Nov 29, 2024
3682eab
Update test_bitmap.F90
AlysonStahl-NOAA Nov 29, 2024
2158894
change to getidx2 to get cbuf
AlysonStahl-NOAA Nov 29, 2024
9da43db
Update test_bitmap.F90
AlysonStahl-NOAA Nov 29, 2024
2d742ed
debug pngunpack
AlysonStahl-NOAA Nov 29, 2024
1e19d10
debug
AlysonStahl-NOAA Nov 29, 2024
f161f44
Update test_bitmap.F90
AlysonStahl-NOAA Nov 29, 2024
91f4e66
debug
AlysonStahl-NOAA Nov 29, 2024
cf826fa
Update test_bitmap.F90
AlysonStahl-NOAA Nov 29, 2024
94a9e43
Update test_bitmap.F90
AlysonStahl-NOAA Dec 3, 2024
165c156
debug
AlysonStahl-NOAA Dec 3, 2024
420d1da
typo
AlysonStahl-NOAA Dec 3, 2024
794d36d
Merge branch 'develop' into as_bitmap
AlysonStahl-NOAA Dec 3, 2024
fcfbff6
Update test_bitmap.F90
AlysonStahl-NOAA Dec 3, 2024
82aa92e
Update test_bitmap.F90
AlysonStahl-NOAA Dec 3, 2024
b7c97bb
add new test file
AlysonStahl-NOAA Dec 3, 2024
4a5c8d7
file name
AlysonStahl-NOAA Dec 3, 2024
8752056
swap file
AlysonStahl-NOAA Dec 3, 2024
0252924
Merge branch 'as_bitmap' of github.com:AlysonStahl-NOAA/NCEPLIBS-g2 i…
AlysonStahl-NOAA Dec 3, 2024
1cc9aa8
checking result
AlysonStahl-NOAA Dec 3, 2024
e16a6bd
Update test_bitmap.F90
AlysonStahl-NOAA Dec 3, 2024
e6ba1ca
checking more values
AlysonStahl-NOAA Dec 3, 2024
1f7a658
Update test_bitmap.F90
AlysonStahl-NOAA Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
cd g2
mkdir build
cd build
cmake -DBUILD_UTILS=OFF -DUSE_AEC=ON -DFTP_LARGE_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DCMAKE_Fortran_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DCMAKE_C_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data -DCMAKE_BUILD_TYPE=Debug ..
cmake -DBUILD_UTILS=OFF -DUSE_AEC=ON -DFTP_LARGE_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DCMAKE_Fortran_FLAGS="-g -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DCMAKE_C_FLAGS="-g -O0 -Wall -fno-omit-frame-pointer -fsanitize=address" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data -DCMAKE_BUILD_TYPE=Debug ..
make -j2 VERBOSE=1
ctest --verbose --output-on-failure --rerun-failed

Expand All @@ -79,7 +79,7 @@ jobs:
mkdir build
doxygen --version
cd build
cmake -DBUILD_UTILS=ON -DG2C_COMPARE=OFF -DUSE_AEC=ON -DFTP_LARGE_TEST_FILES=ON -DENABLE_DOCS=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data ..
cmake -DBUILD_UTILS=ON -DUSE_AEC=ON -DFTP_LARGE_TEST_FILES=ON -DENABLE_DOCS=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-bacio;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-w3emc;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DCMAKE_Fortran_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0" -DCMAKE_C_FLAGS="-g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0" -DFTP_TEST_FILES=ON -DTEST_FILE_DIR=/home/runner/data ..
make -j2 VERBOSE=1
ctest --verbose --output-on-failure --rerun-failed
gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null
Expand Down
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ copy_test_data(ref_gdaswave.t00z.wcoast.0p16.f000.grb2index2)
copy_test_data(g1.grib2)
copy_test_data(gdaswave.t00z.wcoast.0p16.f000.grib2)
copy_test_data(ref_test_jpcpack_4_output.txt)
copy_test_data(ref_jpeg_bitmap.grib2)

# Build a _4 and _d version of each test and link them to the _4 and
# _d builds of the library, for 4-byte real, and 8-byte real.
Expand Down Expand Up @@ -208,6 +209,7 @@ foreach(kind ${kinds})
create_test(test_gettemplates ${kind})
create_test(test_addfield ${kind})
create_test(test_gf_unpack2 ${kind})
create_test(test_bitmap ${kind})

# This test depends on gdt2gds(), which is not present if the GRIB1
# library is not also included in the build.
Expand Down
Binary file added tests/data/ref_jpeg_bitmap.grib2
Binary file not shown.
91 changes: 91 additions & 0 deletions tests/test_bitmap.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
! This is a test program for NCEPLIBS-g2.
!
! This program tests processing a GRIB2 file with bitmaps.
!
! Alyson Stahl 11/5/24
program test_bitmap
use bacio_module
use grib_mod
implicit none

character(*) :: BITMAP_FILE
parameter(BITMAP_FILE = 'data/ref_jpeg_bitmap.grib2')
character(*) :: BITMAP_FILE_INDEX
parameter(BITMAP_FILE_INDEX = 'test_bitmap_index.grb2index')

integer :: lugi, lugb
parameter(lugi = 31, lugb = 11)

integer :: idxver = 2, j = 0, jdisc = 0, jpdtn = 0, jgdtn = 0
integer :: iret, k, i
integer :: jids(13), jpdt(15), jgdt(19)
logical :: unpack = .true.
integer :: expected_idsect(13) = (/ 7, 0, 2, 1, 1, 2021, 11, 30, 0, 0, 0, 0, 1/)
integer :: expected_ipdtmpl(15) = (/ 2, 1, 2, 0, 11, 0, 0, 1, 0, 1, 0, 1, 255, 0, 0 /)
integer :: expected_igdtmpl(19) = (/ 6, 0, 0, 0, 0, 0, 0, 241, 151, 0, 0, 50000000, &
210000000, 48, 25000000, 250000000, 166667, 166667, 0/)
integer :: expected_idrtmpl(7) = (/ 1092616192, 0, 2, 11, 0, 0, 255 /)
type(gribfield) :: gfld

interface
subroutine g2_create_index(lugb, lugi, idxver, filename, iret)
integer, intent(in) :: lugb, lugi, idxver
character*(*) :: filename
integer, intent(out) :: iret
end subroutine g2_create_index
end interface

! Open GRIB2 file for reading.
call baopenr(lugb, BITMAP_FILE, iret)
if (iret .ne. 0) stop 2

! Open output file where index will be written.
call baopen(lugi, BITMAP_FILE_INDEX, iret)
if (iret .ne. 0) stop 3

call g2_create_index(lugb, lugi, idxver, BITMAP_FILE, iret)
if (iret .ne. 0) stop 4

jids = -9999
jpdt = -9999
jgdt = -9999
call getgb2i2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, &
jgdt, unpack, idxver, k, gfld, iret)
if (iret .ne. 0) stop 10
if (k .ne. 1) stop 11
if (gfld%version .ne. 2 .or. gfld%discipline .ne. 0 .or. gfld%idsectlen .ne. 13 .or. &
gfld%locallen .ne. 0 .or. gfld%ifldnum .ne. 1 .or. gfld%griddef .ne. 0 .or. &
gfld%ngrdpts .ne. 36391 .or. gfld%numoct_opt .ne. 0 .or. gfld%interp_opt .ne. 0 .or. &
gfld%num_opt .ne. 0 .or. gfld%igdtnum .ne. 0 .or. gfld%igdtlen .ne. 19 .or. &
gfld%ipdtnum .ne. 0 .or. gfld%ipdtlen .ne. 15 .or. gfld%ndpts .ne. 11041 .or. &
gfld%idrtnum .ne. 40 .or. gfld%idrtlen .ne. 7 .or. gfld%unpacked .neqv. .false. .or. &
gfld%expanded .neqv. .true. .or. gfld%ibmap .ne. 0) stop 12
do i = 1, 13
if (gfld%idsect(i) .ne. expected_idsect(i)) stop 13
end do
do i = 1, 19
if (gfld%igdtmpl(i) .ne. expected_igdtmpl(i)) stop 14
end do
do i = 1, 15
if (gfld%ipdtmpl(i) .ne. expected_ipdtmpl(i)) then
print *, 'got gfld%ipdtmpl', gfld%ipdtmpl
print *, 'expected ', expected_ipdtmpl
stop 15
endif
end do
do i = 1, 7
if (gfld%idrtmpl(i) .ne. expected_idrtmpl(i)) stop 16
end do

call baclose(lugb, iret)
if (iret .ne. 0) stop 100
call baclose(lugi, iret)
if (iret .ne. 0) stop 101

! Free resources.
call gf_free(gfld)
call gf_finalize(iret)
if (iret .ne. 0) stop 102

print *, 'SUCCESS!'
end program test_bitmap
Loading