Fortran Program Porting Issues (egcs version)

Japanese version is here.



Prerequisites

Of course, you have to set up some FORTRAN compiler on your MkLinux box before you can start porting fortran programs. In the following, I am going to use "g77", the GNU version of f77. A version of g77 in the "egcs" suite coming with MkLinux DR3 is based on g77-0.5.22.
  1. Compiler Setup

    The egcs RPMs include those for C, C++, Objective C, and FORTRAN. The C and FORTRAN support is installed in the DR3 installation if "C Development" is selected, while th optional C++ and Objective C support is installed when you add "C++ Development" to your selection.

    If you haven't installed the "C Development" packages, you need to install them by hand. Get the following RPMs to <somewhere> on your local disk:

    $ cd <somewhere>
    $ ls
    egcs-1.0-2e.ppc.rpm
    egcs-as-gcc-1.0-2e.ppc.rpm
    egcs-c++-1.0-2e.ppc.rpm
    egcs-g77-1.0-2e.ppc.rpm
    egcs-objc-1.0-2e.ppc.rpm

    and then install them as:

    $ su
    # rpm -Uvh <somewhre>/egcs*-1.0-2e.ppc.rpm

Getting Started with G77

  1. Simple Test

    Congratulation! Now you are ready to try "g77" to compile your fortran programs. You had better start with something rather simple to test if "g77" works at all.

    $ cat simple.f
    	  real*4  a, b, c
    	  a = 1.
    	  b = 2.
    	  c = a + b
    	  print *, ' a, b, c = ', a, b, c
    	  end
    	
    $ g77 simple.f -o simpletest
    $ simpletest

    Passing this simple test, you can now proceed to more complicated programs (You should if your system is DR3). Then you may encounter various problems like I did.

Experience with G77 on MkLinux

I was brave enough to jump directly to a really huge program package called CERNLIB. This, of course, caused a lot of problems that I suffered from.
  1. If Linux Source Is Available

    If somebody already ported your favorite fortran program to a Linux box, your are lucky, since the source code is very likely to be g77-compilable. If you have to deal with bits, bytes, or integer*2s embedded in an I*4, however, you need to be careful. Intel chips and PPC chips have different byte orders. The software package I mentioned above (CERNLIB) falls into this category. Although the source codes are g77-compilable except for some trivial problems inherent in porting any package to a MkLinux box, the porting was a pains-taking process, because of the byte order difference. This only requires patience and carefulness not to miss any place of swapping bytes or equivalencing I*4 with I*2s.

  2. Otherwise

    You are on your own. Porting issues then include

G77 Performance

I don't have enough time to carry out any systematic performance check of my MkLinux box (PowerMac 8115/110: ppc601). Instead, I have just compared the computing time for a few physics programs that run both on the MkLinux box and a HP workstation (C100: pa7200 + HP-UX10.10 + HP Fortran).
  1. Description of Sample Programs

  2. Results

    Maybe you are just interested in this table:

    C100 (HP-UX) 8115/100 (MkLinux)
    TTH_GEN:BASES 140.73 sec
    (2.94834 +/- 0.00927 fb)
    850.05 sec
    (2.94811 +/- 0.00927 fb)
    TTH_GEN:SPRING 402.19 sec
    (output data: 35MB)
    813.35 sec
    (output data: 35MB)
    TTH_ANL: 8J 218.53 sec 435.08 sec
    TTH_ANL: L+6J 166.2 sec 306.2 sec
    TT_GEN:BASES 410.27 sec
    (0.40153 +/- 0.00061 fb)
    2485.85 sec
    (0.40153 +/- 0.00061 fb)
    TT_GEN:SPRING 103.62 sec
    (output data: 5.6MB)
    244.45 sec
    (output data: 5.6MB)

    where the center of mass energy has been set at 700(340) GeV for TTH (TT) and the top mass is chosen to be 170 GeV. In the SPRING stage, 1000(200) events were generated for TTH (TT). Notice that TT_GEN takes into account the threshold enhancement thus has a finite cross section even at the production threshold.

    Comments

    Except for the BASES step, the difference is about a factor of two, which is probably consistent with the CPU speed difference (I'm not sure though). In the BASES step, the factor becomes about six instead. The performance of the MkLinux box is significantly worse than the other cases. This is probably due to the BASES's randomly accessing a huge array that exceeds a tiny cache. I am going to test this, if time allows.

Back to Keisuke Fujii's MkLinux Page
fujiik@jlcuxf.kek.jp Aug. 1, 1998