ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello:
I encounter some problem when i run my fortran program on the linu WS 4(64bit) .
I compile the program with g95. and my cpu is intel xeon 64bit
real*8 var1=0.2539998000
real*8 var2=0.2539970307
when i compute the var1-var2, it gives "NaN"
So what is the reason of getting a NaN.
Regards
The only possible reason I can think of is that your var1 and var2 variables are not being initialized to what you think they are being initialized to.
Try putting a print statement before the calculation, I bet one or both are already NAN even before the subtraction.
You are setting both var1 and var2 to 8 bits, but you are trying to put values with too many digits into them. They are NaN "not a number" right after they are allocated.
Try shortening out the number of decimal places, one by one, and eventually it will work.
You are setting both var1 and var2 to 8 bits, but you are trying to put values with too many digits into them. They are NaN "not a number" right after they are allocated.
Try shortening out the number of decimal places, one by one, and eventually it will work.
- Dave
REAL*8 equates to a C double which for the OP's environment should have a minimum 15 digits of precision.
Offhand, I don't see the problem. He is on 64 bit box, maybe the compiler is creating 32 bit code and calling the wrong (32 bit)runtime library. Just guessing. I don't know if there is 64 bit support for GNU FORTRAN.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.