replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Run-time Error 11
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Run-time Error 11
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
star2066



Joined: 27 Jan 2015
Posts: 19

PostPosted: Wed Jan 28, 2015 5:13 am    Post subject: Re: Reply with quote

davidb wrote:
mecej4 wrote:
Star2066: Old code such as the one that you posted, with dummy argument arrays with declared size of (1), as in your subroutine RANK, will not behave properly when you use a checking option such as /CHECK.


I would leave checking on. The compiler should be able to cope with the (1) sized arrays if the option \OLD_ARRAYS is enabled. In Plato this is on the language tab (Allow old arrays) in the Properties window. It effectively changes (1) to (*).


I didn't use your way, but thx for your reply.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1901

PostPosted: Wed Jan 28, 2015 1:21 pm    Post subject: Re: Reply with quote

star2066 wrote:

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]

To compile with checks at the command line, use the /check or /undef options. In the IDE, select corresponding options.

In your main program, change
Code:
write(12,*)'   x rank=', xr,'   y rank=',yr
to
Code:
write(12,*)'   x rank=', xr(:n),'   y rank=',yr(:n)
The "reference to undefined" runtime error occurred because the subroutines assigned values only in the subscript range 1:n. Attempting to print the whole array causes an abort when xr(n+1) is referenced.

Last edited by mecej4 on Wed Jan 28, 2015 3:30 pm; edited 1 time in total
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1901

PostPosted: Wed Jan 28, 2015 1:22 pm    Post subject: Re: Reply with quote

You may not be aware that FTN95 comes with a subroutine, RSORT@, for creating a rank index array for a real array. Using that subroutine, your program can be abbreviated to
Code:
      program test
      implicit none
      real :: r1,r2,c1,c2,e,x
      integer, parameter :: NN = 50
      real, dimension(NN) :: xp, yp
      integer, dimension(NN) :: ir,jr
      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 coeff of rel before change point to continue'
      read *, r1
      print *,'input coef of rel after change point to continue'
      read *, r2
      c1 = sqrt(1-r1**2)
      c2 = sqrt(1-r2**2)
      write(*,*) 'c1=', c1,'c2=', c2
      do i = 1,n1+n2
         call random_number(e)
         call random_number(x)
         xp(i)=x
         if (i<n1) then
            yp(i) = x*r1+e*c1
         else
            yp(i) = x*r2+e*c2
         endif
      end do
      n=n1+n2
      call rsort@(ir,xp,n)
      write(*,51)'x-price',(i,ir(i),xp(ir(i)),i=1,n)
      call rsort@(jr,yp,n)
      write(*,51)'y-price',(i,jr(i),yp(jr(i)),i=1,n)
  51  FORMAT(/A,/,(i3,2x,i3,2x,F12.4))
      end program test
Back to top
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Wed Jan 28, 2015 9:09 pm    Post subject: Re: Reply with quote

star2066 wrote:

I didn't use your way, but thx for your reply.


No worries star2066. I hope you made some good progress anyway.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
star2066



Joined: 27 Jan 2015
Posts: 19

PostPosted: Thu Jan 29, 2015 12:28 am    Post subject: Re: Reply with quote

mecej4 wrote:
You may not be aware that FTN95 comes with a subroutine, RSORT@, for creating a rank index array for a real array. Using that subroutine, your program can be abbreviated to
Code:
      program test
      implicit none
      real :: r1,r2,c1,c2,e,x
      integer, parameter :: NN = 50
      real, dimension(NN) :: xp, yp
      integer, dimension(NN) :: ir,jr
      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 coeff of rel before change point to continue'
      read *, r1
      print *,'input coef of rel after change point to continue'
      read *, r2
      c1 = sqrt(1-r1**2)
      c2 = sqrt(1-r2**2)
      write(*,*) 'c1=', c1,'c2=', c2
      do i = 1,n1+n2
         call random_number(e)
         call random_number(x)
         xp(i)=x
         if (i<n1) then
            yp(i) = x*r1+e*c1
         else
            yp(i) = x*r2+e*c2
         endif
      end do
      n=n1+n2
      call rsort@(ir,xp,n)
      write(*,51)'x-price',(i,ir(i),xp(ir(i)),i=1,n)
      call rsort@(jr,yp,n)
      write(*,51)'y-price',(i,jr(i),yp(jr(i)),i=1,n)
  51  FORMAT(/A,/,(i3,2x,i3,2x,F12.4))
      end program test


I run your code, one thing, the xp and yp are same every time. should we use random seed(0) first?
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1901

PostPosted: Thu Jan 29, 2015 12:38 am    Post subject: Reply with quote

Quote:
I run your code, one thing, the xp and yp are same every time. should we use random seed(0) first?
Perhaps; does this remark not apply to your original program, as well? What is the objection to starting with the same seed every time?

I do not know the purpose of your program, and my comments and suggestions were weighted towards the programming aspects, and to indicate how you could concentrate on your problem proper by leveraging available library routines.

In a program that uses pseudo-random numbers, it is useful to start out with code that generates the same sequence every time, which makes debugging easier, after which you can generate a seed using the system clock reading or something similar.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group