Author Topic: Trying to compile large 3rd party program using CodeBlocks  (Read 160 times)

Offline awa5114

  • Single posting newcomer
  • *
  • Posts: 3
Trying to compile large 3rd party program using CodeBlocks
« on: November 23, 2017, 06:26:44 pm »

I am new to gfortran and codeblocks. Up until now I was using intel fortran but am becoming slightly fed up with the lack of introspection tools for fortran and would like to see what the GNU variant has to offer.

To get started though, I need to compile this program. It is a nasty, spaghetti conglomerate of files with all combinations of fixed/free extensions (.F, .F90 and .FOR), including open MP and preprocessor directives. The content varies from strict F77 to F90 free form code. The module dependencies are many and complex. However it all boils down to a kernel program which uses all these modules.

I started off by loading all the files (almost 100) into my fortran console project in codeblocks. Then I messed around a bit with the build options to make them accomodate all the variety I have here. What eliminated all my syntax errors (up to now) has been checking ONLY -ffree-form command line parameter, and changing all my .f to .f90 files. I was getting syntax errors with ampersand for these.

Now I have another problem which I have no idea how to solve:

||=== Build: Debug in test (compiler: GNU Fortran Compiler) ===|
D:\\Functions.f90|5|Fatal Error: Can't open module file 'file.mod' for reading at (1): No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|

Which to me signifies that dependencies are not defined correctly or the file.mod file is dumped into a directory which cannot be accessed by the current build.

I also looked into the makefile but it is too long and confusing to make any sense. Anyhow I am stuck. I'd like to compile this program and unlock the functionality that CodeBlocks can provide but I need a little help. Could anyone provide some guidance? Thanks

Offline gd_on

  • Regular
  • ***
  • Posts: 385
Re: Trying to compile large 3rd party program using CodeBlocks
« Reply #1 on: November 23, 2017, 07:20:32 pm »
First : you can try to use directly the makefile in code::blocks. Right clic on the project / properties ... / check "This is a custom makefile" and enter the path of this makefile. I don't know if it's ok for complex makefiles.
Secondly, the error you have is because your file.mod has not been still compiled when you try to compile Functions.f90. A solution is to detect where is the contains of the module generating this file.mod. In the Sources subfolder in C::B, right clic on this file, Properties ..., Build tab and lower the compilation priority at the bottom. For modules, it's a good practice to put a 0 except when there are other dependancies. You force the order of compilations there.
Last, but important : gfortran 5.1 (last official TDM version) has a real big bug : it cannot open a text file to read data (crash when open instruction is executed) !!!! It's better, for gfortan (but also for gcc in that case) to use a previous version like 4.9.2, or the "reckless" work (found in this forum) or an official MinGW version.

Windows 10, svn C::B self generated (last version or almost!), WxWidgets 2.8.12, Compilers TDM 4.9.2 32 bits version (gcc and gfortran installed in C:\MinGW32). Tests with C::B 64 bits and WxWidgets 2.8.12 (64 bits) compiled by TDM 4.9.2 in C:\MinGW64