Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Line continuation followed by blank line in Fortran

I have a main program and a module. I want the main program to use certain parts of the module under normal circumstances, but to use some added elements if compiled with a "DEBUG" cpp macro. This is the way I have found to make this work:

    program myprogram
    
    use comp_module, only: data1, routine1 &
    #idef DEBUG
                           , debug_data, debug routine
    #endif
    ;
    ....

If I don’t put that semicolon in at the end, the compiler thinks it’s an error when not compiled for debugging. So, this works. It’s just that it looks sort of inelegant. A leading comma in the debug line and a useless semicolon following. And I can just see some developer coming along later, not getting what’s going on, and introducing hos own compiler error. Anyone have a better way?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In this case you can just use two separate use declarations

use comp_module, only: data1, routine1
#idef DEBUG
   use comp_module, only: debug_data, debug routine
#endif
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading