home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / aix / 9281 < prev    next >
Encoding:
Text File  |  1992-09-01  |  1.3 KB  |  61 lines

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!usc!rpi!usenet.coe.montana.edu!news.u.washington.edu!milton.u.washington.edu!quantum
  3. From: quantum@milton.u.washington.edu (Tsung-lung Li)
  4. Subject: Calling fortran from C
  5. Message-ID: <1992Sep1.230240.23905@u.washington.edu>
  6. Sender: news@u.washington.edu (USENET News System)
  7. Reply-To: quantum@u.washington.edu
  8. Organization: University of Washington, Seattle
  9. Distribution: na
  10. Date: Tue, 1 Sep 1992 23:02:40 GMT
  11. Lines: 48
  12.  
  13.  
  14. Dear Netters,
  15.  
  16. I am trying to call a fortran subroutine from a C main program on 
  17. IBM3090 running AIX/370.  
  18. The testing codes are listed below.
  19.  
  20. Main program--- C :
  21.  
  22. extern  void  fsub_();
  23.  
  24. main()
  25. {
  26.   double x;
  27.  
  28.   x = 3.9;
  29.   fsub_( &x );
  30.   printf( "%f\n", x );
  31. }
  32.  
  33.  
  34. Subroutine--- Fortran:
  35.  
  36.     subroutine fsub( x )
  37.     double precision  x
  38.         print *,  x
  39.     x = x + 1.0
  40.     return 
  41.     end
  42.  
  43. The compilation and linking processes are performed as follows.
  44.  
  45. fvs -c -f'optimize(3)' fsub.f
  46. cc -O cmain.c fsub.o -lfvs -lm -lc -o cmain
  47.  
  48. The computer responds "Illegal instruction".
  49.  
  50. However, if the "print *, x" statement is commented out, the program runs all
  51. right.  I wonder why the print command would cause this trouble and if there
  52. is any way to fix it.
  53.  
  54. Please e-mail me at 
  55.         quantum@u.washington.edu
  56.  
  57. Thank you in advance.
  58.  
  59. Tsung
  60.  
  61.