Re: your mail

From: Valery Fine (fine@bnl.gov)
Date: Fri Dec 04 1998 - 16:44:50 MET


  Dear  Canguo Li
On  4 Dec 98 at 16:12, you wrote:


> > ffkey_(key,ptr,Nvar,type,strlen(key),strlen(type));
> 
>   Is this the way to call fortran subroutine ffkey_ (in FFREAD
>   package) --
> adding 2 more arguments strlen(key), strlen(type) in the call? I
> understand fortran would require this info, but is the order
> implementation-independent?

   Not it is not. This order is defined by platform/vendor/compiler.

   For example for Digital Visual Fortran on Windows platform one 
needs:


   FFKEY(key,strlen(key),ptr,Nvar,type,strlen(type));

  where one has to supply the prototype for that FFKEY as follows:

extern "C" { 
    void  _stdcall  FFKEY(char *, int key, void *,int *,char *,int);
}
 
  An attempt to take in account all possible combination was done by
the author of CFortran package.

/* cfortran.h  3.9 */          /* anonymous ftp@zebra.desy.de */
/* Burkhard Burow  burow@desy.de                 1990 - 1997. */

  Most of the CERNLIB entries have been defined with this packages and
available from CERN:

 Directory of asis\share\cern\98\src\cfortran

27.06.98  18:37         <DIR>          .
27.03.98  05:55         <DIR>          ..
27.06.98  18:37         <DIR>          CVS
27.01.98  12:16                106'698 cfortran.h
06.03.98  05:20                 21'636 hbook.h
15.05.96  05:24                218'721 geant315.h
15.05.96  05:24                254'092 geant321.h
30.01.98  11:10                 92'069 gen.h
30.01.98  11:10                 10'296 higz.h
30.01.98  11:10                  6'275 hplot.h
30.01.98  11:10                 13'403 jetset74.h
24.03.98  08:46                 79'257 kernlib.h
30.01.98  11:10                  6'420 lepto62.h
30.01.98  11:10                  8'444 minuit.h
29.01.98  12:59                     76 packlib.h
05.02.98  12:47         <DIR>          Examples
29.01.98  05:49                     37 graflib.h
30.01.98  11:10                    272 kuip.h
30.01.98  11:10                    198 zebra.h
30.01.98  11:48                    342 Imakefile
26.06.98  11:43                 96'063 cfortran.doc



  For more simple case the following "include" may help as well:

fortranc.h:
==========
#ifndef FORTRANC_DEF
#define FORTRANC_DEF

#ifdef WIN32
# ifdef CERNLIB_MSSTDCALL
#  define F77_UCASE
#  define type_of_call _stdcall
#  ifndef CERNLIB_QXCAPT
#    define CERNLIB_QXCAPT
#  endif
# else
#  define F77_LCASE
#  ifndef CERNLIB_QXNO_SC
#    define CERNLIB_QXNO_SC
#  endif
# endif
#endif

#ifdef CERNLIB_QXCAPT
#  define F77_NAME(name,NAME) NAME
#else
#  if defined(CERNLIB_QXNO_SC)
#    define F77_NAME(name,NAME) name
#  else
#    define F77_NAME(name,NAME) name##_
#  endif
#endif

#ifndef type_of_call
# define type_of_call
#endif

#endif

================
 Now one can use it as follows:

#include "fortranc.h"

#define ffkey_ F77_NAME(ffkey,FFKEY)

extern "C" { 
    void  type_of_call   ffkey_(char *, int key, void *,int *,char *,int);
}

#ifdef WIN32
   FFKEY(key,strlen(key),ptr,Nvar,type,strlen(type));
#else
   FFKEY(key,ptr,Nvar,type,strlen(type),strlen(key));
#endif

  Hope this helps,
                       Valery
=================================================================
Dr. Valeri Faine (Fine)
    -------------------          Phone: +1 516 344 7806
Brookhaven National Laboratory   FAX  : +1 516 344 4206
Bldg. 510A /STAR                 mailto:fine@bnl.gov
Upton, New York, 11973-5000      http://nicewww.cern.ch/~fine
USA
                                 
Dr. Valery Fine                  Telex : 911621 dubna su
    -----------
LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
141980 Dubna, Moscow region      Fax   : +7 09621 6 51 45
Russia                           mailto:fine@main1.jinr.dubna.su                              



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:40 MET