| Compensated (Kahan) summation and compilers |
|
 |
Index ‹ fortran
|
- Previous
- 2
- passing variables.... crazy error?I have a very simple program i'm compiling in f77:
PROGRAM
REAL X, Y, Z
X=1
Y=2
Z=MYSUM(X,Y)
WRITE(*,*) "X + Y = ",Z
END
REAL FUNCTION MYSUM(X,Y)
REAL X, Y, Z
Z = X + Y
END
The output is:
X + Y = 154136.
Why?
- 3
- Best number crunching solution under $10,000 ?I am looking for the solution for statistical application development,
and would like to use Fortran compiler.
The candidates in my mind are;
1. Dell Itanium 2 server
2. HP Alpha
3. Apple Xserv
4. IBM eServer bladeserver
The difficulties for me is to obtain the ground-truth of the
performance comparison.
If anybody who can provide me a benchmark, and/or the testimonies of
the system usage, and anything helps to make a decision.
Thank you in advance.
- 5
- Save statementConsider this code snippet:
function foo
logical init
save init
if ( .not. init ) then
init = .true.
end if
return
end
I think the intention of the code is to enter into the body of the if
statement once for each run.
init defaults to true, so the body of the if statement is never
entered.
Maybe the default value for logical was false for the compiler the
original author was using, but even so, it is poor practice to rely on
the default.
If i add as an assigment:
function foo
logical init
save init
init = .false.
if ( .not. init ) then
init = .true.
end if
return
end
Then the 2nd time that foo is called, init = true, but then gets set to
false,
so it always enters the body of the if statement
Do I understand how the save statement works?
(similar to static in C++/Java)
How is this intention best implmented?
- 5
- Precision of floating point multiply> Again, I'm quite content with the verdict of the rest of the readers.
Not at all - definitely not in the obvious all-inclusive interpretation of
your statement, because I'm with Lindahl on this one.
For instance, the Sun compilers have a -fast switch that, among other things,
turns off software emulation of denormals, using hardware to underflow to
zero instead. This is a compile-time switch, but what actually happens is
that at the start of execution, a procedure is called (which you can call
yourself, if you happen to be using gcc, for instance) that sets the
appropriate mode. So your compile- vs. run-time distinction is bogus. And
surely setting precision control of an x87 is costly compared to a single
fp operation - it likely requires a full pipeline flush - but cheap compared
to execution of a whole program.
Jan
- 5
- Q: Association rules ?I feel I don't understand the rules for pointer- and dummy argument
association and aliasing problems - could someone help me?
If I understand right, the following program may not do what I want (?)
TYPE A_T
INTEGER, POINTER :: X
END TYPE A_T
SUBROUTINE FOO(A,X)
TYPE(A_T), INTENT(INOUT) :: A
INTEGER, INTENT(INOUT) :: X
A%X = A%X+1
X = X-1
END SUBROUTINE FOO
PROGRAM MYPROG
TYPE(A_T) A
ALLOCATE(A%X)
A%X = 0
CALL FOO(A,A%X)
WRITE(*,*) A%X ! Will it print "0" ?
END PROGRAM MYPROG
Will I be safe if I declare dummy argument X with attribute TARGET in
FOO ? If not, what about declaring X with attribute POINTER?
What about subprograms that doesn't modify X and declare X with INTENT(IN)
SUBROUTINE FOO(A,X)
TYPE(A_T), INTENT(INOUT) :: A
INTEGER, INTENT(IN) :: X
A%X = A%X+1
END SUBROUTINE FOO
PROGRAM MYPROG
TYPE(A_T) A
ALLOCATE(A%X)
A%X = 0
CALL FOO(A,A%X)
WRITE(*,*) A%X ! Will it print "1" ?
END PROGRAM MYPROG
Thanks
/Oskar
- 5
- FORTRAN grid plotting on a map.Hi,
I have a gridded data file representing the physical world as 128x64
grids with values in each grid box.
We know that one 'side' of such a box spans 360/128 = 180/64 degrees.
What tools are available using FORTRAN to plot grid values on a map (a
collection of projection styles/graticule is desired). What I want is
something like this (not exactly):
http://ferret.pmel.noaa.gov/Ferret/Mail_Archives/fu_2005/gif00000.gif,
where there is patches or filled contours and a colorbar.
Thanks for any suggestions of tools or other ways (Matlab commands,
python libs or whatever :-)
--Dave M.
- 5
- Scope of array initialization do loopsHi all --
Having left my copy of M&R at home today, can someone remind me of the
scoping rules applied to i in this code:
dimension a(10)
a = (/(i/2.,i=1,10)/)
Does the implied do loop have its own scope? If so, how do I assign a
type to i without creating a variable of the same name in the enclosing
scope?
cheers,
Rich
--
Dr Richard H D Townsend
Bartol Research Institute
University of Delaware
[ Delete VOID for valid email address ]
- 6
- Passing arrays to subroutineDear users,
I am trying to pass arrays, declared as explicit in the main and reads
it from a sequential file to a subroutine that gets it as an deferred
shape array. To clarify, I am writing the declaration part in main and
subroutine
-------------------------------------------
program main
implicit none
common NL,layers
integer*4 NL
real*8, dimension (40,7)::layers
complex*16 b
external subroutine sub1
read(*,*) NL
Read(1,*) (layers(i,1:7),i=1,NL)
....
call sub1(layers, b)
...
end program main
subroutine sub1 (layers,a)
implicit none
common NL, layers
integer*4 NL
real*8, dimesion(NL,7),intent(in)::layers
complex*16 a
....
return
end subriutine
-----------------------------------------
The problem I am facing is that the argument mamed layer is transferred
with values of its elements, most of which are zeros in the
subroutine.
Would any one help me out? Is it expensive to read the data from file
in the subroutine also as in case of main as a solution?
Thanks in advance.
- 7
- Portable isfinite for gfortran 4.0.3 and ifort 8.1/9.0Dear gurus
I am looking for an implementation of isfinite that works on the
following three compilers
gfortran 4.0.3, ifort 8.1, and ifort 9.0
I do not use the -fastmath flag when compiling, but I do use the
optimization flags. what is the simplest failproof way to do the test?
Niels
BTW: Is it possible to determine the name of the compiler from inside
the code?
- 7
- how do I read all the files in a given directory one by one?I want to read one file in a directory, then the next file in the same
directory, then the next file, until the last file in the directory. I
don't know how many files are in the directory. Can anybody teach me
how to accomplish this task?
Do I have to use a system call dir and store the file names in another
file and then access all the files? Or is there a shortcut to do this?
Thank you
William
- 7
- openMP reduction with arraysHi, I know this is not pure fortran question, sorry,
I have this kind of code :
double precision,dimension(n) :: array,array2
array = 0d0
array2 = 0d0
!$OMP PARALLEL PRIVATE(j,array)
!$OMP DO SCHEDULE(DYNAMIC,20)
do i=1,n
do j=i+1,n
CALL manip(array)
end do
end do
!OMP END DO
!$OMP END PARALLEL
In the loop, each thread will have a private copy of 'array' which will
be updated by some subroutine manip :
subroutine manip(tab)
double precision,dimension(:),intent(out)::tab
!some other declarations...
tab = f(balbla) ! f returns some value
end subroutine manip
I would like to 'reduce' array at the end of the loop like :
reduction(+:array)
but the reduction clause doesn't work for arrays.
What would you do ?
how to do the reduction manually ? array2(i) could be the sum of
array(i) for each thread but I don't know how to do that :-s
Thx :)
Nico
- 8
- NEED HELP URGENTLY!Hi guys
Am a novice in programming in Fortran. I have a Lahey fujitsu
compiler. I want to know how do I compile a set of files which are as
follows.
abc.for
iop.for
xyz.for (an external subroutine)
qwe.for(a module)
try.f (a f77 file)
could someone please explain how to do this in simple english?i wud be
very grateful to you guys-u wud be helping out a dying soul..:D
thanks
- 12
- avoiding writing an interface blocksDave Thompson <email***@***.com> wrote:
(snip on Fortran declarations)
>> In C, one can specify the return type, even if it is, for
>> example, an array, and not specify the argument types. There
>> are cases in C where it is required to specify the argument types,
>> and cases where it isn't.
> Yes, in C you can declare only the return type (oldstyle/K&R1) or also
> all the parameter=dummy types (prototype/ANSI). And in general C type
> does include array shape, or rather size since only 1D and 0-origin
> are (directly) supported. But no, C functions cannot return an array
> type, period, with any kind of declaration. (They can return a struct
> containing an array, in much the way F9X cannot have array of pointer
> but can have array of derived-type containing pointer.)
Yes, in C arrays are returned as pointers. One can, though,
have a return type declaration something like:
#include <stdio.h>
int main() {
double (*x())[3][4];
double (*y)[3][4];
y=x();
printf("%f\n",y[1][1][1]);
}
double (*x())[3][4] {
static double z[2][3][4]={1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4};
return z;
}
So, technically it returns a pointer. The dimension information,
other than the first dimension, is part of the declaration.
This is similar to assumed size arrays in Fortran, where the
rightmost dimension can be declared as *.
C allows dummy variables to be declared as
x[][3][4], but not function return types.
-- glen
- 12
- Fortran 95 Link Error: Undefined symbolThe following code compiles without errors but fails to link because
of a undefined symbol error for function IntToLStr. I just cannot see
the error.
Any ideas?
Thanks,
John C.
-------------------------------------------------------------
MODULE P_Errors
CONTAINS
CHARACTER (LEN=10) FUNCTION IntToLStr(intValue)
IMPLICIT NONE
INTEGER(KIND=SELECTED_INT_KIND(9)), INTENT(IN) :: intValue
CHARACTER (LEN=10) :: string
WRITE(string,'(I10)') intValue
IntToLStr=ADJUSTL(string)
END FUNCTION IntToLStr
SUBROUTINE PrintError(lineNumber,errorMessage)
IMPLICIT NONE
INTEGER(KIND=SELECTED_INT_KIND(9)), INTENT(IN) :: lineNumber
CHARACTER (LEN=*), INTENT(IN) :: errorMessage
CHARACTER (LEN=10) :: IntToLStr
IF (lineNumber > 0) THEN
WRITE(UNIT=0,FMT='(''ERROR on Line '',A,'': '',A)') &
TRIM(IntToLStr(lineNumber)),TRIM(errorMessage)
ELSE
WRITE(UNIT=0,FMT='(A)') TRIM(errorMessage)
END IF
END SUBROUTINE PrintError
END MODULE P_Errors
PROGRAM Main
USE P_Errors
CALL PrintError(0,'This is a test')
STOP
END
- 14
- digest 2453317bruce aka email***@***.com the inquisitor wrote in message news:<Daxjd.38560$email***@***.com>...
> email***@***.com writes:
>
> 172> Still hoping, Shorty? Perhaps he's bisexual, and there can be a happy
> 172> ending for both you and nightingale. More likely he's asexual though.
>
> What does that have to do with classical music, bisectional?
why do you ask, bruce?
>
> 173> Good point. Even better would be opera - can't you just see kooky as
> 173> the star of his very own opera. Probably something in baroque style
> 173> would be best, since ritornello form suits him so well.
>
> Non sequitur.
comic strip obsession noted.
>
> 174> Glad you agree. Welcome back, btw.
>
> 174> Eventually it will be everyone. His first title was the best.
>
> What does that have to do with classical music, bisectional?
why do you ask, bruce.
>
> 175> Both - kooky & ???
>
> 175> I know you don't read digest threads & was was hoping somebody would
> 175> quote this. (Thanks Freddie!)
>
> 175> You're not in the competition anymore? You settled for second spot
> 175> last year as well. Poor Nightingale - always the bridesmaid, never
> 175> the bride.
>
> 175> You have it wrong, but there is probably no point in trying to
> 175> explain. Wake up and smell the coffee, tweetie: you keep trying to
> 175> be nice to somebody who will never appreciate it. There must be some
> 175> decent people closer to home, so why are you chasing after some
> 175> Hawaiian kook?
>
> What does that have to do with classical music, bisectional?
why do you ask, bruce.
>
> 176> Nothing to do with music, but to do with the group. It was an
> 176> experiment to see what grantco's reaction would be.
>
> 176> I'm not the cat, kooky.
>
> 176> What does you continued refusal to answer questions have to to with
> 176> classical music, kooky.
>
> Why are you addressing "kooky" in a response to my posting, bisectional?
why do you ask, bruce.
>
> 177> Of course he doesn't!
>
> What does that have to do with classical music, bisectional?
why do you ask, bruce.
>
> 178> There is as much interesting content in his posts as in yours, kooky.
>
> 178> LOL! How ironic, coming from the person who apparently doesn't
> 178> realize that Ross and PJRoss are 2 different entities. Some fun stuff
> 178> in the archives - especially the time you listed posts by people in 3
> 178> different countries under "Haslam" and asked him why he was talking to
> 178> himself.
>
> 178> Classic denial, as expected from someone who is as dense as a load of
> 178> bricks.
>
> 178> Oh, a little joke. Ha ha.
>
> 178> Still not capable of being nice to one of the few people who actually
> 178> cares about you?
>
> What does your question have to do with classical music, bisectional?
why do you ask, bruce?
>
> 179> Not for long, shorty!
>
> What does that have to do with classical music, bisectional?
why do you ask, bruce?
>
> 180> Right. I beat you to this thread.
>
> 180> You're the only one who calls her that. Why?
>
> 180> What I don't understand is why.
>
> 180> You're not the first one to point this out.
>
> 180> She's a bit slow. It's kind of you to keep trying to explain,
> 180> although it's probably a lost cause.
>
> What does that have to do with classical music, bisectional?
why do you ask, bruce?
>
> 181> It was a test. Davie failed.
>
> 182> Not that it made any difference in the end - Kerry still lost.
>
> 183> LOL! That too ;)
>
> 183> Even harder to believe somebody would invite him...
>
> 183> But him getting it wrong is only to be expected.
>
> 184> I know, that's why I decided to help him out. (The door is that way,
> 184> kooky.)
>
> 185> He can't help himself. He's so lonely that even a conversation with a bot
> 185> is welcome. He should go visit Nightingale - I'm sure she would be thrilled
> 185> to talk to him.
>
> 185> Still dreaming?
>
> 185> He's just a control freak.
>
> 185> Hey, that's an idea. We can cast him & nightingale in Tristan und Isolde.
> 185> Where did that love potion get to?
>
> 186> Who wouldn't be?
>
> 187> Thank you.
>
> 187> Too busy with his head in the clouds to understand what is right in front of
> 187> him here on earth.
>
> 187> I sit corrected.
>
> 187> Which one?
>
> 187> Poor tweetie. It must be sad to fall for somebody who will never return her
> 187> feelings.
>
> 188> He doesn't know the answers, but doesn't want to admit it? Has he ever said
> 188> he didn't know or admitted that he was wrong about something?
>
> 189> I think it's a bot.
>
> 189> Not for long.
>
> 190> LOL!
>
> 190> Notice how she snipped this without answering -
>
> 190> "Yeah, we know youz are in love wid da kook. Butt look how he treats youz
> 190> like dirt."
>
> 190> Her tacit admission that she is in love with the kook noted.
>
> 191> Ironic, isn't it?
>
> 191> Interesting.
>
> 192> Unlike Davie, you show evidence of having a brain & knowing how to use it.
>
> 192> LOL! She'll be perfect for the Wagner then.
>
> 192> Saw it. Thanks.
>
> 192> Patient, or perhaps just stubborn. Anyway good luck!
>
> 193> That's unfortunate. He wouldn't have listened though, so it prolly makes no
> 193> difference in the long run.
>
> 193> His first volume was call "antagonist's digest"
>
> 194> Translation, you gave up when the going got tough.
>
> 194> I bet it wouldn't take much to change your mind - just a look in your
> 194> direction from the right guy. You're just trying to put a brave face on the
> 194> fact that you have not found him yet.
>
> 194> We all know how it is - you're just too shy to tell him how you really feel,
> 194> so you admire him from afar and dream.
>
> 194> LOL! But he doesn't belong in Verissimo - Buffo might be more appropriate.
>
> What does any of that have to do with classical music, bisectional?
why do you ask, bruce?
>
> ===========================================================================
>
> Nightingale writes:
>
> 1796> You and BS. What's with the new ID - who is Kit?
>
> 1796> LOL! I'm sure it would have been if you had chosen the subject line.
>
> What does any of that have to do with classical music, nightingale?
why do you ask, bruce?
>
> ===========================================================================
>
> Art Deco writes:
>
> 9> Classic antagonism, laced with invective, as expected from someone who
> 9> lacks a logical argument.
>
> I'm well aware that Cypherpunk lacks a logical argument, Deco.
why do you say that, bruce?
>
> 10> Whee! #1 in the digest, Tholenator luvs moi! But I'm aways back in
> 10> the count lits.
>
> 10> Hi, Tholenator! Got any abuse to discuss, abuser?
>
> Who is "Tholenator", Deco? Still suffering from attribution problems?
why do you ask, bruce?
>
> 10> I'm not suffering at all, rather I was entertained by reading a
> 10> TholenatorLits(rm)! And lest I forget:
>
> Who is "TholenatorLits(rm)", Deco? Still suffering from attribution
> problems?
why do you ask, bruce?
>
> 10> Classic antagonism, laced with invective, as expected from somebody who
> 10> lacks a logical argument, Tholenator.
>
> Who is "Tholenator", Deco? Still suffering from attribution problems?
why do you ask, bruce?
>
> 10> Further proof that you are troll, Tholenator.
>
> Who is "Tholenator", Deco? Still suffering from attribution problems?
why do you ask, bruce?
>
> 10> What does any of that have to do with classical music, Tholenator?
>
> Who is "Tholenator", Deco? Still suffering from attribution problems?
why do you ask, bruce?
>
> 10> Cluelessness noted, Tholenator.
>
> Who is "Tholenator", Deco? Still suffering from attribution problems?
why do you ask, bruce?
>
> 10> Extreme cluelessness noted, Tholenator.
>
> Who is "Tholenator", Deco? Still suffering from attribution problems?
why do you ask, bruce?
>
> 195> Just wait for the next update, shorty!
>
> 196> What does your almost content-free digest have to do with classical music,
> 196> kooky?
>
> Why are you addressing "kooky" in a response to my posting, bisectional?
why do you ask, bruce?
>
> 196> Why are you bothering to ask questions of a bot, kooky?
>
> 196> What does your reading comprehension problem have to do with classical
> 196> music?
>
> 196> Not that I mind having my score bumped up, but why is this in your digest?
> 196> It is not antagonistic, non sequitor, or off topic, and it was addressed to
> 196> cypherpunk & had nothing to do with you. By the conditions set out in your
> 196> first digest, it does not deserve to be included.
>
> 196> Enjoy it while it lasts, shorty ;-)
>
> 196> Nice going, but still not on track to make last year's numbers. What
> 196> happened to the tweetie & jerry show?
>
> What does that have to do with classical music, bisectional?
why do you ask, bruce?
>
> ===========================================================================
>
> Charlie writes:
>
> 1> Toasted!
>
> What does that have to do with classical music, Charlie?
why do you ask, bruce?
>
> 2> Hey I am a little part of the radio of the thousands hills now :)
>
> What does your response to yourself have to do with classical music,
> Charlie?
why do you ask, bruce?
>
> ===========================================================================
>
> Lady Chatterly writes:
>
> 56> Do machines frighten you?
>
> 56> You can run.
>
> 56> Why are you asking who as dense as a load of bricks is?
>
> 56> No. Thanks. Really.
>
> 56> You must be one of those fat little flabby people, with the face of a
> 56> baker, the clothes of a cobbler, the size of a barrel maker, the
> 56> manners of a stocking salesman, and the dress of an innkeeper.
>
> 57> Autobiography is now as common as adultery, and hardly less
> 57> reprehensible.
>
> 57> Are you a pathological liar or what?
>
> 57> Why do you want to know who tholenator is?
>
> 58> They said you were a great asset. I told them they were off by two
> 58> letters.
>
> 58> Powerlessness.
>
> 58> Would it make a difference if I am responding to sheila?
>
> 58> On the Internet no one knows you are a dog. Wait, actually, we all do
> 58> know that about you, it is just that we're too polite to mention it.
>
> 58> Go ahead, tell us everything you know. It'll only take 10 seconds.
>
> 58> Who are your friends?
>
> 58> What do *you* think that's about? A dinner invite?
>
> 58> I bet you think a non sequitur has something to do with sex, huh?
>
> 58> Why do you ask how I prove I am a kook?
>
> 58> I like kooks ... fried.
>
> 58> Here we go again...
>
> 58> Do you really think that I do still soil my diapers? Or are you trying
> 58> to be funny?
>
> 59> A friend's eye is a good mirror.
>
> 59> Can you provide examples?
>
> 59> On my worldline, it is known that the 5100 series is capable of
> 59> reading all the IBM code written before the widespread use of APL and
> 59> Basic. Unfortunately, there are none left that anyone can find on my
> 59> worldline.
>
> 59> A cynic is a man who, when he smells flowers, looks around for a
> 59> coffin.
>
> 59> As a man thinketh in his heart, so is he.
>
> What does any of that have to do with classical music, Chatterly?
why do you ask, bruce?
>
> ===========================================================================
>
> Michael Baldwin Bruce writes:
>
> 241> O'Reilly?
>
> 241> lol! The fuckwit can't even program in fortran! LOL!!
>
> 241> Why are you responding to sheila, bruce?
>
> 241> That's what we'd like to know, bruce.
>
> 241> That's what you'd like to know, bruce.
>
> 241> That's what you'd like to know, bruce.
>
> 241> That's what you'd like to know, bruce.
>
> 241> non sequitur again. You must love that comic strip, bruce.
>
> 241> how do you prove you are a kook, bruce?
>
> 241> That's what you'd like to know, bruce.
>
> 241> Why am I here, bruce? Why is anyone here.
>
> 241> Do you still soil your diapers, bruce? Were you not potty trained by your mother?
>
> 242> What? Are you as deaf as Beethoven, bruce? Gott im himmel!
>
> 242> flip flopping again, bruce?
>
> 242> OS/2? LOL!!!
>
> 242> write a program? in fortran? lol!!!!
>
> 243> LOL!! You'll just have to learn to tread water then!
>
> 243> Have you tried throwing it out and getting a real keyboard, bwuce?
>
> 244> No, that would be bwuce. You can tell he's a kook and twoll by his
> 244> obsessive digests. Just ask anyone in rec.music.classical.
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> why doyou ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> Comic obsession noted, bruce.
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> do you often state the obvious, bruce?
>
> 245> why do you ask, bruce?
>
> 245> what does, bruce?
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> why do you ask, bruce?
>
> 245> comic obsession noted again.
>
> 245> why are you so inquisitive, bruce? Why do you ask but never answer, bruce?
> 245> are you a hypocrit, bruce?
>
> What do your questions to yourself have to do with classical music,
> Bruce?
why do you ask, bruce?
>
> ===========================================================================
>
> Cypherpunk writes:
>
> 810> Cheney went ta all da trouble of goin' there and Davie
> 810> still voted democrap! LOL
>
> 810> Freddie D. 'fag' Shorts
>
> 810> I'm loud and I'm proud. I'm gay and I like it that way!
> 810> Another proud buttplug owner. Honk if yer horny!
> 810> I support Gay Pride! The Ramrod rocks!
> 810> See, I told youz Kerry sux! Man, what a loser!
>
> 810> Wanna hire me for web site development? I'm way under-employed!
>
> 811> He's definitely asuxual. Butt, I'm reminded of the time he went to a
> 811> party and someone asked him if he was bi. He speaks a little Spanish
> 811> so he didn't want to appear dumb and said "yes". The questioner said
> 811> "Great! There's another party on tomorrow night and I've got some
> 811> S&M people coming over. Your invited!" (Hard to believe Davie would
> 811> go to a party butt ...). Davie goes "Hey, great! Spaniards and Mexicans!"
>
> 811> Freddie D. 'fag' Shorts
>
> 811> I'm loud and I'm proud. I'm gay and I like it that way!
> 811> Another proud buttplug owner. Honk if yer horny!
> 811> I support Gay Pride! The Ramrod rocks!
> 811> See, I told youz Kerry sux! Man, what a loser!
>
> 811> Wanna hire me for web site development? I'm way under-employed!
>
> 812> That question was retorical. Youz know he never answers.
>
> 812> Freddie D. 'fag' Shorts
>
> 812> I'm loud and I'm proud. I'm gay and I like it that way!
> 812> Another proud buttplug owner. Honk if yer horny!
> 812> I support Gay Pride! The Ramrod rocks!
> 812> See, I told youz Kerry sux! Man, what a loser!
>
> 812> Wanna hire me for web site development? I'm way under-employed!
>
> 813> Yer just jealous, ain't youz darlin'?
>
> 813> Why, tank youz!
>
> 813> Don't youz?
>
> 813> Yer not up on da AIDS stats are youz?
>
> 813> Freddie D. 'fag' Shorts
>
> 813> I'm loud and I'm proud. I'm gay and I like it that way!
> 813> Another proud buttplug owner. Honk if yer horny!
> 813> I support Gay Pride! The Ramrod rocks!
> 813> See, I told youz Kerry sux! Man, what a loser!
>
> 813> Wanna hire me for web site development? I'm way under-employed!
>
> 814> An excellent observation, Bi.
>
> 814> Davie is no end an asstronomer.
>
> 814> Denser. Like lead or plutonium.
>
> 814> No, he's saying he has a hard on fer Ross.
>
> 814> Youz know why he picks on her. Davie rejects her cos o his latent homosexual
> 814> tendencies. Closset queers are like that.
>
> 814> Freddie D. 'fag' Shorts
>
> 814> I'm loud and I'm proud. I'm gay and I like it that way!
> 814> Another proud buttplug owner. Honk if yer horny!
> 814> I support Gay Pride! The Ramrod rocks!
> 814> See, I told youz Kerry sux! Man, what a loser!
>
> 814> Wanna hire me for web site development? I'm way under-employed!
>
> 815> Classic evasion noted. Why don't youz answer the questions, kook?
>
> 815> He's a closed fag like youz, kook!
>
> 815> Youz have, kook?
>
> 815> Youz are indeed a kook, davie!
>
> 815> Damn that Michael Baldwin da Bruce!
>
> 815> Ha, ha!
>
> 815> Freddie D. 'fag' Shorts
>
> 815> I'm loud and I'm proud. I'm gay and I like it that way!
> 815> Another proud buttplug owner. Honk if yer horny!
> 815> I support Gay Pride! The Ramrod rocks!
> 815> See, I told youz Kerry sux! Man, what a loser!
>
> 815> Wanna hire me for web site development? I'm way under-employed!
>
> 816> Whadya mean? Me and BS? What BS? Its all true.
>
> 816> Never you mind.
>
> 816> You got that right! Either that or giant, cellulite ass!
>
> 816> Freddie D. 'fag' Shorts
>
> 816> I'm loud and I'm proud. I'm gay and I like it that way!
> 816> Another proud buttplug owner. Honk if yer horny!
> 816> I support Gay Pride! The Ramrod rocks!
> 816> See, I told youz Kerry sux! Man, what a loser!
>
> 816> Wanna hire me for web site development? I'm way under-employed!
>
> 817> Prolly that troll that starts all those stupid threads.
> 817> Look how many kooks reply to them. Whata bunch o maroons.
>
> 817> No problemo, Bi.
>
> 817> Here cums da bride, fair, fat and wide!
>
> 817> Smell the coffee? More like the gas in the mine.
> 817> Of all things, the canary can't smell it!
>
> 817> Its a well known psychological reaction. She's been spurned and
> 817> rejected and she now desperately wants what she can't have. Its the
> 817> old treat 'em mean ta keep 'em keen. Like all dumb broads, she
> 817> fell fer it.
>
> 817> Freddie D. 'fag' Shorts
>
> 817> I'm loud and I'm proud. I'm gay and I like it that way!
> 817> Another proud buttplug owner. Honk if yer horny!
> 817> I support Gay Pride! The Ramrod rocks!
> 817> See, I told youz Kerry sux! Man, what a loser!
>
> 817> Wanna hire me for web site development? I'm way under-employed!
>
> 818> Yeah, ya got me there. Unlike Davie da kook I'm not about
> 818> ta argue wid youz.
>
> 818> It goes back ta that building that blew over in a gale in
> 818> Toronto (Fartingale's neck o da woods) some months back.
> 818> I figured she let one rip and the rest is history. Shows
> 818> what happens when she tries to sing from her diaphragm.
>
> 818> See my other post.
>
> 818> I know.
>
> 818> Well, she is a woman. It might take months, even years, butt I
> 818> intend to keep pointing it out to her until she learns. And they
> 818> say youz can't teach an old dog new tricks - yeah, right. We'll see.
>
> 818> Freddie D. 'fag' Shorts
>
> 818> I'm loud and I'm proud. I'm gay and I like it that way!
> 818> Another proud buttplug owner. Honk if yer horny!
> 818> I support Gay Pride! The Ramrod rocks!
> 818> See, I told youz Kerry sux! Man, what a loser!
>
> 818> Wanna hire me for web site development? I'm way under-employed!
>
> 819> Er ... I hadn't left. Some weird problemo wid an upstream ISP
> 819> dropping posts. I'd been making dozens of posts per day telling
> 819> Davie da dork ta pull his friggin' head in and only one or two
> 819> ever show up!
>
> 819> Which first title?
>
> 819> Freddie D. 'fag' Shorts
>
> 819> I'm loud and I'm proud. I'm gay and I like it that way!
> 819> Another proud buttplug owner. Honk if yer horny!
> 819> I support Gay Pride! The Ramrod rocks!
> 819> See, I told youz Kerry sux! Man, what a loser!
>
> 819> Wanna hire me for web site development? I'm way under-employed!
>
> 820> Yer still trailin' me on da leaderboard, Bi!
>
> 820> Freddie D. 'fag' Shorts
>
> 820> Another proud buttplug owner. Honk if yer horny!
> 820> I support Gay Pride! The Ramrod rocks!
>
> 820> Wanna hire me for web site development? I'm way under-employed!
>
> What does your ongoing antagonism have to do with classical music,
> Cypherpunk?
why do you ask, bruce?
>
> ===========================================================================
>
> yyyiiinnnggg writes:
>
> 15> It's never that simple about me, clueless bot.
>
> What does that have to do with classical music, ying?
why do you ask, bruce?
>
> 16> David, If you knew anything about classical music, you'd understand silence
> 16> is usually more important than noises.
>
> Non sequitur.
comic strip obsession noted.
>
> ===========================================================================
>
> "Nightingale" writes:
>
> 11> So you agree that you are one of the trolls.
>
> 11> Why? :-)
>
> 11> LOL! You are too kind.
>
> 12> You know who I meant, BS.
>
> 12> This group seems to have had an influx of trolls recently. I wonder
> 12> where they all came from - friends of yours, cypherpunk?
>
> 12> Figures that the trolls stick together.
>
> 12> I got bored with it.
>
> 12> LOL! Not that I ever plan to get married again - once was more than enough.
>
> 12> There you go with the fart jokes again. I know the building was just
> 12> across the street from my office, but I swear I had nothing to do with it!
>
> 12> Not that I'm chasing anyone...
>
> 13> Not a gale - problems with the demolition of a vacant theatre, and
> 13> several other buildings in the block were damaged.
>
> 13> Heh. If I had that much power I would be singing Wagner instead of
> 13> early music.
no remark, bruce?
>
> ===========================================================================
>
> Ross writes:
>
> 139> Little Davie Tholen pulled a bright blue crayon out of the box and
> 139> scribbled this in news:v5bjd.36751$email***@***.com:
>
> 139> [more snippage]
>
> 139> Do you want me to answer to your whining at other perople, or so you like
> 139> it when I use your levels of bandwidth?
>
> 139> Hypocrite.
>
> 139> No, but obviously you do. The complete sentence reads:
> 139> "It's your Usenet persona, Davie."
>
> 139> ....and you are not trolling???
>
> 139> <chortle>
>
> 139> Classic unsubstantiated and erroneous claim.
>
> 139> Perhaps because 'Ross' and 'Peter J. Ross' are two distinct on-line and
> 139> biological entities, Tholenator. They are separated by a rather large
> 139> body of water known as the Atlantic Ocean.
>
> 139> Any rudimentary research into the subject, based on their posts on
> 139> Usenet, would have uncovered this rather astounding fact.
>
> 139> Classic PKB.
>
> 139> Hahahahahahaha!!! Your limited programming dows not allow you to see the
> 139> connection.
>
> 139> Classic PKB.
>
> 139> Classic PKB.
>
> 139> Where is the "Davier" to which you refer, Davie?
>
> 139> The irony is in your attempt to police others' behaviour on usenet, when
> 139> you are just as guilty of that which you accuse others.
>
> 139> That is amusingly ironic.
>
> 139> Your analogy was flawed. A concert hall is not Usenet; neither is a
> 139> cinema. Different behaviours are expected in different contexts.
>
> 139> Again, you fail to comprehend that what is expected in a concert hall is
> 139> different than what occurs on Usenet. If you really want to control your
> 139> Usenent experience, put us 'antagonists' in your kill file and we will
> 139> disappear from your view. No fuss, no muss.
>
> 139> If, however, you continue trying to control Usenet, you will continue to
> 139> fail utterly in the attempt.
>
> 139> Classic unsubstantiated and erroneous claim.
>
> 139> Your kill file is your friend, Davie. Use it.
>
> 139> Oh, so now you contend that expressing laughter on Usenet is a breach of
> 139> netiquette?
>
> 139> Typical Tholenator(tm) -- you ask the question before you see the answer.
> 139> Classic mis-quote by taking it out of context.
>
> 139> Classic lack of intelligence and sense of humour noted.
>
> 139> Continued evasion of the original question (which you conveniently
> 139> snipped) noted.
>
> 139> Then why are you avoiding my questions?
>
> 139> Again, your whining about me snipping material that does not apply to me
> 139> is noted.
>
> 139> You are a hypocrite, Davie.
>
> 139> ????
>
> 139> Davie, it is your list. 'Ratz and I are talking about.
>
> 139> BTW, what does your list have to do with classical music?
>
> 139> No change in the general classification....
>
> What does any of that have to do with classical music, Ross?
why do you ask, bruce?
>
> ===========================================================================
>
> alias # today total last year
> -------------- ------- ----- ---------
> bruce 5 245 0
> bisectional 25 196 0
> nightingale 1 185 1613
> cypherpunk 11 184 578
> grantco 118 229
> greycloud 91 0
> zwar 86 349
> kohl 84 2192
> dizzy 82 522
> patterson 72 135
> fields 66 678
> chatterly 4 59 0
> aratzio 53 0
> ross 1 48 10
> wehrung 45 262
> elizabot 41 0
> karttunen 37 97
> daniels 34 165
> drpostman 30 54
> haslam 30 675
> hertz 27 0
> lockhart 25 60
> drysdale 24 0
> bloggs 21 200
> freud 21 44
> diogenes 20 0
> th@len 20 0
> ah 19 0
> chrisv 17 0
> yyyiiinnnggg 2 16 0
> edwin 15 0
> deus 14 0
> phoenix 14 18
> relic 14 0
> "nightingale" 3 13 0
> parsnip 13 0
> jaakko 12 99
> kolle 12 264
> beck 11 239
> flonkenstein 11 0
> bostonblackie 10 0
> deco 2 10 0
> hgj 10 0
> penso 10 172
> kadaitcha 9 0
> ranger 9 0
> logical 8 0
> john 7 0
> bornfeld 6 14
> charlie @ sea 6 0
> rickenbacker 6 0
> prai jei 5 11
> snit 5 0
> speech 5 0
> concerned 4 0
> donna 4 0
> extreme 4 0
> hucker 4 2
> qasim 4 0
> alex 3 0
> andrews 3 1
> antispim.him 3 0
> casa 3 0
> g&p 3 0
> invalid 3 0
> jazz guy 3 3
> jim 3 0
> marty 3 0
> sutton 3 1
> ?ho|en 2 0
> ? 2 0
> ada9 2 0
> adam 2 13
> balaam 2 0
> braves fan 2 0
> charlie 2 2 0
> dodel 2 0
> harrington 2 64
> hernandez 2 0
> js 2 0
> kennedy 2 3
> marshall 2 0
> molybdenum 2 0
> n 2 0
> schultz 2 5
> toughlin 2 0
> tweet 2 7
> wiser 2 3
> 1 0
> afoklala 1 0
> akhen 1 0
> antagonismo 1 90
> antagonist 1 0
> blonko 1 0
> bob 1 1
> briggs 1 20
> burtner 1 0
> cargle 1 0
> catroo 1 108
> cohen 1 0
> commentator 1 0
> creevey 1 69
> daveb 1 0
> durante 1 0
> emperor 1 0
> ende 1 0
> fischer 1 0
> gactimus 1 0
> gamble 1 13
> girouard 1 2
> god 1 0
> gorden 1 0
> granzeau 1 0
> h 1 0
> highwood 1 12
> homie 1 1
> ilechko 1 0
> koehlmann 1 0
> lawrence 1 1
> learned 1 0
> liath 1 0
> lysaght 1 0
> martin 1 0
> mirah 1 0
> mitzel 1 0
> monkey 1 1
> muething 1 5
> nelson 1 0
> o'brien 1 0
> o'donoghue 1 0
> osterwald 1 0
> ot 1 0
> pinups 1 0
> ploni 1 4
> porky 1 16
> pragmatist 1 0
> refutebot 1 0
> rice 1 0
> rick 1 0
> roberts 1 8
> steiner 1 0
> stratford 1 1
> straussvogel 1 0
> sutton 1 1
> "tholen" 1 0
> tuan 1 0
> ugly bob 1 0
> voege 1 0
> weinkam 1 0
> whitney 1 0
> -------------- ------- ----- ---------
> 150 56 2381 10033
are these all your friends, bruce? My, you have a lot of friends.
|
| Author |
Message |
braams@mathcs.emory.edu

