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

Use of an IMSL function in a FORALL structure

eos_pengwern
Beginner
1,057 Views

Hello,

I have IVF10.1 Professional bundled with IMSL V6.0 and MKL10.0.I'd liketo use one of the IMSL functions (specificially, the version of ASIN that takes complex arguments) within a FORALL structure to initialize a large array.

When I try to compile, I get an error message stating "Any function referenced in a forall-body-stmt must have the PURE attribute explicitly declared [ZASIN]". Fair enough. It's probably safe to assume that the library function meets this criterion, so I go to the top of my module and put in an INTERFACE block, viz.:

include 'link_fnl_static_hpc.h'

use asin_int

implicit none

interface

pure complex(8) function zasin(z)

complex(8), intent(in) :: z

end function zasin

end interface

However, now when I compile I get the error message "The procedure name of the INTERFACE block conflicts with a name in the encompassing scoping unit". This goes away if I comment out "use asin_int", but then the ZASIN function seems no longer to be visible and I get a new warning message saying "This argument's data type is incompatible with this intrinsic procedure; procedure assumed EXTERNAL".

There's obviously a right way to do this. Please could you tell me what it is?

0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,057 Views
I assume that you are actually referencing ASIN in the code? If so, then say:

interface asin

instead of

interface

The way you had it, the compiler thought you were calling the intrinsic asin. which does not accept complex arguments.

However, I would not be quick to assume that the function is pure. Many (if not all) of the IMSL routines have side-effects, in particular, storing an error code for later retrieval. You can probably get away with it, though.

I suppose the way I would approach it is to find module asin_int in numerical_libraries_f90.f90 in the IMSL include folder, copy it into my own source file and call it something like my_asin_int. Edit it to add PURE and then USE MY_ASIN_INT.
0 Kudos
eos_pengwern
Beginner
1,057 Views

Yes indeed, "interface asin" works nicely.

In my installation I can't find any .f90 files in the "include" directory, just precompiled .mod files. If I get problems because the function isn't in fact pure I guess I'll just have to replace the FORALL block with a regular DO loop, but I'm loth to do that as it's a pretty intensive piece of code...

Thank you for your help.

0 Kudos
TimP
Honored Contributor III
1,057 Views
In spite of all the hoops you must jump through, forall doesn't have much advantage over do..end do.
0 Kudos
Steven_L_Intel1
Employee
1,057 Views
The ..f90 files are there - but there's just a few of them and hundreds of .mod files.

FORALL is not a loop construct and isn't necessarily going to get you better performance.
0 Kudos
junziyang
Beginner
1,057 Views
I assume that you are actually referencing ASIN in the code? If so, then say:

interface asin

instead of

interface

The way you had it, the compiler thought you were calling the intrinsic asin. which does not accept complex arguments.

However, I would not be quick to assume that the function is pure. Many (if not all) of the IMSL routines have side-effects, in particular, storing an error code for later retrieval. You can probably get away with it, though.

I suppose the way I would approach it is to find module asin_int in numerical_libraries_f90.f90 in the IMSL include folder, copy it into my own source file and call it something like my_asin_int. Edit it to add PURE and then USE MY_ASIN_INT.

Iused the IMSL routine NEQBF in my code like the following:

subroutine myfun

USE NEQBF_INT

.......

CALL DNEQBF(RATEEQN,X,XGUESS=XGUESS)

........

end subroutine

However, the compiler issues the following error message:

Error: Keyword arguments are invalid without an explicit interface.

According to the code innumerical_libraries_f90.f90 file, DNEQBF's interface is in NEQBF_INT. Then why I got this error message?

Do I have to copy its interface into my code?

0 Kudos
Steven_L_Intel1
Employee
1,057 Views

DNEQBF is a "Fortran 77" interface. You want to call NEQBF instead.

Note - this issue is not related to the rest of this thread.

0 Kudos
junziyang
Beginner
1,057 Views

DNEQBF is a "Fortran 77" interface. You want to call NEQBF instead.

Note - this issue is not related to the rest of this thread.

Thank you very much!

After change DNEQBF to NEQBF, the problem is solved.

It seems that the DOUBLEPRECISION routines for "Root of a System of Equations" are all with"Fortran 77 Interface"!!!

0 Kudos
TimP
Honored Contributor III
1,057 Views
Quoting - junziyang

Thank you very much!

After change DNEQBF to NEQBF, the problem is solved.

It seems that the DOUBLEPRECISION routines for "Root of a System of Equations" are all with"Fortran 77 Interface"!!!

That's one of the features of the Fortran 90 interface. The base name can be used to support automatic selection of single or double precision function. If you want to short circuit that feature, you have to use the Fortran 77 call; you can't do half and half, without a lot of extra implementation, and difficulty with documentation.

0 Kudos
Reply