Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
27427 Discussions

FINAL subroutines work only with the default calling convention in IVF

avinashs
New Contributor I
181 Views

When compiling user-defined data types containing a FINAL subroutine with a calling convention other than default such as /iface:cvf, the build fails with the error

error #5522: FINAL subroutines must be defined with the default calling convention

(a) Is this a Fortran standard requirement or an IVF-imposed restriction?
(b) Is there a workaround other than commenting out FINAL routines for compilation with the /iface:cvf option?

0 Kudos
3 Replies
IanH
Black Belt
181 Views

The Fortran standard has no concept of calling convention (beyond that BIND(C) is required for C interoperable procedures). 

You can specify that the final procedure use default calling convention with `!DEC$ ATTRIBUTES DEFAULT :: name_of_final_procedure` inside the final procedure body.

avinashs
New Contributor I
181 Views

@IanH - Thanks. The suggestion worked perfectly. Using !DEC$ ATTRIBUTES DEFAULT :: mysub allows /iface:cvf to be used for the project without the error above.

One other observation is that the FINAL subroutine is invoked when a variable that is defined in another subroutine (standalone or contained) goes out of scope but not for a variable in a main program when execution ends. I presume the finalization does not cover the termination of the main program itself since the compiler would be automatically "finalizing" in any case.

Steve_Lionel
Black Belt Retired Employee
181 Views

Correct - variables declared in the scope of the main program do not get finalized.

Reply