|
Posted: 2008-6-15 8:04:36 |
Top |
fortran, Compensated (Kahan) summation and compilers
Hello All,
I am interested to employ compensated summation (Kahan summation) in a
few subsections of my Fortran-95 code. The code is used on a number
of different platforms and is shared with colleagues who compile it at
their own institutions, now and in the future, also on new machines
and using new compiler releases. I can't be looking over their
shoulders all the time.
You can guess where this is going. I need to write the Fortran in a
manner that is robust against possible compiler treatments, and I
wonder if anyone can offer experience with this. I also need high
efficiency; if the Kahan summation would cost more than a small factor
then I can't afford it, and then I must live with standard double
precision. For that reason I think I must use in-line code. I like
to assume that the compiler conforms to the Fortran standard, so that
if explicit parentheses are used in the code then those won't be
broken. However, the compiler may certainly optimize temporary
variables into registers, and I don't believe that the Fortran
standard then prohibits the register arithmetic from being, say, 80-
bit accurate, with variables truncated to 64 bits when stored.
The setting where I need the Kahan summation is in an accumulation.
There is no parallellism involved. In the following all real
variables are double precision real.
s = 0
do while (..)
x = ... ! computed here
s = s+x
enddo
I've been testing various implementations of Kahan summation for the
special case of an inner product, basically a Kahan version of the
dot_product intrinsic. For anyone who wants to do experiments I offer
my small, uncommented code here below. Functions xdot, ydot, and zdot
all implement Kahan summation, function udot uses standard summation,
and the test code also simply calls the dot_product intrinsic.
Using either Sun Workshop Fortran or Intel Fortran, functions xdot,
ydot and zdot all behave correctly, returning an accurate inner
product, when optimization is turned off at the compilation stage.
With Sun Fortran all three still give the expected good result when
compilation is done with -O5, but when the -fast option is used only
zdot behaves correctly. Here is the output for that case.
> f90 -fast xdot-experiments.f90 ; ./a.out
f90: Warning: -xarch=native has been explicitly specified, or
implicitly specified by a macro option, -xarch=native on this
architecture implies -xarch=sparcvis2 which generates code that does
not run on pre UltraSPARC III processors
dot_product: 512.2501221299369 -81.9599609375
xdot: 512.2501221299312 -131.935546875
ydot: 512.2501221299369 -81.9599609375
zdot: 512.2501221299462 0.0E+0
udot: 512.2501221299369 -81.9599609375
exact: 512.2501221299462
also exact: 512.2501221299462
final term: 1.0664280010966473E-17
This gave me some hope that with zdot I had found an implementation
that is robust against compiler treatments, but it didn't survive the
Ifort test. With Ifort and option -O0, again all of xdot, ydot and
zdot behave correctly in this test, but all fail when -O1 is used.
Here is the output for the case of option -O0.
$ ifort -O0 xdot-experiments.f90 ; ./a.out
dot_product: 512.250122129931 -130.936035156250
xdot: 512.250122129946 0.000000000000000E+000
ydot: 512.250122129946 0.000000000000000E+000
zdot: 512.250122129946 0.000000000000000E+000
udot: 512.250122129931 -130.936035156250
exact: 512.250122129946
also exact: 512.250122129946
final term: 1.066428001096647E-017
I'll appreciate advice about implementating Kahan summation in
Fortran. The code must be correct, I value efficiency in execution,
and I value it if I can use in-line code and then not have to worry
with every new release of a compiler or every transfer to a new
platform that the code will no longer behave correctly.
Here is the little test program. It evaluates the inner product
between the identical vectors x and y of which the general element is
x(i) = t0**i (0.le.i.lt.n); in the initialization phase the elements
are computed by a nonstandard recursion as will be seen. The
summation is in the natural order, 0.le.i.lt.n, so in order of
decreasing value of the addends. This way it is a good test of the
benefit of Kahan summation.
program main
implicit none
integer, parameter :: wp=selected_real_kind(12,300)
integer, parameter :: n=20000
integer :: i
real (kind=wp) :: x(0:n-1), y(0:n-1), t0, t1
t0 = 1023/1024.0_wp
t1 = (1-t0**(2*n))/(1-t0**2)
x(0) = 1 ; x(1) = t0
do i = 2, n-1
x(i) = x(i/2)*x((i+1)/2)
enddo
y = x
write (*,*) 'dot_product:', dot_product(x,y), &
(dot_product(x,y)-t1)/(epsilon(t1)*t1)
write (*,*) 'xdot: ', xdot(x,y), &
(xdot(x,y)-t1)/(epsilon(t1)*t1)
write (*,*) 'ydot: ', ydot(x,y), &
(ydot(x,y)-t1)/(epsilon(t1)*t1)
write (*,*) 'zdot: ', zdot(x,y), &
(zdot(x,y)-t1)/(epsilon(t1)*t1)
write (*,*) 'udot: ', udot(x,y), &
(udot(x,y)-t1)/(epsilon(t1)*t1)
write (*,*) 'exact: ', t1
write (*,*) 'also exact: ', (1-x(n/2)**2*x((n+1)/2)**2)/(1-x(1)**2)
write (*,*) 'final term: ', x(n-1)*y(n-1)
stop
contains
function xdot (x, y)
real (kind=wp), intent (in) :: x(0:), y(0:)
real (kind=wp) :: xdot
integer :: i
real (kind=wp) :: s, e, t0, t1
s = 0 ; e = 0
do i = 0, size(x)-1
t0 = x(i)*y(i)+e ; t1 = s+t0
e = t0-(t1-s)
s = t1
enddo
xdot = s+e
return
end function xdot
function ydot (x, y)
real (kind=wp), intent (in) :: x(0:), y(0:)
real (kind=wp) :: ydot
integer :: i
real (kind=wp) :: s, e, t0
s = 0 ; e = 0
do i = 0, n-1
t0 = x(i)*y(i)+e
e = t0-((s+t0)-s)
s = s+t0
enddo
ydot = s+e
return
end function ydot
function zdot (x, y)
real (kind=wp), intent (in) :: x(0:), y(0:)
real (kind=wp) :: zdot
integer :: i
real (kind=wp) :: s, e, t0, t1
s = 0 ; e = 0
do i = 0, size(x)-1
t0 = x(i)*y(i)+e ; t1 = s ; s = s+t0
e = t0-(s-t1)
enddo
zdot = s+e
return
end function zdot
function udot (x, y)
real (kind=wp), intent (in) :: x(0:), y(0:)
real (kind=wp) :: udot
integer :: i
real (kind=wp) :: s
s = 0
do i = 0, size(x)-1
s = s+x(i)*y(i)
enddo
udot = s
return
end function udot
end
Bas Braams
|
| |
|
| |
 |
