- Building C::B for Fortran from source files
- Setup of compiler's installation directory (gfortran users)
- How to setup Intel Fortran compiler on Windows
- How to setup Intel Fortran compiler on Linux
- About navigation in Fortran files
- BindTo tool
- MPI in Code::Blocks
- GTK-Fortran with Code::Blocks
- MathGL + GTK + Fortran
- Smart Code-Completion feature
In some cases (for example there is no binaries for your system) you may want to build C::B for Fortran from source files. To do it, I would recommend you first to build official C::B on your system. How to do it, you can find on the C::B wiki site (http://wiki.codeblocks.org). When you have the compiled official C::B running on your system, you can download C::B for Fortran source file archive. Some files in archive have small changes compared to official sources. Unarchive downloaded file and build C::B. You should use your running C::B as is described on Wiki for Windows OS (here). If your OS is not Windows, then use 'CodeBlocks-unix.workspace' or 'CodeBlocks-unix.cbp' and 'ContribPlugins-unix.workspace' and 'update' files instead. Because you have compiled the official C::B, you should have all the required dependencies and the compilation procedure should run without problems. FortranProject plugin comes between other contrib plugins ("<C::B_src_dir>/src/plugins/contrib/FortranProject") and is compiled with other contrib plugins. If not, open 'FortranProject_cbsvn-unix.cbp' C::B project file (if you are on Linux) or 'FortranProject_cbsvn.cbp' (if you are on Windows) and compile it. Run 'update' (or 'update.bat') once more.
Windows users may need to help Code::Blocks to find MinGW and Fortran compiler on their system. Short instruction:
- In Code::Blocks open "Settings -> Compiler..." dialog. Find "GNU GCC Compiler". Open "Toolchain executables" tab. Fill "Compiller's installation directory" text-box (in my case it is C:\MinGW32).
- For gfortran compiler. Find "GNU Fortran Compiler". Open "Toolchain executables" tab. Fill "Compiller's installation directory" text-box (in my case it is C:\MinGW32) and "Program Files" text-boxes. Just remember, that programs on Windows end with ".exe". So your compiler name should end with ".exe" too.
The same procedure is applicable for other compilers/OS.
If you are going to use commercial Intel Fortran compiler on Windows, first you should help C::B to find compiler executable file (Note: I said "compiler", not "debugger". There is no support of the debugger for this compiler on Windows). To do so, in C::B go to Settings->”Compiler and debugger”, select Intel Fortran Compiler for Windows. Go to “Toolchain executables” tab. Here you should fill “Compiler’s installation directory” text field. For example ‘ C:\Program Files\Intel\Compiler\Fortran\11.1\IA32’. "C compiler", "C++ compiler" and "Linker for dynamic libs" text fields should be filled with "ifort.exe". Second problem: environment variables. As is recommended by Intel in documentation, to setup environment variables it is required to execute ‘ifortvars.bat’ file in cmd window. Then you can run C::B from that window. Now you should be able to compile you Fortran files. You can even create ‘somename.bat’ file in C::B installation directory, copy content of ‘ifortvars.bat’ file into ‘somename.bat’ file and add a line with “codeblocks.exe”. Now, when you run ‘somename.bat’ file, C::B will be started with right environment variables.
Note: to be able to run your compiled program from inside of C::B you should install MinGW on your system and setup GCC compiler’s installation directory on Settings->”Compiler”, “Toolchain executables” tab.
More detailed instructions can be found in Setup_Intel_Fortran_onWin.pdf
BindTo (Fortran->Bind To…) automatically generates a wrapping for Fortran code which enables call of Fortran from the C language and can generate Cython files which enables call of Fortran from Python language. Read BindTo Users Guide
If you are using MPI, you can build your code from inside of C::B. You just need to adjust your compiler settings to use "mpif90" compiler (Settings->Compiler).
You may like to have code-completion and call-tips for MPI procedures (it is really useful!). To make it work, you can download a project , and open it in C::B together with your project. It's all.
Screenshots with MPI in C::B:
Gtk+ (www.gtk.org) is a cross-platform toolkit for creating Graphical User Interfaces (GUI). Gtk-fortran enables creation of GUI from Fortran using this toolkit. I tried to build few gtk-fortran examples on Windows 7 64bit. This is my instructions / notes how to use gtk-fortran on Code::Blocks. I hope it will be useful for users of C::B. (read full story on Gtk-Fortran )
The aim is to make code-completion (CC) list shorter. This is achieved by introducing a simple logic. For example, after ‘call’ statement only subroutine names can be appended to the CC list while function names in CC list is added only after symbols “ = ( . , + - / * ” (with some exceptions). In most cases this logic makes its job and the programming with Code::Blocks is even more pleasing. Unfortunately the used filters can be too strict in some cases. As a result some symbols can be not included in CC list. You can always enable/disable Smart CC in FortranProject settings dialog (Settings->Editor->FortranProject).
For Smart CC to work it is required to know which Fortran keywords are intrinsic function names, which are intrinsic subroutine names, and which are other keywords. To make it possible a file fortran_procedures.f90 was created in the FortranProject images directory (directory_with_C::B_executable/share/CodeBlocks/images/fortranproject). This file contains pseudo-interface blocks for standard intrinsic procedures (together with a short description) and list of other keywords, which can be included in CC list. If some keyword is not present in this file, it will be not included in CC list. Mentioned interface blocks for Fortran intrinsic procedures make possible to have intrinsic procedures not only in CC list, but add possibility to have calltips and short descriptions in Fortran info window for intrinsic procedures.