Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
2 Views

FINAL subroutines work only with the default calling convention in IVF

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
Highlighted
Black Belt
2 Views

The Fortran standard has no

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.

0 Kudos
Highlighted
New Contributor I
2 Views

@IanH - Thanks. The

@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.

0 Kudos
Highlighted
Black Belt
2 Views

Correct - variables declared

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

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos