New to programming and Fortran

In summary, the code in the example reads in three numbers and sums and averages them. The program creates an executable file if you can run the code.
  • #1
MechEng2010
13
0
Hello all,

I am new to programming and fortran, I have Intel Fortran 9.1 and using this via Microsoft Visual Studio 2005. To start with I have found a simple exmaple from the a Intel Fortran 90 book. I seem to be able to run a debug, but can't seem to create an executable? Its my first time using Visual Studio and Fortran. Any help would be appreciated.

PROGRAM Sum_and_Average
!
! This program reads in three numbers and sums and averages them
!
IMPLICIT NONE
REAL :: N1,N2,N3,Average = 0.0, Total = 0.0
INTEGER :: N = 3
PRINT *, 'Type in three numbers, separated by spaces or commas'
READ *,N1,N2,N3
Total= N1+N2+N3
Average=Total/N
PRINT *,'Total of numbers is ',Total
PRINT *,'Average of the numbers is ',Average
END PROGRAM Sum_and_Average

For example the Intel Visual Fortran Compiler Documentation provides this information, but no more on how to do this... can anyone help?

"Creating Fortran Executables
The simplest way to build an application is to compile all of your Intel® Fortran source files and then link the resulting object files into a single executable file. You can build single-file executables using the ifort command from the command line. For Windows*, you can also use the visual development environment.

The executable file you build with this method contains all of the code needed to execute the program, including the run-time library. Because the program resides in a single file, it is easy to copy or install. However, the project contains all of the source and object files for the routines that you used to build the application. If you need to use some of these routines in other projects, you must link all of them again.

Exceptions to this are as follows:

If you are using shared libraries, all code will not be contained in the executable file.

On Mac OS* X, the object files contain debug information and would need to be copied along with the executable."
 
Last edited:
Technology news on Phys.org
  • #2
If you can run your code then you will almost certainly have created an executable. It may not be in the same directory as your Fortran - quite often in a sub-directory.
 
  • #3
Yep, problem solved thanks
 

1. What is Fortran and why should I learn it?

Fortran is a high-level programming language commonly used in scientific and engineering applications. It is specifically designed for numerical and scientific computing, making it a powerful tool for data analysis and simulations. Learning Fortran can significantly enhance your skills as a scientist and open up opportunities for career advancement.

2. Is Fortran still relevant in today's programming landscape?

Yes, Fortran is still widely used in many industries, particularly in fields such as aerospace, weather forecasting, and computational physics. It is also constantly being updated and improved, with the latest version, Fortran 2018, released in 2018.

3. How difficult is it to learn Fortran for someone new to programming?

The difficulty of learning Fortran will depend on your previous programming experience and your familiarity with mathematical and scientific concepts. However, Fortran has a relatively simple syntax and is known for its straightforward and readable code, making it a good language for beginners to learn.

4. Are there any resources available for learning Fortran?

Yes, there are many resources available for learning Fortran, including online tutorials, books, and courses. Some popular resources include the official Fortran website, Fortran Wiki, and Fortran-specific forums and communities.

5. Can I use Fortran for other types of programming, or is it only for scientific computing?

While Fortran is primarily used for scientific computing, it can also be used for other types of programming, such as data processing and general-purpose programming. However, other languages may be better suited for specific tasks, so it is important to consider your programming needs before choosing Fortran as your main language.

Similar threads

  • Programming and Computer Science
Replies
0
Views
237
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
22
Views
921
  • Programming and Computer Science
Replies
16
Views
1K
Back
Top