Recently, a cluster I use upgraded to PGI 11.9 and after that I started getting messages like this all over my makelogs:
/usr/local/sles11/pgi/linux86-64/11.9/lib/f90main.o: In function `main':
f90main.c:(.text+0x3c): undefined reference to `MAIN_'
They don’t seem to harm anything, but with a full make of our model, we end up with 10s, 100s of these.
Any idea of why these are occurring with 11.9 but not with earlier versions (as far as I can tell)? Or any idea of where to look? MVAPICH2? Our PGI install routine?
This is only an uneducated guess (since the contents of the makefile or the commands issued by ‘make install’ have not been shown):
The make command is running the PGI compiler, which is one of many Fortran compilers that the makefile is supposed to work with, to figure out which flags to use with the subsequent compilations. The fact that the failure to link did not cause make to abort suggests this explanation.
Hmm. You’re probably right. I know our quite complex make system will include a file that runs “$FC --version” to figure out if you’re building with ifort and which version (and that used to cause warnings up the wazoo until PGI apparently added --version, bless you PGI), so maybe it’s running that in our make environment instead of a command line environment causing the issue?
I tried to whip up a nested example, but I can’t seem to trigger the MAIN_ using the same make style, e.g.:
.F90.o:
$(FC) $(FOPTS) -c $<
and includes even with a truncated FC detection bit:
I think I might have figured this out, at least a little. I think whenever our make system runs “mpif90 -V” or “mpif90 --version”, it throws the warning. To wit:
> pgfortran --version
pgfortran 11.10-0 64-bit target on x86-64 Linux -tp nehalem
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2011, STMicroelectronics, Inc. All Rights Reserved.
> mpif90 --version
pgfortran 11.10-0 64-bit target on x86-64 Linux -tp nehalem
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2011, STMicroelectronics, Inc. All Rights Reserved.
/opt/pgi/linux86-64/11.10/lib/f90main.o: In function `main':
f90main.c:(.text+0x3c): undefined reference to `MAIN_'
So, apparently, when mpif90 gets the --version passed through, MVAPICH2 does something to trigger the warning.
It looks like mpif90 is invoking the linker instead of stopping when using “–version”. In the PGI pre-built MPICH libraries we added the following to the mpif90 script’s argument parsing:
-V) # PGI ADDED
#Pass this argument to the compiler as well. #PGI ADDED
echo "mpif90 for $MPIVERSION" # PGI ADDED
compileargs="$compileargs -V"
DoLink=0 #PGI ADDED
DoCompile=1 #PGI ADDED
;;
You might be able to add something similar to MVAPICH’s mpif90 script for “–version” so it doesn’t perform the link step.
I think you are right. Looking at mpif90, it has this bit:
-v)
# Pass this argument to the compiler as well.
echo "mpif90 for MVAPICH2 version $MPICH2_VERSION"
# if there is only 1 argument, it must be -v.
if [ "$#" -eq "1" ] ; then
linking=no
fi
;;
with linking=yes being the default. Of course, when built with PGI, -v triggers the verbose output which sort of defeats the purpose of this option. Obviously, then, passing -V or --version uses the default linking=yes path.
Well, it’s good to know the mystery is solved. I’m not sure it’s worth bothering the MVAPICH folks to “fix” this. Yes, adding --version would be possible, but -V is tricky. It has the potential of screwing up the -V_ver_ previous-version syntax of PGI when using mpif90 (since you want the linker to activate then).