This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Magnus, >Date: Fri, 17 May 1996 11:15:27 +0200 >From: Magnus Weis <address@hidden> >Organization: . >To: Steve Emmerson <address@hidden> >Subject: 960513: xdrposix_putlong() segmentation fault problems >Keywords: 199605091033.AA23012 In the above message you wrote: ... > > I think the problem is the last line: > > > > call ncvpt(ncid, ncv, nc2cor, nc2cnt, xi, errno) > > > > According to the above code, you're trying to write the following array: > > > > REAL xi(IMAX+1,record) > > > > into the netCDF dataset beginning at coordinates (1,record). > > Unfortunately, the array `xi' doesn't appear to be dimensioned properly > > (indeed, it doesn't appear to be an array at all -- merely a scalar > > variable). > > > > Also, the `t' variable requires that a DOUBLEPRECISION variable be used > > in any NCVPT1 call. The one you are using appears to be only REAL. > > > > Sorry for causing some missunderstanding. I did not show you all my > declarations. Here they are: > > float*8 t > float*8 xi(0:IMAX) > If the array xi() is dimensioned as above, then you're trying to write more data than you have. The relevant section of your code is ncv = ncvid(ncid, 'xi', errno) nc2cor(1) = 1 nc2cor(2) = record nc2cnt(1) = IMAX + 1 nc2cnt(2) = nc2cor(2) ! problem here call ncvpt(ncid, ncv, nc2cor, nc2cnt, xi, errno) Because of the values in the `nc2cnt' array, the netCDF library expects that the `xi' array in the call to ncvpt() is dimensioned xi(IMAX+1,record) -- and it will try to write all (IMAX+1)*record elements. The more records you write, the greater the `record' index will be and the larger the netCDF library will expect the `xi' array to be. I suspect that you should use the following code: ncv = ncvid(ncid, 'xi', errno) nc2cor(1) = 1 nc2cor(2) = record nc2cnt(1) = IMAX + 1 nc2cnt(2) = 1 ! change here call ncvpt(ncid, ncv, nc2cor, nc2cnt, xi, errno) The above code will write one `xi' record per call -- which is what you want, I suspect. -------- Steve Emmerson <address@hidden>