File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,37 @@ module mpas_c_interfacing
4
4
contains
5
5
6
6
7
+ !-----------------------------------------------------------------------
8
+ ! routine mpas_sanitize_string
9
+ !
10
+ !> \brief Converts C null characters in a Fortran string to spaces
11
+ !> \author Michael Duda
12
+ !> \date 19 February 2019
13
+ !> \details
14
+ !> Converts all C null characters in a Fortran string to spaces.
15
+ !> This may be useful for strings that were provided by C code through other
16
+ !> Fortran code external to MPAS.
17
+ !
18
+ !-----------------------------------------------------------------------
19
+ subroutine mpas_sanitize_string (str )
20
+
21
+ use iso_c_binding, only : c_null_char
22
+
23
+ implicit none
24
+
25
+ character (len=* ), intent (inout ) :: str
26
+
27
+ integer :: i
28
+
29
+ do i= 1 ,len (str)
30
+ if (str(i:i) == c_null_char) then
31
+ str(i:i) = ' '
32
+ end if
33
+ end do
34
+
35
+ end subroutine mpas_sanitize_string
36
+
37
+
7
38
!-----------------------------------------------------------------------
8
39
! routine mpas_c_to_f_string
9
40
!
You can’t perform that action at this time.
0 commit comments