Proposed rearrangement of "struct NeXusFile"

F.A.Akeroyd at rl.ac.uk F.A.Akeroyd at rl.ac.uk
Tue Oct 12 13:32:29 BST 1999


There is a further problem i have noted with the the F90 definition of
NXstack: iRefDir and iTagDir are defined as integers whereas they are
in fact pointers to integers. On most operating systems pointers and 
integers occupy the same storage space, but on Digital UNIX this is not
the case (int=32bit, pointer=64bit) and the definition is incorrect.
Should the F90 interface really need to know the format of internal NeXus
C data structures? It strikes me that we may be making problems for
ourselves 
... what we should instead do is have a few "extractor" functions for any
bit of 
a "NexusFile" structure that may be needed ... you could call these
functions
safely from FORTRAN with the opaque NexusFile structure and get the bits you

need.

I also noticed NXgetgroupinfo() is a "core NeXus API" function in F90, but
not implemented in C or F77. I would think the "core API" should be the same
for all languages, so we should implement functions such as this in C/F77
before
releasing (or maybe make them part of NXU?)

Freddie

-----Original Message-----
From: Ray Osborn [mailto:ROsborn at anl.gov]
Sent: 11 October 1999 16:44
To: NAPI at isise.rl.ac.uk; F.A.Akeroyd at RL.AC.UK
Subject: Re: Proposed rearrangement of "struct NeXusFile"


Ironically, the SEQUENCE command in the F90 derived type was inserted to 
improve portability.  The internal details of the NXhandle structure are
only used in the NXU F90 routines to reset the index in certain directory
searches, so unfortunately, the standard test routines won't show them up.
They only test the core NX routines.  However, NXbrowse does make use of
them, so it can provide the test.

If you are convinced that the natural alignment will make work, I certainly
have no objection.  Do you want me to update NXmodule.f90 or should I leave
that to you?

Regards,
Ray
--
Dr Ray Osborn                Tel: +1 (630) 252-9011
Materials Science Division   Fax: +1 (630) 252-7777
Argonne National Laboratory  E-mail: ROsborn at anl.gov
Argonne, IL 60439-4845


> The order of elements in the definition of "struct NexusFile" are such
that
> the
> structure is not naturally aligned, and this has caused a problem with
Ray's
>
> F90 NXbrowse as the F90 definition did not match up with the C one. I
> propose
> that we rearrange the structure to make it "naturally aligned" as far as
> possible.
> This would only break code that relied on a structure member being at a
> given
> byte offset, which i don't believe exists. The rearranged structure would
> look something
> like this:
>
>    typedef struct __NexusFile {
>     struct iStack {
>       int32 *iRefDir;
>       int32 *iTagDir;
>       int32 iVref;
>       int32 __iStack_pad;               /* for 64 bit alignment */
>       int iNDir;
>       int iCurDir;
>     } iStack[NXMAXSTACK];
>     struct iStack iAtt;
>     int32 iVID;
>     int32 iSID;
>     int32 iCurrentVG;
>     int32 iCurrentSDS;
>     int iNXID;
>     int iStackPtr;
>     char iAccess[2];
>   } NexusFile, *pNexusFile;
>
> Anybody any thoughs?
>
> Freddie



More information about the NeXus-developers mailing list