[F90 interface]

Freddie Akeroyd faa at isise.rl.ac.uk
Mon Feb 23 20:31:41 GMT 1998


> 
> Hello everybody,
> 
> I have tried, and finally succeeded, to write a Fortran90 interface for NAPI
> ( Version 0.9 ). However, in order to write the interface in STANDARD F90,
> i had to make minor changes to the C-Routines. Since these changes are
> only minor, i thought you might consider taking them over into your regular
> version of NAPI. ( I haven't actually written a complete interface yet -
> i have only incluede those procedures so far which are used in the
> Test-Programs.)
> 
I think we should keep the C interface the same for backward compatibility,
and so I have updated the FORTRAN interface to remove any use of %VAL constructs:
hopefully it will now compile unmodified with F90.
> 
> For the moment, i didn't use any pointers  in my interface ( for the
> NXhadle ) and so i didn't call NXOpen ( which also expects a variable to
> be passed by value ) directly but rather call NXfOpen. It would be possible
> to define pointers to a NeXusFile-Structure in F90 and pass those directly
> to NXOpen ( i have tested this and it works ), but i'm not sure whether there
> is any gain in doing this: first, you would have to change all Procedures
> ( except NXOpen and NXCLose ) since again they all expect the handle to be
> passe by value. Second, i don't think a user cares to mutch whether he's
> passing a pointer or a target to the NAPI.
> 
I didn't think F90 pointers are guaranteed to be directly compatible with C 
pointers, so using them could be compiler/operating system dependent.
You should be able to call NXopen directly from F90 after you have 
declared    INTEGER FILEID(NXFILESIZE)   by just passing the FILEID name:
in fact you are passing a structure by reference, the structure being written
back into the FORTRAN integer array. Even though the C NXopen takes a 
parameter by value, you do not actually call the C one when you type
NXopen in FORTRAN due to a large amount of #defining and name mangling;
in fact the FORTRAN interface is wrapped to
go totally by reference (the C NXopen becomes nxiopen, and a call to
NXopen from FORTRAN calls the C wrapper function NXfopen, which finally
calls NXopen).

I'm currently playing about with name mangling for a PC port - should
be ready some time this week. The version i have on the WWW server above
contains a few fixes I've put in, and a few Mark informed me of as
well. I also updated the code and examples to use all the NX_ types
etc. What is the current status of NX_CHAR though - are we using DFNT_UINT8
or DFNT_CHAR8 (I tried DFNT_UCHAR8, but it seemed to crash my HDF!)

Regards,

Freddie

-- 
Freddie Akeroyd                        Email:  faa at isise.rl.ac.uk
ISIS Facility                          Tel:    +44 1235 445457   
Rutherford Appleton Laboratory         Fax:    +44 1235 445720   
Chilton,   DIDCOT,   OX11 OQX          WWW:    http://www.isis.rl.ac.uk/



More information about the NeXus-developers mailing list