Error: Unexpected data declaration statement AND symbol has no IMPLICIT type

31 views Asked by At

I'm an amateur in Fortran. I met a strange error when immitating youtube tutorial of FORTRAN in 100 Seconds to write a simple program:

1 program myApp
2 implicit none
3     integer :: jeff
4     jeff = 23
5     print *, jeff
6     real :: c
7     read (*,*) c
8 end program myApp

Error message:

.\app4.f90:6:13:

     real :: c
             1
Error: Unexpected data declaration statement at (1)
.\app4.f90:7:16:

     read (*,*) c
                1
Error: Symbol 'c' at (1) has no IMPLICIT type

I searched by Google and GPT but only to be told to declare c before using it while this actually had been done by me.

I'm using Vscode and my gfortran compiler's version is 6.3.0.

During my debugging, I find that if I delete the 6-7th lines about c, the compilation would pass. Or even if I delete the 3-5th lines about jeff, the compilation would also pass. Or if I modify the 3-5th lines into integer :: jeff = 23 the compilation would still pass. I can't understand what's the problem here. Thanks for any help!

0

There are 0 answers