Main Menu

friends

Banner

Latest articles

FLOSS weekly
30/09/2009 | mad mad mod

FLOSS weekly FLOSS is an acronym for free/libre/open source software. Floss weekly is a podcast from the TWiT Network. The show contains interviews with prominent developers from the open so [ ... ]


convert mysql table from MyISAM to InnoDB
30/12/2009 | mad mad mod

MyISAM is the default storage engine for MySQL. Unfortunately it doesn't support transactions or foreign keys (but it has some other nice features like compression). However, because InnoDB does su [ ... ]


Other Articles

Designed by:
SiteGround web hosting Joomla Templates
Hello World in Fortran E-mail
programming

This article describes how to write, compile and execute a "Hello World" program in Fortran on Linux (RedHat / Centos / Fedora).

 

1. the prerequisites

  • a text editor of your choice (e.g. vi)
  • a Fortran compiler (e.g. gfortran - the GNU Fortran 95 compiler)


make sure you have installed the GNU Fortran 95 compiler rpm:

# rpm -qa  gcc-gfortran
gcc-gfortran-4.1.2-46.el5_4.1

 

If it is not installed yet, you can install it with yum (you need to be root to do that):

# yum install gcc-fortran

 

 

 

2. write the code


open an empty file with a text editor (e.g. vi):


# vi helloworld.f



now write the following code into the sourcefile:


      program helloworld
         print *,"Hello World!"
      end program helloworld

Please note: there are 6 spaces at the beginning of each line!


save the file and exit vi with ":wq + enter"

explanation


program helloworld

The name of our program is "helloworld". This is not required, but is recommended.

 


print *,"Hello World!"

The command "print *" prints items to the screen.

 


      end program helloworld

marks the end of the program "helloworld".

 

 

3. compile the code



# gfortran helloworld.f -o helloworld




This produces an executable called "helloworld".



4. run the program


you can now execute the binary program with:


# ./helloworld
Hello World!

 

 

 

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
mad mad mod, Powered by Joomla! and designed by SiteGround web hosting