"c" calling Fortran, and Fortran calling "c" 
Author Message
 "c" calling Fortran, and Fortran calling "c"

I would like to know how I can combine fortran and "c" programs.  

If you know of a good book that gives examples could you send me the name.

If you have an example, could you send me it.

I am using a SUN with BSD 4.2 Unix.

Thank you in advance.

--
/~~|  |\  |\   John W. Hamill, EDS `""""""" UUCP: ...!uunet!edsews!edstip!alf

\__\_/^\_/|\_/ Bloomfield Hills,            Voice:(313)645-4524  Fax:645-4824
          \/   MI 48013  * The above are my views only!!            



Wed, 17 Feb 1993 17:35:00 GMT  
 "c" calling Fortran, and Fortran calling "c"

Quote:

> I would like to know how I can combine Fortran and "c" programs.  

> If you know of a good book that gives examples could you send me the name.

> If you have an example, could you send me it.

> I am using a SUN with BSD 4.2 Unix.

> Thank you in advance.

It depends on the compilers you are using for fortran and C.  On a HP-9000
the process is totally invisible, i.e you just call the fortran function from
you C program:

                                        external some_fortran_function;
                                        .
                                        .
                                        .

                                        some_fortran_function(arguments)

And the same if you call a c function from a fortran program.  Just remember
that all arguments to a fortran function called from C should be pointers,
and that all argument declarations in a c function called from fortran should
be pointers.  (The only limitation are function pointers, which you cannot
send easily.  Structures can also be a mess).

Compile each object with the corresponding compiler, and then link the objects
together using your favorite linker (Use for example the compiler to which
the main program corresponds).

For other systems, you may have to build a so-called jacket routine, which
translates the function name in C to the corresponding function name in fortran
and inversely.  Check your compilers system manual.

                                                -Kjartan

---------------------------------------------------------------------------
Kjartan Pierre Emilsson
Science Institute of the University of Iceland
Dunhaga 3
Reykjavik



Wed, 17 Feb 1993 17:03:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Fortran version of "String to TOKEN"

2. Using fortran-like "intent" in C

3. Fortran version of "String to TOKEN"

4. "Equivalence" a_la Fortran

5. about "call by value" and "call by reference"

6. remove() vrs fopen("""w")

7. Displaying binary data as ascii "1"'s and "0"'s

8. Looking for "Shroud"/"Obfus"

9. ""help with TSR""

10. Parse trees and "("")"

11. Error "free"-ing "malloc"-ed memory

12. Displaying binary data as ascii "1"'s and "0"'s

 

 
Powered by phpBB® Forum Software