source: trunk/mesoscale/LMD_MM_MARS/SRC/WPS/geogrid/src/despace.f90 @ 11

Last change on this file since 11 was 11, checked in by aslmd, 14 years ago

spiga@svn-planeto:ajoute le modele meso-echelle martien

File size: 943 bytes
Line 
1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2! Name: despace
3!
4! Purpose: Remove all space and tab characters from a string, thus compressing
5!   the string to the left.
6!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7subroutine despace(string)
8
9   implicit none
10 
11   ! Arguments
12   character (len=*) :: string
13 
14   ! Local variables
15   integer :: i, j, length, iquoted
16 
17   length = len(string)
18 
19   iquoted = 0
20   j = 1
21   do i=1,length
22      ! Check for a quote mark
23      if (string(i:i) == '"' .or. string(i:i) == '''') iquoted = mod(iquoted+1,2)
24 
25      ! Check for non-space, non-tab character, or if we are inside quoted text
26      if ((string(i:i) /= ' ' .and. string(i:i) /= achar(9)) .or. iquoted == 1) then
27         string(j:j) = string(i:i)
28         j = j + 1
29      end if
30   end do
31 
32   do i=j,length
33      string(i:i) = ' '
34   end do
35
36end subroutine despace
Note: See TracBrowser for help on using the repository browser.