Programming & plotting on the macs

(assume "#" is the prompt)

 

To compile fortran program "prog.f"

 

# gfortran prog.f

 

If it includes "nplot" compile with

 

# gfortran -lnplot prog.f

 

The resulting executable is "a.out"

 

To execute "a.out"

 

# a.out

 

If there are input & ouput files

 

# a.out < input > output

 

If it produces a plotfile "pltfil"

 

Convert it to postscript

 

# apen -v -t pltfil > pltfil.ps:

 

Preview the poscript

 

# gs pltfil.ps

 

SAMPLE

 

c          program add.f

c add two numbers

            read(5,*) a,b

            c=a+b

            write(6,*)' a = ',a,' b= ',b,'  sum= ',c

            stop

            end

 

INPUT FILE

# cat infile

6. 56.

 

COMPILE

# gfortran add.f

 

EXECUTE

# a.out<infile

 

PRODUCES

 

a =    6.0000000      b=    56.000000       sum=    62.000000