How Can I Define and Use Very Small Numbers in Fortran 90?

  • Fortran
  • Thread starter TheIsingGuy
  • Start date
  • Tags
    Fortran
In summary, non-dimensionalizing variables is a common practice in the high-accuracy CFD world to avoid issues with large and small numbers in computations. For cases where this is unavoidable, alternate algorithms may need to be used. Some resources for finding such algorithms include IEEE papers and the link provided in the conversation.
  • #1
TheIsingGuy
20
0
how do I define and use small numbers for computations? on the scale of 10^-30?

e.g.
Program A
implicit none
double precision a,b,c,d
c = (a*b)/(a+b)
d = etc...

End program

The above has an overflow error when I give a,b the values 3.345 * 10^-27

Can anyone help?

Thanks

Ising
 
Technology news on Phys.org
  • #2
You're going to run into problems on any computer trying to do those computations. I am from the high-accuracy CFD world. Many solvers will attempt to solve for the dimensional variables directly. Unfortunately in the equations, you get very large (and very small, O e+-8) running around. Performing computations on numbers like this results in poor accuracy.

In order to avoid this, we non-dimensionalize all the variables first. Insteady of pressure being 101,300, it becomes 0.714, instead of density being 0.0012, it becomes 1.0. This makes the speed of sound 1.0, etc, etc.

In your case, if this is unavoidable, you'll have to go to alternate algorithms for this. Try to check out some IEEE papers, you might be able to find something. I was able to find this page though:
http://docs.sun.com/app/docs/doc/801-7639/6i1ucu1ug?a=view

The first computation in that equation should give a number on the order of e-700, which is out of the range of double precision.
 
Last edited by a moderator:
  • #3
a small number on the scale of 10^-30 in Fortran 90 can be done by using the scientific notation format. For example, 10^-30 can be written as 1.0E-30. This notation can be used to define and use small numbers for computations in Fortran 90 without encountering overflow errors. Additionally, using the "double precision" declaration for variables can also help with precision and avoid errors when dealing with small numbers. It is important to carefully consider the precision and range of values when defining and using small numbers in Fortran 90 to ensure accurate and reliable results in your computations.
 

Related to How Can I Define and Use Very Small Numbers in Fortran 90?

1. What is Fortran 90?

Fortran 90 is a programming language used for scientific and engineering applications. It is an updated version of the original Fortran language, with new features such as dynamic memory allocation and modular programming.

2. What are the main differences between Fortran 90 and earlier versions?

Fortran 90 introduced new features such as dynamic memory allocation, improved control structures, and the ability to create modules for organizing code. It also has stricter rules for variable declarations and improved array handling.

3. Is Fortran 90 still used today?

Yes, Fortran 90 is still widely used in scientific and engineering fields, particularly for high-performance computing. Many legacy codes are also still written in Fortran 90, and it is still considered a reliable and efficient language for numerical computations.

4. Can Fortran 90 be used for object-oriented programming?

No, Fortran 90 is not an object-oriented language. However, Fortran 2003 introduced some object-oriented features such as data encapsulation and polymorphism.

5. Where can I learn Fortran 90?

There are many online resources and tutorials available for learning Fortran 90, including official documentation from the Fortran Standards Committee and educational websites. Additionally, many universities offer courses on Fortran programming.

Similar threads

  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
2
Replies
59
Views
9K
  • Programming and Computer Science
Replies
8
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
3
Views
3K
  • Programming and Computer Science
Replies
22
Views
4K
  • Programming and Computer Science
Replies
26
Views
3K
Back
Top