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 

A run-time error - what´s the reason?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Wed May 20, 2020 1:40 pm    Post subject: A run-time error - what´s the reason? Reply with quote

After running my program, I get the following run-time crash:
[url]

[/url]

The message above seems to me inexplicable, since I have all definitions needed.

In subroutine is the USE module declared as follows:
Code:

SUBROUTINE MAP ()
   USE MSWIN
    USE DX_DY
   
    IMPLICIT NONE
...

    print*,'X=',x(87312), 'Y=', y(87312),'DX=',dx(87312),'DY=',dy(87312)
    x_min_mr = minval(x); PRINT*,'X_MIN_MR', x_min_mr
    y_min_mr = minval(y); PRINT*,'Y_MIN_MR', y_min_mr
    x_max_mr = maxval(x); PRINT*,'X_MAX_MR', x_max_mr
    y_max_mr = maxval(y); PRINT*,'Y_MAX_MR', y_max_mr
    pause


and also in the module:

Code:

MODULE DX_DY
USE MSWIN
IMPLICIT NONE
REAL*8 x_min_now, x_max_now, y_min_now, y_max_now, x_min_mr, x_max_mr, y_min_mr, y_max_mr
...


The run-time error declares that there is undefined variable (it points to the variables X_MAX_MR and Y_MAX_MR).

However, when I let PRINT them to the screen in the preceding line as
print*,'X=',x(87312), 'Y=', y(87312),'DX=',dx(87312),'DY=',dy(87312),
it prints out to the screen correct maximum values.

Even the commands
Code:

x_min_mr = minval(x); PRINT*,'X_MIN_MR', x_min_mr 
y_min_mr = minval(y); PRINT*,'Y_MIN_MR', y_min_mr 

