| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hello, Anybody knows an intrinsic function for testing if a variable is -+INF. I have found in the reference the function ISNAN but not the equivalent for INF. Thanks |
|
#2
| |||
| |||
| Hi, As if by magic, ddb78s appeared ! > > Anybody knows an intrinsic function for testing if a variable is > -+INF. I have found in the reference the function ISNAN but not the > equivalent for INF. ISNAN is not standard. To perform either of these tests you will either need a non-standard extension ( e.g. ISNAN ), so look in your compiler docs, or, and much better, use the IEEE stuff in Fortran 2003. See e.g. http://docs.sun.com/app/docs/doc/819...7bsi97k?a=view However your compiler might not support this yet, Ian |
|
#3
| |||
| |||
| Ian Bush wrote: > Hi, > > As if by magic, ddb78s appeared ! > >> Anybody knows an intrinsic function for testing if a variable is >> -+INF. I have found in the reference the function ISNAN but not the >> equivalent for INF. > > ISNAN is not standard. To perform either of these tests you will either > need a non-standard extension ( e.g. ISNAN ), so look in your compiler > docs, or, and much better, use the IEEE stuff in Fortran 2003. See > e.g. > > http://docs.sun.com/app/docs/doc/819...7bsi97k?a=view > > However your compiler might not support this yet, > Of course, you can write such functions yourself. |
|
#4
| |||
| |||
| For information: The latest Pathscale compiler (pathf90) compiles and run the following: use ieee_arithmetic .. .. .. if (ieee_is_nan(y(i))) then .... endif Latest Intel or g95 do not recognize resolutiion of the use statement. Skip Knoble On Wed, 18 Jul 2007 13:01:51 GMT, Tim Prince <timothyprince@sbcglobal.net> wrote: -|Ian Bush wrote: -|> Hi, -|> -|> As if by magic, ddb78s appeared ! -|> -|>> Anybody knows an intrinsic function for testing if a variable is -|>> -+INF. I have found in the reference the function ISNAN but not the -|>> equivalent for INF. -|> -|> ISNAN is not standard. To perform either of these tests you will either -|> need a non-standard extension ( e.g. ISNAN ), so look in your compiler -|> docs, or, and much better, use the IEEE stuff in Fortran 2003. See -|> e.g. -|> -|> http://docs.sun.com/app/docs/doc/819...7bsi97k?a=view -|> -|> However your compiler might not support this yet, -|> -| -|Of course, you can write such functions yourself. |
|
#5
| |||
| |||
| I was wrong about g95. It does support logical function ieee_is_nan(x) and companion use ieee_arithmetic. Skip On Wed, 18 Jul 2007 10:12:20 -0400, Herman D. Knoble <SkipKnobleLESS@SPAMpsu.DOT.edu> wrote: -|Latest Intel or g95 do not recognize resolutiion of the use statement. |
|
#6
| |||
| |||
| Ian Bush wrote: .... > As if by magic, ddb78s appeared ! .... >> Anybody knows an intrinsic function for testing if a variable >> is -+INF. I have found in the reference the function ISNAN but not >> the equivalent for INF. > > ISNAN is not standard. To perform either of these tests you will > either need a non-standard extension ( e.g. ISNAN ), so look in your > compiler docs, or, and much better, use the IEEE stuff in Fortran > 2003. [...] The two options are not mutually exclusive. I would recommend USE IEEE_ARITHMETIC, & ISNAN=>IEEE_IS_NAN, & ISFINITE=>IEEE_IS_FINITE That way you're not stuck with the unnecessarily verbose names. -- J. Giles "I conclude that there are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies." -- C. A. R. Hoare |
|
#7
| |||
| |||
| In article <hi8s93t18h4gqd8ukk3isbubuvkgpn7gkc@4ax.com>, Herman D. Knoble <SkipKnobleLESS at SPAMpsu dot edu> wrote: >I was wrong about g95. It does support logical function >ieee_is_nan(x) and companion use ieee_arithmetic. Note that parts of g95 ieee_arithmetic were wrong in versions before 17 July but are now right AFAIK. I had reported the bug that day, and about 25 hours later Andy reported that he had fixed it, so still on 17 July in his time zone:-) Look at the timestamp before downloading: g95 of 2007-07-17 21:52 or later will have been fixed. -- John Harper, School of Mathematics, Statistics and Computer Science, Victoria University, PO Box 600, Wellington 6140, New Zealand e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045 |
|
#8
| |||
| |||
| On Jul 18, 1:06 pm, "ddb..." <ddb...> wrote: > Hello, > > Anybody knows an intrinsic function for testing if a variable is > -+INF. I have found in the reference the function ISNAN but not the > equivalent for INF. > > Thanks The preferable way is the F2003's ieee_is_finite(x). If that's not supported by your compiler, then a reasonably good replacement is abs(x) <= huge(x). This typically works reliably (i.e. regardless of optimization level) with finite numbers and +-Inf, but not with NaN. So if NaN is already ruled out (e.g. by isnan), then it's OK. If not, then perhaps ..not. (abs(x) > huge(x)) may be better, but I would not bet much on magic like that. Of course, various NaN test like x /= x are not reliable either. |
|
#9
| |||
| |||
| On Jul 18, 1:06 pm, "ddb..." <ddb...> wrote: > Hello, > > Anybody knows an intrinsic function for testing if a variable is > -+INF. I have found in the reference the function ISNAN but not the > equivalent for INF. > > Thanks I'd recommend you to simulate the F2003's ieee_is_nan and ieee_is_finite, which are the standard way to achieve this: elemental logical function ieee_is_nan(x) real,intent(in):: x ieee_is_nan = isnan(x) end function elemental logical function ieee_is_finite(x) real,intent(in):: x ieee_is_finite = .not. (isnan(x) .or. abs(x) > huge(x)) end function this is a reasonably reliable replacement (always worked for me on g95, Intel and EkoPath, regardless of optimization level), and once the IEEE modules are supported by intel, you simply remove the definitions. HTH, Jaroslav |
|
#10
| |||
| |||
| On Jul 18, 7:06 am, "ddb..." <ddb...> wrote: > Anybody knows an intrinsic function for testing if a variable is > -+INF. I have found in the reference the function ISNAN but not the > equivalent for INF. See the FP_CLASS intrinsic (an extension). Steve |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.