Re: add a0 format to language to print trimmed character variables
- From: Gary Scott <garylscott@xxxxxxxxxxxxx>
- Date: Sun, 29 Apr 2007 20:26:42 GMT
Beliavsky wrote:
On Apr 29, 2:33 pm, Gary Scott <garylsc...@xxxxxxxxxxxxx> wrote:Certainly, but it is more verbose and potentially more inefficient. Specifying '0a0', the compiler could simply skip over leading blanks rather than physically moving the string left.
Clive Page wrote:
In message <YrOdnaEiBo7Xk67bnZ2dnUVZ_tqnn...@xxxxxxxxxxx>, glen
Beliavsky wrote:
I wish there were an "a0" format for character variables, analogous to
i0 for integers, which would not print trailing spaces in character
variables.
I think that's an excellent suggestion - pity nobody thought of it in
time for F2003.
In order to be analogous to I0 though wouldn't it need to trim both
leading and trailing spaces? I don't think that would be the usual
desire though, but maybe you could specify '0a0' to trim leading and
trailing spaces.
ADJUSTL can be (and is) ELEMENTAL, unlike TRIM, because the LEN of the
RESULT is the same as that of the argument. Quoting the gfortran
documentation, "ADJUSTL(STR) will left adjust a string by removing
leading spaces. Spaces are inserted at the end of the string as
needed."
If a0 were in the language, one could just write
write (*,"(1000(1x,a0))") adjustl(char_vec)
to print an array of character variables with leading and trailing
spaces removed from character variables and one space inserted between
variables.
--
Gary Scott
mailto:garylscott@sbcglobal dot net
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
If you want to do the impossible, don't hire an expert because he knows it can't be done.
-- Henry Ford
.
- References:
- add a0 format to language to print trimmed character variables
- From: Beliavsky
- Re: add a0 format to language to print trimmed character variables
- From: michael
- Re: add a0 format to language to print trimmed character variables
- From: Richard Maine
- Re: add a0 format to language to print trimmed character variables
- From: glen herrmannsfeldt
- Re: add a0 format to language to print trimmed character variables
- From: Clive Page
- Re: add a0 format to language to print trimmed character variables
- From: Gary Scott
- Re: add a0 format to language to print trimmed character variables
- From: Beliavsky
- add a0 format to language to print trimmed character variables
- Prev by Date: Re: add a0 format to language to print trimmed character variables
- Next by Date: Re: Fortran: creating a table and interpolating values
- Previous by thread: Re: add a0 format to language to print trimmed character variables
- Next by thread: Re: add a0 format to language to print trimmed character variables
- Index(es):
Relevant Pages
|