Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29282 Discussions

How to deal with an 'OPTIONAL' problem?

jjqq
Beginner
514 Views

The following code is working well with PGF90, but no good with ifort. Could you tell me a way to let it go smoothly with Intel compiler (still keep 'ldims' empty)? Thanks.

===============================================

IMPLICIT NONE

call opt(1)
end

subroutine opt (i,ldims)

INTEGER ,INTENT(in) :: i
INTEGER ,INTENT(in) ,OPTIONAL :: ldims

print*,i
print*,ldims

end subroutine opt

===============================================

0 Kudos
1 Reply
hajek
Beginner
514 Views
The use of optional, assumed-shape, pointer or allocatable arguments (virtually anything beyond F77-compatible arguments) requires explicit interface in Fortran 95.
You have three ways to do it (each has its own benefits): put the subroutine into a module and USE the module, make it an internal procedure of the main program, or provide interface block.
The first option is usually the best, but not always.
Btw. Even if you did some of these, your program would still be broken: it is illegal to print an optional argument that is not present. The only two things you can do with absent optional arguments in F95 are:
1. inquire their presence by the PRESENT intrinsic
2. pass them as actual arguments to optional orguments of exactly the same TKR and attributes.


0 Kudos
Reply