Hello there.
I have been trying to do this for a couple of hours now but my brain cannot
produce a solution.
Here is the problem. I want to extend the character manipulation functions:
TRIM, LEN_TRIM, ADJUSTL, ADJUSTR
to handle apart from the space character, the tab character too.
Writing LEN_TRIM is easy; however writing TRIM I am stuck in that I cannot
return a character string argument that has the absolutely necessary length.
-------------------- charutils.f90 --------------------------------------------
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
CONTAINS
FUNCTION my_len_trim(s)
INTEGER :: my_len_trim
CHARACTER(LEN=*), INTENT(IN) :: s
INTEGER :: i
my_len_trim = VERIFY(s, space//tab, BACK=.TRUE.)
RETURN
END FUNCTION my_len_trim
FUNCTION my_trim(s)
CHARACTER(LEN=*), INTENT(IN) :: s
CHARACTER(LEN=LEN(s)) :: my_trim
my_trim = s(1:LEN_TRIM(s))
RETURN
END FUNCTION my_trim
END MODULE charutils
-------------------- charutils.f90 --------------------------------------------
The problem with TRIM (i.e. my_trim) is clear. It returns a character string
with length equal to input string s due to the declaration:
CHARACTER(LEN=LEN(s)) :: my_trim
but what else can I do?
Any help/ideas welcome. Thank you for reading this,
Petros
----------------------
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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|