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

Re: 950315: NCREDF



>Organization: .
>Keywords: 199503152223.AA12345

Hi Maureen,

> When I try to run the program CHANGE.F (see attachment), it exits and
> displays the message :
> 
> ncredef: hdata1d.nc:  NC_NOWRITE
> 
> Upon opening the file, I specified "NCWRITE", seeing as I want to
> rename variables and delete/add attributes ... I'm not quite sure
> why the program doesn't run - can you help?

 ...

>       program change

I suspect the problem is that you haven't included the file "netcdf.inc"
that is needed to define parameters (such as NCWRITE) that are used in
programs that call netCDF functions and subroutines.

> 
>       integer rcode,epsid,dengid
> 
> c open netcdf file
>       ncid=ncopn('hdata1d.nc',ncwrite,rcode)

If the parameter "ncwrite" hasn't been defined because the "netcdf.inc" file
wasn't included, Fortran does you the favor of providing a default
definition and value, 0, that just happens to be the value of the parameter
NC_NOWRITE.  Hence the above will behave as if you had used NC_NOWRITE.

One way to avoid problems like this in Fortran (inadvertent use of
undeclared, undefined, or even misspelled variables) is to put an

        implicit none

statement right after the program statement.  Of course then you would have
to declare variables like "ncid" to be integer instead of exploiting
Fortran's implicit typing.

Anyway, please let me know if adding the statement

        include 'netcdf.inc'

doesn't solve the problem.

______________________________________________________________________________

Russ Rew                                                UCAR Unidata Program
address@hidden                                          P.O. Box 3000
http://www.unidata.ucar.edu/                          Boulder, CO 80307-3000
______________________________________________________________________________