Skip to content

Commit

Permalink
use g2c_inq_dim_info()
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Dec 27, 2024
1 parent d41dc7d commit f48d7d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/g2c_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ function g2c_inq_dim(g2id, msg_num, prod_num, dim_num, len, name, val) bind(c)
integer(c_int) :: g2c_inq_dim
end function g2c_inq_dim

function g2c_inq_dim_info(g2id, msg_num, prod_num, dim_num, len, name) bind(c)
use iso_c_binding
integer(c_int), value :: g2id
integer(c_int), value :: msg_num
integer(c_int), intent(out) :: prod_num, dim_num
integer(c_size_t), intent(out) :: len
character(c_char), intent(in) :: name(*)
integer(c_int) :: g2c_inq_dim_info
end function g2c_inq_dim_info

! /* Getting data. */
! int g2c_get_prod(int g2cid, int msg_num, int prod_num, int *num_data_points,
! float *data);
Expand Down
18 changes: 11 additions & 7 deletions src/g2cf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -421,21 +421,25 @@ function g2cf_inq_dim(g2id, msg_num, prod_num, dim_num, dimlen, name, val) resul
cstatus = g2c_inq_dim(g2cid, cmsg_num, cprod_num, cdim_num, cdimlen, &
tmpname, cval)
else
cstatus = g2c_inq_dim(g2cid, cmsg_num, cprod_num, cdim_num, cdimlen, &
tmpname, C_NULL_CHAR)
cstatus = g2c_inq_dim_info(g2cid, cmsg_num, cprod_num, cdim_num, cdimlen, &
tmpname)
endif

! Copy output params to Fortran types.
dimlen = cdimlen
if (cstatus == G2_NOERR) then
dimlen = cdimlen
! Strip c null char from tmpname if present and set end of string.
name(:nlen) = stripcnullchar(tmpname, nlen)

! Copy values.
if (present(val)) then
do i = 1, dimlen
val(i) = cval(i)
end do
endif
endif

! Copy values.
do i = 1, dimlen
val(i) = cval(i)
end do
! Copy exit status.
status = cstatus

end function g2cf_inq_dim
Expand Down

0 comments on commit f48d7d9

Please sign in to comment.