Jun 18, 2010 #1 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
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
Jun 18, 2010 #2 xwb Programmer Jul 11, 2002 6,828 GB Use a format statement Code: print '(F6.3)', tension Upvote 0 Downvote
Jun 18, 2010 Thread starter #3 260791 MIS Jun 14, 2010 16 GB 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 Upvote 0 Downvote
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
Jun 18, 2010 #4 xwb Programmer Jul 11, 2002 6,828 GB 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 http://www.academictutorials.com/fortran/fortran-format-statements.asp Upvote 0 Downvote
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 http://www.academictutorials.com/fortran/fortran-format-statements.asp