Skip to content

Commit

Permalink
more progress
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Dec 21, 2024
1 parent df1cf25 commit cd05c3d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/g2c_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ function g2c_inq(g2id, num_msg) bind(c)
integer(c_int) :: g2c_inq
end function g2c_inq

! int g2c_inq(int g2cid, int *num_msg);
function g2c_inq_msg(g2id, msg_num, discipline, num_fields, &
num_local, center, subcenter, master_version, local_version) bind(c)
use iso_c_binding
integer(c_int), value :: g2id
integer(c_int), intent(in) :: msg_num
integer(c_signed_char), intent(out) :: discipline
integer(c_int), intent(out) :: num_fields, num_local
integer(c_short), intent(out) :: center, subcenter
integer(c_signed_char), intent(out) :: master_version, local_version
integer(c_int) :: g2c_inq_msg
end function g2c_inq_msg

! int g2c_inq_msg(int g2cid, int msg_num, unsigned char *discipline, int *num_fields,
! int *num_local, short *center, short *subcenter, unsigned char *master_version,
! unsigned char *local_version);
Expand Down
37 changes: 37 additions & 0 deletions src/g2cf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,43 @@ function g2cf_inq(g2id, num_msg) result(status)
status = cstatus
end function g2cf_inq

!> Learn about a message are in a GRIB2 file.
!>
!> @param[in] g2id The ID of the open file
!> @param[in] msg_num The number of message to learn about.
!> @param[out] discipline The discipline of the message.
!> @param[out] num_fields Number of fields in the message.
!> @param[out] num_local Number of local sections in the message.
!> @param[out] center Originating center.
!> @param[out] subcenter Originating sub-center.
!> @param[out] master_version Master version.
!> @param[out] local_version Local version.
!>
!> @return 0 for success, error code otherwise.
!>
!> @author Edward Hartnett @date 2024-12-21
function g2cf_inq_msg(g2id, msg_num, discipline, num_fields, &
num_local, center, subcenter, master_version, local_version) result(status)
use iso_c_binding
use g2c_interface
implicit none

integer, intent(in) :: g2id
integer(c_int), intent(in) :: msg_num
integer(c_signed_char), intent(out) :: discipline
integer(c_int), intent(out) :: num_fields, num_local
integer(c_short), intent(out) :: center, subcenter
integer(c_signed_char), intent(out) :: master_version, local_version
integer :: status

integer(c_int) :: cg2id, cnum_msg, cstatus

cg2id = g2id
cstatus = g2c_inq(cg2id, cnum_msg)
!num_msg = cnum_msg
status = cstatus
end function g2cf_inq_msg

!> Close a GRIB2 file.
!>
!> @param g2id The ID of the open file
Expand Down

0 comments on commit cd05c3d

Please sign in to comment.