specifying compilation order

specifying compilation order

Hello All,

How can I specify file-level, compilation order?

I'm presently placing modules in files where they don't naturally belong (e.g., matrix module in a file of statistics modules) to avoid compilation errors because they are being USEd before they would otherwise have been compiled. It seems compilation order is alphabetical by file name when I perform a project build.

I'm almost tempted to place all modules in a single file and order them to facilitate compilation.

I'm using Visual Fortran Compiler XE and Microsoft Visual Studio 2008.


-- jv

P.S. Apologies for this off-topic post. My Knowledge Base and web searches provided no helpful information.

10 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

simply put your modules, as separate files, in the resource Files section of your project/solution and voila! they will be compiled 1st before the subroutines.

Well, no, that won't make a difference.

Unless you have errors in your code, such as a circular module dependency, the order should be correct automatically. If it isn't, we'd like to see a ZIP of the project where it is a problem.

For best results, put each module in a separate source file. And your post is definitely not off-topic!

Retired 12/31/2016

Thanks for the replies.

I do not believe I have circular dependencies, but I should check that again.

Presently, I have multiple modules in all files.

Should I place each module in a separate file and perform a clean build to see if the problem persists and prior to posting my solution files? I am a little confused by the "for best results, ..." suggestion.


-- jv

My suggestion was just to eliminate possible problems by poor ordering within a source file. It is not a requirement.

You might also try removing all the sources from the project and then readding. This probably has no effect, but it's easy to try.

Retired 12/31/2016

I was having this problem myself a few days ago and was searching through all of the Visual Studio & Intel Fortran documentation for a solution, but to no avail. I decided to scan the web and eventually came upon this post and your suggestion. I removed everything from the project and re-added them, and all of asudden everything worked! Obviously there is adependency analysisdone during this process, but it's curious how it got confused in the first place. It would be nice if Studio would allow a user to "force" thisprocess (Visual Studio 2005, 8.0; Intel Fortran 10.1.011). Thanks.

Oh, you're using Fortran 10.0. We significantly improved the dependency checking in version 11. Please update to a newer version. The current version is 12 (aka Intel Visual Fortran Composer XE 2011).

Retired 12/31/2016

Hello, I think I found a very small bug and I think this is the best place to put it. when specifiying wich modules a module should you as such:

module main

    use sub_modA

    use sub_modB


if you do this the build order gets messed up:

module main

    use sub_modA !personal_comment

    use sub_modB!personal_comment


The comment next to sub_modB messes things up unlike the one that has next to sub_modA which has a space before the comment. Took me forever to figure out this was what was happening. Anyway thought your development team should know so they could address the issure.

Thanks - I'll put together a test case and let the developers know.

Retired 12/31/2016

GTA, I can't reproduce this. Which compiler version are you using?

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today