From 7f877f842b1a19b8e909750c0f944db3b3b2a806 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 3 Aug 2016 11:03:23 -0600 Subject: [PATCH] adding fortran interface to PIOc_strerror() --- src/flib/pio_nf.F90 | 60 +++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/flib/pio_nf.F90 b/src/flib/pio_nf.F90 index a3cd06d92b9d..4db50a2a51df 100644 --- a/src/flib/pio_nf.F90 +++ b/src/flib/pio_nf.F90 @@ -37,8 +37,8 @@ module pio_nf pio_set_var_chunk_cache , & pio_get_var_chunk_cache , & pio_redef , & - pio_set_log_level -! pio_strerror + pio_set_log_level , & + pio_strerror ! pio_copy_att to be done interface pio_def_var @@ -195,10 +195,10 @@ module pio_nf set_log_level end interface pio_set_log_level - ! interface pio_strerror - ! module procedure & - ! strerror - ! end interface pio_strerror + interface pio_strerror + module procedure & + strerror + end interface pio_strerror interface pio_inquire module procedure & @@ -684,28 +684,34 @@ end function PIOc_set_log_level end interface ierr = PIOc_set_log_level(log_level) end function set_log_level -!> -!! @defgroup PIO_strerror -!< -!> -!! @ingroup PIO_strerror -!! Returns a descriptive string for an error code. -!! -!! @param errcode the error code -!! @retval a description of the error + + !> + !! @defgroup PIO_strerror !< - ! function strerror(errcode) result(errmsg) - ! integer, intent(in) :: errcode - ! Character(LEN=80) :: errmsg - ! interface - ! Function PIOc_strerror(errcode) BIND(C) - ! USE ISO_C_BINDING, ONLY: C_INT, C_PTR - ! Integer(C_INT), VALUE :: errcode - ! Type(C_PTR) :: PIOc_strerror - ! End Function PIOc_strerror - ! end interface - ! strerror = PIOc_strerror(errcode) - ! end function strerror + !> + !! @ingroup PIO_strerror + !! Returns a descriptive string for an error code. + !! + !! @param errcode the error code + !! @retval a description of the error + !< + integer function strerror(errcode, errmsg) result(ierr) + integer, intent(in) :: errcode + character(len=*), intent(out) :: errmsg + interface + integer(C_INT) function PIOc_strerror(errcode, errmsg) & + bind(C, name="PIOc_strerror") + use iso_c_binding + integer(C_INT), value :: errcode + character(C_CHAR) :: errmsg(*) + end function PIOc_strerror + end interface + errmsg = C_NULL_CHAR + ierr = PIOc_strerror(errcode, errmsg) + call replace_c_null(errmsg) + + end function strerror + !> !! @public !! @ingroup PIO_redef