adwaita#adwaita-HP-2000-Notebook-PC:~/Downloads/netcdf-fortran-4.4.1/v2.9$ make install
f77 -c gwrdge.f
gwrdge.inc: In function `luserd':
gwrdge.inc:32:
STRUCTURE /gwridge/
1 2
Unrecognized statement name at (1) and invalid form for assignment or statement-function definition at (2)
gwrdge.inc:50:
END STRUCTURE
^
Invalid form for END statement at (^)
gwrdge.f:106:
RECORD /gwridge/ rdg
1 2
Unrecognized statement name at (1) and invalid form for assignment or statement-function definition at (2)
gwrdge.inc:50:
END STRUCTURE
1
gwrdge.f:107: (continued):
REAL rt
2
Statement at (2) invalid in context established by statement at (1)
gwrdge.f:100:
LOGICAL FUNCTION LUSERD(rdg)
1
gwrdge.f:111: (continued):
IF(rdg.lon .LT. lon1 .OR.
2
Invalid declaration of or reference to symbol `rdg' at (2) [initially seen at (1)]
gwrdge.f:111:
IF(rdg.lon .LT. lon1 .OR.
^
Period at (^) not followed by valid keyword forming a valid binary operator; `.lon.' is not a valid binary operator
gwrdge.f:111:
IF(rdg.lon .LT. lon1 .OR.
^
Invalid declaration of or reference to symbol `lt' at (^) [initially seen at (^)]
These DEC extensions are just now in the process of being implemented in gfortran. You cannot use them in the present version. See the thread https://gcc.gnu.org/ml/fortran/2014-10/msg00080.html
You may try to convert the code to standard Fortran or use a different compiler. For example, the Oracle Solaris Studio supports them http://docs.oracle.com/cd/E19205-01/819-5262/aeulw/index.html.
Related
I start learning Fortran and I'm doing a little case test program where the user types two real numbers and selects an arithmetic operators (from + - * /). The following error appears when the user selects "*"
F6502 : read <con> - positive integer expected in repeat field
and if the user selects "/" the compiler executes the default case, and displays this message
invalid operator, thanks
the result is 0.000000E+00
The program is as follows.
program operateur
implicit none
CHARACTER(LEN=1) :: oper
real::a,b,res
print*,'Give the first number a :'
read*,a
print*,'Give the second number b :'
read*,b
print*,'which operation ?'
read*,oper
!print*,'donnez a,b,oper :'
! read(*,*)a,b,oper
select case (oper)
case ('+')
res=a+b
case ('-')
res=a-b
case ('*')
res=a*b
case ('/')
res=a/b
case default
print*, "Invalid Operator, thanks"
end select
print*,'the result is ',res
end program operateur
FORTRAN input and output formatting rules are rather involved. Each input and ouptut statement has two arguments that have special meaning. For example
READ (10,"(2I10)") m,n
The first argument is a file descriptor. Here it is 10. The second argument "(2I10)" is the format specifier. If you give an asterisk (*) as a format specifier you switch on the list-directed formatting mode.
List directed input as the name suggests is controlled by the argument list of the input operator.
1. Why asterisk (*) is special in list-directed input mode?
The input list is split into one or more input records. Each input record is of the form c, k*c or k* where c is a literal constant, and k is an integer literal constant. For example,
5*1.01
as an instance of k*c scheme is interpreted as 5 copies of number 1.01
5*
is interpreted as 5 copies of null input record.
The symbol asterisk (*) has a special meaning in list-directed input mode. Some compiler runtimes would report a runtime error when they encounter asterisk without an integer constant in list-directed input, other compilers would read an asterisk. For instance GNU Fortran compiler is known for standards compliance, so its runtime would accept *. Other compiler runtimes might fail.
2. What's up with slash (/)?
A comma (,), a slash (/) and a sequence of one or more blanks ( ) are considered record separators in list-directed input mode.
There is no simple way to input a slash on its own in this mode.
3. Possible solution: specify format explicitly
What you can do to make the runtime accept a single slash or an asterisk is to leave the list-directed input mode by specifying the format explicitly:
read (*,"(A1)") oper
should let you input any single character.
Ok then the correct source code is
program operateur
implicit none
CHARACTER(LEN=1) :: oper
real::a,b,res
print*,'Give the first number a :'
read*,a
print*,'Give the second number b :'
read*,b
print*,'which operation ?'
read (*,"(A1)") oper
select case (oper)
case ('+')
res=a+b
case ('-')
res=a-b
case ('*')
res=a*b
case ('/')
res=a/b
case default
print*, "Invalid Operator, thanks"
end select
print*,'the result is ',res
end program operateur
I start learning Fortran and I'm doing a little case test program where the user types two real numbers and selects an arithmetic operators (from + - * /). The following error appears when the user selects "*"
F6502 : read <con> - positive integer expected in repeat field
and if the user selects "/" the compiler executes the default case, and displays this message
invalid operator, thanks
the result is 0.000000E+00
The program is as follows.
program operateur
implicit none
CHARACTER(LEN=1) :: oper
real::a,b,res
print*,'Give the first number a :'
read*,a
print*,'Give the second number b :'
read*,b
print*,'which operation ?'
read*,oper
!print*,'donnez a,b,oper :'
! read(*,*)a,b,oper
select case (oper)
case ('+')
res=a+b
case ('-')
res=a-b
case ('*')
res=a*b
case ('/')
res=a/b
case default
print*, "Invalid Operator, thanks"
end select
print*,'the result is ',res
end program operateur
FORTRAN input and output formatting rules are rather involved. Each input and ouptut statement has two arguments that have special meaning. For example
READ (10,"(2I10)") m,n
The first argument is a file descriptor. Here it is 10. The second argument "(2I10)" is the format specifier. If you give an asterisk (*) as a format specifier you switch on the list-directed formatting mode.
List directed input as the name suggests is controlled by the argument list of the input operator.
1. Why asterisk (*) is special in list-directed input mode?
The input list is split into one or more input records. Each input record is of the form c, k*c or k* where c is a literal constant, and k is an integer literal constant. For example,
5*1.01
as an instance of k*c scheme is interpreted as 5 copies of number 1.01
5*
is interpreted as 5 copies of null input record.
The symbol asterisk (*) has a special meaning in list-directed input mode. Some compiler runtimes would report a runtime error when they encounter asterisk without an integer constant in list-directed input, other compilers would read an asterisk. For instance GNU Fortran compiler is known for standards compliance, so its runtime would accept *. Other compiler runtimes might fail.
2. What's up with slash (/)?
A comma (,), a slash (/) and a sequence of one or more blanks ( ) are considered record separators in list-directed input mode.
There is no simple way to input a slash on its own in this mode.
3. Possible solution: specify format explicitly
What you can do to make the runtime accept a single slash or an asterisk is to leave the list-directed input mode by specifying the format explicitly:
read (*,"(A1)") oper
should let you input any single character.
Ok then the correct source code is
program operateur
implicit none
CHARACTER(LEN=1) :: oper
real::a,b,res
print*,'Give the first number a :'
read*,a
print*,'Give the second number b :'
read*,b
print*,'which operation ?'
read (*,"(A1)") oper
select case (oper)
case ('+')
res=a+b
case ('-')
res=a-b
case ('*')
res=a*b
case ('/')
res=a/b
case default
print*, "Invalid Operator, thanks"
end select
print*,'the result is ',res
end program operateur
Here's test code:
program testcase
implicit none
integer :: ios, lu
type derived
integer :: a
end type derived
type (derived) :: d
namelist /test/ d
lu = 3
open (lu, file = 'test.dat', status='old', iostat=ios)
read (lu, nml = test, iostat=ios)
if (ios /= 0) then
write (*, *) 'error!'
else
write (*, *) 'good!', d % a
endif
end program testcase
This program reads an input file test.dat which contains a namelist for test whose type is a derived type derived.
When I try next content for test.dat it works fine(it prints good! 7):
&test
d%a = 7
/
However, with next content, I get an error:
&test
d % a = 7
/
Equal sign must follow namelist object name d
What's different is the whitespaces around % sign for component access in derived type.
I've tested with GNU Fortran(gfortran) 5.3.0. I also heard from my colleague that same problem occurred with latest Intel Fortran compiler. He also insisted that the old version of Intel Fortran compiler worked fine with both cases.
Is this behavior is normal? That is, does the standard forbid whitespaces around % in namelist input file, while whitespaces around % are allowed in source code?
Or, is this a bug of compiler or implementation of standard library?
Finally, I found some references which mention this problem.
From http://technion.ac.il/doc/intel/compiler_f/main_for/lref_for/source_files/pghnminp.htm ,
&group-name object = value [, object = value] .../
...
object
Is the name (or subobject designator) of an entity defined in the
NAMELIST declaration of the group name. The object name must not
contain embedded blanks except within the parentheses of a subscript
or substring specifier. Each object must be contained in a single
record.
Another one from http://docs.cray.com/books/S-3693-51/html-S-3693-51/i5lylchri.html ,
2.13.1.1. Names in Name-value Pairs
...
A name in an input record must not contain embedded blanks. A name in the name-value pair can be preceded or followed by one or more
blanks.
So, apparently, it seems that whitespaces in name are never allowed.
I start learning Fortran and I'm doing a little case test program where the user types two real numbers and selects an arithmetic operators (from + - * /). The following error appears when the user selects "*"
F6502 : read <con> - positive integer expected in repeat field
and if the user selects "/" the compiler executes the default case, and displays this message
invalid operator, thanks
the result is 0.000000E+00
The program is as follows.
program operateur
implicit none
CHARACTER(LEN=1) :: oper
real::a,b,res
print*,'Give the first number a :'
read*,a
print*,'Give the second number b :'
read*,b
print*,'which operation ?'
read*,oper
!print*,'donnez a,b,oper :'
! read(*,*)a,b,oper
select case (oper)
case ('+')
res=a+b
case ('-')
res=a-b
case ('*')
res=a*b
case ('/')
res=a/b
case default
print*, "Invalid Operator, thanks"
end select
print*,'the result is ',res
end program operateur
FORTRAN input and output formatting rules are rather involved. Each input and ouptut statement has two arguments that have special meaning. For example
READ (10,"(2I10)") m,n
The first argument is a file descriptor. Here it is 10. The second argument "(2I10)" is the format specifier. If you give an asterisk (*) as a format specifier you switch on the list-directed formatting mode.
List directed input as the name suggests is controlled by the argument list of the input operator.
1. Why asterisk (*) is special in list-directed input mode?
The input list is split into one or more input records. Each input record is of the form c, k*c or k* where c is a literal constant, and k is an integer literal constant. For example,
5*1.01
as an instance of k*c scheme is interpreted as 5 copies of number 1.01
5*
is interpreted as 5 copies of null input record.
The symbol asterisk (*) has a special meaning in list-directed input mode. Some compiler runtimes would report a runtime error when they encounter asterisk without an integer constant in list-directed input, other compilers would read an asterisk. For instance GNU Fortran compiler is known for standards compliance, so its runtime would accept *. Other compiler runtimes might fail.
2. What's up with slash (/)?
A comma (,), a slash (/) and a sequence of one or more blanks ( ) are considered record separators in list-directed input mode.
There is no simple way to input a slash on its own in this mode.
3. Possible solution: specify format explicitly
What you can do to make the runtime accept a single slash or an asterisk is to leave the list-directed input mode by specifying the format explicitly:
read (*,"(A1)") oper
should let you input any single character.
Ok then the correct source code is
program operateur
implicit none
CHARACTER(LEN=1) :: oper
real::a,b,res
print*,'Give the first number a :'
read*,a
print*,'Give the second number b :'
read*,b
print*,'which operation ?'
read (*,"(A1)") oper
select case (oper)
case ('+')
res=a+b
case ('-')
res=a-b
case ('*')
res=a*b
case ('/')
res=a/b
case default
print*, "Invalid Operator, thanks"
end select
print*,'the result is ',res
end program operateur
The Fortran compiler reports an error
Expected right parenthesis in expression at (1)
What does it mean?
program energy
real::Es=0.4,Ep=-0.4,ts=0.2,tsp=2.0
integer::Nx=100
real::kx(101)
real::ky
kx(1)=-0.50
do i=1,Nx
kx(i+1)=kx(1)+i*(1.00/Nx)
end do
print*, 'Enter value for ky'
read*,ky
do i=1,101
! "The error mentions it in the next line in terminal"
Epos(i)=sqrt(-Es*(Ep+2*ts*(cos(kx(i))+cos(ky)))-(2*ts*(cos(kx(i))+cos(ky))*(Ep-2*ts*(cos(kx(i))+cos(ky))))+(4*tsp**2)*((sin(kx(i)))**2 +(sin(ky))**2)))
end do
write(*,*) Epos
end program energy
Your line is too long... You can either specify -ffree-line-length-0 for gfortran to remove the limit, or (what I would prefer), break your lines using &:
Epos(i)=sqrt( - Es*(Ep+2*ts*(cos(kx(i))+cos(ky))) &
- (2*ts*(cos(kx(i))+cos(ky))*(Ep-2*ts*(cos(kx(i))+cos(ky)))) &
+ (4*tsp**2)*((sin(kx(i)))**2 +(sin(ky))**2) )
There are two additional issues with your code:
One right bracket too much
Missing declaration of Epos