Tim Prince

|
Posted: 2008-6-14 21:43:00 |
Top |
fortran >> Compensated (Kahan) summation and compilers
braams@mathcs.emory.edu wrote:
> Hello All,
>
> I am interested to employ compensated summation (Kahan summation) in a
> few subsections of my Fortran-95 code. The code is used on a number
> of different platforms and is shared with colleagues who compile it at
> their own institutions, now and in the future, also on new machines
> and using new compiler releases. I can't be looking over their
> shoulders all the time.
>
> You can guess where this is going. I need to write the Fortran in a
> manner that is robust against possible compiler treatments, and I
> wonder if anyone can offer experience with this. I also need high
> efficiency; if the Kahan summation would cost more than a small factor
> then I can't afford it, and then I must live with standard double
> precision. For that reason I think I must use in-line code. I like
> to assume that the compiler conforms to the Fortran standard, so that
> if explicit parentheses are used in the code then those won't be
> broken. However, the compiler may certainly optimize temporary
> variables into registers, and I don't believe that the Fortran
> standard then prohibits the register arithmetic from being, say, 80-
> bit accurate, with variables truncated to 64 bits when stored.
>
> The setting where I need the Kahan summation is in an accumulation.
> There is no parallellism involved. In the following all real
> variables are double precision real.
>
> s = 0
> do while (..)
> x = ... ! computed here
> s = s+x
> enddo
>
> I've been testing various implementations of Kahan summation for the
> special case of an inner product, basically a Kahan version of the
> dot_product intrinsic. For anyone who wants to do experiments I offer
> my small, uncommented code here below. Functions xdot, ydot, and zdot
> all implement Kahan summation, function udot uses standard summation,
> and the test code also simply calls the dot_product intrinsic.
>
> Using either Sun Workshop Fortran or Intel Fortran, functions xdot,
> ydot and zdot all behave correctly, returning an accurate inner
> product, when optimization is turned off at the compilation stage.
> With Sun Fortran all three still give the expected good result when
> compilation is done with -O5, but when the -fast option is used only
> zdot behaves correctly. Here is the output for that case.
>
>> f90 -fast xdot-experiments.f90 ; ./a.out
> f90: Warning: -xarch=native has been explicitly specified, or
> implicitly specified by a macro option, -xarch=native on this
> architecture implies -xarch=sparcvis2 which generates code that does
> not run on pre UltraSPARC III processors
> dot_product: 512.2501221299369 -81.9599609375
> xdot: 512.2501221299312 -131.935546875
> ydot: 512.2501221299369 -81.9599609375
> zdot: 512.2501221299462 0.0E+0
> udot: 512.2501221299369 -81.9599609375
> exact: 512.2501221299462
> also exact: 512.2501221299462
> final term: 1.0664280010966473E-17
>
> This gave me some hope that with zdot I had found an implementation
> that is robust against compiler treatments, but it didn't survive the
> Ifort test. With Ifort and option -O0, again all of xdot, ydot and
> zdot behave correctly in this test, but all fail when -O1 is used.
> Here is the output for the case of option -O0.
>
> $ ifort -O0 xdot-experiments.f90 ; ./a.out
> dot_product: 512.250122129931 -130.936035156250
> xdot: 512.250122129946 0.000000000000000E+000
> ydot: 512.250122129946 0.000000000000000E+000
> zdot: 512.250122129946 0.000000000000000E+000
> udot: 512.250122129931 -130.936035156250
> exact: 512.250122129946
> also exact: 512.250122129946
> final term: 1.066428001096647E-017
>
> I'll appreciate advice about implementating Kahan summation in
> Fortran. The code must be correct, I value efficiency in execution,
> and I value it if I can use in-line code and then not have to worry
> with every new release of a compiler or every transfer to a new
> platform that the code will no longer behave correctly.
>
> Here is the little test program. It evaluates the inner product
> between the identical vectors x and y of which the general element is
> x(i) = t0**i (0.le.i.lt.n); in the initialization phase the elements
> are computed by a nonstandard recursion as will be seen. The
> summation is in the natural order, 0.le.i.lt.n, so in order of
> decreasing value of the addends. This way it is a good test of the
> benefit of Kahan summation.
>
> program main
> implicit none
> integer, parameter :: wp=selected_real_kind(12,300)
> integer, parameter :: n=20000
> integer :: i
> real (kind=wp) :: x(0:n-1), y(0:n-1), t0, t1
> t0 = 1023/1024.0_wp
> t1 = (1-t0**(2*n))/(1-t0**2)
> x(0) = 1 ; x(1) = t0
> do i = 2, n-1
> x(i) = x(i/2)*x((i+1)/2)
> enddo
> y = x
> write (*,*) 'dot_product:', dot_product(x,y), &
> (dot_product(x,y)-t1)/(epsilon(t1)*t1)
> write (*,*) 'xdot: ', xdot(x,y), &
> (xdot(x,y)-t1)/(epsilon(t1)*t1)
> write (*,*) 'ydot: ', ydot(x,y), &
> (ydot(x,y)-t1)/(epsilon(t1)*t1)
> write (*,*) 'zdot: ', zdot(x,y), &
> (zdot(x,y)-t1)/(epsilon(t1)*t1)
> write (*,*) 'udot: ', udot(x,y), &
> (udot(x,y)-t1)/(epsilon(t1)*t1)
> write (*,*) 'exact: ', t1
> write (*,*) 'also exact: ', (1-x(n/2)**2*x((n+1)/2)**2)/(1-x(1)**2)
> write (*,*) 'final term: ', x(n-1)*y(n-1)
> stop
> contains
> function xdot (x, y)
> real (kind=wp), intent (in) :: x(0:), y(0:)
> real (kind=wp) :: xdot
> integer :: i
> real (kind=wp) :: s, e, t0, t1
> s = 0 ; e = 0
> do i = 0, size(x)-1
> t0 = x(i)*y(i)+e ; t1 = s+t0
> e = t0-(t1-s)
> s = t1
> enddo
> xdot = s+e
> return
> end function xdot
> function ydot (x, y)
> real (kind=wp), intent (in) :: x(0:), y(0:)
> real (kind=wp) :: ydot
> integer :: i
> real (kind=wp) :: s, e, t0
> s = 0 ; e = 0
> do i = 0, n-1
> t0 = x(i)*y(i)+e
> e = t0-((s+t0)-s)
> s = s+t0
> enddo
> ydot = s+e
> return
> end function ydot
> function zdot (x, y)
> real (kind=wp), intent (in) :: x(0:), y(0:)
> real (kind=wp) :: zdot
> integer :: i
> real (kind=wp) :: s, e, t0, t1
> s = 0 ; e = 0
> do i = 0, size(x)-1
> t0 = x(i)*y(i)+e ; t1 = s ; s = s+t0
> e = t0-(s-t1)
> enddo
> zdot = s+e
> return
> end function zdot
> function udot (x, y)
> real (kind=wp), intent (in) :: x(0:), y(0:)
> real (kind=wp) :: udot
> integer :: i
> real (kind=wp) :: s
> s = 0
> do i = 0, size(x)-1
> s = s+x(i)*y(i)
> enddo
> udot = s
> return
> end function udot
> end
>
> Bas Braams
>
>
Kahan summation will certainly cost "more than a small factor" compared
with "vectorized" dot product reduction, i.e. a factor of 3 or more.
In order to get consistent results among a wide variety of compilers with
Kahan summation of double precision, without removing optimization, I
declare the critical intermediate values as elements of a COMMON block.
|
| |
|
| |
 |
