home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!edcastle!hwcs!suthan
- From: suthan@cs.hw.ac.uk (Manickam Umasuthan)
- Newsgroups: comp.lang.c
- Subject: c<->fortran
- Message-ID: <1992Aug30.112532.11192@cs.hw.ac.uk>
- Date: 30 Aug 92 11:25:32 GMT
- Sender: news@cs.hw.ac.uk (News Administrator)
- Organization: Dept of Computer Science, Heriot-Watt University, Scotland
- Lines: 36
-
- Dear Netters,
- I tried the following piece of code which interfaces with a fortran routine
- which in turn uses the EXTERNAL statement and the external function is defined
- in C. But in my machine the output is wrong. I like to know where the error
- is.
- Thanks . PLEASE EMAIL ME.
- -------------
- #include <stdio.h>
- #include <math.h>
-
- float *abs();
- main()
- {
- float y=-2.34;
- start_((float (*)())abs,&y);
- }
- float *abs(t)
- float *t;
- {
- float x;
- printf("LALA\n");
- x = 2.* (*t);
- printf("%f\n",x);
- return &x;
- }
- subroutine start(fname,x)
- EXTERNAL fname
- real x
- print*, fname(x)
- END
- -----------------------------
- --
- -------
- M.Umasuthan, :: EMAIL: suthan@uk.ac.hw.cs
- Dept. of Computing & Electrical Engineering,
- Heriot-Watt University, Riccarton, Edinburgh EH14 4AS, U.K.
-