home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!sgigate!odin!everest.esd.sgi.com!mas
- From: mas@everest.esd.sgi.com (Michael Schulman)
- Newsgroups: comp.sys.sgi
- Subject: Re: Mixed cc and f77 problems
- Message-ID: <1992Jul29.154328.9840@odin.corp.sgi.com>
- Date: 29 Jul 92 15:43:28 GMT
- References: <31574@adm.brl.mil>
- Sender: news@odin.corp.sgi.com (Net News)
- Reply-To: mas@sgi.com
- Organization: Silicon Graphics Computer Systems, Mountain View, CA
- Lines: 115
- Nntp-Posting-Host: everest.esd.sgi.com
-
- In article <31574@adm.brl.mil>, fred@poly2.nist.gov (Frederick R. Phelan Jr.) writes:
- |> From: fred@poly2.nist.gov (Frederick R. Phelan Jr.)
- |> Newsgroups: comp.sys.sgi
- |> Subject: Mixed cc and f77 problems
- |> Date: Wed, 29 Jul 92 05:07:48 PDT
- |> Lines: 88
- |>
- |>
- |> This is a prototype of a problem I am
- |> having trying to use existing f77
- |> read/write subroutines, with graphics
- |> code written in c.
- |>
- |> Here are three file definitions for main.c,
- |> IOstuff.f and test.dat ... main.c attempts
- |> to read an integer value from test.dat using
- |> the subroutine read_val defined in IOstuff.f ...
- |>
- |> (1) main.c :
- |> #include <stdio.h>
- |> #include <stdlib.h>
- |> #include <math.h>
- |>
- |> void read_val_(int);
- |>
- |> int a;
- |>
- |> main()
- |> {
- |> read_val_(a);
- |> printf("a = %d\n",a);
- |> }
- |>
- |>
- |> (2) IOstuff.f :
- |> subroutine read_val(a)
- |> integer a
- |>
- |> read(5,1000) a
- |> 1000 format(I2)
- |>
- |> return
- |> end
- |>
- |> (3) test.dat :
- |> 3
- |>
- |>
- |> Problem 1:
- |> ----------
- |> If I compile with
- |>
- |> cc -o Mix1.exe main.c IOstuff.f -lm
- |>
- |> and then do
- |>
- |> Mix1.exe < test.dat
- |>
- |> it returns the answer
- |>
- |> a = 0
- |>
- |> when according to test.dat a should = 3.
- |>
- |> Problem 2:
- |> ----------
- |> If I compile with
- |>
- |> cc -c main.c -lm
- |> f77 -c IOstuff.f
- |> cc -o Mix2.exe main.o IOstuff.o -lm
- |>
- |> I get the error messages
- |>
- |> /usr/bin/ld:
- |> Undefined:
- |> s_rsfe
- |> do_fio
- |> e_rsfe
- |>
- |>
- |> I'd prefer the second way of compiling in parts,
- |> since the IO programs have been written for a
- |> long time and have no need of edit/recompile.
- |>
- |> Any clues are appreciated.
- |>
- |> ---
- |> Fred Phelan
- |> fred@poly2.nist.gov
- |> /*___________________________________________________
- |> ____ __ ___ __ ___ ___ ___
- |> /__ /_/ /__ / / /__/ /__/ /__ / /__/ /\ /
- |> / / ( /__ /_/ / / / /___ /___ / / / \/
- |> ___________________________________________________*/
-
- 1) you need to pass the variable from a c to a fortran program as an address,
- fortran passes address all over the place.
-
- 2) link with f77
-
- 3) why are you including -lm when compiling with cc -c ???
-
- 4) why are you including -lm at all ?
-
-
- --
-
- Michael Schulman
-
- Silicon Graphics Computer Systems
- 2011 N. Shoreline Blvd.
- Mountain View, CA 94039
-
- mas@sgi.com
-