Peter Herzenstiel said:
> Attached you can find a little program written with Fortran. The Intel
> Fortran Compiler for Windows doesn't compile the program, it aborts
> with the following error messages:
>
> Command Line: "array(1:10)%Nr(1)=1.2345" / Error: The part-name to the
> right of a part-ref with nonzero rank has the ALLOCATABLE attribute
> (6.1.2). [NR]
> Command Line: "write (*,*) 'array(1:10)%Nr(1)=',array(1:10)%Nr(1)" /
> Error: The part-name to the right of a part-ref with nonzero rank has
> the ALLOCATABLE attribute (6.1.2). [NR]
These error messages are correct.
They even give a correct reference to the subclause of the Fortran standard
which contains this requirement.
> So the questions are:
> 1) Does the command line "array(1:10)%Nr(1)=1.2345" agree with the
> Fortran 95/90 standard??
Just having an ALLOCATABLE component makes it not Fortran 90 or 95;
allocatable components were described in an ISO Technical Report in 1998
and are part of Fortran 2003.
In any case, no part-name with either POINTER or ALLOCATABLE is allowed
to follow an array designator. This has been the case since F90 for
pointer, and F2003 for allocatable (the question not arising until
allocatable components were added).
> 2) Maybe the memory administration (management) cannot handle this
> command in the Windows platform but in the Linux platform???
No, your program is just not Fortran.
> The PGI compiler shows no errors for the same program, I included the
> output file (dynamic_array.out) so you can run it.
Well, that's a PGI extension then.
> This problem looks very simple and yes it is
> possible to solve it for this simple case with a do loop.
A designator that combines a pointer or allocatable following an array
part is a "gather" or "scatter" operation. This is not particularly simple,
and is not part of standard Fortran.
> But it has consequences to the usage of the implicit loop for example when
> using the pack command or other commands, because there is is not so easy to
> replace the implicit loop command with a do loop.
You can still do this with an implied do loop by using an array constructor.
I.e. instead of
array(1:10)%Nr(1)
write
[ (array(i)%Nr(1),i=1,10) ]
This is a bit wordier but not that much. And it functions as a reminder that
indeed, a gather operation is what is happening here.
Cheers,
--
...........................Malcolm Cohen, Nihon NAG, Tokyo, Japan.
([log in to unmask])
|