This document is based on a report written as part of readme_linux_g77.doc by Rob Komar, updated to gcc 3.0 by Nick West.
First, it is strongly recommended that you switch to gcc version 3 for this allows debugger to access information in COMMON blacks. Installation instructions can be found here
A similar kind of mangling is done to variable names (ie. the names are converted to lower case, and those with underscores have an extra two underscores attached to the end, but names without any underscores do _NOT_ have any underscores appended to them). So, when debugging, a variable like `RTMP' would be referred to as `rtmp', and one called `RTMP_1' would be referred to as `rtmp_1__'. (Note: this is the default behaviour; it can be controlled by using the `-fno-underscoring', `-fno-second-underscore', `-fsymbol-case-*' and `-fintrin-case-*' switches with g77). When using `gdb' to debug the code, command line completion is available (using the tab key) and is helpful when trying to guess what the mangled symbol name for a variable or procedure might be.
In Fortran, arguments to subroutines and functions are usually passed using `pass-by-reference' (ie. the address of the variable is sent rather than the value). So, an argument within a subroutine must usually be accessed using pointer syntax (for example, if RTMP was passed to a subroutine, you could examine its contents using `p *rtmp' when in the subroutine's stack frame). Things get really hairy when you try to examine arrays passed as arguments to procedures. Their treatment is inconsistent in gdb, although examining the contents of the array with something like `p *arr' inside the subroutine's stack frame usually seems to work. However, sometimes an array such as ARR(3) might appear as a `(real (*)[3])' type in a subroutine, that is, as a pointer to a real[3] object. In such a case, the individual elements can be accessed as arr[0][1], arr[0][2], and arr[0][3] (ie. using a mixture of C and Fortran syntax).
The above information is summarised in the following table. Remember:-
Name Type | Example source | gdb example |
---|---|---|
Global symbol | SUBROUTINE EVMAIN |
To set a breakpoint:-break evmain_ |
Local/global scalar variable | INTEGER I_MODE |
To examine value:-print i_mode_ |
Local/global array variable | REAL DIR_COS(3) |
To examine DIR_COS(1):-print dir_cos_[0] |
Argument scalar variable | SUBROUTINE MCG_SET_DIRECTION((I_PART,... |
To examine I_PART:-print *i_part_ |
Argument array variable | SUBROUTINE GE_NEXT(XYZ, |
To examine XYZ(1):-print print *xyz[0] |
IQ{LMCTKC-4)
contains 4HMCTK
. To display:-
1) Go to: http://www.fsf.org/software/gcc/gcc.html and from the download page get the tar file gcc-3.0.tar.gz 2) Define some installation directory e.g.:- set INSTALLATION = "/snodata" mkdir -p $INSTALLATION 3) Copy the tar file into this directory and unpack:- cd $INSTALLATION tar xvzf gcc-3.0.tar.gz 4) Configure, build and install:- set srcdir = "$INSTALLATION/gcc-3.0" set objdir = "$INSTALLATION/gcc-bin" set insdir = "$INSTALLATION/usr/local" mkdir -p $srcdir mkdir -p $objdir mkdir -p $insdir cd $objdir $srcdir/configure --prefix=$insdir \ --enable-version-specific-runtime-libs gmake bootstrap gmake install 5) Update you PATH so that the compiler is found before the system default:- setenv PATH $INSTALLATION/usr/local/bin:$PATH Try typing:- gcc -v you should see something like:- Reading specs from /snodata4/west/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs Configured with: /snodata4/west/gcc-3.0/configure --prefix=/snodata4/west/usr/local --enable-version-specific-runtime-libs Thread model: single gcc version 3.0 You need to update environmental variable SNO_EXTERNAL_LIBRARIES defined in $SNO_TOOLS/get_lhost_info.scr by appending:- -Wl,-rpath -Wl,$INSTALLATION/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0 -lgcc_s -lstdc++
Go Back to the Snoman Companion Top Page