Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Annonces
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.
29285 Discussions

Internal procedure as actual argument (error)

Ferdinand_T_
Nouveau contributeur II
1 722 Visites

Dear readers, I am seeking you for advice on passing internal procedures as actual arguments, which is a fortran 2008 feature supported by ifort 15.0. The following module does not compile in ifort 15.0, because

error #7069: The characteristics of the associated actual function result
 differ from the characteristics of the dummy function result.   [NESTED]
		call with_dummy_function(nested)
-----------------------------------------^
compilation aborted for test.f90 (code 1)

Here is the code:

module m
	implicit none

	abstract interface
		function dummy_function()
			logical :: dummy_function
		end function
	end interface

contains

	subroutine host()
		call with_dummy_function(nested)
	contains
		function nested()
			logical :: nested
			nested = .true.
		end function
	end subroutine

	subroutine with_dummy_function(func)
		procedure(dummy_function), pointer, intent(in) :: func
	end subroutine
end module 

While I managed to compile and run the same code with ifort 14 (service packs .3 and .4 ), any tips on how to get this feature to work with ifort 15.0 are appreciated!

Best regards

Ferdinand

0 Compliments
1 Solution
Steven_L_Intel1
Employé
1 722 Visites

Escalated as issue DPD200370165. A workaround is to create a procedure pointer, assign the pointer to the internal procedure and pass the pointer. As a note of information, you should be using "abstract interface" for dummy_function.

Voir la solution dans l'envoi d'origine

0 Compliments
6 Réponses
Steven_L_Intel1
Employé
1 722 Visites

The issue here is that you are passing an internal procedure to a procedure pointer. If the argument to with_dummy_function was just a procedure, not a procedure pointer, it works.  I had at first thought that it was not allowable to use an internal procedure in this context, but on research I find that it is. I will escalate this to the developers.

0 Compliments
Steven_L_Intel1
Employé
1 723 Visites

Escalated as issue DPD200370165. A workaround is to create a procedure pointer, assign the pointer to the internal procedure and pass the pointer. As a note of information, you should be using "abstract interface" for dummy_function.

0 Compliments
Ferdinand_T_
Nouveau contributeur II
1 722 Visites

Thank you, Steve, for the prompt reply.

Indeed, dropping the pointer attribute

    subroutine with_dummy_function(func)
        !procedure(dummy_function), pointer, intent(in) :: func
        procedure(dummy_function) :: func
    end subroutine

does work fine.

 

 

0 Compliments
Ferdinand_T_
Nouveau contributeur II
1 722 Visites

Steve Lionel (Intel) wrote:

Escalated as issue DPD200370165. A workaround is to create a procedure pointer, assign the pointer to the internal procedure and pass the pointer. As a note of information, you should be using "abstract interface" for dummy_function.

Thank you for the hint, I edited my code. I never fully understood where to use abstract - and where to use "normal" - interfaces. Probably I should always go with "abstract" in f2k code unless something breaks... 

I implemented the workaround you suggested and it works well!

	subroutine host()
		procedure(dummy_function), pointer :: nested_ptr
		nested_ptr => nested
		call with_dummy_function(nested_ptr)
	contains
		function nested()
			logical :: nested
			nested = .true.
		end function
	end subroutine

	subroutine with_dummy_function(func)
		procedure(dummy_function), pointer, intent(in) :: func
	end subroutine

Best regards

Ferdinand

0 Compliments
Steven_L_Intel1
Employé
1 722 Visites

It's really simple - if you don't use "abstract", you are declaring an external procedure which is assumed to exist. With "abstract", you're just defining the interface.

0 Compliments
Steven_L_Intel1
Employé
1 722 Visites

I expect the problem to be fixed in Update 1 to Parallel Studio XE 2017. If it doesn't make that, then Update 2.

0 Compliments
Répondre