Thread: .sgf file format programs

Started: 2009-03-23 23:11:52
Last activity: 2009-03-23 23:11:52
Topics: SAC Developers
Arthur Snoke
2009-03-23 23:11:52
We have written one program and updated another. These will be in the
next release of SAC, but it would be useful to have testing and feedback.
Plus the new program is written in Fortran, and it would be nice if it
were converted to C so we would not have to introduce a new dependency.

The new program sgfswap (written in Fortran) changes the endian of a .sgf
file. It does not matter what the endian is of the machine running the
program. It has been compiled using gfortran, g77, and Sun Fortran and
run on several platforms. But it would be nice to have more tests.

The updated program is sgftops. The new feature is that it removes some
"phantom" moves and color changes. The motivation for the update is that
one phantom move was to the upper-left-hand corner, and when the .sgf file
was converted to a .eps file, the bounding box was not tight (white space
in the upper-left-hand corner).

The sources can be downloaded from URL Here is the Readme.txt on that

11 March 2009

program sgfswap
c Input is a SAC Graphics Format (SGF) file. Output is a SGF file
c with the opposite endian.
c If input file is named XXXX.sgf, output file is XXXX_swap.sgf
C SGF files are direct access (512 byte blocks) binary files. Data
C are stored in buffers of 2*nbuf I*2 words. Preceding each buffer
C is an I*4 with content nbuf. The first buffer has less than
c 2**16 words, so if nbuf is greater then 2**16, the machine and
c the format of the file have the opposite endian. In that case,
C one needs to do a swap4 on that word to find nbuf.
C Once the number, nbuf, is known one swaps that word and the next
c 2*nbuf I*2 words. This is repeated for the rest of the file
C (although one does not need to test after the first). The only
C tricky part is keeping track of buffers that can vary in length
C (4*nbuf bytes) and blocks that have a fixed length (512 bytes).
C jas/vt march 2009

13 March 2009:

Richard Godbee has modified sgftops.c so that it suppresses phantom moves
(in particular one to the upper-left-hand corner that led to excesssive
white space). Also removes redundant setrgbcolor lines. The SAC code
still has some unnecessary moves-to-homes, but this coding gets rid of
them in producing postscript files.

09:03:21 v.d4df61ad