Skip to content

Commit

Permalink
Update test_bitmap.F90
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA committed Nov 12, 2024
1 parent eef84e9 commit 77d3b41
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions tests/test_bitmap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,56 @@ program test_bitmap

character(*) :: BITMAP_FILE
parameter(BITMAP_FILE = 'data/ref_png_bitmap.png')
character(*) :: BITMAP_FILE_INDEX
parameter(BITMAP_FILE_INDEX = 'test_bitmap_index.grb2index')

integer :: LUGB, LUGI
parameter(LUGB = 3, LUGI = 4)
integer :: iret
integer :: lugi, lugb
parameter(lugi = 11, lugb = 10)

call baopenr(LUGI, BITMAP_FILE, iret)
character(len=1), pointer, dimension(:) :: cbuf(:)
integer :: idxver, myidxver, nlen, nnum, ifldnum, iret
type(gribfield) :: gfld

interface
subroutine getg2i2(lugi, cbuf, idxver, nlen, nnum, iret)
integer, intent(in) :: lugi
character(len=1), pointer, dimension(:) :: cbuf
integer, intent(out) :: idxver, nlen, nnum, iret
end subroutine getg2i2
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 3

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

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

call baclose(lugb, iret)
if (iret .ne. 0) stop 6

! Read the index file.
call getg2i2(lugi, cbuf, myidxver, nlen, nnum, iret)
if (iret .ne. 0) stop 7

call baclose(lugi, iret)
if (iret .ne. 0) stop 8

ifldnum = 6
call gf_getfld(cbuf, nlen, ifldnum, .true., .true., gfld, iret)
if (iret .ne. 0) stop 9

! Free resources.
call gf_free(gfld)

print *, 'SUCCESS!'
end program test_bitmap

0 comments on commit 77d3b41

Please sign in to comment.