Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Source Outlining in Visual Studio.

andrew_4619
Honored Contributor III
3,937 Views

I find the Outlining feature in Visual Studio very useful, with all the sections collapsed it is very fast to page/scroll up and down file and just have a small number of routines that are of current interested expanded.

Sometimes I find inserting lines causes all the sections to expand or sometimes all section above the current point to expand. It this normal behaviour and is there anything way of avoiding this?

Secondly, I often have modules with quite a large declarations/comments section and then a lot of contained procedures. It would be helpful if the zone from after the module statements up to the contains statement where defined as an outline block. I guess that would be a change to the VS integrations for Fortran? Alternatively (I have made a search and failed to find an answer) is there a way of adding outlining start/end ‘tokens’ to the source. If there is how? If not perhaps a global solution might be a comment that is interpreted by outlining. For example the source comments  ! <outlining-block-start>   and ! <outlining-block-end> could define a region as matched pairs, that would give a lot of possibilities.

Best Regards
Andrew

0 Kudos
11 Replies
Steven_L_Intel1
Employee
3,937 Views

It would be helpful if you could provide sample source files that demonstrate the first problem, though I think a similar one has been previously reported to the developers.

There is no ability to add outlining syntax of your own. Your proposal is interesting but is a bit different from the current feature,

0 Kudos
andrew_4619
Honored Contributor III
3,937 Views

I don't think any special source file is needed, it seems to do wrong with any source file (please note that I only use free form) and is the same in VS2010 and VS2013.

If you look at the screen grab with all subroutines collapsed ( <CTRL> MO) and then put the cursor to the end of any line and hit return to insert a line all the routines that are in view will expand. The 'in view' i.e. what you can see on the screen seems relevant BTW as outside this zone they are unexpanded usually.

Similarly if you expand any single routine  click into it and hit return to insert a line a similar thing will happen. The point at which you were about to write can now be many hundreds of lines off screen.

 

 

   outlining.GIF

0 Kudos
FortranFan
Honored Contributor III
3,937 Views

app4619 wrote:

..

Secondly, I often have modules with quite a large declarations/comments section and then a lot of contained procedures. It would be helpful if the zone from after the module statements up to the contains statement where defined as an outline block. I guess that would be a change to the VS integrations for Fortran? Alternatively (I have made a search and failed to find an answer) is there a way of adding outlining start/end ‘tokens’ to the source. If there is how? If not perhaps a global solution might be a comment that is interpreted by outlining. For example the source comments  ! <outlining-block-start>   and ! <outlining-block-end> could define a region as matched pairs, that would give a lot of possibilities.

Best Regards
Andrew

Good point by Andrew about Fortranners needing better code folding options.  it will be very nice if Intel can offer a solution here for its Fortran users.  The points to keep in mind:

  1. Microsoft states and many 3rd party vendors and even casual developers attest (with their actions) Visual Studio can be easily extended and customized,
  2. C/C++ users have #pragma region and #pragma endregion and Microsoft offers #region .. #endregion for .NET users for code folding, and
  3. I feel extremely strongly that Intel Fortran team must completely embrace the goal espoused by Lahey Fortran (http://www.lahey.com/lf76/lf76.htm#VS), "Our attitude is that the Fortran programmer deserves all the features and conveniences that the C# or Visual Basic programmer enjoys." and follow through totally on such a goal; current VS integration falls short by quite a margin in my opinion.

Hey, how about !DEC$ REGION and !DEC$ END REGION as a possible option!? or something along these lines?

0 Kudos
Scott_L_
New Contributor I
3,937 Views

 

Would the fortran 2008 block     ..   end block  accomplkish this?

Syntax

[name:] BLOCK

   [specification-part]

   block

END BLOCK [name]

 

0 Kudos
andrew_4619
Honored Contributor III
3,937 Views

Scott L. wrote:
Would the fortran 2008 block     ..   end block  accomplkish this?

Thanks for the input, an interesting thought but:

1) Inlining does not appear to be implemented for Block (I just made a test)  - @intel perhaps it should be?

2) I think some care is needed here as adding block constructs could change the function of the code by changing scope of variables 

0 Kudos
FortranFan
Honored Contributor III
3,937 Views

Scott L. wrote:

 

Would the fortran 2008 block     ..   end block  accomplkish this?

Syntax

[name:] BLOCK

   [specification-part]

   block

END BLOCK [name]

 

The issue is the scope of BLOCK construct: from a code folding (outlining) point-of-view, it's far more restrictive compared to what's possible with #pragma region for C/C++ users or #region (#Region) for C# .NET (and Visual Basic .NET) users.  Using the latter, a C/C++ or .NET coder has considerable flexibility to outline almost any section of code within a file which may span multiple procedures, etc.  I feel Fortranners deserve an option along these lines.

0 Kudos
jimdempseyatthecove
Honored Contributor III
3,937 Views

I haven't tried this as I haven't installed VS 2013 (yet). Perhaps app4619 can run the test.

Enable Fortran PreProcessor

#pragma region
...
#pragma endregion

FPP might balk or warn at #pragma (and possibly strip it too)

VS Fortran Integration might not enable #pragma (check the editor options)

Alternate test:

If the editor options include a checkbox for #pragma region, then without FPP try

! #pragma region
...
! #pragma endregion

Jim Dempsey

 

0 Kudos
andrew_4619
Honored Contributor III
3,937 Views

jimdempseyatthecove wrote:

#pragma region

#pragma endregion

VS Fortran Integration might not enable #pragma (check the editor options)

Jim Dempsey

Those don't seem to be recognised by the inlining (folding) tool. Reading some MS tech document the folding has a sort of api which a vendor (i.e. Intel in this case) can implement as a DLL for specific file types.  Looking at how it seems to work adding and extra keyword pair might not be such a big trip for Intel. I can see a current issue that the current Fortran folding ignores all the comes after a ! character but that isn't a show  stopper and the #pragma syntax does not fall foul of that. Syntax that is behind a ! is preferred though as it is compiler neutral/portable/has no side effects. 

0 Kudos
andrew_4619
Honored Contributor III
3,937 Views
! inlined
module
end module
type
end type
function
end function
subroutine
end subroutine
interface
end interface

! not inlined but logically should be?
if
end if
do
end do
block
end block

But a general user specified folding zone would be ideal.

0 Kudos
FortranFan
Honored Contributor III
3,937 Views

app4619 wrote:

.. Reading some MS tech document the folding has a sort of api which a vendor (i.e. Intel in this case) can implement as a DLL for specific file types.  Looking at how it seems to work adding and extra keyword pair might not be such a big trip for Intel. I can see a current issue that the current Fortran folding ignores all the comes after a ! character but that isn't a show  stopper and the #pragma syntax does not fall foul of that. Syntax that is behind a ! is preferred though as it is compiler neutral/portable/has no side effects. 

  • Note Lahey Fortran has !#region for collapsible sections of code in Visual Studio.
  • It'll be nice if Intel can offer something similar: I think something like !DEC$ REGION .. !DEC$ END REGION makes sense.
0 Kudos
Steven_L_Intel1
Employee
3,937 Views

I'll pass on the suggestion. Personally, something like !#region makes more sense to me,even better if the user can define it.

0 Kudos
Reply