|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Wed May 20, 2020 1:40 pm Post subject: A run-time error - what´s the reason? |
|
|
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 |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Wed May 20, 2020 1:55 pm Post subject: |
|
|
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 |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Wed May 20, 2020 2:07 pm Post subject: |
|
|
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 |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Wed May 20, 2020 2:23 pm Post subject: |
|
|
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 |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed May 20, 2020 2:49 pm Post subject: |
|
|
Martin, might it be a misspelling in a Common block? Last time round it was variables transposed.
Eddie |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Wed May 20, 2020 2:56 pm Post subject: |
|
|
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 |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Wed May 20, 2020 3:08 pm Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Wed May 20, 2020 3:46 pm Post subject: |
|
|
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 |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Wed May 20, 2020 3:51 pm Post subject: |
|
|
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 |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Wed May 20, 2020 8:40 pm Post subject: |
|
|
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 |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Thu May 21, 2020 3:28 am Post subject: Re: |
|
|
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 |
|
|
Martin_K
Joined: 09 Apr 2020 Posts: 227
|
Posted: Thu May 21, 2020 7:49 am Post subject: |
|
|
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 |
|
|
|
|
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
|