Skip to content

Commit

Permalink
more fortran wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Dec 22, 2024
1 parent 76d4f4a commit 8228223
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tests/test_g2cf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,45 @@ program test_g2cf
use g2cf
implicit none
character (len = *), parameter :: fileName = "data/gdaswave.t00z.wcoast.0p16.f000.grib2"
integer :: g2cid, num_msg
integer :: g2id, num_msg
integer(kind = 1) :: discipline
integer(kind = 4) :: num_fields, num_local
integer(kind = 2) :: center, subcenter
integer(kind = 1) :: master_version, local_version
integer(kind = 1) :: sig_ref_time
integer(kind = 2) :: year
integer(kind = 1) :: month, day, hour, minute, second
integer :: ierr

print *, 'Testing g2cf API...'
!ierr = g2cf_set_log_level(1)

! Open the test file.
ierr = g2cf_open(fileName, 0, g2cid)
ierr = g2cf_open(fileName, 0, g2id)
if (ierr .ne. 0) stop 2

! Check number of messages.
ierr = g2cf_inq(g2cid, num_msg)
ierr = g2cf_inq(g2id, num_msg)
if (ierr .ne. 0) stop 10
if (num_msg .ne. 19) stop 11

! Check the last message.
ierr = g2cf_inq_msg(g2cid, 19, discipline, num_fields, num_local, center, subcenter, &
ierr = g2cf_inq_msg(g2id, 19, discipline, num_fields, num_local, center, subcenter, &
master_version, local_version)
if (ierr .ne. 0) stop 100
!print *, discipline, num_fields, num_local, center, subcenter, master_version, local_version
if (discipline .ne. 10 .or. num_fields .ne. 1 .or. num_local .ne. 0 .or. center .ne. 7 .or. &
subcenter .ne. 0 .or. master_version .ne. 2 .or. local_version .ne. 1) stop 12

! Check the time of the last message.
ierr = g2cf_inq_msg_time(g2id, 19, sig_ref_time, year, &
month, day, hour, minute, second)
!print *, sig_ref_time, year, month, day, hour, minute, second
if (sig_ref_time .ne. 1 .or. year .ne. 2021 .or. month .ne. 11 .or. day .ne. 30 .or. &
hour .ne. 0 .or. minute .ne. 0 .or. second .ne. 0) stop 101

! Close the file.
ierr = g2cf_close(g2cid)
ierr = g2cf_close(g2id)
if (ierr .ne. 0) stop 20

print *, 'SUCCESS!'
Expand Down

0 comments on commit 8228223

Please sign in to comment.