Dealing with fortran
From ATLAS-TRIUMF
[edit] Dealing with Fortran 90 at random local institutes outside CERN
If you want to rebuild one of the parts of Athena that is Fortran 90-based (e.g. Muonboy) against your locally installed Athena kit, it is painful but not impossible.
First download gfortran (preferred, likely to become default fortran 90 compiler for CERN) or g95, a free fortran 90 compiler. I installed mine in /usr/local/share/.
With gfortran I was able to compile more things (e.g. Persint standalone...) but I also had some very ugly side-effects when I put /usr/local/share/gfortran/irun/bin too early in my PATH and ended up accidentally using gcc version 4.2.0 instead of 3.2.3 for most of my compiling for several weeks.... putting it at the end of the path works a lot better.
Next, edit the AtlasFortranPolicy requirements file in your kit release (assuming that in your main cmt setup, you call your site STANDALONE). It should end up looking something like this:
package AtlasFortranPolicy
author Christian Arnault <arnault@lal.in2p3.fr>
#-----------------------------------------------------------------------
#
# Property package for defining all fortran related general features.
#
#-----------------------------------------------------------------------
use AtlasExternalArea AtlasExternalArea-00-* External
# Force a dependency on GaudiPolicy so that it's tags are available
# and it's policies can be overridden.
use GaudiPolicy v*
#----------------------------------------------
# Fortran flags and options
#----------------------------------------------
# Remove fflags values setup by the GaudiPolicy package
macro_remove fflags "" Linux "-O"
macro_remove fflags "" Linux "-fno-automatic"
macro_remove fflags "" Linux "-fdollar-ok"
macro_remove fflags "" Linux "-ff90"
macro_remove fflags "" Linux "-w"
# Setup default ATLAS fflags values
macro_append fflags "" \
Linux " -pipe -fno-second-underscore -Wall -W -Wsurprising -fPIC " \
Solaris " -Qoption fpp -P -PIC"
macro f77_linkopts "" \
Linux "-lg2c -lnsl -lcrypt -ldl" \
Solaris "-lF77 -lM77 -lsunmath -lm"
#----------------------------------------------
# Support for Fortran 90
#
# We differentiate sites wher the full compiler is available from
# sites where only the runtime (free) is available.
#----------------------------------------------
tag HAS_PGI32 HAS_PGI
tag HAS_PGI41 HAS_PGI
tag HAS_PGI51 HAS_PGI
tag HAS_PGIG95 HAS_PGI
tag HAS_PGI HAS_PGI_RUNTIME
tag CERN HAS_PGI32
#tag CERN HAS_PGI41
tag BNL HAS_PGI51
tag LBNL HAS_PGI32
tag SACLAY HAS_PGI STANDALONE
#imt change this locally:
#tag STANDALONE HAS_PGI_RUNTIME
tag STANDALONE HAS_PGIG95
macro f90_native_version "" \
HAS_PGI32 "32" \
HAS_PGI41 "41" \
HAS_PGI51 "51"
set PGI "" \
CERN "/afs/cern.ch/sw/pgi/pgi$(f90_native_version)" \
BNL "/usr/pgi" \
LBNL "/usr/local/pkg/pgi$(f90_native_version)" \
SACLAY "/usr/pgi" \
#imt try this instead
STANDALONE "${SITEROOT}/sw/pgi/pgi32"
macro PGI_libset "" \
HAS_PGI32 " $(PGI)/linux86/lib/event_init.o $(PGI)/linux86/lib/libpgf90.a $(PGI)/linux86/lib/libpgf90_rpm1.a $(PGI)/linux86/lib/libpgf902.a $(PGI)/linux86/lib/libpgf90rtl.a $(PGI)/linux86/lib/libpgftnrtl.a $(PGI)/linux86/lib/libpgc.a" \
HAS_PGI41 "$(PGI)/linux86/lib/libpgf90.a $(PGI)/linux86/lib/libpgf90_rpm1.a $(PGI)/linux86/lib/libpgf902.a $(PGI)/linux86/lib/libpgf90rtl.a $(PGI)/linux86/lib/libpgftnrtl.a $(PGI)/linux86/lib/libpgc.a " \
HAS_PGI51 "$(PGI)/linux86/lib/libpgf90.a $(PGI)/linux86/lib/libpgf90_rpm1.a $(PGI)/linux86/lib/libpgf902.a $(PGI)/linux86/lib/libpgf90rtl.a $(PGI)/linux86/lib/libpgftnrtl.a $/usr/local/share/g95-install/linux86/lib/libpgc.a " \
HAS_PGIG95 "/usr/local/share/g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.1/libf95.a $(PGI)/linux86/lib/event_init.o $(PGI)/linux86/lib/libpgf90.a $(PGI)/linux86/lib/libpgf90_rpm1.a $(PGI)/linux86/lib/libpgf902.a $(PGI)/linux86/lib/libpgf90rtl.a $(PGI)/linux86/lib/libpgftnrtl.a $(PGI)/linux86/lib/libpgc.a"
#
# Settings only appropriate when the full compiler is available
#
pattern pgi_macro \
macro <name>_linux "" HAS_PGI "<value>" ; \
macro <name> "" Linux "$(<name>_linux)"
pattern pgi_runtime_macro \
macro <name>_linux "" HAS_PGI_RUNTIME "<value>" ; \
macro <name> "" Linux "$(<name>_linux)"
apply_pattern pgi_macro name=f90_home value="$(PGI)/linux86/bin"
path_remove PATH "" Linux /pacific/
path_remove PATH "" Linux /pgi/
path_prepend PATH "" Linux "$(f90_home)"
#apply_pattern pgi_macro name=for90 value="pgf90"
apply_pattern pgi_macro name=for90 value="g95"
apply_pattern pgi_macro name=f90pp value="$(for) -E -P $(fincludes) "
apply_pattern pgi_macro name=f90flags value="-Mnosecond_underscore -fPIC"
apply_pattern pgi_macro name=f90ppflags value=" -pipe -fno-second-underscore -Wall -W -Wsurprising -fPIC "
apply_pattern pgi_macro name=f90comp value="$(for90) -c $(fincludes) $(f90flags) $(pp_f90flags)"
apply_pattern pgi_macro name=f90link value="$(for90) $(f90linkflags)"
#
# This macro should be installed in AtlasFortranPolicy_linkopts. However,
# since nowadays this package is used automatically (through AtlasPolicy)
# by all packages, it's probably better to keep it manual.
# Thus F90 users are advised to append $(f90_linkopts) to their
# <application>linkopts macro
#
apply_pattern pgi_runtime_macro name=f90_linkopts value="$(PGI_libset) -lm -lgcc -lc -lgcc $(f77_linkopts)"
#
# ff90 suffix is for fixed format compiling
# f90 suffix is for free format compiling
#
language fortran90 -suffix=ff90 -suffix=FF90 -suffix=f90 -suffix=F90 -linker=$(f90link) -preprocessor_command=$(ppcmd)
macro fortran90_fragment "" HAS_PGI "fortran90"
macro fortran90_library_fragment "" HAS_PGI "fortran90_library"
make_fragment $(fortran90_fragment)
make_fragment $(fortran90_library_fragment)
macro AtlasFortranPolicy_linkopts "$(f77_linkopts)"
#
# When using f90, please install the following statement to your requirements file
#
###macro AtlasFortranPolicy_linkopts "$(f90_linkopts)"
macro AtlasFortranPolicy_export_paths "$(PGI_libset)"
Probably the best way to see what to change is to save this version and do a diff against the original version in your release.
It is still a bit of a pain - you can't just compile some of the Fortran you will be using; you have to rebuild all of it. So if you want Muonboy, rebuild all the Muonboy subpackages and all the Amdcsimrec subpackages. It takes a while, but eventually it works.
For reasons not at all clear to me, recent versions of the kit have not been installing the file sw/pgi/pgi32/linux86/lib/event_init.o. I had to copy this manually: cp /afs/cern.ch/atlas/software/installed/rel/sw/pgi/pgi32/linux86/lib/event_init.o /triumfcs/trshare/atlas/AtlasSoftware/AtlasReleaseArea/sw/pgi/pgi32/linux86/lib/.
--Isabel 11:45, 25 Aug 2005 (PDT)

