Skip to content

Commit

Permalink
adding fortran interface to PIOc_strerror()
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Aug 3, 2016
1 parent c0dd8dd commit 7f877f8
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions src/flib/pio_nf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 &
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7f877f8

Please sign in to comment.