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

How to force compilation order?

WSinc
New Contributor I
1,563 Views

Suppose I have a large set of routines, and I need them to compile in a certain order.

i.e . when rebuilding a project from scratch.

For example, one might have a set of Modules, and one would like to compile those first,

before compiling the routines that have the corresponding USE statements.

 

Hopefully, the compiler would know: if I am doing to a rebuild of the project,

that those SHOULD be done first. but I don't know if that's really the case.

 

If I make changes to a MODULE, does that force the recompilation of the corresponding

routines that USE it?

 

Another example is routines that call each other. Does it make sense to compile the Called routine first,

if one has made changes to the argument sequence? EX:

----------------------------------------------------------------------------------------------

Subroutine Sub1()

call sub2 (x,y,z)

end

subroutine sub2(p,q,r) !  separate file in the project.

end subroutine

_______________________________________________________

Now if I change the number and type of the arguments in SUB2,

it should compile that BEFORE compiling SUB1. Of course, one should make the appropriate changes to SUB1

first.

0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,563 Views

The compilation order is determined for each build by scanning sources that have changed, looking for MODULE, USE and INCLUDE lines. You don't have any visibility into this process. Yes, if you make ANY changes to a module, even changing a comment, that will trigger recompilation of any source that USEs that module.

In the future, a Fortran 2008 feature called submodules will lessen the pain here, but that is still in the future.

0 Kudos
Adrian_F_
Beginner
1,563 Views

I have this problem now, see my post a few hours ago.  Module A uses module B, yet the build is not building B first, so the compilation of A fails.  Any idea how to get around this?

0 Kudos
FortranFan
Honored Contributor III
1,563 Views

Usually Visual Studio is very good at this - see discussion here.

As described in there, another thing to watch out for is circular dependencies i.e., MODULE A uses MODULE B which uses C which in turn has some dependency on A/B.

0 Kudos
WSinc
New Contributor I
1,563 Views

I guess one obvious way is to put Modules A and B in the same file.

And put module B first.

 

Does Fortran allow one to set up a BATCH list,

where you can compile files in a given order?

 

If you did not have Visual Studio, then you would

pretty much have to use that.

0 Kudos
Steven_L_Intel1
Employee
1,563 Views

You can certainly compile files from the command line in any order you want. If you are seeing incorrect orders in Visual Studio, using a current version of the product (Composer XE 2013 SP1 Update 2), please attach a ZIP of the project and sources (or provide to us via Intel Premier Support) and we'll be glad to investigate. I don't know of any open issues in this area.

0 Kudos
Reply