basics

Arjen Markus arjen.markus@wldelft.nl
Sun Jan 11 12:09:00 GMT 2009


>
> Hi, I am just about starting to learn fortran. I installed gfortran on my
> ubuntu 8.10
> sudo apt-get install gfortran g77
> and wanted to run:
> program hello
> write(*,*) ‘ Hello world!’
> end
> Where should I write the code? in a text file and then save as hello.f or
> should I use other souce? I know this is simple question but I am very
> beginner. thanks
> r

Hello,

that sort of very general questions is best posted to the comp.lang.fortran
newsgroup. This list is intended for specific questions about the
gfortran compiler.

But to answer your question:
Yes, save the code in a file (hello.f90, say) and with a command like:

   gfortran -o hello hello.f90

you get a program "hello" that you can run.

However:
- Use ordinary quotes, not "smart" quotes. Smart quotes are
  not part of the Fortran language and are thus not recognised.
  (Though this may be an artificial effect of your mail program
  of course) Best use an ordinary text editor.
- Another thing is the extension of the source file:
  .f90 is commonly used to signify the so-called free form.
  Most compilers recognise that extension as such.
- If your program grows and you are using more than one file
  or you start using all manner of libraries, the compile and
  link command above will need to be extended, but that is
  something to keep in mind for the future.
- (A minor nitpicking: the Fortran standard does not speak of source
  files, and very deliberately does not. Most if not all compilers
  will expect ordinary text files though to do their job.)

Regards,

Arjen



More information about the Fortran mailing list