are OK (the minimum values are correctly determined by the function MINVAL both for X and Y.

It fails with functions MAXVAL
Code:

 x_max_mr = maxval(x); PRINT*,'X_MAX_MR', x_max_mr
    y_max_mr = maxval(y); PRINT*,'Y_MAX_MR', y_max_mr


and writes the run-time error message above.

Has anyone a tip what´s wrong?
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1420

PostPosted: Wed May 20, 2020 1:55 pm    Post subject: Reply with quote

You are confusing "declared/undeclared" with "defined/undefined".

Look at the variables whose values are used on line 242 of your graphics.f95. The runtime error message is saying that one or more of those variables were being referenced, but had no value entered into it/them earlier. In other words, the value of the variable is "undefined".

A future version of the compiler may name the variable(s) concerned in addition to reporting the line number and giving a traceback (see http://forums.silverfrost.com/viewtopic.php?t=4157). For now, you can run the program inside the debugger and, when the error is encountered, examine the values of the variables that occur on that line.
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Wed May 20, 2020 2:07 pm    Post subject: Reply with quote

Thanks for reply Mecej4!

However, I am still confused! A few lines before the line 242, there is a DO loop defined which read in all data necessary for variable X and Y (both are one dimensional arrays), each with 87312 values, so X(87312) and Y(87312).

I PRINT last values on the screen - and they are there and OK.
MINVAL command for both variables produces correct minimum values and
MAXVAL commands causes run-time although 3 lines before I am able to see on the screen their correct maximum values. So, in my opinion, all X,Y values are defined.
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Wed May 20, 2020 2:23 pm    Post subject: Reply with quote

Mecej4,

just to illustrate my confusion - have a look at this picture:
[url]

[/url]

So, this is output of MAX values for X,Y (1st line) and MIN values for X,Y
(subsequent lines). This PRINT is placed just before MINVAL and MAXVAL functions. MINVAL works, MAXVAL not. Why, when both arrays (X,Y) are fully defined?
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2178
Location: Yateley, Hants, UK

PostPosted: Wed May 20, 2020 2:49 pm    Post subject: Reply with quote

Martin, might it be a misspelling in a Common block? Last time round it was variables transposed.

Eddie
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1420

PostPosted: Wed May 20, 2020 2:56 pm    Post subject: Reply with quote

Martin, please show/make available the entire code.

It is usually a waste of time to speculate about a small segment of code. The source of the error may well lie in the portions not shown, and your expectations and disgnoses of the bugs may misguide and bias the reviewer.

The usual recipe is: zip up the program source, include files, if any, data files, if any, plus instructions to build (which compiler options to use, compiler version, etc.) and run the program, with sufficient detail to enable any interested person to reproduce the problem. Then, upload the zip file to a cloud service such as Dropbox, Google Cloud, etc., allow public access to the uploaded file in the cloud, and provide a link to that file in a reply in this forum.
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Wed May 20, 2020 3:08 pm    Post subject: Reply with quote

Eddie,

here more illustrative part of the code (it is in a subroutine with a DO loop reading in the X,Y,DX,DY values). The subroutine uses MODULE DX_DY.

Code:

X_Y_DX_DY_nacitavanie: do m = 1,pr_subor4
   
      if (m.le.7) then   
          read (8,*) riadok
      else
         
         read (8,*) x(m-7), y(m-7), dx(m-7), dy(m-7)
         
        end if

    end do X_Y_DX_DY_nacitavanie


And then - directly comes the MINVAL/MAXVAL functions (the PRINT is temporary only, since I do NOT understand the reason of run-time, therefore
I PRINT the MAX values of X, Y arrays immediately AFTER ending the DO loop above to see the MAX values on the screen, since below the MAXVAL function does not work (causes crash).

Code:

   print*,'X=',x(87312), 'Y=', y(87312),'DX=',dx(87312),'DY=',dy(87312)
    x_min_mr = minval(x); PRINT*,'X_MIN_MR', x_min_mr
    y_min_mr = minval(y); PRINT*,'Y_MIN_MR', y_min_mr
    x_max_mr = maxval(x); PRINT*,'X_MAX_MR', x_max_mr
    y_max_mr = maxval(y); PRINT*,'Y_MAX_MR', y_max_mr
    pause


Also here, the PRINT is temporary only to see the values. Therefore
you see in my previous post the Xmax and Ymax transposed (but they are not really transposed, they are juts PRINTed in such way before calling MAXVAL function which causes run-time.

Although I use in the subroutine two COMMON blocks (from main program), MODULE DX_DY is unaffected with these COMMONS. So, I am stuck now.

But maybe elsewhere is the error, since I created the MODULE DX_DY from the subroutine itself (which contained all what is now in MODULE) to streamline the programming, since I had to use many COMMON blocks.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6561
Location: Salford, UK

PostPosted: Wed May 20, 2020 3:46 pm    Post subject: Reply with quote

Martin

As mecej4 has pointed out, you have two options.

1) Run your executable by starting up the debugger. Press F6 to "Continue". The execution will stop at the point of failure. Then you can look at the values of the variables and array elements at the current line. The debugger will show variables or array elements as "undefined" when this is the case. Or

2) Zip up your project, put it in DropBox and post a link.
Back to top
View user's profile Send private message AIM Address
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Wed May 20, 2020 3:51 pm    Post subject: Reply with quote

Thanks to all!

It seems that I am on the trace of the problem. I will inform about it in this section!
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Wed May 20, 2020 8:40 pm    Post subject: Reply with quote

I catched it! I use 2 parameter values and their were interchanged in my MODULE!

Again - many thanks for all your reactions!
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1420

PostPosted: Thu May 21, 2020 3:28 am    Post subject: Re: Reply with quote

Martin_K wrote:
I catched it! I use 2 parameter values and their were interchanged in my MODULE!


There was no mention of "parameter" in any of your posts in this thread, and I don't think that you should have expected us to diagnose your problem from the incomplete information that you provided.
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Thu May 21, 2020 7:49 am    Post subject: Reply with quote

I know that I did not mention the parameters. But I never thought that there could be a problem. Simply, by re-programming a subroutine (which was already very large and became untransparent) to a module, I interchanged their values. Finally, the message of the run time error was correct.

I printed out last few final values of one array and there were some values missing at the end which should be there (because it had smaller dimension due to interchanged values). So I found the problem.

Again - many thanks for your considerations and tips!
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
Page 1 of 1

 
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