Jeff,
The problem you note results from using Geosoft compressed grids as your
default. Compressed grids that are written need to be closed and re-opened
before they can be read so that the compression algorithm can finish
indexing the grid. The majority of applications either open/read/close or
open/write/close a grid, so this problem is rarely encountered.
Your workaround is fine.
Another way to do this is to open your scratch grid uncompressed as follows:
call NewGrid_WF(scr1unit,'scratch1.grd;comp=none',...
An uncompressed grid does not need to be closed before it is read.
See dat_xgd.doc in your geosoft directory for other useful decorations that
you can use when opening grid files.
We will think about adding an automatic close if we detect that an entire
grid has been written before you try to read the grid. However, there will
still be an apparent "bug" if you try to read and write compressed grids at
same time.
Hope this helps...
_______________
Geosoft Inc.
Ian MacLeod
[EMAIL PROTECTED]
(416) 369 0111 x323
Geosoft: Spatial Data Processing and Analysis Solutions
http://www.geosoft.com
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 19, 2000 5:30 PM
To: [EMAIL PROTECTED]
Subject: [gxnet]: BUG REPORT and WORKAROUND for Fortran GX Developers -
2nd try
I have discovered a bug that requires closing and re-opening of grid files
between Fortran subroutine calls.
The following Fortran code demonstrates the problem and the work-around.
I am using the wrapper functions
in wfuncs.c supplied with Oasis/Montaj.
c bugtest.f
c
c Demonstrates a bug requiring closing and reopening of grid files
c between subroutine calls.
c
subroutine bugtest(ifile,ierr)
character*(*) ifile
integer*4 inunit,scr1unit,scr2unit,ierr
data inunit/0/,scr1unit/0/,scr2unit/0/
c
c open and read header of input grid
c
call OpenGrid_WF(ifile,inunit,ierr)
if(ierr.ne.0) go to 9999
c call ReadHeader_WF(inunit,nc,nr,xo,dx,yo,dy,iproj,cmer,blat,ierr)
call GetGridInfo_WF(inunit,nc,nr,xo,yo,dx,dy,rot,ierr)
if(ierr.ne.0) go to 9999
c
c create a scratch grid
c
call NewGrid_WF(scr1unit,'scratch1.grd',nc,nr,xo,yo,dx,dy,rot,
1ierr)
if(ierr.ne.0) go to 9999
c
c copy the input grid to the scratch grid
c
call copy(inunit,scr1unit,nc,nr)
if(ierr.ne.0) go to 9999
call CloseGrid_WF(inunit,ierr)
if(ierr.ne.0) go to 9999
c
c The following four lines of code should not be necessary, but are a
c required work-around for an apparent bug in CloseGrid_WF
c
call CloseGrid_WF(scr1unit,ierr)
if(ierr.ne.0) go to 9999
call OpenGrid_WF('scratch1.grd',scr1unit,ierr)
if(ierr.ne.0) go to 9999
c
c create another scratch grid
c
call NewGrid_WF(scr2unit,'scratch2.grd',nc,nr,xo,yo,dx,dy,rot,
1ierr)
if(ierr.ne.0) go to 9999
c
c copy the first scratch grid to the second scratch grid
c
call copy(scr1unit,scr2unit,nc,nr)
if(ierr.ne.0) go to 9999
c
c Without the above work-around, the following error message results:
c "Cannot write to compressed grid file scratch1.grd out of sequence.
c Attempt to write to vector 1 while current vector was 0."
c
9999 return
end
c **************************************************************
subroutine copy(in,io,nc,nr)
c copy a grid
c in: input unit number
c io: output unit number
c nc: columns in input grid
c nr: rows in input grid
dimension g(8192)
do 10 j=1,nr
call GetRow_WF(in,j,nc,g,ierr)
if(ierr.ne.0) go to 9999
call PutRow_WF(io,j,nc,g,ierr)
if(ierr.ne.0) go to 9999
10 continue
9999 return
end
_____________________________________________________________
Jeffrey D. Phillips Research Geophysicist
U.S. Geological Survey phone: 303-236-1206
Denver Federal Center fax: 303-236-1425
Denver, CO 80225 USA email: [EMAIL PROTECTED]
_______________________________________________________
More mailing list info http://www.geosoft.com/support/listserv/index.html
_______________________________________________________
More mailing list info http://www.geosoft.com/support/listserv/index.html