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 3105836 commit 198b655
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/g2cf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -348,42 +348,42 @@ end function g2cf_inq_prod
!> @return 0 for success, error code otherwise.
!>
!> @author Edward Hartnett @date 2024-12-22
! function g2cf_inq_dim(g2id, msg_num, prod_num, dim_num, len, name, val) result(status)
! use iso_c_binding
! use g2c_interface
! implicit none

! integer, intent(in) :: g2id, msg_num, prod_num, dim_num
! integer(kind = 8), intent(out) :: len
! character, intent(out) :: name(*)
! real, intent(out) :: val(*)
function g2cf_inq_dim(g2id, msg_num, prod_num, dim_num, len, name, val) result(status)
use iso_c_binding
use g2c_interface
implicit none

integer, intent(in) :: g2id, msg_num, prod_num, dim_num
integer(kind = 8), intent(out) :: len
character, intent(out) :: name(*)
real, intent(out) :: val(*)

! integer(c_int) :: g2cid, cmsg_num, cprod_num, cdim_num
! integer(c_size_t) :: clen
! character(c_char) :: cname(G2_MAX_NAME)
! real(c_float) :: cval(*)

! integer(c_int) :: cstatus
! integer :: status

! ! Copy input params to C types.
! g2cid = g2id
! cmsg_num = msg_num - 1 ! C is 0-based.
! cprod_num = prod_num - 1 ! C is 0-based.
! cdim_num = dim_num - 1 ! C is 0-based.

! ! Call the C function.
! cstatus = g2c_inq_dim(g2cid, cmsg_num, cprod_num, cdim_num, clen, cname, cval)
integer(c_int) :: g2cid, cmsg_num, cprod_num, cdim_num
integer(c_size_t) :: clen
character(c_char) :: cname(G2_MAX_NAME)
real(c_float) :: cval(*)

integer(c_int) :: cstatus
integer :: status

! Copy input params to C types.
g2cid = g2id
cmsg_num = msg_num - 1 ! C is 0-based.
cprod_num = prod_num - 1 ! C is 0-based.
cdim_num = dim_num - 1 ! C is 0-based.

! Call the C function.
cstatus = g2c_inq_dim(g2cid, cmsg_num, cprod_num, cdim_num, clen, cname, cval)

! ! Copy output params to Fortran types.
! len = clen
! name = cname
! do i = 1, len
! val(i) = cval(i)
! end do
! status = cstatus
! Copy output params to Fortran types.
len = clen
name = cname
do i = 1, len
val(i) = cval(i)
end do
status = cstatus

! end function g2cf_inq_dim
end function g2cf_inq_dim

! /* Getting data. */
! int g2c_get_prod(int g2cid, int msg_num, int prod_num, int *num_data_points,
Expand Down

0 comments on commit 198b655

Please sign in to comment.