| 1 | The NAPI FORTRAN interface consists of wrapper routines (napif.f) and |
|---|
| 2 | an include file of definitions (napif.inc). The routines are called |
|---|
| 3 | exactly like their C counterparts, but the setup for NXHandle |
|---|
| 4 | and NXlink structures is done slightly differently (see the |
|---|
| 5 | example program "napif_test.f") |
|---|
| 6 | |
|---|
| 7 | For a NXhandle, you use: |
|---|
| 8 | |
|---|
| 9 | INTEGER FILEID(NXHANDLESIZE) |
|---|
| 10 | |
|---|
| 11 | And for an NXlink |
|---|
| 12 | |
|---|
| 13 | INTEGER LINK(NXLINKSIZE) |
|---|
| 14 | |
|---|
| 15 | --- Running the Examples --- |
|---|
| 16 | |
|---|
| 17 | The Fortran 77 library is now built by the standard Makefile. See the |
|---|
| 18 | README file for installation instructions. |
|---|
| 19 | |
|---|
| 20 | The test program, napif_test, should print the following: |
|---|
| 21 | |
|---|
| 22 | Number of global attributes: 4 |
|---|
| 23 | NeXus_version = 2.0.0. |
|---|
| 24 | file_name = NXtest.nxs |
|---|
| 25 | HDF5_Version = 1.4.3 |
|---|
| 26 | file_time = 2002-05-17 14:40:24-0600 |
|---|
| 27 | Group: entry(NXentry) contains 8 items |
|---|
| 28 | ch_data( 4) |
|---|
| 29 | Values : NeXus data |
|---|
| 30 | Subgroup: data(NXdata) |
|---|
| 31 | i1_data(20) |
|---|
| 32 | Values : 1 2 3 4 |
|---|
| 33 | i2_data(22) |
|---|
| 34 | Values : 1000 2000 3000 4000 |
|---|
| 35 | i4_data(24) |
|---|
| 36 | Values : 1000000 2000000 3000000 4000000 |
|---|
| 37 | r4_data( 5) |
|---|
| 38 | Values : 1.00 2.00 3.00 4.00 |
|---|
| 39 | : 5.00 6.00 7.00 8.00 |
|---|
| 40 | : 9.00 10.00 11.00 12.00 |
|---|
| 41 | : 13.00 14.00 15.00 16.00 |
|---|
| 42 | : 17.00 18.00 19.00 20.00 |
|---|
| 43 | r8_data( 6) |
|---|
| 44 | Values : 1.00 2.00 3.00 4.00 |
|---|
| 45 | : 5.00 6.00 7.00 8.00 |
|---|
| 46 | : 9.00 10.00 11.00 12.00 |
|---|
| 47 | : 13.00 14.00 15.00 16.00 |
|---|
| 48 | : 17.00 18.00 19.00 20.00 |
|---|
| 49 | ch_attribute : NeXus |
|---|
| 50 | i4_attribute : 42 |
|---|
| 51 | r4_attribute : 3.141593 |
|---|
| 52 | Subgroup: sample(NXsample) |
|---|
| 53 | Link Check OK |
|---|
| 54 | |
|---|
| 55 | A file called "NXtest.nxs" is also created. |
|---|
| 56 | |
|---|
| 57 | *** FORTRAN Interface Notes *** |
|---|
| 58 | |
|---|
| 59 | - NAPIF.F uses the non-standard type specification BYTE to convert Fortran |
|---|
| 60 | character data to C strings. There is no method of specifying single-byte |
|---|
| 61 | storage under the Fortran 77 standard, but if the BYTE specification is |
|---|
| 62 | not allowed by your Fortran compiler, please try one of the other common |
|---|
| 63 | compiler extensions, e.g., INTEGER*1, LOGICAL*1. |
|---|
| 64 | |
|---|
| 65 | - There are separate routines for reading and writing character data |
|---|
| 66 | and attributes (NXGETCHARDATA, NXGETCHARATTR, NXPUTCHARDATA, NXPUTCHARATTR). |
|---|
| 67 | This is necessary because character strings are passed by descriptor rather |
|---|
| 68 | than by reference. |
|---|
| 69 | |
|---|
| 70 | - If you don't wish to use these routines, it is possible to pass character |
|---|
| 71 | data to the C interface using the regular routines (i.e. NXGETDATA etc) |
|---|
| 72 | by forcing the string arguments to be passed by reference. Either |
|---|
| 73 | equivalence the string to a BYTE array or use the %REF (or equivalent) |
|---|
| 74 | function. It does not appear to be necessary to null-terminate the strings |
|---|
| 75 | since the string length, passed to the HDF file, does not include the |
|---|
| 76 | terminator. |
|---|
| 77 | |
|---|
| 78 | -- |
|---|
| 79 | Freddie Akeroyd |
|---|
| 80 | ISIS Facility |
|---|
| 81 | Rutherford Appleton Laboratory |
|---|
| 82 | Chilton, Didcot, OX11 OQX, GB |
|---|
| 83 | |
|---|
| 84 | Email: Freddie.Akeroyd@rl.ac.uk |
|---|
| 85 | |
|---|
| 86 | $Id$ |
|---|