« previous next»

1.4    Compiling in UNIX

    Once you have written your code you must compile it before running.  Compiling translates the written source code into machine language, or an object program.  In order to compile in UNIX, at the prompt  type f90 followed by the program name (e.g  % f90 progname.f90). This should create an executable file named a.out. You should then be able to run the program by typing a.out at the UNIX prompt (i.e % a.out, should run the program).  Every time you compile a program without  the -o option (discussed in the next paragraph) a new a.out file will be created and if a previous a.out file exists it will be overwritten.

    Many options are available when compiling code and some of these will be discussed later in the notes.  One option (-o) allows you to define the name for your executable file.  You do not have to use the default executable named a.out.  In this way you can compile a program once and have the executable available whenever it is needed.  Also, in more advanced cases, two or more executables will need to be linked.  In these cases, you must have different names for all executables.  For example:

   % f90 -o progname progname.f90

    This command compiles the program progname.f90 and creates an executable file named progname.  The typical convention is to name your executable file with the same name as your program, but without an extension.

    Again, compiling and running in Sun Workshop will be different.  Refer to the manuals if interested.

Practice: Compile and run the program written previously in 1.3.
 

« previous next»