Author Topic: Plugin for Fortran  (Read 23442 times)

Offline darmar

  • Multiple posting newcomer
  • *
  • Posts: 68
Plugin for Fortran
« on: August 18, 2009, 09:49:31 am »
Hello

I would like to make Code::Blocks more usable for Fortran language. I have started to develop FortranProject plugin. This plugin adds code browser for Fortran. Most of code was simply taken from CodeCompletion plugin and very simplified and adapted for Fortran. I tested it on Windows and Linux.
It would be nice if somebody tried this plugin and wrote his opinion or suggestions about it.

Now I am thinking about the compilation of Fortran files. It is easy to add some fortran compiler in CB as is described in http://wiki.codeblocks.org/index.php?title=Installing_Fortran_Compiler. And with Fortran77 it works. But in Fortran90, if modules are used, files depends on each other. As a result, files have to be compiled in particular order and the change in one file should force recompilation another one.

What can I do to solve this problem in CB?

Thanks for your opinion and suggestions.

[attachment deleted by admin]

ffmo

  • Guest
Re: Plugin for Fortran
« Reply #1 on: September 08, 2009, 05:33:21 am »
Hi,

Thanks for sharing your plugin.

As to the compilation problem, you can try to give the module source higher priority in the 'Build' tab of the 'Propertity' dialog.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Plugin for Fortran
« Reply #2 on: September 08, 2009, 06:27:11 am »
What can I do to solve this problem in CB?
In terms of a "module" I would suggest you create special targets for the modules actually being static libraries and then link everything together. This also allows you sharing of the modules without hassle. However - as ffmo said: The compilation priority would be another (good) choice.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline darmar

  • Multiple posting newcomer
  • *
  • Posts: 68
Re: Plugin for Fortran
« Reply #3 on: September 08, 2009, 07:44:44 pm »
Thank you ffmo and MortenMacFly for your suggestions.
Now I think, that the plugin could follow these steps:
1) After parsing of files, the plugin should collect information about file dependencies using parsed information (I have started to work with it).
2) Sets file weights in order to compile in right order.
3) Two possibilities: a) Removes object files (*.o) of dependent files if the parsed file was changed. In this way the dependent files will be forced to recompile. b) Second possibility (may be) is to write some script which is run in the pre-compilation step. But this script should somehow access information from the plugin, and I don't know if it is possible.

What is your opinion?

Thank you in advance.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Plugin for Fortran
« Reply #4 on: September 16, 2009, 01:47:07 pm »
3) Two possibilities: a) Removes object files (*.o) of dependent files if the parsed file was changed. In this way the dependent files will be forced to recompile. b) Second possibility (may be) is to write some script which is run in the pre-compilation step. But this script should somehow access information from the plugin, and I don't know if it is possible.
Can't you manage all that just with dependencies as it's done in C/C++, too? I mean: If you setup the module as external dependency through the project's (targets) option, then if the module has changed the main project will automatically be re-linked, re-compiled (if needed).

Can you provide a sample so that I can better understand?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline darmar

  • Multiple posting newcomer
  • *
  • Posts: 68
Re: Plugin for Fortran
« Reply #5 on: September 18, 2009, 02:44:49 pm »
Thank you Morten for your reply.

Can't you manage all that just with dependencies as it's done in C/C++, too? I mean: If you setup the module as external dependency through the project's (targets) option, then if the module has changed the main project will automatically be re-linked, re-compiled (if needed).

Yes, I think, I could solve dependency problems by using targets. This solution will ensure right order of compilation and that all dependent files is updated. But I am unsure if it is best solution from user's point of view, because instead of, say, two targets (debug, release) he will see additional, say, 20 (depending on how many files with modules are) automatically generated targets. And I am unsure if I could manage to make up-to-date these targets when the user change something.

Can you provide a sample so that I can better understand?

I don't know what kind of sample do you like? Code sample? I will try to explain how Fortran'90 works.
For example, we have two files in a project: one file with main function a_main.f90 and second file b_file.f90. In second file b_file.f90 is declared module b_file_module. a_main.f90 uses this module. When compiler is asked to compile b_file.f90, it generates not only b_file.o file, but additionally b_file_module.mod file. This *.mod file is like *.h file in c++. If we change something in b_file.f90, then b_file.f90 will be re-compiled and new b_file_module.mod file will be generated. Because a_main.f90 uses this mod file, a_main.f90 has to be recompiled too.



« Last Edit: September 27, 2009, 07:26:54 am by darmar »

Offline darmar

  • Multiple posting newcomer
  • *
  • Posts: 68
Re: Plugin for Fortran
« Reply #6 on: October 21, 2009, 04:39:46 pm »
Hello

I have made new version of FortranProject plugin. Now, besides code browser for Fortran, the plugin manages file dependencies when modules are used, and enables the compilation of Fortran files in right sequence (file weights are used for it).

[attachment deleted by admin]

Offline darmar

  • Multiple posting newcomer
  • *
  • Posts: 68
Re: Plugin for Fortran
« Reply #7 on: January 22, 2010, 06:09:33 pm »
Hello
I have updated FortranProject plugin. In this version I added code-completion (for names of function/subroutines only) and call-tips for Fortran files.
As was suggested by MortenMacFly (forums.codeblocks.org/index.php/topic,11119.0.html) I set my web page where you can download pre-compiled binaries: darmar.vgtu.lt

By the way I would like to write about the problems I met by developing  FP plugin:
1) Code-Completion plugin tries to parse every file in a project regardless of which programming language the file is. It shows code-completion list even for Fortran files. This behaviour prevents FP plugin to show own code-completion list.
2) By default the key combination Ctrl+Space is used to show code-completion list with CC plugin. I haven't found a way how can I use the same key combination for FP plugin. I think it is inconvenient for user to have different key combinations for every different programming language he use.

As a consequence in FP plugin I made so, that the user should disable CC plugin if he wants to use code completion for Fortran files. I have read the proposal on C::B wiki to split CC plugin (wiki.codeblocks.org/index.php?title=Code::Completion_Rewrite). I think it would solve my mentioned problems, but I do not know how far the C::B team with it is.


[attachment deleted by admin]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for Fortran
« Reply #8 on: January 22, 2010, 07:01:19 pm »
Hi darmar.

Nice to see someone doing this. Thankyou.

By the way I would like to write about the problems I met by developing  FP plugin:
1) Code-Completion plugin tries to parse every file in a project regardless of which programming language the file is. It shows code-completion list even for Fortran files. This behaviour prevents FP plugin to show own code-completion list.
2) By default the key combination Ctrl+Space is used to show code-completion list with CC plugin. I haven't found a way how can I use the same key combination for FP plugin. I think it is inconvenient for user to have different key combinations for every different programming language he use.

I think we can make the CC plugin a bit more accomodative by using mimetype/syntax checks to disable its functionality for unsupported languages (presumably we do this for plain text files?). Better yet would be restructuring the CC plugin to allow people to more easily build onto it for different languages, but that is a much bigger job.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Plugin for Fortran
« Reply #9 on: January 22, 2010, 07:34:29 pm »
I think we can make the CC plugin a bit more accomodative by using mimetype/syntax checks
That's not so easy as you might think. What about libs like iostream? They have no extension and can be any language (e.g. C++ or D...). How to differ?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Plugin for Fortran
« Reply #10 on: January 22, 2010, 09:44:33 pm »
I think we can make the CC plugin a bit more accomodative by using mimetype/syntax checks
That's not so easy as you might think. What about libs like iostream? They have no extension and can be any language (e.g. C++ or D...). How to differ?

good point. Perhaps we could allow users/plugins to add a "no-cc" attribute to files in a project?