64-bit specific CERNLIB issues
------------------------------

If you are intending to use CERN libraries on a 64-bit platform (such as
the Itanium [ia64], Alpha, or AMD64 / EM64t [amd64] Debian architectures),
you should be aware of some potential problems.

CERNLIB was never designed to run on machines where the size of a pointer
is 64 bits.  The code implicitly assumes that
	sizeof(void *) == sizeof(int) == 4
in many different places.  The biggest culprits are the ZEBRA and COMIS sets
of routines in the packlib and pawlib libraries, respectively.  This would be
difficult to fix without rewriting megabytes of FORTRAN source code.

Harald Vogt has, however, succeeded in putting together enough workarounds
to permit PAW and Paw++ to run on 64-bit machines.  These workarounds
are valid only when the entire set of code in a program's memory space can
be addressed by 32-bit values.  This will generally be true for statically
linked programs, but not for dynamically linked ones.

Hence, many of the CERN libraries on 64-bit machines may only work well when
linked against statically.  Routines outside of ZEBRA and COMIS may be safe to
use if dynamically linked, but I would not bet money on it.  Furthermore, you
will want to make sure that any variables used as parameters in COMIS routines
are within the program data segment, either by putting them in COMMON blocks
or by compiling the block of code in which the variable is declared with the
-fno-automatic flag of gfortran.  (-fno-automatic used on FORTRAN code has the
same effect as declaring all local variables "static" would in C code.)  See
the example program comis-64bit-example.F in the libpawlib2-dev package under
/usr/share/doc/libpawlib2-dev/examples, for instance.

Static linking is the default behavior if you use the "cernlib" script when
linking, like this:

	# Should work everywhere:
	gfortran -o myprogram myprogram.F `cernlib -G Motif pawlib`

but not if you directly tell the library names to the compiler, like this:

	# Possibly results in a non-working program on 64-bit!
	gfortran -o myprogram myprogram.F -lpawlib -lpacklib ...

For more information, please see Harald Vogt's web page about CERNLIB ported
to 64-bit machines:
    http://www-zeuthen.desy.de/linear_collider/cernlib/new/cernlib_2005.html

-- Kevin McCarty <kmccarty@debian.org>, Wed,  8 Aug 2007
