Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to declare real constants? Please help

Status
Not open for further replies.

260791

MIS
Jun 14, 2010
16
GB
How do I declare constants beginning with "zero" in Fortran to get the output beginning with zero ?

If I declare :

REAL, parameter :: tension = 0.025

I get the output:

2.500000E-02



Thanks in advance
 
Use a format statement
Code:
print '(F6.3)', tension
 
Excellent ! It works :) Thank you

And another problem that I have now is that:

E.g. for this calculation:

mddc = 0.3625 * ( tension / density ) ** 0.6
PRINT '(F6.3)', mddc

I'm getting: 0.001

while it should be 0.00069

and for others I'm getting 0.005, but should be 0.00471, so it rounds up the last digits.

What can I do, so that it will NOT round up the numbers at the end?



Thanks
 
Think you have to read up about format statements.

F means fixed format
6 is the number of digits in total including sign and decimal point
3 is the number of decimal places

It does round the answer up to the number of digits you specify. You probably want F10.5

For further reference, have a look at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top