From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,de9de2f8fd1d9bb X-Google-Attributes: gidfee84,public From: fuhrmann@weyl.wias-berlin.de (Juergen Fuhrmann) Subject: Re: passing between C and Fortran Date: 1995/11/15 Message-ID: #1/1 X-Deja-AN: 119439302 references: <48aa3t$9im@news.cea.fr> organization: Technical University Berlin, Germany newsgroups: comp.unix.osf.osf1 >Hi, >I have a C program calling Fortran functions, and inside the Fortran, >i need to call some C functions. >My programs comes from HPUX and i have to compile it on OSF1. >But the f77 compiler isn't very happy with my source file.. >any help ? Try this: >>> file main.c <<< #define essaifort essaifort_ main() { essaifort(); } >>> file fortran.F <<< integer function essaifort() integer ii=123 call recupfort(ii) return end >>> file c2.c <<< #include #define recupfort recupfort_ void recupfort(ic) int *ic; { printf(" ic arg = %d\n",ic); } IMHO this should work under most unix systems. If not, the Fortran compiler generates the external symbols in a different way, and one should change the #define statements. The rule is that fortran passes everything by reference, so in C you should receive or pass pointers. You should assure that int* goes to integer*4, double* to REAL*8 etc. Character strings are a (very) different story. Juergen -- Juergen Fuhrmann fuhrmann@wias-berlin.de Weierstrass Institute for Applied Analysis and Stochastics (WIAS) Mohrenstrasse 39 D-10117 Berlin, Germany phone: (49) 030 20377 560 fax: (49) 030 2044975 * Bad News is No News *