Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29243 Discussions

porting code to Linux -> allocatable dummy argument

Dusan_Z_
Beginner
1,502 Views

Hello,

I am trying to build an executable on Linux that was successfully built in Intel Fortran 11 on a Windows machine. Only, the Linux compiler is version 10.1, so I suspect that is causing problems.

I get an error message: "allocatable dummy argument may only be argument associated with an allocatable actual argument"... in one of the source files.

Do I need to upgrade the Linux compiler or is there a way around this?

Best regards

0 Kudos
9 Replies
TimP
Honored Contributor III
1,502 Views
If you took the risk of disabling checking on Windows, and got away with it, you might do the same for linux. It would be better to correct your source code. No harm in upgrading your compiler, but that doesn't appear to be a solution to your problem.
0 Kudos
Dusan_Z_
Beginner
1,502 Views

I appreciate your help.

Can you please clarify this for me:

if I set:

integer(8) klb(:)

allocatable:: klb

in the main program and:

integer(8) klb(:)

allocatable:: klb

intent (out)::klb

...

allocate(klb,...)

...

in the subroutine, that is ilegal?

0 Kudos
Hirchert__Kurt_W
New Contributor II
1,502 Views

The 10.1 compiler appears to be complaining that you are providing a nonallocatable actual argument to be associated with a dummy argument declared allocatable. Such a condition would not be acceptable to the 11 compiler either, so upgrading to 11 might not solve your problem.

The first thing you need to do is investigate whether this is really is what's happening in your program. If it is not, then the erroneous diagnosis is likely the result of a compiler bug, and an upgrade to 11 would likely fix it. There might be a workaround in 10.1, but you are unlikely to get much help in finding one until you provide more information about the nature of the problem.

If, on the other hand, the error message is correctly describing the situation, you need to look at what else may have changed in your port from Windows to Linux. This situation should not have been acceptable to the Windows compiler either, so it seems likely that something has changed. Perhaps the contents of a standard include file is different, or the interface for a library routine. I'm not asserting that difference will turn out to be Windows vs. Linux issue; it may just as easily turn out to be a difference in the tools provided with 10.1 versus those provided with 11, or it may be some other difference between the two machines that none of us have yet considered. The only way to find out is to dig into the specifics of the error. (Don't forget to consider the possibility that the source you have is not the version of the source that actually ran on the Windows machine.)

We have a tendency to assume that once a program is running on one platform it is "debugged". The reality is that running programs often still contain bugs that may be exposed by the change to a new compiler version or the change to a new platform. (I've seen bugs found in programs that were running on dozens of other platforms.)

0 Kudos
Hirchert__Kurt_W
New Contributor II
1,502 Views

The part you've posted looks legal, but you haven't shown us either the actual argument list or the dummy argument list.

Is klb in the dummy argument list?

Is klb in the actual argument list? If so, do you pass it as klb or klb(:)? [The latter would likely cause the problem you are seeing.]

[The incomplete syntax you show for the allocate statement looks questionable, but that would produce a different error, so I'm assuming that the questionable part is just an error in transcription from your program to your post.]

0 Kudos
Dusan_Z_
Beginner
1,502 Views

Thanks.

I acknowledge all the possible causes of problems. I have given the code above, and if I replace this code by

a simple:

integer(8) klb(30000000)

in the main program and:

integer(8) klb(1)

in the subroutine, everything builds and works on Linux, as it was on Win. That's why I suspected that the upgrade could fix the problem.

0 Kudos
Dusan_Z_
Beginner
1,502 Views

Hi,

here it is:

call example(nfq,fq,klb)

and :

subroutine example(nfq,fq,klb)

The quationable allocate statement was not fully written in my post because I considered it good, it is actually:

allocate (klb(n), stat=istate)

Regards,

Drazen

0 Kudos
Steven_L_Intel1
Employee
1,502 Views

My guess is that on Windows, you're building in Visual Studio where, by default, a Debug configuration enables generated interface checking. (On Linux in version 11 this would be "-warn interface". In version 10 you also need "-gen-interface".) This allows the compiler to see errors that it would not otherwise.

If a dummy argument is declared as assumed shape (dimension(:)) or ALLOCATABLE, the Fortran standard requires that an explicit interface be visible to the caller. The ideal method for this is to put the subroutine in a module and USE the module where you want to call it.

0 Kudos
Dusan_Z_
Beginner
1,502 Views

Thank you for all the tips.

I did put this subroutine in a module and "used" the module from the main program. There were no warning or error messages in Visual Studio and I don't remember I changed anything concerning what warnings and errors the compiler should see.

Anyway, I decided to upgrade the compiler anyway, since I will need it in future and that's the only way to keep the compatibility on Win and Linux. As soon as I install it I will try to build the executable and will report what happened.

0 Kudos
Dusan_Z_
Beginner
1,502 Views

Hi,

I upgraded to Intel Fortran Compiler 11.1 and compiled and linked the same code as on Windows without any problems. So, thank you all for helping me on this one.

Regards,

Drazen

0 Kudos
Reply