block comments

block comments

Is there still no block commnet characters available (as in /* in c) in CVF 6.5?

9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Fortran is not C. Fortran has no "block comment". Unlike C, Fortran assumes that each line is a complete statement, unless a continuation indicator is used.

Steve

Steve - Intel Developer Support

It's not hard to write a Visual Studio macro to comment out a selection block in the IDE's editor. The macro can be assigned to a toolbar button or keystroke. I posted an example some time ago.

hth,
John

Stevo,
Your answer surprises me. There is nothing wrong with utility features even if martians thought of it. There is surely frequent need for disabling large sections of the code which can be done with block comments. As it is things are more difficult in fortran since it swtiched from C to ! adding a zillion shift keys to the barrage of keystyrokes to diasble a few consecutive lines.

Even if this is not in f95 standard it could have been implemented as an extension or perhaps the way wordperfect does it by hiding blocks as a "hidden comment" with a "bubble" marker.

Tim

Tim,

Actually, yes, there is something wrong with adding such an extension, where the language already provides an appropriate syntax. It serves to fracture the language and encourage users to write non-portable programs. Our philosophy is to invent extensions very cautiously, and then only when they are "in the spirit of Fortran" Block comments, which would be a radical shift in the way Fortran code is parsed, would not make the cut.

Steve

Steve - Intel Developer Support

I use these VBA Macros:

Option Explicit 
 
Sub DECBeginCommentBlock() 
 
'DESCRIPTION: Comment a block of code in a CVF source. 
 
dim strFunctionName 
 
strFunctionName = ActiveDocument.Selection 
if strFunctionName = "" Then 
	ActiveDocument.Selection = "!DEC$ IF (.FALSE.)" & vbCrLf 
end if 
 
End Sub 
 
Sub DECEndCommentBlock() 
 
'DESCRIPTION: End a comment block in a CVF source. 
 
dim strFunctionName 
 
strFunctionName = ActiveDocument.Selection 
if strFunctionName = "" Then 
	ActiveDocument.Selection = "!DEC$ END IF" & vbCrLf 
end if 
 
End Sub 

This saves you having to select: just run the Begin/End around your block.

--
Gerry T.

Thanks GT,
Now if I only could figure out what a VBA macro is and where to put it.

Tim deBiped

GT,
Please disregard my hasty posting. I figured out how to use your Macro. I even assigned the smiley faces to begin and end.
As I understand it I run the "begin" macro at the beginning then put the cursor at the end of the block and runthe "end" macro. right?

Is is possible to repalce the strings :"!DEC...." with more a descriptive text?

Thanks again,
Tim

You could do:

!DEC IF (.false) !Begin block
...
!DEC END IF !End block

Ciao,
Gerry T.

Leave a Comment

Please sign in to add a comment. Not a member? Join today