|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
KL Guest
|
Posted: Thu Dec 07, 2006 11:15 am Post subject: Problem with MAX |
|
|
Dear Paul,
this is certaily a programmer's error and of less importance.
Nevertheless, I send it because such a misuse should
lead to an error message:
I understood, that the elemental function MAX needs at least
2 arguments. Since MAX is elemental, they can be scalars or arrays.
In the following test program, MAX is used only with one array argument x. This is of course a programmer error. The statement
Max_x = Max (x)
leads to a compiler error with the message
"Array expressions, such as the array 'X', cannot be on the right hand side of scalar assignments".
However, the statement
Max_x = Max (x (1:3))
gives the wrong value 1.
Would it not be better, to give an error message whenever MAX is called with just one argument, whether it is a scalar, an array or an array section?
I have run the program with FTN95 Version 4.7 and a bat file:
del comp.lis
del *.obj
del *.exe
ftn95 MAX_Test.f95 /Checkmate /underflow /Link >> comp.lis
sdbg MAX_Test.exe
The program is:
Winapp
Program MAX_Test
Implicit None
Real , Dimension ( 3 ) :: x
Real :: Max_x
x (1) = +9.
x (2) = 0.
x (3) = +1.
! The next statement is wrong. It is detected by the compiler:
! "Array expressions, such as the array 'X', cannot be on the right hand side
! of scalar assignments"
! Max_x = Max (x)
! The next statement is also wrong, but it is not detected:
Max_x = Max (x (1:3)) ! gives the wrong answer
Write (*,*) Max_x
End MAX_Test |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Fri Dec 08, 2006 9:23 am Post subject: |
|
|
Klaus
Thank for this. I will add it to the list of things to investigate. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Wed Dec 13, 2006 8:19 am Post subject: |
|
|
Following your recommendation, this has now been fixed and improved.
The change will appear in version 5.1. |
|
Back to top |
|
|
KL Guest
|
Posted: Thu Dec 14, 2006 10:14 am Post subject: |
|
|
Paul, thank you very much
Klaus |
|
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
|