mpfun and allocatable

Hi,
I’m trying to compile Dr. Bailey’s mpfun (http://crd.lbl.gov/~dhbailey/mpdist/) with pgf90, and I am stuck. The README file for mpfun says:

IV. Makefiles and System-Dependent Issues

The two Makefiles are set up for an Apple or IBM system, using the IBM
xlf90 Fortran-90 comipler. These Makefile will need to be changed for
other systems. In many cases, it is simply necessary to change the
name of the compiler, and make a couple of simple changes to the
compiler flags. Typical flags that may need to be set include a flag
to specify free-form Fortran source code format (instead of fixed
column format), and a flag to specify that a backslash () in a
literal string does not mean an escape character (this latter feature
is needed for the mathtool.f program).

So , in the Makefile I used pgf90 with “-Mfree -Mbackslash”. When I try to compile it, I get a lot of errors:

pgf90 -Mfree -Mbackslash -c mpfun90.f
PGF90-S-0084-Illegal use of symbol mpcosq - must be a deferred shape array (mpfun90.f: 41)
PGF90-S-0084-Illegal use of symbol mpsinq - must be a deferred shape array (mpfun90.f: 41)
0 inform, 0 warnings, 2 severes, 0 fatal for mpfuna
0 inform, 0 warnings, 2 severes, 0 fatal for mpabrt
PGF90-W-0189-Argument number 1 to mpeq: association of scalar actual argument to array dummy argument (mpfun90.f: 3466)
PGF90-W-0189-Argument number 1 to mpeq: association of scalar actual argument to array dummy argument (mpfun90.f: 3467)
0 inform, 2 warnings, 0 severes, 0 fatal for mpcssn
PGF90-S-0084-Illegal use of symbol mpcosq - must be an allocatable array (mpfun90.f: 3695)
PGF90-S-0084-Illegal use of symbol mpsinq - must be an allocatable array (mpfun90.f: 3696)
PGF90-W-0189-Argument number 2 to mpeq: association of scalar actual argument to array dummy argument (mpfun90.f: 3703)

[… a lot more, pretty the same… ]

PGF90-S-0072-Assignment operation illegal to external procedure mpuu2 (mpfun90.f: 4932)
PGF90-S-0072-Assignment operation illegal to external procedure mpuu2 (mpfun90.f: 4935)
PGF90-S-0072-Assignment operation illegal to external procedure mpuu2 (mpfun90.f: 4948)
0 inform, 0 warnings, 7 severes, 0 fatal for mpinix
PGF90-S-0074-Illegal number or type of arguments to conjg (mpfun90.f: 5020)
0 inform, 0 warnings, 1 severes, 0 fatal for mpfftcr
PGF90-S-0074-Illegal number or type of arguments to conjg (mpfun90.f: 5112)
0 inform, 0 warnings, 1 severes, 0 fatal for mpfftrc
make: *** [mpfun90.o] Error 2

So I looked at the first error line (mpfun90.f: 41). It says:

allocatable mpcosq, mpsinq

Sadly, I dont know but a little Fortran. The definitions of allocatable from IBM’s documentation (http://publib.boulder.ibm.
com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlf101l.doc/xlflr/alloc.htm):
and from PGI’s documentation (http://www.pgroup.com/doc/pgifortref.pdf) looks like they are describing the same thing. Also,
there is an example in PGI’s doc:


Example
REAL SCORE(:), NAMES(:,:)
REAL, ALLOCATABLE, DIMENSION(:,:,:) :: TEST
ALLOCATABLE SCORE, NAMES
INTEGER, ALLOCATABLE :: REC1(: ,: , :)

So, the sintax looks right. Does anybody know why does it says it must be a deferred shape array? Am I missing something? How can I debug this some more? This is a pgf90 6.1-2 64-bit target on x86-64 Linux.

TIA,
– Diego.

Hi gway,

The problem is that the allocatable statement is being used on an a varaible that hasn’t been declared yet. So the fix is to swap lines 41 and 42 of mpfun90.f. With this change mpfun90 compiles correctly. You’ll also need to change “ETIME_” to “ETIME” in second.f.

Example:

!allocatable mpcosq, mpsinq
real*4, allocatable :: mpcosq(:,:), mpsinq(:,:)
allocatable mpcosq, mpsinq

In looking through my Fortran reference manuals, even though all the examples show the allocatable statement being used after the declaration, I can’t find anything to indicate that it’s illegal to put it before. Hence, I’ve created a technical problem report (TPR#3912) and passed it on to our engineers.

Thanks,
Mat

Hi mkcolg,
Thank you very much for your fast and accurate reply: that solved the problem completely.

Thanks again,
– Diego.