Print

Print


On Tue, 25 Jan 2000 11:23:32 +0100 (MET) Roland Schilling 
<[log in to unmask]> wrote:

> On Tue, 25 Jan 2000, Clive Page wrote:
> 
> > Further to the question put by Roland Schilling, and Richard Maine's
> > reply, I agree that the rules of f95 make it easier, but it is possible to
> > do something in f90, albeit with some difficulty.  A discussion (I think
> > on this list) early last year on how to produce a function which converts ...
>  
> Is there an archive where one could look up discussion from a year ago?

all mailbase lists keep messages for two years and I got
them to keep this list indefinitely a couple of months ago.

>  
> > ... an integer to a trimmed and left-justified string produced a couple of
> > answers.  My contribution was a function of which the declaration part
> > was:
> > 
> > FUNCTION int2str(intval) RESULT(string)
> >   INTEGER , INTENT(IN) :: intval
> >   INTEGER :: n
> >   CHARACTER(LEN=12 - MAX(0,SIGN(1,intval)) - VERIFY(TRANSFER(ACHAR(48+&
> >       (/(MOD(MAX(1,ABS(intval))/10**n,10),n=9,0,-1)/) ), &
> >            "1234567890"), ACHAR(48)) ) :: string
> >     INTEGER :: absval, j, k
> >     CHARACTER(LEN=11) :: buf
> > 
> > If you inspect the CHARACTER statement carefully you can see how it works. 
> > It seems to be valid Fortran90; at the time it broke several compilers,
> > though I think they are mostly fixed now.
> > 
> > An alternative formulation, longer but perhaps more elegant was given by
> > someone else (sorry I lost the author's attribution for the moment):
> > 
> >   FUNCTION INT2STR(intval) RESULT(string)
> >     INTEGER , INTENT(IN) :: intval
> >     CHARACTER(LEN=12 - MAX(0,SIGN(1,intval)) - VERIFY(  &
> >        ACHAR(48+MOD(ABS(intval)/1000000000,10)) // &
> >        ACHAR(48+MOD(ABS(intval)/100000000,10)) // &
> >        ACHAR(48+MOD(ABS(intval)/10000000,10)) // &
> >        ACHAR(48+MOD(ABS(intval)/1000000,10)) // &
> >        ACHAR(48+MOD(ABS(intval)/100000,10)) // &
> >        ACHAR(48+MOD(ABS(intval)/10000,10)) // &
> >        ACHAR(48+MOD(ABS(intval)/1000,10)) // &
> >        ACHAR(48+MOD(ABS(intval)/100,10)) // &
> >        ACHAR(48+MOD(ABS(intval)/10,10)) // &
> >        ACHAR(48+MOD(MAX(1,ABS(intval)),10)), ACHAR(48))) :: string
> >     INTEGER :: absval, j, k
> >     CHARACTER(LEN=11) :: buf
> > 
> > Perhaps one of these will give Roland Schilling some ideas.  :-)
>  
> Yes, it does.  Thanks a lot.  Studying the rules for 'specification
> expressions' resulted in the understanding that I cannot solve my
> problem this way.  What I really do not understand is why I'm not
> allowed to embed something like the trim command in a character 
> function such that it returns the trimmed character string.
>   
> > One thing to bear in mind is that Standard Fortran does not permit
> > recursive I/O, so that if you have a function containing even an internal
> > file READ or WRITE the function cannot itself be used in the I/O list of
> > another READ or WRITE statement.  This can be a significant restriction.
>    
> Yes, I know this, and I agree that this is another significant 
> restriction.  I can imagine why it is not allowed to do recursive 
> I/O, as long as it is external I/O.  But I cannot see why this
> restriction also applies to internal I/O.  Hopefully these
> deficiencies will go away with F2K.
> 
> Roland Schilling
>  
> +----------------------------------------------------------------------+
> |  Roland Schilling                     Home-Office: +49(89)32929-670  |
> |  Max-Planck-Institut fuer Quantenoptik      Phone: +49(89)32905-265  |
> |  Hans-Kopfermann-Str. 1                       Fax: +49(89)32905-200  |
> |  D-85748 Garching                          E-mail:   [log in to unmask]  |
> |  Germany                          http://www.geo600.uni-hannover.de  |
> +----------------------------------------------------------------------+
> 

I'm the list owner. url is

http://www.mailbase.ac.uk/lists-a-e/comp-fortran-90/

-------------------
Ian Chivers
[log in to unmask]

* This e-mail message was sent with Execmail V5.0 *



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%