Subroutine LENCH for program GSAS2CIF
This subroutine is used to find the length of an ASCII string.
Trailing spaces, tab & null characters are ignored.
See the gsas2cif documentation for an
explanation of this code.
INTEGER*4 FUNCTION LENCH(STR)
C---------------------------------------------------------------------------
c Function LENCH
c
c This function takes a character string and finds out how long the
c "actual" string is (i.e. not including padded blanks on the right).
c
C---------------------------------------------------------------------------
!Calling arguments:
CHARACTER*(*) STR
!Local variables:
CHARACTER*1 NUL,TAB
LOGICAL*4 DONE
!Data:
data nul /0/
data tab /' '/
!Code:
if ( str.ne.' ' .and. str(1:1).ne.nul ) then
ilench = len(str)+1
done = .false.
do while ( .not.done .and. ilench.gt.0 )
ilench = ilench-1
if ( str(ilench:ilench).ne.' '
1 .and. str(ilench:ilench).ne.tab !Look for trailing tabs as well
1 .and. str(ilench:ilench).ne.nul ) done=.true.
END DO
lench = ilench
else
lench=0
end if
return
end