File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ program main
1818 ! ! ```
1919 use :: nng
2020 use :: nng_pipeline0
21+ use :: nng_util
2122 implicit none (type, external )
2223
2324 character (80 ) :: message, name, url
@@ -32,14 +33,6 @@ program main
3233 case default ; print ' ("Usage: pipeline node0|node1 <URL> <ARG> ...")'
3334 end select
3435contains
35- pure function f_c_str (f_str ) result(c_str)
36- ! ! In Fortran 2023, use `f_c_string()` instead.
37- character (* ), intent (in ) :: f_str
38- character (:), allocatable :: c_str
39-
40- c_str = trim (f_str) // c_null_char
41- end function f_c_str
42-
4336 subroutine fatal (rc , str )
4437 integer , intent (in ) :: rc
4538 character (* ), intent (in ) :: str
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ module nng_util
88 private
99
1010 public :: c_f_str_ptr
11+ public :: f_c_str
1112contains
1213 subroutine c_f_str_ptr (c_str , f_str )
1314 ! ! Copies a C string, passed as a C pointer, to a Fortran string.
@@ -44,4 +45,15 @@ end function c_strlen
4445
4546 if (.not. allocated (f_str)) f_str = ' '
4647 end subroutine c_f_str_ptr
48+
49+ pure function f_c_str (f_str ) result(c_str)
50+ ! ! Converts Fortran string to C string. In Fortran 2023, use
51+ ! ! `f_c_string()` instead.
52+ use , intrinsic :: iso_c_binding, only: c_null_char
53+
54+ character (* ), intent (in ) :: f_str
55+ character (:), allocatable :: c_str
56+
57+ c_str = trim (f_str) // c_null_char
58+ end function f_c_str
4759end module nng_util
You can’t perform that action at this time.
0 commit comments