Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!ames!skipper!elxsi!maine From: maine@elxsi.dfrf.nasa.gov (Richard Maine) Newsgroups: comp.lang.fortran Subject: Re: What is the FORTRAN for ? Message-ID: Date: 14 Aug 90 03:41:21 GMT References: <1990Jul25.174153.16896@ecn.purdue.edu> <11029@chaph.usc.edu> <10583@batcomputer.tn.cornell.edu> <241@cadlab.sublink.ORG> Sender: news@skipper.dfrf.nasa.gov Organization: NASA Dryden, Edwards, Cal. Lines: 40 In-reply-to: staff@cadlab.sublink.ORG's message of 5 Aug 90 09:25:05 GMT On 5 Aug 90 09:25:05 GMT, staff@cadlab.sublink.ORG (Alex Martelli) said: >There's no standard for calling sequences from C to FORTRAN, especially >for CHARACTER arguments. Our code has to run under VAX/VMS, IBM VM/CMS, >Ultrix, Unix, AIX, and so on--so portability is important, and cross >language calls are not currently portable. Alex> I built a set of C macros for this, which currently make C/Fortran Alex> calls with character parameters (and other tough cases, such as Alex> procedures as parameters) fully portable across the wide range of Alex> platforms CAD.LAB products support - all you mentioned, except CMS, Alex> plus OS/2, Apollo DOMAIN, etc. The syntax on the C side gets ugly, Alex> but it DOES work! Takes some days poring over the disassembled Alex> output of the Fortran compiler, that's all... Well..., that's not quite all. I'll ignore issues such as that I often send out code to people who sometimes have to be helped with how to run the compiler, much less pour over its disassembled output. I'll also ignore the issue of portability to systems where both compilers are not even installed (I've seen plenty of such systems). Talking about the argument passing and entry point naming only addresses the easiest half of the problem (I didn't say easy; I said easiest). The hard part is when you want to do i/o during such interlanguage calls. I didn't see that discussed in these macros at all. The c i/o routines tend to assume that they were initialized by a c main program, and conversely for the fortran i/o routines. Doing i/o from a c subroutine called from a Fortran main (or vice-versa) is real tricky. Yes, I've seen it done successfully on some systems, but I'm unconvinced that it can be done at all on other systems, much less portably. If you've managed to find a way to do this with any degree of portability, I'll be very, very impressed (that is, after I get over being dubious). Restricting the solution to solely Unix systems doesn't count as being portable enough, by the way. -- Richard Maine maine@elxsi.dfrf.nasa.gov [130.134.64.6]