47 character(len=*),
intent(inout) :: str
53 if (str(i:i) /=
' ')
then
68 character(len=*),
intent(inout) :: str
70 character(64) :: tmp_str
72 if (index(str,
'/', .
true.) /= len_trim(str))
then
74 write(str,
'(a,a1)') trim(tmp_str),
'/'
82 character (len=*),
intent(inout) :: str
87 if (str(i:i) /=
' ')
exit
103 character(len=80) function str_center(s_in, l_in)
result(s_out)
104 character(len=*),
intent(in) :: s_in
105 integer,
intent(in) :: l_in
107 integer :: pad, i, li, l
112 s_out(1:l) = s_in(1:l)
122 s_out(pad + 1:pad + li) = s_in(1:li)
123 do i = pad + li + 1, l
132 integer,
intent(in) :: iunit
133 type(c_ptr),
intent(in) :: str
134 character(len=*),
optional,
intent(in) :: pre
135 character(len=*),
optional,
intent(in) :: advance
138 character(len=256) :: line
139 character(len=5) :: advance_
142 if (
present(advance)) advance_ = advance
147 if (.not. c_associated(s))
exit
148 if (
present(pre))
then
149 write(iunit,
'(a,a)', advance=advance_) pre, trim(line)
151 write(iunit,
'(a)', advance=advance_) trim(line)
159 character(len=*),
intent(out) :: str
164 str(j+1:j+1) = achar(0)
172 character(len=*),
intent(in) :: f_string
173 character(kind=c_char,len=1) :: c_string(
c_str_len(f_string))
177 strlen = len_trim(f_string)
180 c_string(i) = f_string(i:i)
182 c_string(strlen+1) = c_null_char
188 character(kind=c_char,len=1),
intent(in) :: c_string(*)
189 character(len=*),
intent(out) :: f_string
194 do while(c_string(i) /= c_null_char .and. i <= len(f_string))
195 f_string(i:i) = c_string(i)
198 if (i < len(f_string)) f_string(i:) =
' '
204 type(c_ptr),
intent(in) :: c_string
205 character(len=*),
intent(out) :: f_string
207 character(len=1, kind=c_char),
pointer :: p_chars(:)
210 if (.not. c_associated(c_string))
then
213 call c_f_pointer(c_string, p_chars, [huge(0)])
215 do while(p_chars(i) /= c_null_char .and. i <= len(f_string))
216 f_string(i:i) = p_chars(i)
219 if (i < len(f_string)) f_string(i:) =
' '
228 integer pure function
c_str_len(fortran_char)
229 character(len=*),
intent(in) :: fortran_char
subroutine, public string_c_to_f(c_string, f_string)
subroutine, public string_c_ptr_to_f(c_string, f_string)
subroutine, public str_trim(str)
removes leading spaces from string
subroutine, public conv_to_c_string(str)
converts to c string
subroutine, public compact(str)
Removes all spaces from a string.
subroutine, public print_c_string(iunit, str, pre, advance)
prints the C string given by the pointer str
integer pure function, public c_str_len(fortran_char)
Convert fortran character length to C character length.
character(len=80) function, public str_center(s_in, l_in)
puts space around string, so that it is centered
character(kind=c_char, len=1) function, dimension(c_str_len(f_string)), public string_f_to_c(f_string)
subroutine, public add_last_slash(str)
Adds a '/' in the end of the string, only if it missing. Useful for directories.