|
Prev: Call Array valued Fortran function from C
Next: Advice on how to keep track of allocated memory
From: Gerry Ford on 23 Apr 2008 00:31 "Richard Maine" <nospam(a)see.signature> wrote in message news:1ifqm0o.di6px0khbs3kN%nospam(a)see.signature... > Gerry Ford <gerry(a)nowhere.ford> wrote: > > >> My compiler spits out an error here, Ron, and leaves me with warning >> 179 - >> Comparing floating point quantities for equality may give misleading >> results. > > No, that is not an error. It is a warning. Error/=warning. It's no big deal, but I *did* draw an error. print *, SUM(a, MASK=MOD(a, 2)==1) error 702 - The arguments of MOD must be of the same type and kind When I changed 2 to 2.0, I was let go with a warning. I'm sick today and decided to surf and read archives. I found this from you on related topics in 2007: This is an absolutely critical point that gets repeated here many times. I suppose it has been a while. Time for the next repeat. :-) There is a specific list of things that compilers are required to detect. It is a tiny fraction of the requirements of the standard. The general philosophy is that the compiler is required to diagnose things that are always easily detectable at compile time. That's not the actual rule, but that's the flavor of the motivation. There turn out to be many rules where the simple cases are detectable at compile time, but complicated cases aren't. The standard doesn't tend to require detection of violation of those rules, but many compilers do detect the simple ones. Note that the f77 standard had *NO* required diagostics. I repeat *NONE*. That doesn't mean that the f77 standard didn't have lots of rules; the compiler just wasn't required to diagnose them. Do not make the mistake of equating things that are illegal with things that the compiler is required to diagnose. One is a rather small subset of the other. !end excerpt Maybe this covers the 2008 rehashing. Who gets the stomach flu in April? :-( -- "Life in Lubbock, Texas, taught me two things: One is that God loves you and you're going to burn in hell. The other is that sex is the most awful, filthy thing on earth and you should save it for someone you love." ~~ Butch Hancock
From: Gerry Ford on 23 Apr 2008 00:39 "Ron Shepard" <ron-shepard(a)NOSPAM.comcast.net> wrote in message news:ron-shepard-512C60.11252921042008(a)comcast.dca.giganews.com... > However, if you want to solve a different problem that does require > a mask argument, then it is generally unwise to use a floating point > comparison for equality in that mask. The same thing applies if you > write out the do loop and perform a test on each element, so this is > not something unique to mask arguments in general or to the sum() > intrinsic function in particular. In the latest example given, I > don't think that I would ever use a floating point mod() to try to > extract odd integer values, that seems like a long, round-about, and > error-prone way to do a simple operation. For example, once you get > up somewhere over a million, roundoff causes all floating point > representations of integers to be incorrect, whereas the integer > values themselves are still exact for three more orders of > magnitude. I would have to get the standard to even know what a > floating point mod() function is supposed to do in these cases, and > even after that, I would have to test my compilers to make sure they > did the right thing in these edge cases. I was surprised that it works. I'd been wanting to use a mask to figure out how the optional syntax works in something like minloc: MINLOC (ARRAY, DIM [, MASK, KIND]) Anyways, these give the same answer on my machine: s=0. do 1 i=5,50 s=s+a(i) 1 continue asum = SUM(a(5:50)) print *, SUM(a, MASK= a > 4.3) -- "Life in Lubbock, Texas, taught me two things: One is that God loves you and you're going to burn in hell. The other is that sex is the most awful, filthy thing on earth and you should save it for someone you love." ~~ Butch Hancock
First
|
Prev
|
Pages: 1 2 3 4 5 6 Prev: Call Array valued Fortran function from C Next: Advice on how to keep track of allocated memory |