home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.aix
- Path: sparky!uunet!usc!rpi!usenet.coe.montana.edu!news.u.washington.edu!milton.u.washington.edu!quantum
- From: quantum@milton.u.washington.edu (Tsung-lung Li)
- Subject: Calling fortran from C
- Message-ID: <1992Sep1.230240.23905@u.washington.edu>
- Sender: news@u.washington.edu (USENET News System)
- Reply-To: quantum@u.washington.edu
- Organization: University of Washington, Seattle
- Distribution: na
- Date: Tue, 1 Sep 1992 23:02:40 GMT
- Lines: 48
-
-
- Dear Netters,
-
- I am trying to call a fortran subroutine from a C main program on
- IBM3090 running AIX/370.
- The testing codes are listed below.
-
- Main program--- C :
-
- extern void fsub_();
-
- main()
- {
- double x;
-
- x = 3.9;
- fsub_( &x );
- printf( "%f\n", x );
- }
-
-
- Subroutine--- Fortran:
-
- subroutine fsub( x )
- double precision x
- print *, x
- x = x + 1.0
- return
- end
-
- The compilation and linking processes are performed as follows.
-
- fvs -c -f'optimize(3)' fsub.f
- cc -O cmain.c fsub.o -lfvs -lm -lc -o cmain
-
- The computer responds "Illegal instruction".
-
- However, if the "print *, x" statement is commented out, the program runs all
- right. I wonder why the print command would cause this trouble and if there
- is any way to fix it.
-
- Please e-mail me at
- quantum@u.washington.edu
-
- Thank you in advance.
-
- Tsung
-
-