<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Il giorno 14/mar/2011, alle ore 21.54, juan sotelo ha scritto:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>It seems the problem could be solved by creating a fortran-format on<br>the fly, e.g.,<br>=====<br>program foo<br>! hints from <a href="http://www.sdsc.edu/~tkaiser/f90.html">http://www.sdsc.edu/~tkaiser/f90.html</a><br> implicit none<br> character (len=30)fstr ! create a format on the fly<br> integer n_dgts, na, nb<br> na = 30000<br> nb = 1000000<br> n_dgts = floor(log10(abs(real(max(na,nb)))))+1<br> !create a format on the fly<br> write(fstr,'("(2i",i4,")")')n_dgts+1<br> write(*,fstr) na, nb<br>end program<br>=====<br>Output:<br> 30000 1000000<br></div></blockquote><div><br></div><div>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.</div><div>Just for information, on which compilers have you tried?</div><div><br></div><div>Thanks,</div><div><br></div><div><br></div><div>GS</div><br></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div><span class="Apple-style-span" style="color: rgb(126, 126, 126); font-size: 16px; font-style: italic; "><br class="Apple-interchange-newline">§ Gabriele Sclauzero, EPFL SB ITP CSEA</span></div><div><font class="Apple-style-span" color="#7E7E7E"><i> PH H2 462, Station 3, CH-1015 Lausanne</i></font></div></span>
</div>
<br></body></html>