This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Fortran help
On Thu, Jul 31, 2008 at 01:25:46PM -0400, Vardhan, Sundara (GE Infra, Energy) wrote:
>
> Please find the below code which has been tested successfully
> using f77, but fails on the FORMAT statement when trying to
> compile with gfortran. Hope this helps. Thanks much in advance.
>
> PROGRAM TESTGE
>
> INTEGER TESTLEN
> PARAMETER (TESTLEN = 4)
>
> CHARACTER*(1*TESTLEN) ANS
CHARACTER(len=10) fmt
>
> WRITE(*,*) "enter a string",TESTLEN," chars long"
write(fmt, '(A,I0)') 'A', TESTLEN
> READ (*,100) ANS
READ(*,fmt) ANS
> 100 FORMAT(A<1*TESTLEN>)
> WRITE(*,*) "The string entered was: ",ANS
>
> END
>
FORMAT(A<1*TESTLEN>) is a poorly thought out extension introduced
into g77. It should be avoided. Use the above standard conforming
use of an internal write to build your format. Hopefully, the
gfortran developers will let this extension die a timely death.
--
Steve