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

970611: building using NAG f90



Steve,

>Date: 11 Jun 1997 11:08:21 -0500 
>From: "Steve Mauget" <address@hidden>
>Organization: USDA
>To: "Steve E" <address@hidden>
>Subject: netcdf test program 
>Keywords: 199706021417.IAA27579

In the above message, you wrote:

>      The following is the standard output and error of a stripped
> down version of the previous program. This program just creates
> a netcdf file ('TST.NC'), defines dimensions, variables, & attributes,
> confirms values, and then closes. IERR is echoed after every
> netcdf subroutine call. Note the non-zero value after NCVDEF (-46).
> Any idea what that means?
>      I have e-mailed the people at NAG regarding the install test
> problems and will let you know what they say.
>      Finally, I note in the users manual that netcdf has been tested
> on Irix 5.3 and the 64 bit version of 6.1. We're running ver.6.2
> on a 32 bit machine. Could this have anything to do with these
> problems?

Possibly, but try correcting the error mentioned below first.

> 
>                                           Steve M.
> 
> C****************STANDARD OUT/ERR*************************72
> ncvardef: ncid 3: Invalid dimension id or name
> OUTPUT =  TST.NC
>   IERR AFT NCCRE      0
> NCID=  3
>   IERR AFT NCDDEF     0
> NCSHT  3
>   IERR AFT NCVDEF   -46  << what does ierr = -46 indicate ?

The error return code -46 is the value of the Fortran parameter
NF_EBADDIM, which is defined in the Fortran include file "netcdf.inc".
It indicates an invalid dimension ID or name.  The error code can be
used in the Fortran function NF_STRERROR() to obtain the corresponding
error string.

> NPCP  -1

A returned variable ID of -1 is consistent with an error return from 
NCVDEF due to an invalid dimension ID.

>   IERR AFT NCENDF     0
>   IERR AFT NCINQ      0
>   NCID     3
>   IMON     1
>   ISTA     2
>   NPCP    -1
>   NDIMS    2
>   NATTS    1
>  IRCDIM   -1
>  XMULT 100.00
> 
> C*******************PROGRAM TEXT***************************72
>       program tstnetcdf   !   
> c 
>       parameter (nsta=234,nyrs=117,ndim=2,nmon=1404)
>       real null  !    
> c* corners and edge lengths
>       integer corner(ndim), edges(ndim), idim(ndim)
> C      
>       character*3 Vname
>       character*6 Outfile                     
> C
> C ON LBK155...
> c     link with '/usr/local/lib/libnetcdf.a'
> C     -I/usr/local/include in compile statement...
>       include 'netcdf.inc'
>       save
> C
>       null=-99.99
>       edges(1) = nmon ! Write 1404 (117 yr) month data sequences...
>       edges(2) = 1 ! Write one time series segment at a time...
>       Vname='TST'
>       OutFile=Vname//'.NC'
>       write(*,'(a10,a6)')'OUTPUT =  ',OutFile   !OUTPUT =  TST.NC
> C
> C*********************************************************************72
> C      Write error messages, but do not terminate
>        call NCPOPT(NCVERBOS)
> C
> c Create output NetCDF file....
> C
> C      Enter define mode, create new file...
>       ncid = NCCRE(OutFile,ncclob,ierr)
>       write(*,'(1x,a17,1x,I4)')' IERR AFT NCCRE  ',ierr
>         write(*,'(a6,i2)')'NCID= ',ncid
> C      Define dimensions...
>       imon = NCDDEF(ncid,'month',nmon,ierr)
>       ista = NCDDEF(ncid,'nstation',nsta,ierr)
>       write(*,'(1x,a17,1x,I4)')' IERR AFT NCDDEF ',ierr
> C      Define Variable(s)...
>       idim(1) = nmon      
>       idim(2) = nsta
>         write(*,'(a6,i2)')'NCSHT ',NCSHORT      
>       npcp = NCVDEF(ncid,Vname,NCSHORT,2,idim,ierr)

You appear to be using the dimension-ID vector (5th argument to
NCVDEF()) incorrectly.  It should contain the dimension IDs for the
variable (i.e. "imon" and "ista"), instead it contains the sizes of the
respective dimensions (i.e. "nmon" and "nsta") which (being as large
as they are) aren't valid dimension IDs.

Try modifying the "idim" assignments to the following:

    idim(1) = imon
    idim(2) = ista

>       write(*,'(1x,a17,1x,I4)')' IERR AFT NCVDEF ',ierr
>         write(*,'(a6,i2)')'NPCP  ',npcp       
> C      Create & define attributes...
>         xmult=100.0
>         call NCAPT(ncid,ncglobal,'scale_factor',NCFLOAT,1,xmult,iret)
> C      End definitions, exit define mode...
>       call NCENDF(ncid,ierr)
>       write(*,'(1x,a17,1x,I4)')' IERR AFT NCENDF ',ierr       
> C
> C     Confirm/Inquire about open file....
> C
>       call NCINQ(ncid,ndims,nvars,natts,irecdim,ierr)
>       write(*,'(1x,a17,1x,I4)')' IERR AFT NCINQ  ',ierr
>       write(*,'(1x,a6,1x,I4)')' NCID ',ncid
>       write(*,'(1x,a6,1x,I4)')' IMON ',imon
>       write(*,'(1x,a6,1x,I4)')' ISTA ',ista
>       write(*,'(1x,a6,1x,I4)')' NPCP ',npcp
>       write(*,'(1x,a6,1x,I4)')' NDIMS',ndims
>       write(*,'(1x,a6,1x,I4)')' NATTS',natts
>       write(*,'(1x,a6,1x,I4)')'IRCDIM',irecdim
>       write(*,'(a6,1x,f6.2)')' XMULT',xmult
>         write(*,*)
> C
> C     Close file....  
>       call NCCLOS(ncid,ierr)
>       close(infunit)
>       stop
>       end

--------
Steve Emmerson   <address@hidden>