- #1
Hercuflea
- 596
- 49
I'm working on a code to compute the Kahan summation of two arrays. I'm a bit new to fortran so my error is probably obvious, but I have no idea why. It seems as if I have declared the subroutine according to standard that I have read on the internet. The code is still a work in progress so I haven't written the OMP part yet. I'm getting the following errors from the ifort compiler:
summation.f90(18): error #6236: A specification statement cannot appear in the executable section.
subroutine compute(n)
----^
summation.f90(19): error #6236: A specification statement cannot appear in the executable section.
integer,parameter::dp2=selected_real_kind(15,300)
--------^
summation.f90(20): error #6236: A specification statement cannot appear in the executable section.
integer::i,count,t_stop,tick
--------^
summation.f90(21): error #6236: A specification statement cannot appear in the executable section.
real(kind=dp2),allocatable,dimension(:)::a,b
--------^
summation.f90(22): error #6236: A specification statement cannot appear in the executable section.
real(kind=dp2)::sum1
Here's my code:
summation.f90(18): error #6236: A specification statement cannot appear in the executable section.
subroutine compute(n)
----^
summation.f90(19): error #6236: A specification statement cannot appear in the executable section.
integer,parameter::dp2=selected_real_kind(15,300)
--------^
summation.f90(20): error #6236: A specification statement cannot appear in the executable section.
integer::i,count,t_stop,tick
--------^
summation.f90(21): error #6236: A specification statement cannot appear in the executable section.
real(kind=dp2),allocatable,dimension(:)::a,b
--------^
summation.f90(22): error #6236: A specification statement cannot appear in the executable section.
real(kind=dp2)::sum1
Here's my code:
Code:
program summation
implicit none
include 'omp_lib.h'
integer,parameter::dp1=selected_real_kind(15,300)
call compute(10.0d3)
call compute(2.0d0*(10.0d3))
call compute(5.0d0*(10.0d3))
call compute(10.0d4)
call compute(2.0d0*(10.0d4))
call compute(5.0d0*(10.0d4))
call compute(10.0d5)
call compute(2.0d0*(10.0d5))
call compute(5.0d0*(10.0d5))
call compute(10.0d6)
call compute(2.0d0*(10.0d6))
call compute(5.0d0*(10.0d6))
subroutine compute(n)
integer,parameter::dp2=selected_real_kind(15,300)
integer::i,count,t_stop,tick
real(kind=dp2),allocatable,dimension(:)::a,b
real(kind=dp2)::sum1
allocate(A(n))
allocate(B(n))
tick=1
count=0
t_stop=2*(10**20)
call system_clock(count,tick,t_stop)
sum1=0.0_dp2
do i=1,n
a(i)=i
b(i)=a(i)*a(i)
a(i)=a(i)+sqrt(abs(sin(b(i))))*2.34
sum1=sum1+a(i)
end do
write(*,*) n, sum1, count
deallocate(a)
deallocate(b)
end subroutine compute
end program summation