For Programmers: Free Programming Magazines  


Home > Archive > Fortran > April 2005 > ignore code lines









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ignore code lines
Gertjan Spierenburg

2005-04-22, 3:59 pm

during modification of my code I sometimes like to ignore large part of code
there must be a better way then putting !!!!! sign before every line :-)

Thanks!


Gareth Owen

2005-04-22, 3:59 pm

"Gertjan Spierenburg" <Spier75@hotmail.com> writes:

> during modification of my code I sometimes like to ignore large part of code
> there must be a better way then putting !!!!! sign before every line :-)
>
> Thanks!


logical :: extracode = .false.

if(extracode) then

<Your code here>

end if

--
Gareth Owen
There ain't no sanity clause
Duane Bozarth

2005-04-22, 3:59 pm

Gareth Owen wrote:
>
> "Gertjan Spierenburg" <Spier75@hotmail.com> writes:
>
>
> logical :: extracode = .false.
>
> if(extracode) then
>
> <Your code here>
>
> end if


If your existing code compiles during modification.

Otherwise, see if your compiler supports conditional compilation
directives. While not standard, many have such extensions.
Gareth Owen

2005-04-22, 3:59 pm

Duane Bozarth <dpbozarth@swko.dot.net> writes:

> Otherwise, see if your compiler supports conditional compilation
> directives. While not standard, many have such extensions.


And others have a flag that cause the C-preprocessor to be run on files first.
--
Gareth Owen
Font-o-Meter! Proportional Monospaced
^
Gordon Sande

2005-04-22, 8:57 pm



Gareth Owen wrote:
> "Gertjan Spierenburg" <Spier75@hotmail.com> writes:
>
>
>
>
> logical :: extracode = .false.
>
> if(extracode) then
>
> <Your code here>
>
> end if
>


I use/mix both schemes. Every now and then when I strip the leading "!"s
I discover that some intermediate change has left me with a syntax
error. That never happens when using the "if ( .false. )" but then
I do sometimes have syntax errors in the nonexecuted portions. It
is mostly a choice of when you want the blunders exposed as well as
how much code is involved.

The "if ( .false. )" style has the merit that that it can be changed
into a dynamic switch that can be set either after some event (like
when a trouble only shows up after 35000 iterations or so) or by reading
a parameter (so you can see the internals after a user has complained
about silly output).

Walt Brainerd

2005-04-22, 8:57 pm

Gertjan Spierenburg wrote:

> during modification of my code I sometimes like to ignore large part of code
> there must be a better way then putting !!!!! sign before every line :-)
>
> Thanks!
>
>

One of the neat little things in Photran is a
pull down with "Comment" and "Uncomment" selections.
Just select the block of code and click. Of course,
you still get ! in front of every line, but it is
easy to do (and undo).

--
Walt Brainerd +1-877-355-6640 (voice & fax)
The Fortran Company +1-520-760-1397 (outside USA)
6025 N. Wilmot Road walt@fortran.com
Tucson, AZ 85750 USA http://www.fortran.com
E. Robert Tisdale

2005-04-22, 8:57 pm

Gertjan Spierenburg wrote:

> During modification of my code,
> I sometimes like to ignore large part of code.
> There must be a better way then putting ! sign before every line.


> cat f.f90

subroutine f()
if (.false.) then
print *, 'No code should be generated for this.'
end if
end subroutine f

> f90 -O2 -S f.f90
> cat f.s

.file "f.f90"
.version "02.10"
.ident "CFT90 frontend"
.data
//
// Absoft Code Generator Version 2.1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com