- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By default the Fortran VS integration creates a source fold ( the little + or – sign on the left margin) at each subroutine or function declaration that you click to collapse or expand the visibility of that section. I like this feature as with one shortcut keystroke you can collapse “all” and then just browse/see the list of subroutines and expand the one you want to look at. Yes the are other ways to speed browse but I like this one.
The only ‘problem’ is that it gets rather spoiled by anything in the file that is not in a subroutine so I never put comments outside a subroutine other than we often have a large block of declarations, comments etc at the top of modules that might span several pages.
I would this like a way of creating a fold but I have this far looked and failed. In C++ we can have
#pragma region name
#pragma endregion comment
Is there any way of manually creating a fold in Fortran?
Would it be nice to add a !DEC$ that did something like the #PRAGMA region? That way a user can do whatever takes there fancy in "sectionising" the code.
Help/comments please.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see no reason why the folding could not simply fold at multiple contiguous comment lines. And should you desire to fold part of the multi-line comments, then simply insert a blank line. I do not favor using a !DEC$ for this purpose. As far as naming the section/region, I suggest having this as the first line of a multi-line comment. Facilitating "folding" in this manner places no burden on the language.
Edit: or use something like:
[-]!YourTagHere! More comment here
! More comment here
! More comment here
! More comment here
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see what you are saying Jim, in general I agree in that I don’t like compiler directives where they are used instead of using standard and thus portable language syntax, the behaviour of code should be clear from the code and the Fortran standard wherever it is possible and not reliant on understanding the behaviour of a compiler that may have been obsolete by many years at the time some guys is having to work with the code. But is this case it is not a language feature it is only a style feature to be interpreted in VS. A couple of additional points:
1] Intel Fortran folds as currently implemented on a minimalistic way, other languages have folds at all ‘block’ structures such as (the equivalent of) if>else>endif or do>enddo and many others. Whilst that might be nice that would be a big and fundamental change that might be loved by some and hated by others.
2] Multiple comments would not cover cases such as large blocks if declarations and data initialisations in a module header but would insert them automatically in lots of places.
The feature has suggested has no impact on the code as far as other systems are concerned as !DEC$ is based within a comment. A user can chose to have are have not at will and an in a style or manner of his own choosing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The directive you are asking for are not for use by the compiler. Rather they are intended for use by an IDE/editor. What you are asking for has been implemented in the past (decades ago) by placing defined tokens within the comments. These used to be used by a document-processor to generate a table of contents as well as an index for the source listing.
See: https://stackoverflow.com/questions/9586478/ide-comment-keywords
An alternative is to permit the character following the comment indicator (!) to provide a hint to the editor as to what you want it to do. Currently !$... is a compiler directive, but ! followed by character of your choice could be configured for use by the editor. In this manner, these directives will be workable regardless as to if you use IVF, gFortran, or any of the other Fortran compilers (which do not support !DIR$ ...).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
andrew_4619 wrote:..
I would this like a way of creating a fold but I have this far looked and failed. In C++ we can have
#pragma region name
#pragma endregion commentIs there any way of manually creating a fold in Fortran?
Would it be nice to add a !DEC$ that did something like the #PRAGMA region? That way a user can do whatever takes there fancy in "sectionising" the code.
Help/comments please.
Andrew,
Note Microsoft's term for what you're looking for is "outlining" See this page on Microsoft Docs: https://docs.microsoft.com/en-us/visualstudio/extensibility/walkthrough-outlining?view=vs-2019 which has an example on how to outline even a text file with opening and closing brackets.
My suggestion will be to try it yourself using Microsoft's instructions such as in the link above or get a developer to do it for you as in hire/entice someone (teenager!?) to put together an app extension for VS that works with Fortran or make a request with Intel at the OSC.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the Input FF I had looked at that previously, the main problem is that the Intel Fortran VS integrations are not open to user change and it seems like a lot of work (which I bet would break/need more work in each new release). All I am suggesting is a simple workability improvement In the Intel Fortran integrations which is adding a new "!xyz" token pair to the list which it seems to be currently "subroutine"/"end subroutine" , "Function"/"end function", "interface"/"end interface".
The windows Fortran is branded "Visual Fortran" so it would seem to be that feature to help working in the "Visual" part are entirely in order.
I will file a request with Intel at the OSC.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page