-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bitmap test file * add test file * copy test data * Update test_bitmap.F90 * Update test_bitmap.F90 * debug memcheck * Update test_bitmap.F90 * debug test coverage * debug workflows * fix test coverage * debug failing workflows * Update test_bitmap.F90 * debugging * Update test_bitmap.F90 * debugging memory errors * undo last change * debug * Update test_bitmap.F90 * debug * Update test_bitmap.F90 * remove comments * Update test_bitmap.F90 * Update test_bitmap.F90 * Update test_bitmap.F90 * change to getidx2 to get cbuf * Update test_bitmap.F90 * debug pngunpack * debug * Update test_bitmap.F90 * debug * Update test_bitmap.F90 * Update test_bitmap.F90 * debug * typo * Update test_bitmap.F90 * Update test_bitmap.F90 * add new test file * file name * swap file * checking result * Update test_bitmap.F90 * checking more values * Update test_bitmap.F90
- Loading branch information
1 parent
18074e3
commit e357ffc
Showing
4 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |