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

970610: building using NAG f90



Steve,

>Date: 10 Jun 1997 16:59:40 -0500 
>From: "Steve Mauget" <address@hidden>
>Organization: USDA
>To: "Steve E" <address@hidden>
>Subject: Disregard last message... 
>Keywords: 199706021417.IAA27579

In the above message, you wrote:

>       Disregard everything in my last message about why my
> program crashed. The problem is with an NCVDEF of an NCSHORT
> variable, and not with ncid and NCCRE. See below.
> 
>                                             Steve M.   
>                                       :
>                                       :
>                                       :
> \/
> 
>               *** Standard Out & Error ***
> 
> 
> ncvardef: ncid 3: Invalid dimension id or name
> 
> ( I dunno why these error messages from loop
>   of program here at the beginning...)
>
> NCVPT: : Variable not found
> NCVPT: : Variable not found
> NCVPT: : Variable not found
> NCVPT: : Variable not found
> NCVPT: : Variable not found
> NCVPT: : Variable not found
> NCVPT: : Variable not found

Because they're being written to standard error rather than standard
output.  The two streams are asynchronous with one another.

> 
> 
> NCSHT  3
> IPCP  -1  (<< Is this a valid variable # ??)

No.

> 
>      (  write(*,'(a6,i2)')'NCSHT ',NCSHORT      
>       ipcp = NCVDEF(ncid,Vname,NCSHORT,2,idim,ierr)
>         write(*,'(a6,i2)')'IPCP  ',ipcp     )
> 
>   NCID     3
>   NDIMS    2
>   NATTS    1
>  IRCDIM   -1
>  XMULT 100.00
> 
>    1 030936 03   0
>    1 030936 03 -49
>    2 031632 03 -49
>    3 032356 03 -49
>    4 034572 03 -49
>    5 035186 03 -49
>    6 035508 03 -49
>    7 036928 03 -49
> 
>   NDIMS  2
>   NCID   3
>   NVARS  0   (<< but still, NVARS =0)
>   NATTS  1
>   IREC   -1
>   STINDX  7
>   IERR   0
>   ::::::::::::::::::::::::::::::::::::::::::::::::::::
> Fortran-90 STOP
> 
> 
> C******************* ENTIRE PROGRAM TEXT**********************72
>       program wrnetcdf   !  As in, USHCN Filnet pcp data loader into netCDF
> file, 
> C                           see script WRNETCDF  
> c 
>       parameter (nsta=234,nyrs=117,ndim=2,nmon=1404)
>       parameter (ibegyr=1880,iendyr=1996)
>       real yrin(12),yrin13,null  !    
>       real xlat(nsta),xlon(nsta)
>       integer stnindx
> c* corners and edge lengths
>       integer corner(ndim), edges(ndim), idim(ndim)
> C
>       integer*2 iyrin(12),istnrec(nmon)      
>       character*2 dc,state
>       character*3 Vname
>       character*4 flg1,flg2,flg3,flg4,flg5,flg6,
>      &            flg7,flg8,flg9,flg10,flg11,flg12,flg13
>       character*6 Outfile,stnlist(nsta),curid,stnid,Chr6                      
>       character infile*72,nb*144
> 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
>       write(*,*) 'enter input filename?'
>       read(*,'(a)') infile
>       write(*,*) 'enter 2 chr stid'
>       read(*,'(a2)') state
>       write(*,*) 'Enter 0/1 for initial/continuing run'
>       read(*,*)init
> c
>       null=-99.99
>       infunit=11
>       edges(1) = nmon ! Write 1404 (117 yr) month data sequences...
>       edges(2) = 1 ! Write one time series segment at a time...
>       curid='      '
>       Vname='PCP'
>       OutFile=Vname//'.NC'
>       write(*,'(a10,a6)')'OUTPUT =  ',OutFile
>       write(*,'(a10,I2)')'NCID =    ',ncid
> C
> C*********************************************************************72
> C      Write error messages, but do not terminate
>        call NCPOPT(NCVERBOS)
> C
> c Create or open the output NetCDF file....
> c
>       if(init.eq.0)then !***Create new NetCDF file ***
> 
> C      Enter define mode, create new file...
>       ncid = NCCRE(OutFile,ncnoclob,ierr)
>         write(*,'(a6,i2)')'NCID= ',ncid
> C      Define dimensions...
>       imon = NCDDEF(ncid,'month',nmon,ierr)
>       ista = NCDDEF(ncid,'nstation',nsta,ierr)
> C      Define Variable(s)...
>       idim(1) = nmon      
>       idim(2) = nsta
>         write(*,'(a6,i2)')'NCSHT ',NCSHORT      
>       ipcp = NCVDEF(ncid,Vname,NCSHORT,2,idim,ierr)
>         write(*,'(a6,i2)')'IPCP  ',ipcp       
> 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)
> C
> C      Load station ID, lat,lon...
>         open(unit=10,file='qastnloc.asc',access='sequential',
>      &                  form='formatted',status='old')
>         do n = 1, nsta
>          read(10,'(a6,1x,f5.2,1x,f7.2)')stnlist(n),xlat(n),xlon(n)
> C         write(*,'(1x,I3,1x,a6,1x,f5.2,1x,f7.2)') ! echo to log...
> C     &                    n,stnlist(n),xlat(n),xlon(n)
>         enddo
>         close(10)
>         open(unit=10,file='qastnloc.dat',form='unformatted',
>      &                                   status='new')
>         write(10)stnlist,xlat,xlon
>         close(10)  
>        endif
> C     
>       if(init.eq.1)then ! ***Open old NetCDF file***
>       ncid  = NCOPN(OutFile,NCWRITE,ierr)
> C       Get dimension IDs... 
>       imon = NCDID(ncid,'month',ierr)
>       ista = NCDID(ncid,'nstation',ierr)
> C       Get variable ID... 
>       ipcp  = NCVID(ncid,Vname,ierr)
> C       Get multiplier value...
>         call NCAGT(ncid,ncglobal,'scale_factor',xmult,ierr)
> C      Get station IDs, lats & lons...
>         open(unit=10,file='qastnloc.dat',form='unformatted',
>      &                                   status='old')
>         read(10)stnlist,xlat,xlon
>         close(10)
>       endif
> C
> C     Confirm/Inquire about open file,get multiplier value...
> C
>       call NCINQ(ncid,ndims,nvars,natts,irecdim,ierr)
>       write(*,'(1x,a6,1x,I4)')' NCID ',ncid
>       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*********************************************************************72      
> c Creep forward in the station list file to first record for state...
> C
>       stnindx=1
>       call InitInt2(istnrec,nmon,null,xmult)
> 15    chr6=stnlist(stnindx)
>       if(state.eq.chr6(1:2))then
>         goto 17
>       else
>         stnindx=stnindx+1
>         goto 15
>       endif
> 17    continue ! Now at first record for state...
>       write(*,'(1x,i3,1x,a6,1x,a2,1x,I3)')
>      &       stnindx,stnlist(stnindx),state,ierr ! echo to log     
> C
> c Creep forward in the station data file to first record for state...
> C Open and read line 1 of the data input file for state
> C
>       open(unit=infunit,file=infile,access='sequential',
>      &         form='formatted',status='old')
> 18    read(infunit,'(a144)',end=90,err=90)nb
>       if(nb(51:55).eq.'+++++')goto 90  ! ...exit
> C*
>       if(nb(1:6).eq.stnlist(stnindx))then ! write data to istnrec buffer...
> C*
>        read(nb,'(a6,1x,i4,1x,a2,13(f6.2,a4))')
>      &             stnid,iyr,dc,
>      &             yrin(1),flg1,yrin(2),flg2,yrin(3),flg3,yrin(4),flg4,
>      &             yrin(5),flg5,yrin(6),flg6,yrin(7),flg7,yrin(8),flg8,
>      &             yrin(9),flg9,yrin(10),flg10,yrin(11),flg11,
>      &             yrin(12),flg12,yrin13,flg13
>        curid=stnid
>        if(iyr.lt.ibegyr)goto 18 ! do not load data prior to 1880...
> C      imoend=12*(iyr-1880)+1
> C      imoend=12*(iyr-1880)+12
>        call REtoINT(iyrin,yrin,12,xmult)
>        do imo=1,12  ! write data to buffer...
>           istnrec(12*(iyr-ibegyr)+imo)=iyrin(imo)
>        enddo
>        if(iyr.eq.iendyr)then ! write buffer to netCDF file...         
>         corner(1) = 1  ! edges(1)=nmon=1404
>         corner(2) = stnindx ! edges(2)=1 
>         call NCVPT(ncid,ipcp,corner,edges,istnrec,ierr)

It appears that something is happening to "ipcp" in this loop that
causes it be become an invalid variable ID.

>         write(*,'(1x,i3,1x,a6,1x,a2,1x,I3)')
>      &               stnindx,stnlist(stnindx),state,ierr ! echo to log
>         call InitInt2(istnrec,nmon,null,xmult) ! Initialize buffer for next
> station in list..
>         stnindx=stnindx+1 ! advance stnindx...       
>        endif
>        goto 18
> C*
>       else ! read next record..
> C*
>        goto 18
> C*
>       endif
> C*********************************************************************72      
> 
> C*
> C     Inquire about open file before exiting...
> 90    call NCINQ(ncid,ndims,nvars,natts,irecdim,ierr)
>       write(*,*)
>       write(*,*)' NDIMS ',ndims
>       write(*,*)' NCID  ',ncid
>       write(*,*)' NVARS ',nvars
>       write(*,*)' NATTS ',natts
>       write(*,*)' IREC  ',irecdim
>       write(*,*)' STINDX ',stnindx-1
>       write(*,*)' IERR  ',ierr
>       write(*,*)' ::::::::::::::::::::::::::::::::::::::::::::::::::::'
>       call NCCLOS(ncid,ierr)
>       close(infunit)
>       stop
>       end
> c
> 
> 
> 

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