[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: on number of continuation lines



>To: address@hidden
>From: "James E. Klein" <address@hidden>
>Subject: Re: 20000530: on number of continuation lines
>Organization: TRW
>Keywords: ncgen Fortran-77 continuation lines

Hi Jim,

> I've been trying to use ncdump and ncgen to dump an existing .nc file
> and then build a program that will re-generate it.
> 
> ncgen -c works fine but ncgen -f complains about excessive length of a
> fortran line. This makes me think the -ansi switch is set during rebuild
> of ncgen. Do you know how to over ride this problem of can you refer me
> to somone who might know?

The output of ncgen -f is supposed to be understandable by Fortran-77
compilers, so the data statements it generates are limited to 19
continuation lines, which are all some standard-conforming compilers
can handle.  We have never rewritten ncgen to generate Fortran-90
or free-format code, though that should be done someday.

If your FORTRAN compiler will accept statements with more than 1320
characters (20 lines * 66 characters per line), you can get ncgen to
generate them by changing a line in ncgen/genlib.h and recompiling
ncgen.  The line to change is:

  #define FORT_MAX_LINES        20      /* max lines in FORTRAN statement */

which you should change to something like

  #define FORT_MAX_LINES        100     /* max lines in FORTRAN statement */

(to permit ncgen to generate 99 continuation lines).  Then recompile
with "make all" and try the resulting ncgen on your CDL file.

However, the netCDF User's Guide advises that ncgen

    ... is only useful for relatively small CDL files, since all the
    data is included in variable initializations in the generated
    program.

By using large enough variables or CDL files, you will be able to
break ncgen, if only because the output will ultimately be too much
for a FORTRAN or C compiler to handle.  You may want to use the output
of ncgen as a guide but use different techniques for variable
initialization for large files.

Also be advised that the way the Fortran generated by ncgen -f stores
text data in character variables is somewhat of a hack (using the
concatenation operator and a long character string argument rather
than a data statement), to avoid multiple passes over the input file
that still generates standard-conforming code.  You should not have to
jump through the same hoops in order to store characters in your
character variables.

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu