Hi all
OK ... just for the hell of it ... here's an intrinsic version for 'in
place' application:
(NOTE - there is no mention of string length necessary for the
intrinsics, and it stops at the end of real content. Surely it would
have to be significantly (?) SLOWER than the implied array character
form, though, for larger 'high-content' strings.)
program blank_glance
character str*256
integer i,j
str=' for tran '
str=adjustl(str)
j=1
do
i=index(str,' ')
if(i.eq.0)EXIT
if(i.eq.j)EXIT
str=str(1:i-1)//str(i+1:)
j=i
end do
write(6,*)str
end program blank_glance
AND... here's an intrinsic version as a subroutine in a full demo
program:
program blank_look
character s*256
integer m
s=' for tran '
m=len(s)
call de_blank(s,m)
write(6,*)s
end program blank_look
subroutine de_blank(str,k)
integer i,j,k
character (len=k) :: str
intent (in out) str
str=adjustl(str)
j=1
do
i=index(str,' ')
if(i.eq.0)EXIT
if(i.eq.j)EXIT
str=str(1:i-1)//str(i+1:)
j=i
end do
return
end subroutine de_blank
(I wonder know how much slower it really is than the implied array form
for strings of various lengths and compositions?)
Gaz
-----Original Message-----
From: robin [mailto:[log in to unmask]]
Sent: Monday, 8 October 2001 10:05
To: [log in to unmask]
Subject: Re: De-blanking Strings (was: Strings)
The string can be formed in place:
S = ' for tran '
J = 0
DO I = 1, LEN_TRIM(S)
IF (S(I:I) /= ' ') THEN
J = J + 1
IF (J < I) THEN
S(J:J) = S(I:I)
S(I:I) = ' '
END IF
END IF
END DO
************************************************************************
The information in this e-mail together with any attachments is
intended only for the person or entity to which it is addressed
and may contain confidential and/or privileged material.
Any form of review, disclosure, modification, distribution
and/or publication of this e-mail message is prohibited.
If you have received this message in error, you are asked to
inform the sender as quickly as possible and delete this message
and any copies of this message from your computer and/or your
computer system network.
************************************************************************
|