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 have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

gen-interfaces hook

jimdempseyatthecove
Honored Contributor III
862 Views

Steve,

I have a rather unusual request. IVF has /gen-interfaces which creates interface modules. What I wish to do is to insert a build procedure between the gen-interfaces pass and the compile pass. Essentualy the procedure is a language extension and having the interface files would be handy (and eliminate redundant effort). I thought about changing FPP, however I think that runs prior to the gen-interfaces pass. The pre-build procedure could be run first, however then the programmer would have to make several compilation attempts (getting errors) while making it through the gen-interfaces.

Essentially what I am trying to do is to insert something similar to the C++ template capability into (onto) IVFto be used to automaticallycreate generic interface declarations.

Jim Dempsey

0 Kudos
6 Replies
Steven_L_Intel1
Employee
862 Views

The compiler does not actually "compile" the source you see - it creates the modules internally. The .f90 sources are there for your convenience. I don't fully understand what you want to do, but I don't think trying to hook into generated interfaces is the right approach.

0 Kudos
jimdempseyatthecove
Honored Contributor III
862 Views

The compiler does not actually "compile" the source you see - it creates the modules internally. The .f90 sources are there for your convenience. I don't fully understand what you want to do, but I don't think trying to hook into generated interfaces is the right approach.


Steve,

What I want to do is to use /gen-interfaces to have IVF generate the .f90 source of the module containing the interface declarations (wether they are used or not by the compiler I do not care). Then after these files are created, I want to insert a pre-compilation process that examines the user's source files for the language extension statements that I am adding. These language extension statements use generic interface declarations. I wish to auto-generate these generic interface declarations for the permutations of the arguments used. Once these generic interfaces are declared (new .f90 source for module), I want to recompile the interfaces module and then USE that within the application.

Without the hook, the user would run a compilation generating oodles of error messages for missing generic interface declarations. However in the process the (or some of the) .f90 interface files would have been created. On the next pass the pre-build process would incorporate the appropriate interfaces into the generic interfaces, then compile, generating a lesser number of oodles of error messages, the user would repeat this until all interface declaration files were created.

I do not want the programmer to suffer that abuse. Therefore, I would prefer to generate all the interface files (.f90) then have the compiler signal somehow that it is complete with that phase (or simply not formaly compile to output). With a signal (hook) I could then build the generic interface blocks, compile that, then resume with the main project compilation (with the new USE interfaces.mod file available).

Lacking a hook, is there a way to abort the compilation after all the interface file(s) are generated? (i.e. make it a two step process when interfaces change)

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
862 Views

It seems to me that what you really want is what I call "auto-include". This is something our C++ compiler has. It causes a named source file to be automatically included in each program unit in the location that a USE would be valid. So you could do your preprocessing, generate a module with all the interfaces, and then have that module automatically used by the compilation. Would that work? We have an active feature request for this.

0 Kudos
jimdempseyatthecove
Honored Contributor III
862 Views

It seems to me that what you really want is what I call "auto-include". This is something our C++ compiler has. It causes a named source file to be automatically included in each program unit in the location that a USE would be valid. So you could do your preprocessing, generate a module with all the interfaces, and then have that module automatically used by the compilation. Would that work? We have an active feature request for this.

Close, but no cigar.

Recall from my prior posts that my interest is for use in insertion into a generic interface block. What the add-on process needs to do is:

a)identifya statement that calls a generic name for afunction/subroutine (these statements are marke some how TBD). This interface contains a functor (C++ term to indicate function address), the functor is followed by the arguments that define the signature for the subroutine/function referenced by the functor. The functor and arguments together are arguments for a higher level subroutine/function (that may also contain additional arguments not related to the functor).

b) Using the name of the functor, consult the gen-interface .f90 file to get the argument declarations (template of arguments) use by the function specified with the functor. If file not there error out (user forgot /gen-interfaces)

c) Using the templates of arguments, consult the file under construction containing the list ofgeneric interfaces for the generic interface indentified in the original source file. If, within the generic interface, theargument template is found, do nothing (already have argument template), When argument template not found, generate arbitrary name (name mangled on argument template) based on argument list and adda specificly named routine using generic name. This name is ALIAS'd to point back at a common messaging routine.

After above process iterates over all files that caused a new gen-interfaces genn'ed .f90 interface file

d) compile the generic interfaces file into a .mod file

e) build project (some files using the updated generic interfaces file). If errors occure on the lines containing the calls to the generic interface, then the user has an argument specification error. (too many, too few, incorrect,...)

Just a tad different froma simple include.

If you have a good C++ programmer nearby, mention to him/her that I am trying to add templates to generic interfaces, then see what they have to say about it. By doing this (if I can do this) a whole bunch of mindless repetitive coding goes away.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
862 Views

Interesting. Well, I'm pretty sure that such a "hook" is not going to happen - it would require significant changes in the way generated interface processing is done. I suppose you could do a build with /gen-interface and not /warn:interface to generate the files. Seems like a lot of work to turn Fortran into something else, though.

Maybe when we have more of F2003 OO stuff done you might make use of that.

0 Kudos
jimdempseyatthecove
Honored Contributor III
862 Views


I suppose

/gen-interfaces /warn:nointerface

For pass 1, then assume potential for interface problems, fixup generic interfaces if necessary, and for pass 2

/warn:interface

A bit of a hack

May have to put that on mySanta wish list.

Jim Dempsey

0 Kudos
Reply