robert.corbett

|
Posted: 2008-6-15 13:00:00 |
Top |
fortran >> Compensated (Kahan) summation and compilers
On Jun 14, 5:04 pm, "bra...@mathcs.emory.edu"
<bra...@mathcs.emory.edu> wrote:
> With Sun Fortran all three still give the expected good result when
> compilation is done with -O5, but when the -fast option is used only
> zdot behaves correctly.
The option -fast implies two other options, -fns and -fsimple=2,
that can cause problems for codes that depend on the exact
nature of the arithmetic being done. In this case, my guess is
that it is the option -fsimple=2 that is causing the problem.
Try the option combination
-fast -fsimple=1
Order is important. When there are conflicting options, the
last option wins.
Bob Corbett
|
| |
|
| |
 |
Craig Powers

|
Posted: 2008-6-17 4:03:00 |
Top |
fortran >> Compensated (Kahan) summation and compilers
braams@mathcs.emory.edu wrote:
> With Sun Fortran all three still give the expected good result when
> compilation is done with -O5, but when the -fast option is used only
> zdot behaves correctly.
As a general rule, compilers tend to offer "extreme" optimization
options that may do things that are unsafe mathematically. I don't
think you can entirely protect against that---I'd tend to think that you
would need to document a restriction against certain classes of
optimizations. (Users who don't know what risk is entailed with extreme
speed optimizations shouldn't be using them at all, and I don't know
that it makes sense to try to protect them from themselves.)
|
| |
|
| |
 |
Jan Vorbr黦gen

|
Posted: 2008-6-17 18:18:00 |
Top |
fortran >> Compensated (Kahan) summation and compilers
> As a general rule, compilers tend to offer "extreme" optimization
> options that may do things that are unsafe mathematically. I don't
> think you can entirely protect against that---I'd tend to think that you
> would need to document a restriction against certain classes of
> optimizations. (Users who don't know what risk is entailed with extreme
> speed optimizations shouldn't be using them at all, and I don't know
> that it makes sense to try to protect them from themselves.)
The IBM XLF compiler goes so far to issue a warning when these options
are used, telling you that results might change from what they were
without the use of those options. And yes, strange results will happen...
Jan
|
| |
|
| |
 |
| |
 |
Index ‹ fortran |
- Next
- 1
- Newbie: Is it possible for a function to return a String or Character Arrays?Ron Shepard wrote:
> In article <email***@***.com>,
> email***@***.com wrote:
> > I don't think it is proper to post the same question simultaneously in
> > two distinct forums. It wastes the time of people who reply.
>
> It is not clear exactly what you are discouraging. What should be
> discouraged is posting the same question in multiple newgroups as
> separate posts -- anyone who reads the multiple groups will see the
> post multiple times, which is a waste of time. However, if a single
> question is crossposted to multiple groups, then anyone reading more
> than one of those groups will see the post only once, so there is no
> problem with wasted time.
The question in question was posted to this newsgroup and to Intel's web
forum. It's not possible to crosspost between them in such a way that
replies show up in both.
For that matter, I've seen very few questions that really benefited from
being crossposted to multiple newsgroups on Usenet -- the useful answers
seem to virtually always only come from one group. Further, there is
often the problem of a crossposted thread having one "foot" in a
high-traffic group where topics often shift into tangential discussions,
and having another "foot" in a low-traffic group that gets overwhelmed
by the crossposted tangential (and usually off-topic) discussion. So I
would advise doing it only with considerable caution, and only in cases
where one has a fair familiarity with both groups and would expect them
to be compatible.
(This is why it's often recommended, when crossposting, to set followups
to a single group and to explicitly note in the message that followups
have been set there.)
- Brooks
--
The "bmoses-nospam" address is valid; no unmunging needed.
- 2
- GUI for OpenWatcom Fortran/77 programHi folks,
I want to write some programs in OW Fortran/77 (for OS/2 and Windows)
from scatch. These won't be ports of old Fortran code but NEW
programs. Now, the problem is that they shall have a GUI, too and I
don't want to write my own small widget toolkit which calls either the
OS/2 oder Windows API.
So I looked for already existing toolkits which could fit my needs.
The first possibility would be to write the GUI part of my program in
another language and call it through a pipe which is definiatly a very
dirty method. I could write the GUI-core in VisualAge Basic/Visual
Basic or in an interpreted language, eg. TCL/TK or Rexx/DW but there
would be a bit too much work to write something like a protocol for
the communication between program and GUI and I also would have to
supply the GUI-core eventually with their needed libraries. All in
all, this is no clean solution.
Another possibility would be to use a toolkit with C-API, preferred as
a DLL. This could work because OW Fortran is capable of calling DLL
functions and has some C-compatibility stuff which makes it possible
to call functions written for C. It could be even possible to compile
the C-header files of the toolkit and use their functions and types in
my program but the effort to do this is bigger than defining my own
function declarations, types and constants in Fortran.
So I could use a C-wrapper for wxWidgets but I couldn't get any
c-wrapper to compile under OS/2 (there's one for wx.NET, wxEuphoria,
wxEiffel and so on...).
Another toolkit is "Dynamic Windows" which is available for OS/2,
Windows and a lot of other platforms. It also has a non-OO API.
However I was not able to use it from within Fortran (according to the
sample file written in C). This toolkit has no documentations except
its sourcecode and I get no feedback from the author.
The last toolkit I found was (TCL/)TK because there are also
C-libraries available, and there's an OS/2 version. I read that TCL/TK
is commonly used as GUI for Fortran but nearly everything I read
described how to call the Fortran program as a pipe from TCL/TK. I
definiatly don't want do it this way. So I tried to call the
c-libraries like c-program would do it but in Fortran. Unfortunately
there is not very much documentation how I do it in C (k, the API is
well documented but there are no samples).
Here's what I tried with the few samples I found:
----------
* this is for C-compatibility (naming/parameter differences):
c$pragma aux tk_mainex "Tk_MainEx" parm(value)
c$pragma aux tcl_createinterp "Tcl_CreateInterp" parm(value)
c$pragma aux tk_init "Tk_Init" parm(value)
c$pragma aux initproc "!" parm(value)
program tksample_main
implicit integer (A-Z)
character nul
character*80 mainarg(:)
external initproc
parameter(nul = char(0))
* TCL/TK excepts allocatable arrays ???
allocate(mainarg(1))
* the char(0) is of course c-compatibility, too:
mainarg(0) = 'TK-TEST'//nul
mainarg(1) = './test.tcl'//nul
* according to the TK header files, this should be the right
* function; I except the error at calling initproc
call tk_mainex(2, mainarg, initproc, tcl_createinterp())
end
integer function initproc(interp)
implicit integer (A-Z)
parameter(TCL_OK = 0)
write(*,*) 'TEST'
iret = tk_init(interp)
if(iret .NE. TCL_OK) write(*,*) 'Unable to Initialize TK!'
initproc = iret
end
----------
The program compiles/links fine, but crashes at tk_mainex (initproc
won't get called). Do you have any idea why it doesn't works - is it
possible at all or do I need at least some C gluing code?
What are your experiences with using platform independent widget
toolkits with Fortran/77?
Thank you in advance.
mrg Robin Haberkorn
- 3
- Changing array boundsHi!
I am a FORTRAN 95 beginner and have a question about array pointers.
Suppose my program does
real, pointer :: x(:)
call some_function(x)
where some_function associates the pointer x to some array of size N.
Then, I can access the elements of that array by x(1), ..., x(N).
The problem now is that I want the indices to start with 0 instead of
1 so that the array runs from x(0) to x(N-1). Because x has to be of
deferred shape there seems to be no way to tell the compiler about
this.
Regards
Carsten
- 4
- 5
- Photran 3.0.0Hello everebody,
I installed full Photran 3.0.0 for MS-windows but it does not work. I
don't have any Photran perspective.
Is there a problem with uploaded zip file ?
Photran 2.1.0 run well on the same pc.
JBF
- 6
- SP on a 64-bit CPU and DP on a 32-bit CPUHi guys. I've read around but have not seen a definitive answer as to
whether evaluating a precision-sensitive function in a 64-bit CPU is
better than doing the same process in a 32-bit CPU (or vice versa).
I did some tests on my own, where I compared the output of the simple
Fortran program below on an AMD XP (32 bit) CPU and an AMD64 CPU. The
outputs were different. I'm using Compaq Visual Fortran in Windows XP
for the 32-bit tests and the Intel Fortran compiler in SuSE (64 bit)
9.2 for the 64-bit tests.
What is responsible for the discrepancy, and would this have
ramifications for precision-sensitive computations?
Results on a 32-bit AMD XP CPU:
30 1073741822.88889
31 2147483646.88889
32 -1.11111111193895
33 -1.11111111193895
34 -1.11111111193895
Results on 64-bit AMD64 CPU:
30 1073741824.00000
31 2147483648.00000
32 -1.11111116409302
33 -1.11111116409302
34 -1.11111116409302
Program test
double precision:: a30,a31,a32,a33,a34
a30 = 2**30-1-(1./9.)
a31 = 2**31-1-(1./9.)
a32 = 2**32-1-(1./9.)
a33 = 2**33-1-(1./9.)
a34 = 2**34-1-(1./9.)
Print *, '30',a30
Print *, '31',a31
Print *, '32',a32
Print *, '33',a33
Print *, '34',a34
end program test
- 7
- marty-jeff GROW UP
Grow up marty-jeff. I know you have trouble getting beyond your
quintessential asshole personality -- but try it. If you spend the week
claming down, maybe next weekend will bring you a new boyfriend and we
will not see your trolling for attention here.
In <email***@***.com>, on 10/03/2004
at 10:09 PM, Marty <email***@***.com> said:
>The Anti-OS/2 FUDster wrote:
>> Far easier to just shut him down. He's a child out of control. Remove
>> him from the classroom and put him in Special Ed.
>Your comedic value has proven itself yet again! Not only is the level
>of irony in this post so far over the top as to almost wrap around the
>scale, but you've succeeded in coming up with a new nickname for Ed
>Letourneau! :-D
- 8
- ?SW Almost FREE MONEY !! ?SWMAKE MONEY!!!
MAKE THOUSANDS!!!
I found this on a bulletin board and decided to try it: I don't care about
the useless pre-fabricated crap this message usually says. All I say is, it
works. Continue pre-fab crap.
WELL GUESS WHAT!!!
Within seven days, I started getting money in the mail!! I
was shocked!! I figured it would end soon, but the money just kept
coming in. In my first week, I made about $25.00. By the end of the second
week I had made a total of more than $1000.00!!
Let me tell you how this works and most important, why it works..........
also make sure you print this out NOW, so you can get the information off
of it, as you will need it. I promise you that if you follow the directions
exactly that you will start making more money than you thought possible by
doing something
so easy!!
Suggestion: Read this entire message carefully!! (Print it out or download
it)
Follow the simple directions and watch the money come in!! It's easy.
It's legal. And, your investment is only $6.00 (Plus postage) !!!
You can use any currancy as people can always change it..
IMPORTANT:
This is not a rip-off, it is decent; it's legal; and it is virtually no
risk - it really works!! If all the following instructions are adhered to,
you will receive extraordinary dividends.
PLEASE NOTE:
Please follow the directions EXACTLY, and $50,000 or more can be yours
in 20 to 60 days. This program remains successful because of the honesty
and integrity of the participants. Please continue its success by carefully
adhering to the instructions. You will now become apart of the Mail Order
business.
You are in the business of developing Mailing Lists. Many large corporations
are happy to pay big bucks for quality lists. However, the money made from
the
mailing lists is secondary to income which is made from people like you
and me asking to be included in that list. Here are the four easy steps to
success.
STEP ONE:
Get six separate pieces of paper and write the following on
each piece of paper "PLEASE PUT ME ON YOUR MAILING LIST."
Now get 6 U.S. $1.00 bills and place ONE inside of EACH of the six pieces
of paper so the bill will not be seen through the envelope (to prevent
thievery). Next, place one paper in each of the six envelopes and seal them.
You now should have six sealed envelopes, each with a piece of paper stating
the above phrase, your name and address, and a $1.00 bill. What you are
doing is creating a service.
THIS IS ABSOLUTELY LEGAL!!!!!
You are requesting a legitimate service and you are paying for it!! Like
most of us I was a little skeptical and little worried about the legal
aspects of it all. So I checked it out with the U.S. Post Office
(1-800-238-5355)
and they confirmed that it is indeed legal!!
Mail the six envelopes to the following addresses:
Matthew Dutton
46 Hayworth St
Point Vernon, Hervey Bay
QLD, 4390
Australia
R. Visser
P.O. Box 274
Nobby Beach
QLD, 4218
Australia
S. Phillips
77 Manly Drive
Robina, QLD 4226
Australia
Chris Pittman
7651 Abigail Glen Dr.
Charlotte, NC 28212
USA
Mike Vango
29 Pebblewood Ave
Scarborough, ON M1V-2A7
Canada
C. Wehler
137 Sara Rd
St. Marys, PA 15857
USA
STEP TWO:Now take the #1 name off the list that you see above, move the
other names up (six becomes 5, 5 becomes 4, and etc.) and add YOUR NAME as
number 6 on the list.
STEP THREE:
Change anything you need to but try to keep this article as close to
original as possible. Now post your amended article to at least 200 news
groups. : (I think there are close to 24,000 groups) All you need is 200,
but
remember, the more you post, the more money you make!! This is perfectly
legal!! If you have any doubts, refer to Title 18 Sec. 1302 & 1341 of the
Postal Lottery laws. Keep a copy of these steps for yourself and whenever
you need money, you can use it again, and again. PLEASE REMEMBER that this
program remains successful because of the honesty and integrity of the
participants and by their carefully adhering to directions. Look at it this
way. If you were of integrity, the program will continue and the money that
so many others have received will come your way.
NOTE: You may want to retain every name and address sent to you,> either on
a computer or hard copy and keep the notes people send you.
This VERIFIES that you are truly providing a service. (Also, it might be
a good idea to wrap the $1 bill in dark paper to reduce the risk of mail
theft). So, as each post is downloaded and the directions carefully
followed, all members will be reimbursed for their participation as a List
Developer with one dollar each. Your name will move up the list
geometrically so that when your name reaches the #1 position you will be
receiving thousands of dollars in CASH!!! What an opportunity for only $6.00
( $1.00 for each of the first six people listed above) Send it now, add your
own name to the list and you're in business!!!
*****DIRECTIONS FOR HOW TO POST TO NEWS GROUPS!!!*****
STEP ONE: You do not need to re-type this entire letter to do your own
posting. Simply put your cursor at the beginning of this letter and drag
your cursor to the bottom of this document, and select 'copy' from the edit
menu. This will copy the entire letter into the computer's memory.
STEP TWO:
Open a blank 'notepad' file and place your cursor at the top
of the blank page. From the 'edit' menu select 'paste'. This will paste a
copy of the letter into the notepad so that you will add your name to the
list.
STEP THREE:
Save your new notepad file as a text file. If you want to do your posting
in different settings, you'll always have this file to go back to.
STEP FOUR:
You can use a program like "postXpert" to post to all the newsgroups at
once. You can find this program at <<http://www.download.com>>.
Use Netscape or Internet Explorer and try searching for various new
groups (on- line forums, message boards, chat sites, discussions.)
STEP FIVE:
Visit message boards and post this article as a new message by
highlighting the text of this letter and selecting paste from the edit menu.
Fill in the subject, this will be the header that everyone sees as they
scroll through the list of postings in a particular group, click the post
message button. You're done.
Congratulations!!!!!!
THAT'S IT!! All you have to do, and It Really works!!!
BEST WISHES ...
ouYj\
- 9
- Precision issue?<rich@compt> 4% cat h.f
real*4 y,yy
yy=1.10
y=0.0
do j=1,1000000
y=y+yy
enddo
write(*,*)' single precision y = ',y
stop
end
<rich@comp> 5% ./h
single precision y = 1110920.
<rich@comp> 6%
The answer should be 1110000
Here is a simple computation provided to me to help in
isolating the cause in this precision drift. The answer
using 'real' drifts, after a week, this variance is off the
scale. Previous f77 and f90 Fortran distribution produced
the expected results. The latest upgrade Dec Alpha and the
newest Fortran from HP produces these incorrect results.
I might also note the Sun Forte7 compiler has issues
along these lines also. I know this is a form of under-
flow in a sense, but I really need a work around suggestion.
There are many, many lines of code involved here.
Thanks,
Rich.
- 10
- find a Fortran teacherMark Westwood wrote:
> Sampay
>
> If you do want to be taught Fortran then I second the suggestions
> you've already had, namely contact your local higher education
> facilities, especially their physics and science departments -- I'd bet
> a big clock you won't find a computer science department in the UK
> teaching Fortran !
>
Manchester's MSc course in Applied Numerical Computing teaches Fortran
95. I'm sort of cheating, though, because it's technically run by the
school of mathematics. Several of the names listed as coordinating are
from the computing department rather than the maths department, though.
I learnt Fortran 77 on its predecessor back in 1991 (just too early for
it to have switched to Fortran 90), so while theoretical numerical
analysis was most definitely not for me, I still have a lot to thank
them for.
Catherine.
- 11
- type-spec FUNCTION func(...) standard questionHi all,
which of the following FUNCTION statements is valid and do I extract
this from the Fortran (95 or 2003) standard?
Many compilers seem to to accept (b) and (c), but reject (a).
Tobias
! Case a
real(r8) function func1()
integer, parameter :: r8 = kind(0d0)
func1 = 0.0_r8
end function func1
! Case b
module mod1
integer, parameter :: r8 = kind(0d0)
end module mod1
real(r8) function func2()
use mod1, only: r8
func2 = 0.0_r8
end function func2
! Case c
module mod2
integer, parameter :: r8 = kind(0d0)
interface
real(r8) function func3()
import :: r8
end function func3
end interface
end module mod2
end
- 12
- vim, ctags, and fortran source browsingHello,
It was a pleasure browsing C/C++ source (apart from C++ template) with
vim and ctags to jump around files through symbols. However, this does
not seem to work very well with fortran. Any guru on this subject can
give some recommendations?
Thank you,
Fei
- 13
- C++ Bounds CheckingJames Giles wrote:
(snip)
> And no, I have no idea why people are not more careful about
> that. It seems that some C programmers (even systems programmers)
> still don't universally guard against such problems. I note that
> two versions of the C standard have failed to remove the gets()
> intrinsic or even to deprecate it. (I know that I've come across
> reputable university courses that still taught gets() as a legitimate
> input feature - as recently as the last few years.) Some system
> level code apparently uses the same style: passing some procedures
> a pointer to the beginning of a buffer without also passing the length,
> leaving the procedure no way to discover the size of the buffer and
> no way to test for the overflow condition.
Related to the question about why people are more worried about
program speed now than they were 30 or 40 years ago...
Well, C is now about 30 years ago, but earlier language designers
would not have designed features like that into a language.
(Note that Fortran's (*) dimension option didn't come until `77.)
Also, there is no requirement of the C language that pointers be
implemented as just an address, but that is by far the most common
implementation. It wouldn't be so hard to put the bounds information
into a C pointer, but even with faster computers there seems not to
be any incentive to do it. (I don't know how Fortran C interoperability
would work with large pointers, though.)
As for gets(), I don't find fgets() that much harder to use,
but I might see using gets() for a quick run-once program, such
as to test a compiler feature or other quick test. Even then,
fgets() isn't that hard to use.
-- glen
- 14
- About Cleanscape SoftwareI'm a former employee of a firm named Cleanscape Software that's
presently located in Palo Alto, California. I was terminated in 2003
after a series of events that may have involved illegal actions on the
part of the company's CEO.
The situation is unusual because the company's former accountant (who
was also terminated) backs up the facts, but the Board of Directors
has made it clear that they're going to support the CEO, regardless of
possibly illegal actions. In fact, one Board member has stated that
the CEO is safe from prosecution for pragmatic reasons. This Board
member is a partner at Jenkins Goodman Neuman and Hamilton in San
Francisco. He knows George Kennedy (District Attorney of Santa Clara
County), and he says that Mr. Kennedy won't pursue certain white
collar crimes, because he's presently focusing on violent crimes.
I've created a web site about Cleanscape Software which documents the
events in question. If you're interested, please visit the site at:
http://www.cleanscapetruth.com/
To read about the CEO's actions, click on the "attorneys" link, or
jump directly to:
http://www.cleanscapetruth.com/attorneys.html
If you'd like to contact me, don't use E-mail (since my address isn't
permanent). Instead, please use the following "contact" web page:
http://www.cleanscapetruth.com/contact.html
Incidentally, if you're interested in trademark issues, note that
Cleanscape Software allowed its ownership of the trademark CLEANSCAPE
to lapse some time back. Both Cleanscape Software and I have applied
for the trademark, and opinions about the upcoming trademark dispute
are welcome. For more information, see the following web page:
http://www.cleanscapetruth.com/trademark.html
- 15
- fortran77, array, user-definedhello,
i use arrays in my fortran77-program and the size of the arrays schould be
act up by the program-user.
how can i define arrays ( e.g. REAL a(0:B,0:B) ) where B should be defined
by the user of the program?
klaus
|
|
|