Re: Standard pre-processing ?



David Flower wrote:
kis wrote:

Hi,

I use CVF 6.6 editor to write Fortran code and want to comment out (put
" ! or C " at the beginning of) hundreds of lines. Is there an easy
way to do that? What I did so far is to put the comment signs line by
line; very tedious and time consuming. FYI, in MATLAB (6.0 or higher),
simply block the lines that need to be commented out and press CTRL+R
simultaneously. All the blocked lines will be commented out (with %
sign).

Look forward to kind help.

Irfan


I am aware of at least three non-standard pre-processor command formats
(C, DEC, Salford).

Is there anything proposed, or implemented, in the standards ?

Dave Flower

Most Fortran compilers include a built-in compile flag for a C preprocessor. This allows you to comment out a large block with:
#if 0
....
#endif

For inserting actual Fortran comments, you could use gVim: highlight a block, then do :s/^/!/
which means substitute beginning-of-line with '!'. The beginning-of-line is zero-width, so it;s really an insert.

COCO is an 'official' preprocessor, an actual ISO standard. However, it never has caught on, probably because the C preprocessor (in traditional mode) was already very common. Also, the are several FPP's, which are just C preprocessors that are better at handling Fortran source.

There is also a Perl-based preprocessor, fpx3. It is overkill for most users, but can also do simple cpp-like code exclusions.

Joe
.



Relevant Pages

  • Re: COCO and/ior CPP users?
    ... preprocessor standards, but the Fortran standards groups have a hard ... enough time agreeing on the languag that things like preprocessor standards are just outside the current efforts. ... do Fortran programmers just not care that much about such things? ... Behrens) -- but never for portability. ...
    (comp.lang.fortran)
  • Re: COCO and/ior CPP users?
    ... >> preprocessor standards, but the Fortran standards groups have a hard ... OR, do Fortran ... perspectives do find lots of use for preprocessors with Fortran code. ...
    (comp.lang.fortran)
  • Re: templates - generic programming
    ... > Is there a preprocessor type of tool available that is sophisticated ... "a preprocessor for Fortran 90 code, ... Generic programming in Fortran 90 ...
    (comp.lang.fortran)
  • Re: Calling C Macros from Fortran
    ... >> of a simulation program written in Fortran. ... >> Is calling C macros from Fortran possible? ... >> how do you call these macros in Fortran and link the Fortran code ... > The C preprocessor doesn't understand C or Fortran ...
    (comp.lang.fortran)
  • Re: Preprocessor and conditional compilation
    ... > is it possible to write macroses inside Fortran programs, ... > there any compiler-independent preprocessor for Fortran, ...
    (comp.lang.fortran)