[comp.sys.sun] Mixed language I/O problems

revans@voodoo.ucsb.edu (02/27/90)

I have a problem porting a large application to a Sun 4/280.  For the
record, the compilers are not up-to-date; the installation is about a year
old.

The code I am porting is a FORTRAN-77 program of some vintage.  I recently
revised it under VMS and ensured that it was ANSI compliant, except for
using the INCLUDE keyword and the VMS DATE/TIME intrinsic subroutines,
which functionality is supplied by the Sun f77cvt utility.  I am grafting
it onto a data system written in C for the Sun; the code involved is only
a few hundred lines and appears of good quality.  Both elements have been
extensively used in their own environments.

The FORTRAN code performs I/O on units 5 & 6, apparently corresponding to
stdin and stdout, to establish some basic parameters.  It opens another
unit (I have tried both 10 and 17), from which control information about
the data system is read, and unit 23 for output of results to a file.  It
reads a series of commands from the control stream, and then requests data
from the local data system.  This opens two files, one using read(), one
using fread().  The data is read, processed and output successfully.
However, the next attempt by the FORTRAN code to read from the control
stream (unit 10/17) finds an EOF, regardless of the actual contents of the
file.  I have had limited success in attempting to use the debugger to
trace the problem - it doesn't seem to care for FORTRAN :-).  I have
established that the problem seems to be connected with the fopen()
section of the code, rather than the open() section.  This appears to make
sense, because the Sun FORTRAN guide says that FORTRAN I/O is implemented
over stdio.  I guess that stdio is corrupting the contents of a block
belonging to the FORTRAN system.  

Please note that I am NOT trying to do I/O on the same channels; there are
two FORTRAN units and two C streams plus std.. involved, and they should
all be operating independently.  I have done the usual things such as
turning off all optimisation in sight, setting array bound checking on all
FORTRAN code, and RTFM to the extent that the rather scattered
documentation at this site permits.

I am running out of time on this job, so any help you folks can offer will
be most gratefully accepted.  I am about to spend the evening recoding the
fopen() fread() .. code to use open(), read() .. in the hopes that this
will prove to be a worthwhile workaround.

Russ Evans                    e_gs18@va.nmh.ac.uk
British Geological Survey, Edinburgh UK
 .. just visiting (and working hard) at UCSB ..