Author Topic: gfortran, and modules  (Read 10870 times)

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 42
gfortran, and modules
« on: September 03, 2010, 10:38:05 am »
I've just started using Code::Blocks (on Windows 7) and I'm very impressed with it.  I have managed to build a reasonably complex gfortran DLL project, and an executable that links to it.  In the process I encountered a couple of issues with modules, and I'm not sure if there is a way to deal with them in CB.  The first thing I noticed, after loading the 10 or so source files, was that the build command produced errors because it was trying to compile code before the modules used by the code had been compiled.  I manually compiled each file, in the required order, to get the whole project installed.  So my first question is this: is there a way to control the order in which files are compiled?  Later I discovered another couple of things about how CB handles modules.  Modules are not deleted when a "clean" is invoked.  In a way this is fortunate, because if they were removed I'd need to do the manual recompilation sequence after a clean, but it does create a potential problem when "stale" modules are left in the directory.  This created a puzzle for me when I changed the gfortran version, then couldn't get the executable to link to the DLL (after cleaning and rebuilding).  I eventually realized that the .mod files I was using had been built by the previous compiler version, and were in some way incompatible (I was getting "multiple definition" errors on linking).

Can I force CB to remove .mod files on a clean?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: gfortran, and modules
« Reply #1 on: September 03, 2010, 10:45:08 am »
Are this mod files generated by an post build step or normal compiling?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 42
Re: gfortran, and modules
« Reply #2 on: September 03, 2010, 10:51:26 am »
The .mod files (Fortran 90 and later) are generated by the compile.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 796
Re: gfortran, and modules
« Reply #3 on: September 03, 2010, 05:32:19 pm »
Some of the problems you mentioned are quite recurrent on the forum. Did you try a search with keywords : gfortran mod
or even : fortran mod
Among others you'll find this : http://forums.codeblocks.org/index.php/topic,12672.0.html

If you have problem with the order of compilation, set the compilation priority for the .f file which produce .mod file to a lower value than 50 (the default value), and don't use multithread compilations.

Nevertheless, the cleaning process is not solved. May be the solution proposed in the linked post, but I have not tried it.

gd_on
« Last Edit: September 03, 2010, 05:36:52 pm by gd_on »
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 42
Re: gfortran, and modules
« Reply #4 on: September 04, 2010, 09:05:02 am »
All the .f90 files generate .mod files.  I need to control the order of compiling.
...
I have set the different priority levels, as you suggested, and now the build goes without a hitch.

Thanks a lot!

Gib
« Last Edit: September 04, 2010, 09:28:48 am by gib »

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: gfortran, and modules
« Reply #5 on: September 12, 2010, 08:57:31 am »
Try to choose the module file -- build this file only to generate the module.
Regards,
xunxun

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 42
Re: gfortran, and modules
« Reply #6 on: September 12, 2010, 09:46:22 am »
Try to choose the module file -- build this file only to generate the module.

Sorry, I don't understand this message. :(