MONC
string_utils.F90
Go to the documentation of this file.
1 
3  implicit none
4 
5 #ifndef TEST_MODE
6  private
7 #endif
8 
9  public replace_character
10 contains
11 
16  subroutine replace_character(str, src_char, tgt_char)
17  character(len=*), intent(inout) :: str
18  character, intent(in) :: src_char, tgt_char
19 
20  integer :: i, n, idx
21 
22  n=len_trim(str)
23  i=1
24  do while (i .le. n)
25  idx=index(str(i:n), src_char)
26  if (idx == 0) exit
27  i=i+idx+1
28  str(i-2:i-2)=tgt_char
29  end do
30  end subroutine replace_character
31 end module string_utils_mod
32 
String utility functionality that is commonly used throughout MONC.
Definition: string_utils.F90:2
subroutine, public replace_character(str, src_char, tgt_char)
Replaces all occurances of a character in a string with another character.