Simple Guide to Programming Languages

Enquiry : Mr.Jason Chan (mwchan@phy.cuhk.edu.hk, Rm348)


Fortran 77

Compilation :

Example : compile ax.f, bx.f & cx.f into one program "foo"

f77 -o foo ax.f bx.f cx.f

Example : compile foo.f to foo.exe, improve the run-time preformance, suppresses all warning

f77 -fast -O5 -w -o foo.exe foo.f

See on-line manual for the details of f77 : > man f77

Fortran 77 Quick Reference can be found in Rm326 (Computational Physics Laboratory)

If you want Beginner's Guide of Fortran77, please ask Mr.Jason Chan.


KAP for Fortran 77 --- Parallelize fortran programs for SMP (DEC only)

If you have a fortran 77 program running on a multi-CPUs server (axps1,2,3) and want to take the adventages of multi-CPU processing power, there are 2 fortran preprocessors on DEC machines for achieving this purpose : kapf (Fortran Preprocessor) & kf77 (Preprocessor + Compiler)

Example :

(Preprocess a program for parallel execution on a SMP)

> kapf -conc -cmp=myprog.smp.f myprog.f

> f77 myprog.smp.f -fast -tune host -automatic -non_shared -lkmp_osf -threads

(Using KF77 to preprocessing & compilying a program at the same time)

> kf77 -o myprog.exe myprog.f

(default options is "-fast -math_library accurate -non_shared -tune host")

(output files : myprog.cmp.f = the optimized source file & myprog.exe = the executable file)


Fortran 90 -- On DEC only

Compilation :

Example : compile ax.f90, bx.f90 & cx.f90 into one program "foo"

f90 -o foo ax.f90 bx.f90 cx.f90

Example : compile foo.f90 to foo.exe, improve the run-time preformance, suppresses all warning

f90 -fast -O5 -w -o foo.exe foo.f90

See on-line manual for the details of f90 : > man f90

If you want User's Guide or Reference Manuals of Fortran 90, please ask Mr.Jason Chan.


KAP for Fortran 90---Parallelize fortran90 programs for SMP(DEC only)

If you have a fortran 90 program running on a multi-CPUs server (axps1,2,3) and want to take the adventages of multi-CPU processing power, there are 2 fortran 90 preprocessors on DEC machines for achieving this purpose : kapf90 (Fortran 90 Preprocessor) & kf90 (Preprocessor + Compiler)

Example :

(Preprocess a program for parallel execution on a SMP)

> kapf90 -conc -cmp=myprog.smp.f90 myprog.f90

> f90 myprog.smp.f90 -fast -tune host -automatic -non_shared -lkmp_osf -threads

(Using KF90 to preprocessing & compilying a program at the same time)

> kf90 -o myprog.exe myprog.f90

(default options is "-fast -math_library accurate -non_shared -tune host")

(output files : myprog.cmp.f90 = the optimized source file & myprog.exe = the executable file)


IMSL Fortran Library --- Many useful mathematics functions for Fortran

IMSL provides many useful mathematics & statistical Fortran functions for fortran programming.

To get use of IMSL for F77, you can simply do this : > source /imsl.csh

To get use of IMSL for F90, you can simply do this : > source /imslf90.csh

Then you will see some instructions on compilying your program involving IMSL

Use the variables displayed when compiling programs :

e.g. > f77 -o myprog.exe $FFLAGS $SHARED myprog.f

or   > f90 -o myprog.exe  $F90FLAGS  myprof.f  $LINK_F90_SHARED

You can read  the IMSL Library On-line Manual  by :  acroread  /usr/local/imsl/MATH.pdf
or borrow the manuals from Mr.Jason Chan


Numerical Recipes ---Another source of maths functions for Fortran

There are many Fortran source of mathematics functions at Find your treasure in there!


C Language

Compilation :

(Compile a C program, output to "myprog.exe")

> cc -o myprog.exe myprog.c

C language Programmer's Guide can be found in Rm326, or you can borrow from Mr.Jason Chan

See the on-line manual pages for the C compiler options : > man cc


C++ Language (On DEC only)

Compilation :

( Compile a C++ program, output to "myprog.exe")

> cxx -o myprog.exe myprog.cxx

See the on-line manual pages for the C++ compiler options : > man cxx

Note : C++ is an Object Oriented Programming Language, is quite different from C