Software Archive
Read-only legacy content

block comments

rahzan
Novice
2,406 Views
Is there still no block commnet characters available (as in /* in c) in CVF 6.5?
0 Kudos
8 Replies
Steven_L_Intel1
Employee
2,406 Views
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
0 Kudos
Intel_C_Intel
Employee
2,406 Views
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
0 Kudos
rahzan
Novice
2,406 Views
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
0 Kudos
Steven_L_Intel1
Employee
2,406 Views
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
0 Kudos
Intel_C_Intel
Employee
2,406 Views
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.
0 Kudos
rahzan
Novice
2,406 Views
Thanks GT,
Now if I only could figure out what a VBA macro is and where to put it.

Tim deBiped
0 Kudos
rahzan
Novice
2,406 Views
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
0 Kudos
Intel_C_Intel
Employee
2,406 Views
You could do:

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

Ciao,
Gerry T.
0 Kudos
Reply