- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I have the following code which will crash when compiled without /warn:interfaces option, but no any problem if have the /warn:interfaces option. Is there any bug of IVF compiler, or any problem in my code? How should I modify the code to let the pointer to be passed to a subroutine?
Thanks,
Zhanghong Tang
I have the following code which will crash when compiled without /warn:interfaces option, but no any problem if have the /warn:interfaces option. Is there any bug of IVF compiler, or any problem in my code? How should I modify the code to let the pointer to be passed to a subroutine?
Thanks,
Zhanghong Tang
[bash]! test_mp.f90 ! ! FUNCTIONS: ! test_mp - Entry point of console application. ! !**************************************************************************** ! ! PROGRAM: test_mp ! ! PURPOSE: Entry point for the console application. ! !**************************************************************************** module element type pointp integer,pointer::p = > null() endtype endmodule program test_mp use element implicit none ! Variables type(pointp),pointer::pp allocate(pp) ! read model size and resistivity parameter call testpp(pp) ! Body of test_mp print *, 'Hello World' end program test_mp subroutine testpp(pp) use element implicit none type(pointp),pointer::pp if(associated(pp%p))then write(*,*)1 endif end subroutine [/bash]
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is your program that has the bug. Which compiler version are you using? When I compile with /warn:interfaces, I get this:
t.f90(17): warning #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source. [PP]
call testpp(pp)
----------------^
As the error says, you are calling a procedure that has a dummy argument (PP) with the POINTER attribute. This requires that an explicit interface be visible to the caller, and you do not. If you put testpp in module element, that would be sufficient. Or testpp could be a CONTAINed routine of the main program.
t.f90(17): warning #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source. [PP]
call testpp(pp)
----------------^
As the error says, you are calling a procedure that has a dummy argument (PP) with the POINTER attribute. This requires that an explicit interface be visible to the caller, and you do not. If you put testpp in module element, that would be sufficient. Or testpp could be a CONTAINed routine of the main program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Dr. Steve,
Thank you very much for your kindly reply. I also noticed this warning, and also noticed that if I put the subroutine inside the module, everything is OK. But I don't understand that if the argument has some other attributes such as integer, there is no any problem. So I think that it's better to take ALL types of argument the same: require explicit interface or not.
Thanks,
Zhanghong Tang
Thank you very much for your kindly reply. I also noticed this warning, and also noticed that if I put the subroutine inside the module, everything is OK. But I don't understand that if the argument has some other attributes such as integer, there is no any problem. So I think that it's better to take ALL types of argument the same: require explicit interface or not.
Thanks,
Zhanghong Tang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are some attributes that require that the compiler know about the attribute when compiling the call. For example, OPTIONAL, or POINTER, or ALLOCATABLE or if the argument is deferred-shape. There are other attributes, such as INTEGER, that the compiler doesn't need to know.
I wrote about this many years ago in Doctor Fortran Gets Explicit. Since I wrote that, the set of cases where an explicit interface is required has grown (for example, if a dummy argument is a coarray).
That said, it is good Fortran programming practice to have an explicit interface visible for all procedures you call, so if you put all the routines in a module, that takes care of it and eliminates a large class of problems you may see when running the program.
By the way, I am not a "real doctor" - I just pretend to be one on the web.
I wrote about this many years ago in Doctor Fortran Gets Explicit. Since I wrote that, the set of cases where an explicit interface is required has grown (for example, if a dummy argument is a coarray).
That said, it is good Fortran programming practice to have an explicit interface visible for all procedures you call, so if you put all the routines in a module, that takes care of it and eliminates a large class of problems you may see when running the program.
By the way, I am not a "real doctor" - I just pretend to be one on the web.

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