From f48d7d9359f352aa3e3254cfa5e9df601e3a7ef9 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Fri, 27 Dec 2024 05:45:01 -0700 Subject: [PATCH] use g2c_inq_dim_info() --- src/g2c_interface.F90 | 10 ++++++++++ src/g2cf.F90 | 18 +++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/g2c_interface.F90 b/src/g2c_interface.F90 index 34845781..16c936ab 100644 --- a/src/g2c_interface.F90 +++ b/src/g2c_interface.F90 @@ -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); diff --git a/src/g2cf.F90 b/src/g2cf.F90 index 96909910..fbc5b40f 100644 --- a/src/g2cf.F90 +++ b/src/g2cf.F90 @@ -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