Newsgroups: comp.unix.cray,comp.parallel.pvm
From: robijn@Strw.LeidenUniv.NL (Frank Robijn)
Subject: Re: String passing between Fortran & C on a Cray T3D
Organization: Sterrewacht Leiden / Leiden Observatory, The Netherlands
Date: 20 Feb 1995 23:25:10 GMT
Message-ID: <3ib8cm$5c7@highway.LeidenUniv.nl>

In article <3hq6ms$dis@whitbeck.ncl.ac.uk>, D. Jain <D.Jain@ncl.ac.uk> wrote:
> [...]
>We are using a Cray T3D to carry out Solid State Physics calculations. The
>parallelization is carried out by using pvm calls and libraries such as
>scalapack (version 2), pbblas, pblas, pblacs. Now for our problem ...
>
>When passing strings between C and Fortran routines we encountered "operand out
>of range" errors. Eventually we discovered that fortran, when passing strings,
>passes additional "phantom" integers which equal 8* the length of the string.

I don't know about the T3D, but on the C98 a call in Fortran:

	call func (str1,str2)

must be matched in C by:

	#include <fortran.h>
	void FUNC (_fcd str1, _fcd str2)
	{
	    /* Access the string as: */
	    char *ptr1 = _fcdtocp (str1);
	}

If this is not the case on the T3D, look at the alternative.
On most Unix workstations the function would look like:

	void _func (char *str1, char *str2, int str1len, int str2len)
	{
	}

When I was examining a bug in a Fortran/C interface on the C98, I noticed
that the machine has all its addresses in multiples of 8 bytes, i.e., when
allocating two blocks of 80K, the addresses differ only 10240. That may
explain the 8*length parameter. By the way Fortran works (no pointer types
in Fortran 77), it seems unlikely that you can get a null pointer error.
Hope this helps a little bit,

					Frank
-- 
    _____ ____
   /     /   /     Frank Robijn     URL: http://WWW.Strw.LeidenUniv.NL/~robijn/
  /___  /___/   Sterrewacht Leiden   Internet: Robijn@Strw.LeidenUniv.NL
 /     /  \    Phone (31) 71 275878    Bitnet: Robijn@HLERUL51
/     /    \   Fax : (31) 71 275819     Local: Robijn@HL707
              Snail: P.O.Box 9513, 2300 RA Leiden, The Netherlands
-- 
    _____ ____
   /     /   /     Frank Robijn     URL: http://WWW.Strw.LeidenUniv.NL/~robijn/
  /___  /___/   Sterrewacht Leiden   Internet: Robijn@Strw.LeidenUniv.NL
 /     /  \    Phone (31) 71 275878    Bitnet: Robijn@HLERUL51
/     /    \   Fax : (31) 71 275819     Local: Robijn@HL707
              Snail: P.O.Box 9513, 2300 RA Leiden, The Netherlands

