[comp.windows.ms.programmer] Windows I/O problem

dre@sequoia.cray.com (Dennis Ellis) (04/26/91)

Greetings all you Win3 programming gurus.

  I have an I/O problem which I hope someone can help me solve.

  I have the usual C main routine (actually the FILEOPEN program from the
supplied 'samples') which calls a Fortran subroutine. The Fortran routine
calls some user interface routines which have been included with the main
C driver. This all works fine under Win3.

  UNTIL ... I attempt to open a file and do I/O in the Fortran routine. I
get a UAE when I run the resulting EXE. I have tried various combinations
of 'share' and 'mode' settings on the OPEN statement without much luck.

  If anyone has gotten this to work, or has some idea what might be wrong,
or knows for a fact that it can't be done, I would like to hear from you.

Thanks.


--
*******************************************************************************
* Dennis Ellis (dre@sequoia.cray.com) *                                       *
* Cray Research, Inc.                 *                                       *
* Eagan, MN 55121                     * All the normal stuff about opinions.. *

mikel@dosbears.UUCP (Mike Lipsie) (04/28/91)

In article <092008.19563@timbuk.cray.com> dre@sequoia.cray.com (Dennis Ellis) writes:
>Greetings all you Win3 programming gurus.
>
>  I have an I/O problem which I hope someone can help me solve.
>
>  I have the usual C main routine (actually the FILEOPEN program from the
>supplied 'samples') which calls a Fortran subroutine. The Fortran routine
>calls some user interface routines which have been included with the main
>C driver. This all works fine under Win3.
>
>  UNTIL ... I attempt to open a file and do I/O in the Fortran routine. I
>get a UAE when I run the resulting EXE. I have tried various combinations
>of 'share' and 'mode' settings on the OPEN statement without much luck.
>
I am _not_ a "Win3 programming guru" (by a long shot;  I'm just getting
into it) but I am a compiler person.

Like most languages, Fortran has an extensive library that needs to be 
initialized.  Either in the code generated from the Fortran MAIN or the 
routine that calls it there is a call to the I/O initialization code.
When you call a Fortran subroutine from a C program, that initialization 
has not happened and who knows what uninitialized pointer you are following.

The solution is either to (a) don't do I/O in the Fortran routines or
(b) find out the calls and put them into your C program.

--
Mike Lipsie
mikel%dosbears.uucp@ingres.com