Green Hills Fortran I/O init on Xenix

Ed Segall segall at caip.rutgers.edu
Sun Oct 21 07:49:23 AEST 1990


HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I'm working on an Intel iPSC/2, running Green Hills FORTRAN under
Xenix.  I've managed to successfully link C and Fortran routines (with
the main procedure being in C), except for one nasty little detail:

The fortran I/O doesn't work!

Here's the details:


I am calling fortran subroutines from a c main program, and the
fortran i/o is causing runtime errors. It doesn't cause any problems
when the main program is fortran.  I don't believe it's a problem with
argument passing, since I can reproduce the error without passing any
values.  In fact, a C program that does nothing but call a fortran
subroutine (with no parameters), which does nothing but print, causes
the problem.  Also, I've had no trouble passing values from fortran to
C and then having C print them.  (If necessary, I'll rewrite
everything so that C does the output, but I'd rather fix the problem
properly). 

Some versions of fortran have a special function that you can 
call that initializes the i/o system.  On the Sun, it's called ioinit.
Do you know if such a thing exists for the iPSC, and if it does,
what it's called and what parameters it takes? I'd appreciate it 
very much if you would check.

Here's the code:

c program (testc.c)
-----------------------------------------------------------------------------
#include <stdio.h>
extern void     testf_();

main()
{
        printf("c: ready to call testf()\n");
        testf_();
        printf("c: passed call to testf()\n");
}
-----------------------------------------------------------------------------

fortran (testf.f)
-----------------------------------------------------------------------------
        subroutine testf()
        integer i

        print *, 'f: in testf'
        i = 1
        print *, 'f: i = ', i
        end
-----------------------------------------------------------------------------

How compiled & linked:
-----------------------------------------------------------------------------
f77 -c -g testf.f
cc -g testc.c -o test testf.o -lf -lm
-----------------------------------------------------------------------------

output:
-----------------------------------------------------------------------------
c: ready to call testf()
test: Segmentation violation -- Core dumped
-----------------------------------------------------------------------------

Note that no output appears from fortran.  Sometimes (I'm not sure of
the circumstances, but I think it may be if I flush stdout), some of
the fortran output appears in a file called Fort.6.  This suggests to
me that something isn't getting initialized, so a default file name is
being used.  Also, if I open unit 6 as /dev/tty, and then do
	write(6,*) 

instead of 
	print *,...  

this allows some fortran output to appear on stdout, but only if I
just print strings.  I.e. the first print statement (if converted to
write) appears, but the second causes the program to break.

This is causing me real problems, and has made it unlikely that I'll
be able to present my results (with regard to the particular program
I'm working) at a conference at the end of this week.  If there's
anything you can do to find out how to fix or work around this, I'd
appreciate it.

Thank you,

Ed

PS This happens both on nodes (where it causes a segmentation
violation) and on the host (where it causes a bus error).


PPS  Here's another version of the same program, that explicitly opens
unit 6, and does formatted output (to remove any ambiguity about what
the i/o system has to do):

fortran (testwritef.f):
-----------------------------------------------------------------------------      subroutine testf()
      integer i

      i = 1
      open(unit=6, file='/dev/tty')
      write(6,100)
  100 format('f: in testf')
      write(6,101) i
  101 format('f: i = ', i4)
      end
-----------------------------------------------------------------------------

c (testwritec.c, same as testc.c):
-----------------------------------------------------------------------------
#include <stdio.h>
extern void     testf_();

main()
{
        printf("c: ready to call testf()\n");
        testf_();
        printf("c: passed call to testf()\n");
}
-----------------------------------------------------------------------------


output:
-----------------------------------------------------------------------------
c: ready to call testf()
f: in testf
testwrite: Bus error -- Core dumped
-----------------------------------------------------------------------------

Note that with unit 6 opened explicitly, the fortran output does appear.

How made:
-----------------------------------------------------------------------------
f77 -c -g testwritef.f
cc -g testwritec.c -o testwrite testwritef.o -lf -lm
-----------------------------------------------------------------------------
-- 


uucp:   {...}!rutgers!caip.rutgers.edu!segall
arpa:   segall at caip.rutgers.edu



More information about the Comp.unix.xenix.misc mailing list