Richard-
great! Your reply covers me completely. In fact I have F95 compilers (Compaq's
on both VMS and PC/WinNT).
To summarize...
Objective: enhance LEN_TRIM and TRIM to handle as blanks not only spaces but
also tab characters.
Tricky point: Of all the character manipulation functions, TRIM(s) is the only
one that returns a string with length only known at run-time.
i.e. 0 <= LEN(TRIM(s)) <= LEN(s) and depends on s!
but (for example) LEN(ADJUSTL(s)) = LEN(s)
Implementation: Fortran95 code follows at end of email.
Thank you again,
Petros
==========================================================================
MODULE charutils
IMPLICIT NONE
INTERFACE LEN_TRIM
MODULE PROCEDURE my_len_trim
END INTERFACE LEN_TRIM
INTERFACE TRIM
MODULE PROCEDURE my_trim
END INTERFACE TRIM
CHARACTER(LEN=1), PARAMETER, PRIVATE :: space = ACHAR(32)
CHARACTER(LEN=1), PARAMETER, PRIVATE :: tab = ACHAR(9)
CONTAINS
PURE FUNCTION my_len_trim(s) ! PURE is required to make my_trim() work
INTEGER :: my_len_trim
CHARACTER(LEN=*), INTENT(IN) :: s
my_len_trim = VERIFY(s, space//tab, BACK=.TRUE.)
RETURN
END FUNCTION my_len_trim
PURE FUNCTION my_trim(s) ! PURE not necessary here but may be useful
! where this module is used.
CHARACTER(LEN=*), INTENT(IN) :: s
CHARACTER(LEN=LEN_TRIM(s)) :: my_trim ! ok to use LEN_TRIM
! since it's PURE
my_trim = s(1:LEN_TRIM(s))
RETURN
END FUNCTION my_trim
END MODULE charutils
==========================================================================
----------------------
Petros Dafniotis, PhD
DuPont de Nemours Intl. S.A. - Central Research & Development
[log in to unmask]
---
DISCLAIMER: My employer, DuPont de Nemours, has nothing to do with
the opinions and ideas expressed in this post / message.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|