So I was trying to make algorithm in fortran for solving simpsons 1/3rule. The code works for real kind=4 but not for real kind 16 it throws segmentation fault. So here I will give the code. Module file:-
   module simpsonsonethirdmod
   implicit none
   public::si
   contains
   subroutine si(f,A,B,i,e,d,s1,s2,sum_,s_even,s_odd,result_,s,k)
   real(kind=16),external::f
   real(kind=16),allocatable,dimension(:)::A,B
   real(kind=16):: i,e,d,s1,s2,sum_,s_even,s_odd,result_
   integer(kind=16)::s,k
   print *,"enter the starting value of integral"
   read(*,*) i
   print *,"enter the final value of the integral"
   read(*,*) e
   print *,"enter the number of intervals you want"
   read(*,*) s
   allocate(A(s+1),B(s+1))
   A(1)=f(0)
   d=(e-i)/real(s)
   s1=d
   s2=d
   sum_=0
   do k=2,s+1
   A(k)=f(d)
   d=s2+d
   end do
   do k=1,s+1
   B(k)=A(k)
   end do
   do k=2,s+1,2
   B(k+2)=B(k+2)+B(k)
   s_odd= B(k+2)
   end do
   do k=1,s+1
   sum_=sum_+A(k)
   end do
   s_even=sum_-s_odd-A(1)-A(s+1)
   d=s1
   result_=(d/3.0)*(A(1)+A(s+1)+2*s_even+4*s_odd)
   print *,"The integral by simpson's rule is",result_
   deallocate(A,B)
   end subroutine si
   end module simpsonsonethirdmod
Main program::-
 program simpsonsonethird
 use simpsonsonethirdmod
 real(kind=4),external::f
 real(kind=4)::i,e,d,s1,s2,sum_,s_even,s_odd,result_,start_time,end_time
 real(kind=4),allocatable,dimension(:)::A,B
 integer(kind=4)::s,k
 call cpu_time(start_time)
 call si(f,A,B,i,e,d,s1,s2,sum_,s_even,s_odd,result_,s,k)
 call cpu_time(end_time)
 print *,"Time taken in seconds =",end_time-start_time
 end program simpsonsonethird
 real(kind=4) function f(x)
 real(kind=4)::x
 f=x**2
 end function f
However when i run the program for kind 16. So the program becomes. Module file:-
       module simpsonsonethirdmod
       implicit none
       public::si
       contains
       subroutine si(f,A,B,i,e,d,s1,s2,sum_,s_even,s_odd,result_,s,k)
       real(kind=16),external::f
       real(kind=16),allocatable,dimension(:)::A,B
       real(kind=16):: i,e,d,s1,s2,sum_,s_even,s_odd,result_
       integer(kind=16)::s,k
       print *,"enter the starting value of integral"
       read(*,*) i
       print *,"enter the final value of the integral"
       read(*,*) e
       print *,"enter the number of intervals you want"
       read(*,*) s
       allocate(A(s+1),B(s+1))
       A(1)=f(0)
       d=(e-i)/real(s)
       s1=d
       s2=d
       sum_=0
       do k=2,s+1
       A(k)=f(d)
       d=s2+d
 end do
       do k=1,s+1
        B(k)=A(k)
        end do
        do k=2,s+1,2
        B(k+2)=B(k+2)+B(k)
       s_odd= B(k+2)
        end do
        do k=1,s+1
        sum_=sum_+A(k)
        end do
        s_even=sum_-s_odd-A(1)-A(s+1)
        d=s1
        result_=(d/3.0)*(A(1)+A(s+1)+2*s_even+4*s_odd)
        print *,"The integral by simpson's rule is",result_
  
        deallocate(A,B)
       
 
 
        end subroutine si
 
        end module simpsonsonethirdmod
Main file:-
 program simpsonsonethird
 use simpsonsonethirdmod
real(kind=16),external::f
 real(kind=16)::i,e,d,s1,s2,sum_,s_even,s_odd,result_,start_time,end_time
 real(kind=16),allocatable,dimension(:)::A,B
 integer(kind=16)::s,k
 call cpu_time(start_time)
 call si(f,A,B,i,e,d,s1,s2,sum_,s_even,s_odd,result_,s,k)
 call cpu_time(end_time)
print *,"Time taken in seconds =",end_time-start_time
end program simpsonsonethird
real(kind=16) function f(x)
real(kind=16)::x
  f=x**2
end function f
So I am working on windows 10 and i am working on 20.04.3 LTS. And I can assure you real 16 variables work for me .ie. they have worked for previous code. Please help me on how to modify this code for real 16.

