View previous topic :: View next topic |
Author |
Message |
KL
Joined: 16 Nov 2009 Posts: 155
|
Posted: Wed Jul 20, 2011 12:49 pm Post subject: Arguments of Min and Max |
|
|
It seems that arguments of different types are accepted in the elemental functions Max and Min. If this is intended, I would suggest to give a warning if not all arguments have same type and kind parameter.
Best regards,
Klaus
Code: |
Winapp
Program Test70
Real :: A_sp
Double Precision :: A_dp
Integer :: A_i4
A_sp = 1.0e+00
A_dp = 5.0d+00
A_i4 = 7
Wert_max = Max ( A_sp, A_dp, A_i4 )
Wert_min = Min ( A_sp, A_dp, A_i4 )
Write (*,*) 'Wert_max = ', Wert_max, ' Wert_min = ', Wert_min
End Program Test70
|
|
|
Back to top |
|
 |
skeptic
Joined: 22 Mar 2009 Posts: 14
|
Posted: Wed Jul 20, 2011 3:14 pm Post subject: Arguments of Min andMax |
|
|
It depends on the order of the arguments?
Try I,R then D - correct!
but R,D and I - incorrect |
|
Back to top |
|
 |
skeptic
Joined: 22 Mar 2009 Posts: 14
|
Posted: Wed Jul 20, 2011 5:32 pm Post subject: Arguments of Min and Max |
|
|
Klaus, which version are you using?
Using v5.0.0, I have tried all permutations (of Integer, Single and Double)
and all yield the correct answers. |
|
Back to top |
|
 |
KL
Joined: 16 Nov 2009 Posts: 155
|
Posted: Thu Jul 21, 2011 7:24 am Post subject: |
|
|
The standard says that "all arguments must have the same type and kind type parameters. This is also said in FTN95's help. Such coding as given in the example may not be accepted by other compilers and reduces the portability, although the "correct" answer is given.
Klaus |
|
Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Thu Jul 21, 2011 7:39 pm Post subject: |
|
|
They should be of the same type (and kind) as KL says. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
|