Quoted from mecej4
With two changes, your program runs fine with /check. The first is to replace (1) by (N) in the DIMENSION statement in subroutine RANK; the second is to replace (:) (darn smileys; that was left-paren, colon, right-paren) by (N) in subroutine SORT. You may not use assumed size arrays as formal arguments to a subprogram unless you also provide an explicit interface to the subprogram in the caller.
Thank you for you answer, it works. But I have a new problem:
*** Error 112, Reference to undefined variable, array element or function result (/UNDEF)
TEST - in file freeformat2.f95 at line 39 [+0efb]
program test
implicit none
real :: r1,r2,c1,c2,e,x
real,dimension(500) :: xp
real,dimension(500) :: y
real,dimension(500) :: xr
real,dimension(500) :: yr
integer :: i,n1,n2,n
print *,'input numbers before change point to continue'
read *, n1
print *,'input numbers after change point to continue'
read *, n2
print *,'input coefficient of relationship before change point to continue'
read *, r1
print *,'input coefficient of relationship after change point to continue'
read *, r2
open(unit=1, file='results.txt')
open(unit=2, file='rankresults.txt')
c1 = sqrt(1-r1**2)
c2 = sqrt(1-r2**2)
write(1,*) 'c1=', c1,'c2=', c2
y=0
do i = 1,n1+n2 ! call random_seed(0)
call random_number(e)
if (i<n1) goto 10
if (i>=n1) goto 20 ! call random_seed(0)
10 call random_number(x)
xp(i) = x
y(i) = xp(i)*r1+e*c1 ! call random_seed(0)
20 call random_number(x)
xp(i)=x
y(i) = xp(i)*r2+e*c2
write(1,*)'i=',i,' x price=', xp(i),' y price=',y(i)
print *,'i=',i,' x price=', xp(i),' y price=',y(i)
end do
n=n1+n2
call rank(xp,n,xr)
call rank(y,n,yr)
write(2,*)' x rank=', xr,' y rank=',yr
end program test