home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / sgi / 11587 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  2.8 KB

  1. Path: sparky!uunet!olivea!sgigate!odin!everest.esd.sgi.com!mas
  2. From: mas@everest.esd.sgi.com (Michael Schulman)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: Mixed cc and f77 problems
  5. Message-ID: <1992Jul29.154328.9840@odin.corp.sgi.com>
  6. Date: 29 Jul 92 15:43:28 GMT
  7. References: <31574@adm.brl.mil>
  8. Sender: news@odin.corp.sgi.com (Net News)
  9. Reply-To: mas@sgi.com
  10. Organization: Silicon Graphics Computer Systems, Mountain View, CA
  11. Lines: 115
  12. Nntp-Posting-Host: everest.esd.sgi.com
  13.  
  14. In article <31574@adm.brl.mil>, fred@poly2.nist.gov (Frederick R. Phelan Jr.) writes:
  15. |> From: fred@poly2.nist.gov (Frederick R. Phelan Jr.)
  16. |> Newsgroups: comp.sys.sgi
  17. |> Subject: Mixed cc and f77 problems
  18. |> Date: Wed, 29 Jul 92 05:07:48 PDT
  19. |> Lines: 88
  20. |> 
  21. |> 
  22. |> This is a prototype of a problem I am
  23. |> having trying to use existing f77 
  24. |> read/write subroutines, with graphics
  25. |> code written in c.
  26. |> 
  27. |> Here are three file definitions for main.c,
  28. |> IOstuff.f and test.dat ... main.c attempts
  29. |> to read an integer value from test.dat using
  30. |> the subroutine read_val defined in IOstuff.f ...
  31. |> 
  32. |> (1) main.c :
  33. |> #include <stdio.h>
  34. |> #include <stdlib.h>
  35. |> #include <math.h>
  36. |> 
  37. |> void read_val_(int);
  38. |> 
  39. |> int a;
  40. |> 
  41. |> main()
  42. |> {
  43. |>   read_val_(a);
  44. |>   printf("a = %d\n",a);
  45. |> }
  46. |> 
  47. |> 
  48. |> (2) IOstuff.f :
  49. |>       subroutine read_val(a)
  50. |>       integer a
  51. |> 
  52. |>       read(5,1000) a
  53. |>  1000 format(I2)
  54. |> 
  55. |>       return
  56. |>       end
  57. |> 
  58. |> (3) test.dat :
  59. |>  3
  60. |> 
  61. |> 
  62. |> Problem 1:
  63. |> ----------
  64. |> If I compile with
  65. |> 
  66. |>     cc -o Mix1.exe main.c IOstuff.f -lm
  67. |> 
  68. |> and then do 
  69. |> 
  70. |>     Mix1.exe < test.dat
  71. |> 
  72. |> it returns the answer
  73. |> 
  74. |>     a = 0
  75. |> 
  76. |> when according to test.dat a should = 3.
  77. |> 
  78. |> Problem 2:
  79. |> ----------
  80. |> If I compile with
  81. |> 
  82. |>     cc -c main.c -lm
  83. |>     f77 -c IOstuff.f
  84. |>     cc -o Mix2.exe main.o IOstuff.o -lm
  85. |> 
  86. |> I get the error messages
  87. |> 
  88. |>     /usr/bin/ld:
  89. |>     Undefined:
  90. |>     s_rsfe
  91. |>     do_fio
  92. |>     e_rsfe
  93. |> 
  94. |> 
  95. |> I'd prefer the second way of compiling in parts,
  96. |> since the IO programs have been written for a 
  97. |> long time and have no need of edit/recompile.
  98. |> 
  99. |> Any clues are appreciated.
  100. |> 
  101. |> ---
  102. |> Fred Phelan
  103. |> fred@poly2.nist.gov
  104. |> /*___________________________________________________
  105. |>    ____ __  ___  __    ___       ___        ___ 
  106. |>   /__  /_/ /__  / /   /__/ /__/ /__   /    /__/ /\  /  
  107. |>  /    / ( /__  /_/   /    /  / /___  /___ /  / /  \/
  108. |> ___________________________________________________*/
  109.  
  110. 1) you need to pass the variable from a c to a fortran program as an address,
  111.    fortran passes address all over the place.
  112.  
  113. 2) link with f77
  114.  
  115. 3) why are you including -lm when compiling with  cc -c ???
  116.  
  117. 4) why are you including -lm at all ?
  118.  
  119.  
  120. -- 
  121.  
  122. Michael Schulman
  123.  
  124. Silicon Graphics Computer Systems
  125. 2011 N. Shoreline Blvd.
  126. Mountain View, CA 94039
  127.  
  128. mas@sgi.com
  129.