Il giorno 14/mar/2011, alle ore 21.54, juan sotelo ha scritto:

> It seems the problem could be solved by creating a fortran-format on
> the fly, e.g.,
> =====
> program foo
> ! hints from    http://www.sdsc.edu/~tkaiser/f90.html
>      implicit none
>      character (len=30)fstr   ! create a format on the fly
>      integer n_dgts, na, nb
>      na = 30000
>      nb = 1000000
>      n_dgts = floor(log10(abs(real(max(na,nb)))))+1
>      !create a format on the fly
>      write(fstr,'("(2i",i4,")")')n_dgts+1
>      write(*,fstr) na, nb
> end program
> =====
> Output:
>   30000 1000000

This is a nice trick, but I'm not sure that all compilers will accept it. I 
remember complaints about the fact that the format string should be either a 
constant string or a pointer to a format line.
Just for information, on which compilers have you tried?

Thanks,


GS



? Gabriele Sclauzero, EPFL SB ITP CSEA
   PH H2 462, Station 3, CH-1015 Lausanne

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.democritos.it/pipermail/pw_forum/attachments/20110315/e74236cd/attachment.htm
 

Reply via email to