Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Mixed Fortran/C porting to VMS - SUMMARY
@ 1993-01-29  0:51 JONES,FRED_W.
  0 siblings, 0 replies; only message in thread
From: JONES,FRED_W. @ 1993-01-29  0:51 UTC (permalink / raw)


Thanks to those who replied to my query about a problem porting 
a large mixed Fortran/C application from UNIX to VMS.
[The problem is that UNIX Fortran compilers suffix all external routine
and common names with an underscore while VMS Fortran does not, making
the source code non-portable unless you put in alternate declarations,
bracketed with #ifdef VMS, for the relevant C functions and structs,
which in my case are many.]

I was hoping that there might be a simple solution to this problem
that I wasn't aware of, e.g. a compiler or linker switch.

Ray Bellis pointed out that some Unix compilers have a no-underscore
switch.  Our Ultrix Fortran does, but not the MIPS Fortran we use
on SGI machines.

Ray, and Arne Vajhxj, gave me examples of cpp macros that will do
the job, e.g.:

#ifdef VMS
#define F77symbol(x) x
#else
#define F77symbol(x) x##_
#endif
  ...
struct {    ...       } F77symbol(edgr_mx);
void F77symbol(mxshell)(i, a)
{
}

This is more elegant than the in-line #ifdefs, but still not too
readable.

In a similar vein, Bob Tapp mentioned a package from CERN called
CFORTRAN that provides a completely transparent platform-independent
calling interface between Fortran and C.  It involves a 900-line
include file full of cpp stuff and seems like overkill for my problem.

On the VMS side, Terry Poot's posting suggested checking out the
Linker, but my (non-expert) reading of the Linker manual didn't reveal
any obvious kosher way to play with symbol names.  Another possibility
might be some sort of code similar to sharable-image transfer vectors,
written in MACRO.


In summary, it appears that there is no quick-and-clean solution and
I decided to just stick with the #ifdef bracketing.  
However, my office-next-door neighbour suggested the following way to
get the same result without cluttering up the main body of the code:

#ifdef VMS
#define name1_ name1
#define name2_ name2
..etc.
#endif

This is still some work, but has the virtue of simplicity.


I didn't hear from any DEC people on this issue -- I wonder if they
have addressed it.  There are a lot of large Fortran applications
around that are candidates for X Window front ends, and mixed
Fortran/C programming may become more common.

Fred Jones
TRIUMF
fwj@reg.triumf.ca


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1993-01-29  0:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-01-29  0:51 Mixed Fortran/C porting to VMS - SUMMARY JONES,FRED_W.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox