- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
===============================================
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page