NEFIS Programming Manual NEFIS_User_Manual User

User Manual: Pdf NEFIS_User_Manual

Open the PDF directly: View PDF PDF.
Page Count: 68

DownloadNEFIS Programming Manual NEFIS_User_Manual User
Open PDF In BrowserView PDF
3D/2D modelling suite for integral water solutions

DR
AF

T

Delft3D

NEFIS

User Manual

DR
AF
T

T

DR
AF

NEFIS Library

Neutral File System for data storage and retrieval

User Manual

Version: 5.00
SVN Revision: 50387
April 18, 2018

DR
AF

T

NEFIS Library, User Manual

Published and printed by:
Deltares
Boussinesqweg 1
2629 HV Delft
P.O. 177
2600 MH Delft
The Netherlands

For sales contact:
telephone: +31 88 335 81 88
fax:
+31 88 335 81 11
e-mail:
software@deltares.nl
www:
https://www.deltares.nl/software

telephone:
fax:
e-mail:
www:

+31 88 335 82 73
+31 88 335 85 82
info@deltares.nl
https://www.deltares.nl

For support contact:
telephone: +31 88 335 81 00
fax:
+31 88 335 81 11
e-mail:
software.support@deltares.nl
www:
https://www.deltares.nl/software

Copyright © 2018 Deltares
All rights reserved. No part of this document may be reproduced in any form by print, photo
print, photo copy, microfilm or any other means, without written permission from the publisher:
Deltares.

Contents

Contents
v

1 Introduction
1.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Comments on the use of NEFIS . . . . . . . . . . . . . . . . . . . . . . . .

1
1
1

2 Definitions
2.1 Element definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Cell definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Group definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3
3
3
3

3 Data handling
3.1 Accessing data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Data conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Error handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5
5
5
5

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

DR
AF

4 API to NEFIS functions
4.1 Clsnef . . . . . .
4.2 Credat . . . . . .
4.3 Crenef . . . . . .
4.4 Defcel . . . . . .
4.5 Defelm . . . . . .
4.6 Defgrp . . . . . .
4.7 Flsdat . . . . . . .
4.8 Flsdef . . . . . . .
4.9 Getels/Getelt . . .
4.10 Gethdf . . . . . .
4.11 Gethdt . . . . . .
4.12 Getiat . . . . . . .
4.13 Getnfv . . . . . .
4.14 Getrat . . . . . . .
4.15 Getsat . . . . . .
4.16 Inqcel . . . . . . .
4.17 Inqdat . . . . . . .
4.18 Inqelm . . . . . .
4.19 Inqfcl/Inqncl . . . .
4.20 Inqfel/Inqnel . . .
4.21 Inqfgr/Inqngr . . .
4.22 Inqfia/Inqnia . . .
4.23 Inqfra/Inqnra . . .
4.24 Inqfsa/Inqnsa . . .
4.25 Inqfst/Inqnxt . . .
4.26 Inqgrp . . . . . .
4.27 Inqmxi . . . . . .
4.28 Neferr . . . . . . .
4.29 Putelt/Putels . . .
4.30 Putiat . . . . . . .
4.31 Putrat . . . . . . .
4.32 Putsat . . . . . .

T

List of Tables

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

7
8
8
9
10
11
12
13
14
15
16
17
18
19
19
20
21
22
22
24
25
26
27
28
29
30
31
32
32
33
34
35
36

A Example of a data structure

39

B Error/Warning numbers

41

Deltares

iii

NEFIS Library, User Manual

C Demonstration programs
45
C.1 Demonstration program 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
C.2 Demonstration program 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

T

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

55
55
55
55
55
56
56
56
56
56
56
56
57
57

DR
AF

D Release notes
D.1 Differences between Version 5.00 and 4.00
D.2 Differences between Version 4.00 and 3.10
D.2.1 Improvements . . . . . . . . . .
D.2.2 New functions . . . . . . . . . .
D.2.3 Outdated functions . . . . . . . .
D.2.4 Unavailable functions . . . . . . .
D.3 Differences between Version 3.10 and 3.00
D.3.1 Improvements . . . . . . . . . .
D.3.2 New functions . . . . . . . . . .
D.4 Differences between Version 3.00 and 2.00
D.4.1 Improvements . . . . . . . . . .
D.4.2 New functions . . . . . . . . . .
D.4.3 Outdated functions . . . . . . . .

iv

Deltares

List of Tables

List of Tables
Supported basic types

. . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

DR
AF

T

2.1

Deltares

v

DR
AF

T

NEFIS Library, User Manual

vi

Deltares

1 Introduction
1.1

General

1.2

DR
AF

T

NEFIS is a library of functions designed for scientific programs. These programs are characterised by their large volume of input and output data. NEFIS is able to store and retrieve large
volumes of data on file or in shared memory. To achieve a good performance when storing
and retrieving data, the files are self-describing binary direct access files. Furthermore one of
the array dimensions may be variable and the sequence on the file can be prescribed. NEFIS
also allows users to store data in a machine-independent way on files, which means that the
data files can be interchanged between computer systems without having to be converted.
Data within NEFIS is divided into a hierarchical structure of groups, cells and elements. This
hierarchical structure is used to find the location in the file where the data should be stored or
retrieved. An element is the smallest unit which can be accessed at one time. One or more
elements make up a cell; and a group is defined as one or more dimensional arrays of cells.
This shows the logical cohesion of the data to be represented. Flags (in this context referred
as attributes) can be attached to groups as desired. These attributes can, for example, define a match between groups. They may also contain superscripts and subscripts for graphic
design. NEFIS can exist of one file for input and retrieval of data (i.e. a definition and a data
part). The previous NEFIS version needed two files for input and retrieval of data (i.e. a data
file and a definition file). A data file contains the data supplied by the user and the attributes
that have been added. The definition file contains the description of the structure. The relationship between a data file and a definition file is determined by the application. This means
that one definition file can be used by various data files. The opposite is also possible (i.e. a
data file can be used from different definition files). More over, a well-defined definition file is
able to scope all data files of a company.
Comments on the use of NEFIS

In almost all cases calling up a NEFIS function involves the use of a file descriptor. This file
descriptor is a integer value which is used by the NEFIS function to determined which files
need to be accessed. All NEFIS functions return an integer∗4 value representing an error
code. In the description of the functions, FORTRAN 77 notation is used to indicate the length
of arrays. An array A with N elements is therefore given as follows: A(1 : N ). A ’dummy’
must be entered for a parameter in several functions. The value represents the size of the
memory that is available to store data. Not all data is written to the files after every operation;
parts are buffered. The functions Flsdef and Flsdat are available to compel these buffers to be
written to the file. It is then prudent to call these functions up after writing data. The function
Clsnef writes these buffers to the files depending on the access type, the functions Clsdat
and Clsdef also write these buffers to the files. The Cldtnf and Cldfnf functions do not write
these buffers to the files and therefor the timestamp will not be changed if nothing is written
to file. The functions Clsdat, Clsdef, Cldtnf and Cldfnf should be used if the functions Opndat
and Opndef are used. To overcome the problem of two types of functions to close the NEFIS
files the combination of Crenef and Clsnef function should be used, these functions take into
account the accesstype of the files.

Deltares

1 of 60

DR
AF

T

NEFIS Library, User Manual

2 of 60

Deltares

2 Definitions
2.1

Element definition
An element is the smallest unit, which can be accessed at one time. An element is a single
variable, or one or more dimensional array of single variables with fixed limits. The type,
dimensions, etc., of the element are fixed in a so-called element definition which is being
stored in the definition file.
The definition of an element consists of:
a unique name
the type of the element
the size of the single variable (in bytes) of which the element is made up
the number of dimensions (0 for a single variable)
the dimensions (for an array of single variables)
meta data which state the quantity, unit and the description of the element

T








DR
AF

The following "basic" types are permitted in NEFIS (given for C and Fortran 77):
Table 2.1: Supported basic types

2.2

Size [bytes]

C

Fortran

4
8
2
4
8
2
4
1
2∗4
2∗8

Float
Double
Short
Int
Long
Short
Int
Char
2 ∗ float
2 ∗ double

REAL∗4
REAL∗8
INTEGER∗2
INTEGER∗4
–
LOGICAL∗2
LOGICAL∗4
CHARACTER∗1
COMPLEX∗8
COMPLEX∗16

Cell definition

A cell consists of combination of one or more elements whose type may differ. This combination is fixed in a so-called cell definition that is stored in the definition file/part. In the cell
definition the elements which make up the cell are fixed as well as their storage sequence.
Once a cell has been defined it has a fixed size. Each cell definition has a unique name.
2.3

Group definition
A group consists of one or more dimensional arrays of cells. One of the dimensions may be
variable. The description of the group is fixed in a so-called group definition, which is stored
in the definition file/part. The storage sequence needs to be defined in the case of multidimensional structures. This storage sequence defines which index must count first (most
rapidly), which index must count second, etc.

Deltares

3 of 60

DR
AF

T

NEFIS Library, User Manual

4 of 60

Deltares

3 Data handling
3.1

Accessing data

3.2

DR
AF

T

Data is written to and retrieved from file by means of a group name. Before data can be
accessed, the group name must be defined on the data file. At that moment space is reserved
for the data and for a number of attributes. NEFIS allows you to define several different group
names with the same group definition. When the group has been defined, the data can be
accessed using the group name and the element name as defined in the cell. The desired
dimensions of a group can be specified. Remember that an element is the smallest unit that
can be accessed. A buffer is used when data is stored or retrieved. The physical arrangement
of data in this buffer must correspond with the way in which the cells are defined. When for
example a cell is defined with REAL velocity components (u, v, w), then the values for the
elements of this cell must also appear in the same order in the buffer. The type of buffer is
of no importance for NEFIS functions and is determined by the user. For this reason, in the
description of functions the type of buffer is given as "void". Data can be written and read.
Data can also be altered (overwritten), but cannot be removed. Definitions can be written and
read, but cannot be altered (overwritten) or removed.
Data conversion

Where files have to be used on several different computer systems, they may be stored in a
standardised neutral (ANSI/IEEE 754) representation using xdr-routines if the variables occupy more than 4 bytes. Characters (CHARACTER∗1) are written directly to file. Integers
and logicals (INTEGER∗2 and LOGICAL∗2) are handled by a NEFIS routine. This is done by
giving the value "N" when the files are created with function "Crenef" via the CODING parameter. This enables the data to be correctly converted when written. If the data is subsequently
entered into another system, it is converted back into the relevant machine representation. If
the coding parameter is not a "N" while creating the NEFIS files the data will not be converted
and is written directly to file. Proposed coding value is than "B" (binary). When reading a
NEFIS the best choice is to assign a blank (" ") as coding value, this means that the coding
type is read from file.
3.3

Error handling

All NEFIS functions are INTEGER∗4 functions. The functions give a return value equal to 0
when the function has been completed without an error. If the value is not equal to 0, the
function has ended abnormally and the corresponding error message can be obtained with
the function Neferr.

Deltares

5 of 60

DR
AF

T

NEFIS Library, User Manual

6 of 60

Deltares

4 API to NEFIS functions
The functions currently available in NEFIS to manipulate descriptions and data are given
below in alphabetical order:
Definition

4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
4.9
4.10
4.11
4.12
4.14
4.15
4.16
4.17
4.18
4.19
4.20
4.21
4.22

Close a NEFIS data and definition file
Declare a data group in the data file
Create a NEFIS data and definition file
Define a cell
Define an element
Define a group
Flush buffers to the data file
Flush buffers to the definition file
Read one or all string elements from the data file
Read one or all alpha numeric elements from the data file
Give information from the header of a NEFIS definition file
Give information from the header of a NEFIS data file
Read an integer attribute from the data group
Read a real attribute from the data group
Read a character attribute from the data group
Read a cell definition
Read a group definition name from a data group
Read an element definition
Read the first cell name on a definition file
Read the first element from the definition file
Read the first group from the definition file
Read the first name and corresponding value of the integer attributes of a
given data group
Read the first name and corresponding value of the real attributes of a
given data group
Read the first name and corresponding value of the character attributes of
a given data group
Read the first data group name and definition name from the data file
Read the group definition
Determine the maximum used index of a data group with free dimension
Read the next cell name on the definition file
Read the first element from the definition file
Read the next group from the definition file
Read the next name and corresponding value of the integer attributes of a
given data group
Read the next name and corresponding value of the real attributes of a
given data group
Read the next name and corresponding value of the character attributes of
a given data group
Read the next data group name
Retrieve an error message
Write one or more character elements to the data file
Write one or more elements to the data file
Write an integer attribute to the data group
Write a real attribute to the data file
Write a character attribute to the data file

DR
AF

T

Name

4.23
4.24
4.25
4.26
4.27
4.19
4.20
4.21
4.22
4.23
4.24
4.25
4.28
4.29
4.29
4.30
4.31
4.32

Deltares

7 of 60

NEFIS Library, User Manual

The following sections contain a detailed description of NEFIS functions.
4.1

Clsnef
Description
Close the data and definition file. Depending on the access type the output buffers will be
written to the files before closing the files.
Syntax
error = Clsnef (fd_nefis)
Parameters
type

error

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

DR
AF

input
output

input/output
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
Set to -1, if function is successful

T

fd_nefis

type

=0
6= 0

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
4.2

Credat

Description
Declare a data group in the data file.

Syntax
error = Credat (fd_nefis, grpnam, grpdef)
Parameters
fd_nefis

type

input

grpnam
type
input

grpdef
type

8 of 60

input
c
int
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
input
c
char ∗
Fortran
character∗16
Name of the data group to be created. This name must be unique
to the data file.
input
c
Fortran

char ∗
character∗16

Deltares

API to NEFIS functions

input

error
type

=0
6= 0

Name of the group definition to be used for this data group. This
group definition must already be defined on the definition file (see
function Defgrp 4.6).
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

T

Remarks:

 Space is reserved on the data file, but this space is not initialised.
 For data groups with a variable dimension the space is only then reserved when the data

4.3

DR
AF

is being written.
Crenef

Description
Create or open a NEFIS data and definition file

Syntax
error = Crenef (fd_nefis, dat_name, def_name, coding, access)
Parameters
fd_nefis

type

input
output

dat_name

type

input

def_name

type

input

coding
type

= ’B’
= ’L’
6= ’B’ or

input/output
c
int ∗
Fortran
integer∗4
NEFIS file descriptor
Set to -1, if function is unsuccessful

input
c
char ∗
Fortran
character(len=∗)
Name of the data file, maximum file name length is 256 characters.
input
c
char ∗
Fortran
character(len=∗)
Name of the definition file, maximum file name length is 256 characters.
input
c
char[1]
Fortran
character(len=1)
big-endian representation of the data, we called it neutral representation
little-endian representation of the data
Endianess-representation is taken from the machine

’L’

Deltares

9 of 60

NEFIS Library, User Manual

If the data file does not exist, this is an input parameter stating whether the data
in the file have to be converted into the big-endian (IEEE-754) representation.
Where the data file does already exist, this is an output parameter stating
whether or not the data in the file are already in neutral representation.

type

= ’c’
= ’r’
= ’u’
error
type

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

DR
AF

=0
6= 0

input
c
char
Fortran
character(len=1)
create a NEFIS file set, existing NEFIS file will be deleted
read only access of the NEFIS file set
update of the NEFIS file set, write and read access of the NEFIS
file set.

T

access

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
4.4

Defcel

Description
Define a cell

Syntax
error = Defcel (fd_nefis, celnam, nelems, elmnms)
Parameters
fd_nefis

type

input

celnam

type

input

nelems
type
input
elmnms
type

10 of 60

input
c
int
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
input
c
char ∗
Fortran
character(len=16)
Name of the cell to be defined.

input
c
int ∗
Fortran
integer∗4
Number of elements in this cell.
input
c
Fortran

int ∗
integer∗4

Deltares

API to NEFIS functions

input

error
type

=0
>0

Array(1:NELEMS) with the names of the elements which make
up this cell. The element names must already be defined. (see
function Defelm 4.5). The sequence of the names in this array is
also the physical order in which the data in the buffer are expected
when reading and writing entire cells.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Defelm
Description
Define an element.

DR
AF

4.5

T

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

Syntax
error = Defelm (fd_nefis, elmnam, elmtyp, nbytsg, elmqty, elmunt, elmdes, elmndm, elmdms)
Parameters
fd_nefis

type

input

elmnam

type

input

elmtyp

type

input

nbytsg
type
input

elmqty
type
input
elmunt

Deltares

input
c
int
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
input
c
char ∗
Fortran
character(len=16)
Name for the element to be defined.

input
c
char ∗
Fortran
character(len=8)
Type of element. The following types can be used: REAL, INTEGER, LOGICAL, CHARACTE(R) and COMPLEX.
input
c
int
Fortran
integer∗4
The size in bytes of a single variable of this type. For example, this
is usually 4 for an element that will contain real values.
input
c
char ∗
Fortran
character(len=16)
The quantity of this element.
input

11 of 60

NEFIS Library, User Manual

input
elmdes
type
input
elmndm
type
input

elmdms
type

error

input
c
char ∗
Fortran
character(len=64)
The description of this element.
input
c
int
Fortran
integer∗4
The number of dimensions of this element. This is 0 for a single
element. For elements other than single elements, the number of
dimensions may be from 1 to 5.
input
c
int ∗
Fortran
integer∗4
This is an array(1:ELMNDM) with the dimension for an element
other than a single element. The sequence and the size of the
values in this array determine the structure of the element. For
a single element, this value may be 0. The dimensions must be
larger than 0 for an array. The correctness of the dimensions is
not being checked.

DR
AF

input

c
char ∗
Fortran
character(len=16)
The unit of this element.

T

type

type

=0
>0

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
4.6

Defgrp

Description
Define a group on the definition file.

Syntax
error = Defgrp (fd_nefis, grpnam, celnam, grpndm, grpdms, grpord)
Parameters
fd_nefis
type
input
grpnam
type

12 of 60

input
c
int
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
input
c
Fortran

char ∗
character(len=16)

Deltares

API to NEFIS functions

celnam
type
input

grpndm
type
input

grpdms
type

input
c
char ∗
Fortran
character(len=16)
Name of the cell with which this group is made up. This cell must
already be defined (see function Defcel 4.4).
input
c
int ∗
Fortran
integer∗4
The number of dimensions of this group. The number of dimensions may be 0 for a group with only 1 cell. The maximum number
of dimensions is 5.
input
c
int ∗
Fortran
integer∗4
This is an array(1:GRPNDM) with the dimensions. One of the dimensions may be 0 which number indicates the part that is variable. The correctness of the dimensions is not being checked.

DR
AF

input

Name for the group to be defined.

T

input

grpord

type

input

error

type

=0
>0

input
c
int ∗
Fortran
integer∗4
This is an array(1:GRPNDM) which gives the order in which the
cells must be written to the data file (which index runs most rapidly,
which runs next most rapidly etc.). The sequence which operates
in FORTRAN for a multi-dimensional array is 1, 2, 3, etc.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 The group order array (grpord) allows you to write data to a file in a several different
order. The best possible performance is achieved by selecting a sequence which is
the same as that in which the data will usually be retrieved later. For example, where
it is necessary to store precipitation observations which are made on a daily basis in
various locations and where the pattern of access to these observations is normally
that all locations call them up at a specific time, it is advisable to arrange for the counter
giving the locations to open more rapidly than the others. This parameter is dummy
where the number of dimensions is 0 or 1.
4.7

Flsdat
Description
Flush the buffers to the data file.

Deltares

13 of 60

NEFIS Library, User Manual

Syntax
error = Flsdat (fd_nefis)
Parameters
type
input
error
type

=0
>0

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

T

fd_nefis

DR
AF

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 It is prudent to use this function after writing data to the file, because otherwise if the application ends abnormally the data is present on the file but can no longer be accessed.
The Clsnef function also writes the buffers to the file.
4.8

Flsdef

Description
Flush the buffers to the definition file.
Syntax
error = Flsdef (fd_nefis)
Parameters
fd_nefis

type

input

error

type

=0
>0

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 It is prudent to use this function after writing the definition file, because otherwise if the
application ends abnormally the definitions is present on the file but can no longer be
accessed. The Clsnef function also writes the buffers to the file.

14 of 60

Deltares

API to NEFIS functions

Getels/Getelt
Description
Read one or all (same kind) elements from a group on a data file. Getels is used for string
values and Getelt is used for alpha-numeric values.
Syntax
error = Getels (fd_nefis, grpnam, elmnam, uindex, usrord, buflen, buffer)
error = Getelt (fd_nefis, grpnam, elmnam, uindex, usrord, buflen, buffer)
Parameters
type
input
grpnam
type
input

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

T

fd_nefis

input
c
char ∗
fortran
character∗16
Name of the data group of which one or more elements must e
read.

DR
AF

4.9

elmnam

type

input

uindex

type

input

usrord

type

input

buflen
type
input
buffer
type

Deltares

input
c
char ∗
fortran
character∗16
Name of the element which is to be read. When Elmnam = ’∗’, this
means that all elements must be read.
input
c
int ∗ Uindex[][3]
fortran
integer Uindex(3,)
This array contains information on the indices of the cells that must
be run. For each dimension of the data group three numbers must
be given, namely the start index, the end index and the step size.
input
c
int ∗ Usrord[]
fortran
integer Usrord()
This is an array (1:GRPDNM) which determines the sequence in
which the cells must be run. This is achieved by stating which
index runs most rapidly, which runs next most rapidly etc.) With
this the "view" of a group can be changed provided that also the
buffer is filled in this sequence.

input
c
int ∗
fortran
integer
Size in bytes of the available buffer.
output
c
fortran

void
void

15 of 60

NEFIS Library, User Manual

output

error
type

=0
>0

Buffer in which the values of the cells concerned are written
(strings and numbers). When the buffer is used to receive strings,
it also possible to use the function Getels.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

T

Remarks:
 If a character string/array is retrieved by a c/c++ program no ’\0’ is added to the string
or array item. This is because the NEFIS library does not recognize the single item, it
is just reading the bites.

DR
AF

 How parameter UINDEX works can best be presented by an example: Suppose you
have defined with Defgrp a group with dimensions (20,13) and reversed the array with
parameter USRORD towards (13, 20). With the following values in UINDEX:
UINDEX(1-3,1) = 1, 13, 3
UINDEX(1-3,2) = 5, 20, 5

then the cells will be run in the following sequence:
[ 5,1]
[10,1]
[15,1]
[20,1]

[ 5,4]
[10,4]
[15,4]
[20,4]

[ 5,7]
[10,7]
[15,7]
[20,7]

[ 5,10]
[10,10]
[15,10]
[20,10]

[ 5,13]
[10,13]
[15,13]
[20,13].

The given indices must be within the defined limits. Obviously, for indices of the variable
dimension (see Defgrp 4.6) this restriction does not hold. The step size must be positive.

4.10

Gethdf

Description
Give information from the header of a definition file.
Syntax
c: error = Gethdf (fd_nefis, header)
Parameters
fd_nefis
type
input
header
type

16 of 60

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
input
c
fortran

char ∗ [128+1]
character∗128

Deltares

API to NEFIS functions

input

error
type

=0
>0

In this string the information from the file header is being put.
Among other things this information contains the name of the system upon which the file is being created and whether or not the
data representation is neutral (ANSI/IEEE 754). When using two
separated NEFIS files for data and definition the size of the header
can be 60 instead of 128.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

T

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

4.11

DR
AF

Remark:
 If the header is retrieved by a c/c++ program no ’\0’ is added to the string
Gethdt

Description
Give information from the header of a data file.
Syntax
error = Gethdt (fd_nefis, header)
Parameters
fd_nefis

type

input

header

type

input

error
type

=0
>0

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

input
c
char ∗
fortran
character∗128
In this string information from the file header is being put. Among
other things this information contains the name of the system upon
which the file is being created and whether or not the data representation is neutral (ANSI/IEEE 754). When using two separated
NEFIS files for data and definition the size of the header can be
60 instead of 128.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

Deltares

17 of 60

NEFIS Library, User Manual

Remark:
 If the header is retrieved by a c/c++ program no ’\0’ is added to the string
Getiat
Description
Read an integer attribute from a data group.
Syntax
error = Getiat (fd_nefis, grpnam, attnam, attval)
Parameters
type
input
grpnam

type

input

attnam

type

input

attval

type

input

error

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

T

fd_nefis

input
c
char ∗
fortran
character∗16
Name of the data group from which an integer attribute is to be
read.

DR
AF

4.12

type

=0
>0

input
c
char ∗
fortran
character∗16
Name of the attribute (see function Putiat 4.30).
output
c
int ∗
Fortran
integer∗4
Attribute value.

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 See also the functions Inqfia and Inqnia 4.22.

18 of 60

Deltares

API to NEFIS functions

4.13

Getnfv
Description
Returns the full version number of the NEFIS library.
Syntax
error = Getnfv (nef_version)
Parameters
type
input

error
type

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

DR
AF

=0
>0

output
c
char ∗∗
fortran
character∗
In this string the full version number of the NEFIS library is returned.

T

nef_version

The corresponding error message can not be retrieved with the function Neferr.
Example:

@(#)Deltares, NEFIS Version 5.07.02.3965M, Aug 4 2014, 20:09:15

4.14

Getrat

Description
Read a real attribute from a data group.

Syntax
error = Getrat (fd_nefis, grpnam, attnam, attval)
Parameters
fd_nefis

type

input

grpnam
type
input

attnam
type
input

Deltares

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

input
c
char ∗
fortran
character∗16
Name of the data group from which an integer attribute is to be
read.
input
c
char ∗
fortran
character∗16
Name of the attribute (see function Putrat 4.31).

19 of 60

NEFIS Library, User Manual

attval
type
output
error
type

=0
>0

output
c
float ∗
fortran
real∗4
Attribute value.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

4.15

Getsat

DR
AF

Remark:
 See also the functions INQFRA and INQNRA.

T

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

Description
Read a string attribute from a data group.

Syntax
error = Getsat (fd_nefis, grpnam, attnam, attval)
Parameters
fd_nefis

type

input

grpnam

type

input

attnam

type

input
attval
type
output
error
type

=0
>0

20 of 60

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

input
c
char ∗
fortran
character∗16
Name of the data group from which an integer attribute is to be
read.
input
c
char ∗
fortran
character∗16
Name of the attribute (see function Putrat 4.31).
output
c
char ∗
fortran
character∗16
Attribute value.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Deltares

API to NEFIS functions

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remarks:
 If string attribute is retrieved by a c/c++ program no ’\0’ is added to the string
 See also the functions Inqfsa and Inqnsa 4.24.
Inqcel
Description
Read a cell definition from the definition file

T

Syntax
error = Inqcel (fd_nefis, celnam, nelems, elmnms)
Parameters
fd_nefis
type

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

DR
AF

4.16

input

celnam

type

input

nelems

type

input

output

elmnms

type

error

type

=0
>0

input
c
char ∗
fortran
character∗16
Name of the cell to be defined.

input/output
c
int ∗
Fortran
integer∗4
current length of array ELMNMS, value will be
checked against number of elements in this cell definition
the number of elements used in this cell definition

output
c
char ∗ elmnms[nelems][16+1]
fortran
character∗16 elmnms(nelems)
An array (1:NELEMS) with the names of the elements used in this cell definition.

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

Deltares

21 of 60

NEFIS Library, User Manual

4.17

Inqdat
Description
Read corresponding group definition from the data group.
Syntax
error = Inqdat (fd_nefis, grpnam, grpdef)
Parameters
type
input
grpnam
type

grpdef

type

output

error

input
c
char ∗
fortran
character∗16
Name of the data group of which the definition name is to be read.
output
c
char ∗
fortran
character∗16
Name of the definition used for this data group.

DR
AF

input

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

T

fd_nefis

type

=0
>0

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
4.18

Inqelm

Description
Read an element definition from the definition file.

Syntax
error= Inqelm (fd_nefis, elmnam, elmtyp, nbytsg, elmqty, elmunt, elmdes, elmndm, elmdms)
Parameters
fd_nefis
type
input
elmnam
type
input

22 of 60

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
input
c
char ∗
fortran
character∗16
Name of the element whose definition is to be read.

Deltares

API to NEFIS functions

type
output
nbytsg
type
output
elmqty
type
output
elmunt
type

output
c
int
Fortran
integer∗4
The size in bytes of a single variable of the element.
output
c
char ∗
fortran
character∗16
The quantity of this element.
output
c
char ∗
fortran
character∗16
The unit of this element.

DR
AF

output

output
c
char ∗
fortran
character∗8
Type of element.

T

elmtyp

elmdes

type

output

elmndm

type

input

output

elmdms

type

output

error

type

=0
>0

output
c
char ∗
fortran
character∗64
The description of this element.

input/output
c
int ∗
Fortran
integer∗4
Current length of array ELMDMS, value will be checked against
number of dimensions of this element. Because ELMNDM is not
known in advance, it is recommended that the current length of
this array be set at the maximum value (=5).
The number of dimensions of this element (maximum 5).
output
c
int
Fortran
integer∗4
This is an array(1:ELMNDM) with the dimension for an element
other than a single element.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

Deltares

23 of 60

NEFIS Library, User Manual

Inqfcl/Inqncl
Description
Read the first and next cell name, dimension, size in bytes and containing element names
from the definition file.
Syntax
error = Inqfcl (fd_nefis, celnam, nelems, bytes, elmnms)
error = Inqncl (fd_nefis, celnam, nelems, bytes, elmnms)
Parameters
type
input
celnam
type
output

nelems

type

input

output

bytes

type

output

elmnms

type

output

error

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

T

fd_nefis

output
c
char ∗
fortran
character∗16
Name of the cell for which data is retrieved.
output
c
int ∗
Fortran
integer∗4
Current length of array ELMNMS, value will be checked against
number of elements in this cell definition.
The number of elements used in this cell definition.

DR
AF

4.19

type

=0
>0

output
c
int ∗
Fortran
integer∗4
Length of the cell in bytes.

output
c
char ∗ elmnms[nelems][16+1]
fortran
character∗16 elmnms(nelems)
Array(1:NELEMS) with the names of the elements which make
up this cell. The element names must already be defined. (see
function Defelm 4.5) The sequence of the names in this array is
also the physical order in which the data in the buffer are expected
when reading and writing entire cells.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 The elmnms array is a character array, the ’\0’ is not added to the array items when
retrieving the array.

24 of 60

Deltares

API to NEFIS functions

Inqfel/Inqnel
Description
Read the first and next element from the definition file.
Syntax
error = Inqfel (fd_nefis, elmnam, elmtyp, elmqty, elmunt, elmdes, bytes, numbyt, elmndm,
elmdms)
error = Inqnel (fd_nefis, elmnam, elmtyp, elmqty, elmunt, elmdes, bytes, numbyt, elmndm,
elmdms)
Parameters
type
input
elmnam
type

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
output
c
char ∗
fortran
character∗16
Name of the element.

T

fd_nefis

DR
AF

4.20

output

elmtyp

type

output

elmqty

type

output

elmunt

type

output

elmdes

type

output

bytes
type
output

numbyt
type

Deltares

output
c
char ∗
fortran
character∗8
Type of element. An element can be one of the following types:
REAL, INTEGER, LOGICAL, CHARACTE(R) or COMPLEX.
output
c
char ∗
fortran
character∗16
The quantity of the element.
output
c
char ∗
fortran
character∗16
The unit of the element.

output
c
char ∗
fortran
character∗64
The description of the element.

output
c
int ∗
Fortran
integer∗4
The size in bytes of a single variable of this type. For example, this
is usually 4 for an element that will contain real values.
output
c
Fortran

int ∗
integer∗4

25 of 60

NEFIS Library, User Manual

elmndm
type
input

output

elmdms
type

error

output
c
int ∗
Fortran
integer∗4
current length of array ELMDMS, value will be checked against
number of dimensions of this element. Because ELMNDM is not
known in advance, it is recommended that the current length of
this array be set at the maximum value (=5).
the number of dimensions of the element. The number of dimensions may be from 1 to 5.
output
c
int ∗
Fortran
integer∗4
This is an array(1:ELMNDM) with the dimension for an element.
The sequence and the size of the values in this array determine
the structure of the element.

DR
AF

output

The size in bytes of the complete element. That is usually
bytes∗elmdms(1)∗...∗elmdms(elmndm) for an element which will
contain real values.

T

output

type

=0
>0

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
4.21

Inqfgr/Inqngr

Description
Read the first or next group from definition file.

Syntax
error = Inqfgr (fd_nefis, grpnam, celnam, grpndm, grpdms, grpord)
error = Inqngr (fd_nefis, grpnam, celnam, grpndm, grpdms, grpord)
Parameters
fd_nefis
type
input
grpnam

output

output
c
char ∗
fortran
character∗16
Name of the group.

type

output
c

type

celnam

26 of 60

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

char ∗

Deltares

API to NEFIS functions

grpndm
type
input

output

grpdms
type

output
c
int ∗
Fortran
integer∗4
This is an array(1:GRPNDM) with the dimensions. One of the dimensions may be 0 which number indicates the part that is variable. The correctness of the dimensions is not being checked.

DR
AF

output

input/output
c
int ∗
Fortran
integer∗4
current length of array GRPDMS and GRPORD, this value will be
checked against number of dimensions of this group. Because
GRPNDM is not known in advance, it is recommended that the
current length of this array be set at the maximum value (=5).
The number of dimensions of this group. The maximum number
of dimensions is 5.

T

output

fortran
character∗16
Name of the cell with which this group is made up. (see function
Defcel, 4.4).

grpord

type

output

error

type

=0
>0

output
c
int ∗
Fortran
integer∗4
This is an array(1:GRPNDM) which gives the order in which the
cells must be written to the data file (which index runs most rapidly,
which runs next most rapidly etc.). The sequence which operates
in FORTRAN for a multi-dimensional array is 1, 2, 3, etc..
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
4.22

Inqfia/Inqnia

Description
Read the names and values of the first and next integer attributes, INQFIA and INQNIA respectively, of a data group.
Syntax
error = Inqfia (fd_nefis, grpnam, attnam, attval)
error = Inqnia (fd_nefis, grpnam, attnam, attval)
Parameters
fd_nefis
type

Deltares

input
c
Fortran

int ∗
integer∗4

27 of 60

NEFIS Library, User Manual

grpnam
type
input

attnam
type
output
attval
type
output
error

input
c
char ∗
fortran
character∗16
Name of the data group of which the names and values of the
attributes must be read.
output
c
char ∗
fortran
character∗16
Name of the attribute (see function Putiat 4.30).
output
c
int ∗
Fortran
integer∗4
Attribute value.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

DR
AF

type

NEFIS file descriptor (see function Crenef, 4.3)

T

input

=0
>0

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 The function INQFIA gives the first name and the corresponding value. With function
INQNIA possibly following names and values may be retrieved.
4.23

Inqfra/Inqnra

Description
Read the names and values of the first and next real attributes, INQFRA and INQNRA respectively, of a data group.
Syntax
error = Inqfra (fd_nefis, grpnam, attnam, attval)
error = Inqnra (fd_nefis, grpnam, attnam, attval)
Parameters
fd_nefis
type
input
grpnam
type
input

28 of 60

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
input
c
char ∗
fortran
character∗16
Name of the data group of which the names and values of the
attributes must be read.

Deltares

API to NEFIS functions

type
output
attval
type
output
error
type

=0
>0

output
c
char ∗
fortran
character∗16
Name of the attribute (see function Putrat 4.31).
output
c
int ∗
Fortran
integer∗4
Attribute value.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

T

attnam

DR
AF

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 The INQFRA function gives the first name and corresponding value. With the INQNRA
function the possibly following names and values may be retrieved.
4.24

Inqfsa/Inqnsa

Description
Read the names and values of the first and next character attributes, INQFSA and INQNSA
respectively, of a data group.
Syntax
error = Inqfsa (fd_nefis, grpnam, attnam, attval)
error = Inqnsa (fd_nefis, grpnam, attnam, attval)
Parameters
fd_nefis

type

input

grpnam
type
input

attnam
type
output
attval

Deltares

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

input
c
char ∗
fortran
character∗16
Name of the data group of which the names and values of the
attributes must be read.
output
c
char ∗
fortran
character∗16
Name of the attribute (see function Putsat, 4.32).
output

29 of 60

NEFIS Library, User Manual

type
output
error
type

=0
>0

c
char ∗
fortran
character∗16
Attribute value.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

Inqfst/Inqnxt

DR
AF

4.25

T

Remark:
 The INQFSA function gives the first name and corresponding value. With the INQNSA
function the possibly following names and values may be retrieved.

Description
Read the name of the first (INQFST) and the next (INQNXT) data group from a data file and
the corresponding group definition name.
Syntax
error = Inqfst (fd_nefis, grpnam, grpdef)
error = Inqnxt (fd_nefis, grpnam, grpdef)
Parameters
fd_nefis

type

input

grpnam

type

output

grpdef

type
output

error
type

=0
>0

30 of 60

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

output
c
char ∗
fortran
character∗16
Name of the first and the next data group, INQFST and INQNXT
respectively, on the data file (see function Credat, 4.2).
output
c
char ∗
fortran
character∗16
Name of the definition used for this data group (see function Credat, 4.2).
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Deltares

API to NEFIS functions

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 INQFST gives the first name, INQNXT the next one until there are no names left.
Inqgrp
Description
Read a group definition from the definition file.
Syntax
error = Inqgrp (fd_nefis, grpdef, celnam, grpndm, grpdms, grpord)

fd_nefis
type
input

T

Parameters

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

DR
AF

4.26

grpdef

type

input

celnam

type

output

grpndm

type

input

output

grpdms

type

output
grpord
type
output

error
type

Deltares

input
c
char ∗
fortran
character∗16
Name for the group whose definition is to be retrieved.
output
c
char ∗
fortran
character∗16
Name of the cell with which this group is made up.
input/output
c
int ∗
Fortran
integer∗4
The number of dimensions which can be stored in the arrays GRPDMS and GRPORD. Because GRPNDM is not known in advance, it is recommended to fix the current length of this array
at the maximum value (=5).
The number of dimensions of this group.
output
c
int
Fortran
integer∗4
This is an array(1:GRPNDM) with the dimensions of the group.
output
c
int
Fortran
integer∗4
This is an array (1:GRPNDM) which gives the order in which the
data was written to the data file (which index runs most rapidly,
which runs next most rapidly, etc.).
return value
c
int

31 of 60

NEFIS Library, User Manual

=0
>0

Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
4.27

Inqmxi

Syntax
error = Inqmxi (fd_nefis, grpnam, max_index)
Parameters
fd_nefis

input

grpnam

type

input

max_index

type

output

error

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

DR
AF

type

T

Description
Give the maximum used index of the free dimension of a data groupp.

type

=0
>0

input
c
char ∗
fortran
character∗16
Name for the group whose maximum variable index is to be retrieved.
output
c
int ∗
Fortran
integer∗4
Maximum index of group ’grpnam’. If the maximum index is zero
then there is no data written to that group.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
4.28

Neferr
Description
Error message can be retrieved from the NEFIS library and/or printed to standard output.
Syntax
error = Neferr (print_flag, error_string)
Parameters

32 of 60

Deltares

API to NEFIS functions

type
input

error_string
type
output

error
type

4.29

return value
c
int
Fortran
integer∗4
No error occurred

DR
AF

=0

input
c
int
Fortran
integer∗4
Print flag to indicate whether the error message is send to standard output.
== 0
Do not print error string
== 1
Do print the error string on standard output
== 2
Do print the error string on standard error
output
c
char ∗
fortran
character∗1024
The string error_string contains the error message generated by
the last NEFIS function which detected the error. Or if the last
function did not detected an error the number of errors occurred
when using the NEFIS library.

T

print_flag

Putelt/Putels

Description
Write one or all (same kind) elements to a group on the data file. Putelt is used for alphanumeric values and Putels is used for string values.
Syntax
error = Putels (fd_nefis, grpnam, elmnam, uindex, usrord, buffer)
error = Putelt (fd_nefis, grpnam, elmnam, uindex, usrord, buffer)
Parameters
fd_nefis

type

input

grpnam

type

input

elmnam
type
input

uindex
type

Deltares

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

input
c
char ∗ grpname[16+1]
fortran
character∗16 grpnam
Name of the data group of which one or all elements must be
written.

input
c
char ∗ elmnam[16+1]
fortran
character∗16 elmnam
Name of the element which must be written. When Elmnam = ’∗’,
this means that all (same kind) elements must be written.
input
c
fortran

int ∗ Uindex[][3]
integer Uindex(3,)

33 of 60

NEFIS Library, User Manual

usrord
type
input

buffer
type

input
c
int ∗ Usrord[]
fortran
integer Usrord ()
This is an array (1:GRPNDM) which determines the sequence in
which the cells must be stepped through. This is achieved by stating which index runs most rapidly, which runs next most rapidly
etc.. This allows you to make up a desired group representation,
provided that the buffer has the same sequence.
output
c
void ∗
fortran
void
Buffer with values which must be written in the given element of
the cells indicated by UINDEX. Obviously, the data in the buffer
must have the same sequence.

DR
AF

input

This array contains information on the indices of the cells that must
be walked through. For each dimension of the data group three
numbers must be given viz. the start index, the end index and the
step size.

T

input

error

type

=0
>0

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 How parameter UINDEX works can best be presented by an example: Suppose you
have defined with DEFGRP a group with dimensions (20,13) and reversed the array
with parameter USRORD towards (13,20). With the following values in UINDEX:
UINDEX(1-3,1) = 1, 13, 3
UINDEX(1-3,2) = 5, 20, 5

then the cells will be run in the following sequence:
[ 5,1]
[10,1]
[15,1]
[20,1]

[ 5,4]
[10,4]
[15,4]
[20,4]

[ 5,7]
[10,7]
[15,7]
[20,7]

[ 5,10]
[10,10]
[15,10]
[20,10]

[ 5,13]
[10,13]
[15,13]
[20,13].

The given indices must be within the defined limits. Obviously, for indices of the variable
dimension (see Defgrp 4.6) this restriction does not hold. The step size must be positive.

4.30

Putiat
Description
Write an integer attribute to a data group.
Syntax
error = Putiat (fd_nefis, grpnam, attnam, attval)

34 of 60

Deltares

API to NEFIS functions

Parameters
type
input
grpnam
type
input

attnam
type
input
attval

input
c
char ∗
fortran
character∗16
Name of the data group at which an integer attribute is to be written.
input
c
char ∗
fortran
character∗16
Name of the attribute.
input
c
int ∗
Fortran
integer∗4
Attribute value.

DR
AF

type

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

T

fd_nefis

input

error

type

=0
>0

return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 If this attribute name already exists then the previous value will be replaced by a new
one.
4.31

Putrat

Description
Write a real attribute to a data group.

Syntax
error = Putrat (fd_nefis, grpnam, attnam, attval)
Parameters
fd_nefis
type
input
grpnam
type

Deltares

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)
input
c
fortran

char ∗
character∗16
35 of 60

NEFIS Library, User Manual

attnam
type
input
attval
type
input
error
type

input
c
char ∗
fortran
character∗16
Name of the attribute.
input
c
int ∗
Fortran
integer∗4
Attribute value.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

DR
AF

=0
>0

Name of the data group at which an integer attribute is to be written.

T

input

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.
Remark:
 If this attribute name already exists then the previous value will be replaced by a new
one.
4.32

Putsat

Description
Write a string attribute to a data group.

Syntax
error = Putsat (fd_nefis, grpnam, attnam, attval)
Parameters
fd_nefis

type

input

grpnam
type
input
attnam

input
c
char ∗
fortran
character∗16
Name of the data group at which an string attribute is to be written.

input

input
c
char ∗
fortran
character∗16
Name of the attribute.

type

input
c

type

attval

36 of 60

input
c
int ∗
Fortran
integer∗4
NEFIS file descriptor (see function Crenef, 4.3)

char ∗

Deltares

API to NEFIS functions

input
error
type

=0
>0

fortran
character∗16
Attribute value.
return value
c
int
Fortran
integer∗4
No error occurred
Fatal error occurred

Corresponding error message can be printed to standard error or retrieved with the function
Neferr, 4.28.

DR
AF

T

Remark:
 If this attribute name already exists then the previous value will be replaced by a new
one.

Deltares

37 of 60

NEFIS Library, User Manual

DR
AF

T

Deltares, 2016. “BIBTEX key with no entry, needed if no citations are made in the document.”

38 of 60

Deltares

A Example of a data structure
Before data from an application can be written to NEFIS files, the structure in terms of elements, cells and groups must be determined. This can be done in various ways. For instance
a field of 5 000 points (a 2-dimensional raster of 100×50) with at each point:
a discharge Q
a velocity V(2), consisting of two components
waveheight spectrum Hs(10,4), 10 angles, 4 periods
output data at 12 points in time

DR
AF

T






This data can be portrayed in various ways. Some options are described below.
Option A
Elements:

Cell:
Group:

Option B
Elements:

Cell:
Group:

Option C
Elements:

Cell:
Group:

"DISCH"
"VELO"
"SPEC"
"POINT"
"MODEL"

Q
V(2)
Hs(10,4)
[DISCH, VELO, SPEC]
(100, 50, 12) of type POINT

"DISCH"
"VELO"
"SPEC"
"CROSS-SECTION"
"MODEL"

"DISCH"
"VELO"
"SPEC"
"AREA"
"MODEL"

Q(100)
V(100,2)
Hs(100,10,4)
[DISCH, VELO, SPEC]
(50, 12) of type CROSS-SECTION

Q(100,50)
V(100,50,2)
Hs(100,50,10,4)
[DISCH, VELO, SPEC]
(12) of type AREA

The most important criterion when selecting one of the three possibilities is:
in which units data will need to be accessed subsequently (the larger the units, the better
the performance) and in which units the data is available. The smallest unit which can be
accessed is an element.

Deltares

39 of 60

DR
AF

T

NEFIS Library, User Manual

40 of 60

Deltares

B Error/Warning numbers

DR
AF

1013
1014
1015
1016
1019
1020
1021

Error/Warning description
—
Crenef: Data filename too long ( length < %d )
Crenef: Definition filename too long ( length < %d )
Gethdt: Supplied character string too small for header
Gethdt: Unable to read data file header (file write only?)
Gethdt: During reading of data file header
Gethdf: Supplied character string too small for header
Gethdf: Unable to read definition file header (file write only?)
Gethdf: During reading of definition file header
—
Inqcel: User supplied array too small to contain Cell properties: ’%s’ %ld>%ld
Inqelm: User supplied array too small to contain Element properties: ’%s’
%ld>%ld
Inqfcl: User supplied array too small to contain Cell properties: ’%s’ %ld>%ld
Inqncl: User supplied array too small to contain Cell properties: ’%s’ %ld>%ld
Inqfgr: User supplied array too small to contain group properties: ’%s’ %ld>%ld
Inqngr: User supplied array too small to contain group properties: ’%s’ %ld>%ld
Putiat: Groupname ’%s’ or integer attribute name ’%s’ too long
Putrat: Groupname ’%s’ or real attribute name ’%s’ too long
Putsat: Groupname ’%s’ or real attribute name ’%s’ or attribute value ’%s’ too
long

T

Nr
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012

2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028

Deltares

—
Crenef: Data filename too long ( length < %d )
Crenef: Definition filename too long ( length < %d )
Gethdt: Supplied character string too small for header
Gethdt: Unable to read data file header (file write only?).
Gethdt: During reading of data file header.
Gethdf: Supplied character string too small for header
Gethdf: Unable to read definition file header (file write only?).
Gethdf: During reading of definition file header.
—
Getsat: User supplied attribute string too small
Inqcel: Supplied array too small to contain all element names: ’%s’ %ld>%d
Inqcel: User supplied array too small to contain Cell properties: ’%s’ %ld>%ld
Inqdat: User supplied array to store group definition too small
Inqelm: User supplied array’s to store element definition too small: %s, %ld, %ld,
%ld, %ld,%ld
Inqelm: Element name ’%s’ too long
Inqelm: User supplied array to contain element names too small
Inqfst: User supplied array to contain names too small
Inqelm: User supplied array’s to store element definition too small
Inqfel: User supplied array to contain element names too small
Inqelm: User supplied array’s to store element definition too small
Inqfel: User supplied array to contain element names too small
Inqfcl: Supplied array too small to contain all element names: ’%s’ %ld>%d
Inqfcl: User supplied array too small to contain Cell properties: ’%s’ %ld>%ld
Inqfcl: Supplied array too small to contain all element names: ’%s’ %ld>%d
Inqncl: User supplied array too small to contain Cell properties: ’%s’ %ld>%ld
Inqfgr: User supplied array to contain names too small
Inqfgr: User supplied array too small to contain group properties: ’%s’ %ld>%ld

41 of 60

NEFIS Library, User Manual

Error/Warning description
Inqfgr: User supplied array to contain names too small
Inqngr: User supplied array too small to contain group properties: ’%s’ %ld>%ld
Inqfia: User supplied array to contain integer attribute names too small
Inqfra: User supplied array to contain real attribute names too small
Inqfsa: User supplied array to contain string attribute names too small
Inqgrp: Group name too long ’%s’
Inqgrp: User supplied array to contain group dimensions too small
Inqnxt: User supplied array to contain names too small
Inqnia: User supplied array to contain integer attribute names too small
Inqnra: User supplied array to contain real attribute names too small
Inqnra: User supplied array to contain string attributes (name/value) too small
Putiat: Groupname ’%s’ or integer attribute name ’%s’ too long
Putrat: Groupname ’%s’ or real attribute name ’%s’ too long
Putsat: Groupname ’%s’ or string attribute name ’%s’ or attribute value ’%s’ too
long

3001
3002
3003
3004
3005
3006

Start value user index [%ld,2]=%ld should be smaller than [%ld,2]=%ld
Increment value user index [%ld,2]=%ld should be greater than 0
Start value user index [%ld,0]=%ld should be greater than zero
Stop value %ld should be smaller than %ld
Buffer length too small, should be %ld instead of %ld Group "%s", element "%s"
Variable dimension %ld not found for: group "%s", element "%s"

5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024

42 of 60

DR
AF

4001
4002
4003
4004

T

Nr
2029
2030
2031
2032
2033
2034
2035
2037
2038
2039
2040
2042
2043
2044

Start value user index [%ld,2]=%ld should be smaller than [%ld,2]=%ld
Increment value user index [%ld,2]=%ld should be greater than 0
Start value user index [%ld,0]=%ld should be greater than zero
Stop value %ld should be smaller than %ld

Number of dimensions not within the range [1,%d] Element ’%s’ has dimension
%ld
This size of real (%ld) is not supported
This size of integer (%ld) is not supported
This size of complex (%ld) is not supported
This size of logical (%ld) is not supported
This element type is not supported ’%s’
Element ’%s’ already exists
Error writing element ’%s’ to definition file
Element ’%s’ does not exist
Cel ’%s’ already exists
Error writing cel ’%s’ to definition file
—
Cel ’%s’ does not exist
Group ’%s’ already exists.
Error on writing group ’%s’ to definition file.
Number of dimensions not within the range [1,MAX_DIM] Group ’%s’
Group definition ’%s’ does not exist.
Cel ’%s’ does not exist.
Data group ’%s’ already exists in data file
Error on writing group ’%s’ with variable dimension.
Error on writing group ’%s’ with fixed dimension
Error on writing group ’%s’ with variable dimension.
Error on writing group ’%s’ with fixed dimension
Maximum size reached in DataDefinition file "%s"

Deltares

Error/Warning numbers

Error/Warning description
Maximum size reached in definition file "%s"
Maximum size reached in definition file "%s"
Maximum size reached in definition file "%s"
Maximum size reached in definition file "%s"
Maximum size reached in definition file "%s"
Maximum size reached in DataDefinition file "%s"
Maximum size reached in definition file "%s"

6001
6002
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
-6021

6029
6030
6031
6032
6033
6034

Hashtable not written to data file ’%s’
Hashtable not written to definition file ’%s’
Hashtable not written to DefinitionData file ’%s’
Cell ’%s’ does not exist in definition file
Group ’%s’ does not exist in data file
Element ’%s’ does not exist in definition file
—
Group ’%s’ does not exist in definition file
—
On reading attribute of group ’%s’
No space left in data file for integer attribute of group ’%s’
No space left in data file for real attribute of group ’%s’
No space left in data file for string attribute of group ’%s’
Group ’%s’ does not exist in data file
On reading attribute of group ’%s’
Integer attribute ’%s’ of group ’%s’not found
No valid attribute name found
Real attribute ’%s’ of group ’%s’not found
No valid attribute name found
String attribute ’%s’ of group ’%s’not found
No valid attribute name found
No more data groups available in DefinitonData file ’%s’
No data groups available in DefinitonData file ’%s’
No more data groups available in data file ’%s’
No data groups available in data file ’%s’
No more elements available in DefinitionData file ’%s’
No elements available in DefinitionData file ’%s’
No more elements available in definition file ’%s’
No elements available in definition file ’%s’
No more cells available in DefinitionData file ’%s’
No cells available in DefinitionData file ’%s’
No more cells available in definition file ’%s’
No cells available in definition file ’%s’
No more defined groups available in DefinitionData file ’%s’
No defined groups available in DefinitionData file ’%s’
No more defined groups available in definition file ’%s’
No defined groups available in definition file ’%s’
On reading first variable pointer table
On reading variable pointer table, table %ld
On reading variable pointer table, table %ld
On reading variable pointer table, table %ld
Maximum size reached in DataDefinition file
Maximum size reached in data file

7001

No entry found in hash table for key ’%s’

DR
AF

T

Nr
5025
5026
5027
5028
5029
5030
5031

-6022
-6023
-6024
-6025
-6026
-6027
-6028

Deltares

43 of 60

NEFIS Library, User Manual

Error/Warning description
Unable to read next pointer (file write only?)
During reading of next pointer
During reading of cell structure
During reading of element structure
During reading of group structure
During reading of data structure

8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031

Data file ’%s’ has already been opened
Definition file ’%s’ has already been opened
Maximum number (=%d) of open files has been achieved
Header was not written to data file ’%s’
Hashtable was not written to data file ’%s’
Hashtable was not written to data file ’%s’
Unable to access data file ’%s’
During reading header of data file ’%s’
File ’%s’ is not a NEFIS data file
During reading hashtable of data file ’%s’
Unable to write header of definition file ’%s’
Unable to write hashtable of definition file ’%s’
Unable to write hashtable of definition file ’%s’
Unable to access definition file ’%s’
during reading header of definition file ’%s’
File ’%s’ is not a NEFIS definition file
On reading hashtable of definition file ’%s’
Unable to write header of DefinitionData file ’%s’
Unable to write hashtable of DefinitionData file ’%s’
Unable to write hashtable of DefinitionData file ’%s’
Unable to access DefinitionData file ’%s’
during reading header of DefinitionData file ’%s’
File ’%s’ is not a NEFIS DefinitionData file
On reading hashtable of DefinitionData file ’%s’
Unable to close data file ’%s’
Unable to close definition file ’%s’
Unable to close DefinitionData file ’%s’
—
File ’%s’ can not be opened with unsupported NEFIS access type ’%c’
Cannot open file ’%s’ for access type ’%c’
File ’%s’ can not be opened as read only

DR
AF

9001

T

Nr
7002
7003
7004
7005
7006
7007

9002

The variable MAX_VAR_GROUPS needs to be increased. Contact Deltares |
Delft Hydraulics
Element "%s" of group "%s" not found on file "%s"

10001
10002
10003
10004
10005
10006

This size of integer (%d) is not supported
This size of real (%d) is not supported
This size of character (!=1) is not supported
This size of complex (%d) is not supported
This size of logical (%d) is not supported
This element type is not supported ’%s’

44 of 60

Deltares

C Demonstration programs
Two demonstration programs are appended, DEMO_01 and DEMO_02. DEMO_01 particularly demonstrates how the stored and retrieved sequences can be handled. The program
uses the file DEMO_01.INP and generates the definition file (DEMO_01.DEF) and the data file
(DEMO_01.DAT). The program DEMO_01 is the example mentioned earlier (see Examples
option A). The measurement data is defined as:

depth
1000×location number + 10×time + 4

T

velocity
depth 1: 1000×location number+10×time+1
depth 2: 1000×location number+10×time+2
depth 3: 1000×location number+10×time+3

C.1

DR
AF

Program DEMO_02 shows an example of how variable dimensions are handled and also
demonstrates how easy it is to use only the relevant part of available data. This program does
not need an input file.
Demonstration program 1

program demo01
implicit none
!
!
Company name
: Deltares | Delft Hydraulics
!
P.O.Box 177
!
2600 MH Delft
!
The Netherlands
!
DESCRIPTION :
!
!
This program demonstrates how the NEFIS functions can be used
!
to write data to a NEFIS file, and how this data can be
!
retrieved again from the same file.
!
!=======================================================================
!
..
!
.. Local Scalars ..
!
character*1024 errstr
! character string to catch the nefis error message
character coding*1
! indicates y/n neutral representation of data
integer :: dummy
! dummy parameter in function calls
integer :: error
! contains return-value of nefis functions
integer :: i
! loop control variabel, array index
integer :: j
! loop control variabel, array index
integer :: k
! loop control variabel, array index
integer :: obsfil
! unitnumber of user’s observation file
!
!
.. local arrays ..
!
character elmnms(2)*14
! cell element names
integer :: fds
! nefis file descriptor
integer :: grpdms(5)
! dimensions of data group to define
integer :: grpord(5)
! order information of data group to define
integer :: usrord(5)
! ordering information of user data
integer :: usrind(3,5)
! ordering information of user data
real
:: veloctiy(3,4)
! array to contain velocity-element info of 4 points
integer :: depth(12)
! array to contain depths
integer :: obsdat(4,100,10) !
.. array to contain observed data
!
..
!
.. external functions ..

Deltares

45 of 60

NEFIS Library, User Manual

!
integer
integer
integer
integer
integer
integer
!
!
!

::
::
::
::
::
::

crenef
defelm
defcel
defgrp
credat
putelt

nefis-function:
nefis-function:
nefis-function:
nefis-function:
nefis-function:
nefis-function:

open a data and definition file
define an element
define a cell
define a group
create space for data on data file
write data of 1 or more elements

.. to data file
integer :: getelt

!
!
!

!
!
!
!
!
!

! nefis-function: retrieve data of 1 or more

.. elements from data file

DR
AF

T

integer :: clsnef
! nefis-function: close a data and definition file
!
!=======================================================================
!
obsfil = 11
coding = ’b’ ! let us write the data to a big endian format
rdwr
= ’c’ ! create a nefis file set
!
..
write(*,’(’’Demo_01: Open NEFIS data and definition file’’)’)
error = crenef(fds, ’data_d01.def’, ’data_d01.def’, coding, rdwr)
if (error /= 0) goto 9999
!=======================================================================
!
!
FIRST, LET’S DEFINE SOME ELEMENTS
!
!
DEFINE A 1 DIMENSIONAL ELEMENT OF 3 REALS,
!
NAMED: MEAN VELOCITY
!
write(*,’(’’demo_01: Define ELEMENT: MEAN VELOCITY (3)’’)’)
error = defelm (fds, ’MEAN VELOCITY’, ’REAL’, 4, &
’VELOCITY’, ’[M/S]’, &
’Mean velocity in centre of river at ’ // &
’3 different levels’, 1, 3)
IF (ERROR /= 0) GOTO 9999
!
!
DEFINE A (0 DIMENSIONAL) ELEMENT OF 1 REAL,
!
NAMED: WATERDEPTH
!
write(*,’(’’demo_01: Define ELEMENT: WATERDEPTH’’)’)
dummy = 1
error = defelm (fds, ’WATERDEPTH’, ’REAL’, 4, ’DEPTH’, &
’[M]’, ’DEPTH AT CENTRE OF RIVER’, 1, dummy)
if (error /= 0) goto 9999
!
!
LET’S DEFINE A CELL TO CONTAIN OBSERVATIONS AT A
!
CERTAIN POINT AND A CERTAIN PLACE,
!
NAMED: OBSERVATION
!
elmnms(1) = ’MEAN VELOCITY’
elmnms(2) = ’WATERDEPTH’
write(*,’(’’demo_01: Define CELL: ’’, &
’’OBSERVATION = MEAN VELOCITY + WATERDEPTH’’)’)
error = defcel(fds, ’OBSERVATION’, 2, elmnms)
if (error /= 0) goto 9999
!
!
DEFINE A GROUP FOR 10 DIFFERENT LOCATIONS,
!
ABLE TO CONTAIN 100 OBSERVATIONS (TIME SERIES)
!
FOR EACH LOCATION, NAMED: RIVER DATA
!
grpdms(1) = 100 ! MAX. 100 OBSERVATIONS FOR EACH LOCATION
grpdms(2) = 10 ! MAX. 10 LOCATIONS
grpord(1) = 2

46 of 60

Deltares

Demonstration programs

grpord(2) = 1
!
!
!
!

CELLS WILL BE STORED IN THE FILE IN THE ORDER:
(1,1), (1,2) ..... (1,10), (2,1), (2,2).... ETC.
write(*,’(’’demo_01: Define GROUP:’’, ’’ RIVERDATA = OBSERVATION (100,10)’’)’)
error = defgrp (fds, ’RIVERDATA’, ’OBSERVATION’, 2, grpdms, grpord)

!

DR
AF

T

if (error /= 0) goto 9999 ! END OF DEFINITION PART
!
!=======================================================================
!
!
NOW, LET’S CREATE SPACE ON THE DATA FILE FOR
!
RED RIVER DATA
!
write(*,’(’’demo_01: Create space for data labelled: RED RIVER,’’, &
’’ using THE RIVERDATA GROUP DEFINITION’’)’)
error = credat (fds, ’RED RIVER’, ’RIVERDATA’)
if (error /= 0) goto 9999
!
!
NOW, READ ALL FIELD OBSERVATIONS FROM A FILE
!
write(*,’(’’demo_01: Read observation data from input file’’, &
’’ (not a NEFIS action)’’)’)
!
open (obsfil,file=’observ.inp’)
do i = 1, 10
read (obsfil,*)
do j = 1, 100
read (obsfil,*) (obsdat(k,j,i), k=1,4) ! VELOCITIES AND WATERDEPTH AT LOCATION I,
enddo
enddo
close (obsfil)
!=======================================================================
!
!
OBSERVATIONS CAN BE WRITTEN TO THE NEFIS DATA FILE
!
FOR EXAMPLE CELL AFTER CELL
!
usrord(1) = 1
usrord(2) = 2
!
!
THIS IS THE FORTRAN ORDER, IE.:
!
(1,1), (2,1) .. (100,1), (1,2), (2,2) .. ETC.
!
!
write(*,’(’’demo_01: Write DATA to NEFIS file, ONE cell at a time’’)’)
!
do 40 i = 1, 100
!
do 30 j = 1, 10
!
usrind(1,1) = i
!
usrind(2,1) = i
!
usrind(3,1) = 1
!
usrind(1,2) = j
!
usrind(2,2) = j
!
usrind(3,2) = 1
!
usrind(1,3) = 3
!
usrind(2,3) = 3
!
usrind(3,3) = 3
!
usrind(1,4) = 4
!
usrind(2,4) = 4
!
usrind(3,4) = 4
!
usrind(1,5) = 5
!
usrind(2,5) = 5
!
usrind(3,5) = 5
!
write(*,’(’’demo_01: Data: ’’,i8)’) OBSDAT(4,I,J)
!
error = putelt (fds, ’RED RIVER’, ’WATERDEPTH’, usrind, usrord, obsdat(4,i,j))
!
if (error /= 0) goto 9999
!
enddo

Deltares

47 of 60

NEFIS Library, User Manual

!
!
!
!
!

enddo
write(*,’(’’demo_01: RED RIVER written in [sec]’’,1PE13.5)’) cpu2-cpu1
OR ALL CELLS TOGETHER (10*100 CELLS)
usrind(1,1)
usrind(2,1)
usrind(3,1)
usrind(1,2)
usrind(2,2)
usrind(3,2)

!
!
!

=
=
=
=
=
=

1
100
1
1
10
1

INDEX OF FIRST CELL TO STORE INFORMATION TO
usrord(1) = 1
usrord(2) = 2

!
!
!
!

T

.. THIS IS THE FORTRAN ORDER, IE.:
(1,1), (2,1) .. (100,1), (1,2), (2,2) .. ETC.

write(*,’(’’demo_01: Write the DATA, all cells at ONE go’’)’)
error = putelt (fds, ’RED RIVER’, ’*’, usrind, usrord, obsdat)
IF (ERROR /= 0) GOTO 9999

DR
AF

!
!
ALL DATA IS NOW STORED ON THE NEFIS DATA FILE
!
!=======================================================================
!
!
LET’S DO SOME RETRIEVAL
!
!
LET’S RETRIEVE THE VELOCITIES FROM LOCATIONS
!
6-9 AT TIME 54, IE. FROM
!
CELLS (54,6), (54,7), (54,8) AND (54,9).
!
THE PERFORMANCE WILL BE RATHER GOOD, BECAUSE THE
!
DATA ON THE NEFIS DATA FILE IS WRITTEN IN THIS
!
ORDER (SEE DEFGRP).
!
usrind(1,1) = 6
usrind(2,1) = 9
usrind(3,1) = 1
usrind(1,2) = 54
usrind(2,2) = 54
usrind(3,2) = 1
!
usrord(1) = 2
usrord(2) = 1
!
!
MEANS: FROM CELL (54,6), (54,7), (54,8) AND (54,9)
!
write(*,’(’’demo_01: Start retrieval’’)’)
Error = getelt (fds, ’RED RIVER’,’MEAN VELOCITY’, &
usrind, usrord, 48, velocity)
if (error /= 0) goto 9999
!
..
write(*,’(’’demo_01: Velocities at time 54’’)’)
do i = 1, 4
write (*,’(a,i2,’’:’’,3f8.1)’) ’ Location ’, i+5, (velocity(j,i), j=1,3)
enddo
!
!
NOW, RETRIEVE AT LOCATION 7 THE WATERDEPTHS FROM
!
TIME 35-46
!
usrind(1,1) = 7
usrind(2,1) = 7
usrind(3,1) = 1
usrind(1,2) = 35

48 of 60

Deltares

Demonstration programs

usrind(2,2) = 46
usrind(3,2) = 1
!
usrord(1) = 2
usrord(2) = 1
!
!
!

MEANS: FROM CELL (35,7), (36,7), (37,7) .... (46,7)

C.2

DR
AF

T

error = getelt (fds, ’RED RIVER’, ’WATERDEPTH’, &
usrind, usrord, 48, depth)
if (error /= 0) goto 9999
!
..
write (*,’(’’demo_01: Waterdepths at location 7’’)’)
do i = 1, 12
write (*,’(a,i2,’’:’’,f8.1)’) ’ Time ’, i+34, depth(i)
enddo
!=======================================================================
!
!
close the NEFIS files
!
write(*,’(’’demo_01: Close the NEFIS files’’)’)
error = clsnef (fds)
!
9999 continue
!
error = neferr( 0, errstr)
write(*,’(a)’) trim(errstr)
write(*,*)
write(*,’(’’demo_01: End of demonstration’’)’)
end program

Demonstration program 2

program demo_02
implicit none
!
!
Company name
: Deltares | Delft Hydraulics
!
P.O.Box 177
!
2600 MH Delft
!
The Netherlands
!-----------------------------------------------------------------------------!
System: NEFIS
!
!
$Header: /delft3d/libraries/nefis/demo/demo_02/demo_02.f 2
10/03/06 9:56 Mooiman $
!-----------------------------------------------------------------------------!
Programmer
: A. Hoekstra
!
Project
: NEutral FIle Structure
!-----------------------------------------------------------------------------!
* * * * * * * * * * * * * DESCRIPTION * * * * * * * * * * * * *
!
!
- This demo-program demonstrates the use of NEFIS store!
and retrieval functions. Special is the use of a
!
datagroup with a variable dimension.
!
!
This program performs the following tasks:
!
- create an element, cel and a 3-d group defintion
!
- create a data group
!
- store data in this group
!
- retrieve data from this group, using a
!
different view
!
- retrieve data using a filter
!
!
Note: the error-return code from the NEFIS-functions is
!
not checked
!------------------------------------------------------------------------------

Deltares

49 of 60

NEFIS Library, User Manual

Scalars
character*1024 errstr
character coding*1
character rdwr*1
integer
error

!
!
!

fds

! nefis file descriptor

Declarations of NEFIS-functions
integer
integer
integer
integer
integer

::
::
::
::
::

clsnef
credat
flsdat
crenef
neferr

Executable statements

Open a definition file

DR
AF

!
!
!
!
!
!

character string to catch the NEFIS error message
indicates Y/N neutral representation of data
indicates read write acces of the file
contains return-value of NEFIS-functions

Arrays
integer

!
!
!

!
!
!
!

T

!
!
!

coding = ’L’
rdwr
= ’c’
error = crenef (fds, ’data_d02.daf’, ’data_d02.daf’, coding, rdwr)
if (error /= 0) goto 9999
!
!
!

Define element, cel, and group-definition
call define (fds)

!
!
!

Create space for data

error = credat (fds, ’GrpNaam’, ’Groep’)
if (error /= 0) goto 9999
!

error = flsdat (fds)
if (error /= 0) goto 9999
!
!
!

Write data to file
call putdat (fds)

!
!
!

Retrieve data, using a different view
call dtview (fds)

!
!
!

Retrieve a part of the data
call filter (fds)

!
!
!

Close the files
9999 continue

!
if (error.eq.0) error = clsnef (fds)
!
error = neferr( 1, errstr)
!
end program
!================================================================================
subroutine define (fds)
implicit none

50 of 60

Deltares

Demonstration programs

!
integer

fds

!
integer
error
character*134 errstr
!
integer :: grpdms(5)
integer :: grpord(5)
!
integer
integer
integer
integer
integer

defcel
defelm
defgrp
flsdef
neferr

Executable statements
Define a simple element, type Real*4

T

!
!
!
!
!

::
::
::
::
::

!
!
!

DR
AF

error = defelm (fds, ’ElmName’, ’Integer’, 4, &
’ElmQuantity’, ’ElmUnity’, ’ElmDescription’, &
1, 1)
if (error /= 0) goto 9999
Define a cel with only one real value

error = defcel (fds, ’Cell’, 1, ’ElmName’)
if (error /= 0) goto 9999
!
!
!
!

Define a 3-d group of dimension (3,5,0),
so a group with a variable dimension

grpdms(1) = 3
grpdms(2) = 5
grpdms(3) = 0
grpord(1) = 1
grpord(2) = 3
grpord(3) = 2
error = defgrp (fds, ’Groep’, ’Cell’, 3, grpdms, grpord)
if (error /= 0) goto 9999
!
!
!

Flush buffers to file

error = flsdef (fds)
if (error /= 0) goto 9999
!

9999 continue
error = neferr( 1, errstr)
end subroutine
!================================================================================
subroutine putdat (fds)
implicit none
!
character*1024 errstr
!
integer
fds
!
integer
start, stop, incr
parameter (start=1, stop=2, incr=3)
equivalence(aarray,array)
!
character :: space*7
integer
:: col
integer
:: error
integer
:: plane
integer
:: row

Deltares

51 of 60

NEFIS Library, User Manual

integer
integer
integer
integer

::
::
::
::

uindex(3,5)
usrord(5)
array (3,5,7)
aarray (105)

integer
integer
integer

:: flsdat
:: putelt
:: neferr

!

Executable statements
space = ’

!
!
!

’

Set view to (3,5,*)
usrord (1) = 1
usrord (2) = 2
usrord (3) = 3

!
!
!

Define indices for each dimension

!
!
!

(start,1)
(stop ,1)
(incr ,1)
(start,2)
(stop ,2)
(incr ,2)
(start,3)
(stop ,3)
(incr ,3)

=
=
=
=
=
=
=
=
=

1
3
1
1
5
1
1
7
1

DR
AF

uindex
uindex
uindex
uindex
uindex
uindex
uindex
uindex
uindex

T

!
!
!

Fill array with values
do

plane = 1,7
do col = 1,5
do row = 1,3
array (row, col, plane) = row*1000+col*100+plane
enddo
enddo
enddo
!
!
!

Write data to file

error = putelt (fds, ’GrpNaam’, ’*’ ,uindex, usrord, array)
if (error /= 0) goto 9999
!
!
!

Flush the buffers

error = flsdat (fds)
if (error /= 0) goto 9999
!
!
!

Output data to screen

write(*,’(’’ ARRAY(3,5,7) written to file:’’)’)
do plane = 1,7
do col = 1,5
write (*,’( 3i10)’) (array(row,col,plane),row=1,3)
enddo
write (*,*)
enddo
!
9999 continue
error = neferr( 1, errstr)
end subroutine
!================================================================================
subroutine dtview (fds)

52 of 60

Deltares

Demonstration programs

implicit none
!
character*1024 errstr
!
integer

:: fds

!
integer
:: start, stop, incr
parameter (start=1, stop=2, incr=3)
!
::
::
::
::
::
::
::
::

space*7
col
error
plane
row
uindex(3,5)
usrord(3)
array (7,3,5)

integer
integer

:: getelt
:: neferr

!

!
!
!

Executable statements
’

DR
AF

space = ’
!
!
!

T

character
integer
integer
integer
integer
integer
integer
integer

Change view to (*,3,5)
usrord (1) = 3
usrord (2) = 1
usrord (3) = 2

!
!
!

define indices for each dimension
uindex
uindex
uindex
uindex
uindex
uindex
uindex
uindex
uindex

!
!
!

(start,1)
(stop ,1)
(incr ,1)
(start,2)
(stop ,2)
(incr ,2)
(start,3)
(stop ,3)
(incr ,3)

=
=
=
=
=
=
=
=
=

1
7
1
1
3
1
1
5
1

Retrieve data

error = getelt (fds, ’GrpNaam’, ’*’ ,uindex, usrord, 7*3*5*4, array)
if (error /= 0) goto 9999
!
!
!

Output data to screen

write(*,’(’’ Same values now retrieved in ARRAY(7,3,5)’’)’)
do plane = 1,5
do col = 1,3
write (*,’( 7i10 )’) (array(row,col,plane),row=1,7)
enddo
write (*,*)
enddo
!
9999 continue
error = neferr( 1, errstr)
end subroutine
!================================================================================
subroutine filter (fds)
implicit none
!
character*1024 errstr

Deltares

53 of 60

NEFIS Library, User Manual

!
integer

:: fds

!
integer
:: start, stop, incr
parameter (start=1, stop=2, incr=3)
!
character
integer
integer
integer
integer
integer
integer
integer

::
::
::
::
::
::
::
::

space*7
col
error
plane
row
uindex(3,5)
usrord(3)
array (4,2,3)

integer
integer

:: getelt
:: neferr

!
!
!

Executable statements
space = ’

’

Change view to (*,3,5)

DR
AF

!
!
!

T

!

usrord (1) = 3
usrord (2) = 1
usrord (3) = 2
!
!
!
!

Define indices and step for each dimension
The stepsize of 2 creates a filter
uindex
uindex
uindex
uindex
uindex
uindex
uindex
uindex
uindex

!
!
!

(start,1)
(stop ,1)
(incr ,1)
(start,2)
(stop ,2)
(incr ,2)
(start,3)
(stop ,3)
(incr ,3)

=
=
=
=
=
=
=
=
=

1
7
2
1
3
2
1
5
2

Retrieve data

error = getelt (fds, ’GrpNaam’, ’*’, uindex, usrord, 4*2*3*4, array)
if (error /= 0) goto 9999
!
!
!

Output data to screen

write(*,’(’’ Every other value retrieved in ARRAY(4,2,3)’’)’)
do plane = 1,3
do col = 1,2
write (*,’( 4i10 )’) (array(row,col,plane),row=1,4)
enddo
write (*,*)
enddo
!
9999 continue
error = neferr( 0, errstr)
write(*,’(a)’) trim(errstr)
end subroutine

54 of 60

Deltares

D Release notes
D.1

Differences between Version 5.00 and 4.00
NEFIS5 support file sizes up to 264 − 1 byte. The internal pointers to the data on the file is
64-bits, these pointers are also written to the NEFIS-file. As a consequence the files made
by NEFIS5 and NEFIS4 are not compatible. The Application Programming Interface (API) is
compatible with NEFIS4. NEFIS5 will read NEFIS4 data, and if necessary NEFIS5 will write
32-bit data to an existing NEFIS4 file. New files will always be a NEFIS5 file.

D.2.1

Differences between Version 4.00 and 3.10
Improvements
The following improvements are obtained:

Variable dimension
Elements
Qdblok3

D.2.2

For reading a NEFIS files no write access is needed.
If the same name for the data and the definition file is used, one
NEFIS file is created. That NEFIS files has the same performance and usability as when using two files.
The performance to retrieve data from a group with variable dimension is highly improved.
The performance for cells containing more than 40 elements is
highly improved.
The object qdblok3 is not needed anymore. This object contained a separated data block (Fortran: Data Block), which was
separately compiled. The data is now integrated into the NEFIS
library.

DR
AF

Access
One file

T

D.2

New functions

The following function are added to NEFIS version 4.00:
Name
Crenef

Clsnef

Getels
Neferr
Putels

Inqfcl/Inqncl
Inqfel/Inqnel
Inqfgr/Inqngr

Deltares

Definition
Open or create a NEFIS file set at once, you have to supply the access type of the files. So, for post-processing the "read" permission is
enough to make graphs.
Close the NEFIS file set. Depending on the access type the buffer will
be written to file or not.
For all architectures the function Getels is added. This function reads
one or all string elements from the data file.
NEFIS error function to retrieve more sensible error messages.
For all architectures the function Putels is added. This function writes
one or more character elements to the data file
Reading first and next cell definition from the definition file
Reading first and next element definition from the definition file
Reading first and next group definition from the definition file

55 of 60

NEFIS Library, User Manual

D.2.3

Outdated functions
The next functions are still available in NEFIS but are not supported anymore:

Cldtnf
Clsdat
Clsdef
Opndat
Opndef
D.2.4

Definition
Close the definition file without flushing the buffer (timestamp does not change
due to this function).
Close the data file without flushing the buffer (timestamp does not change due
to this function).
Flush buffers to the data file and close that file.
Flush buffers to the definition file and close that file.
Create or open a NEFIS data file.
Create or open a NEFIS definition file.

Unavailable functions

T

Name
Cldfnf

The following functions are not available anymore within this version NEFIS.

D.3
D.3.1

Definition
Replaced by function Getelt.
Replaced by function Putelt.

DR
AF

Name
Getelm
Putelm

Differences between Version 3.10 and 3.00
Improvements

Two functions are added to the library, which avoid changing the time stamp of the NEFIS
files. These functions can only be used when reading data from file, if also data is written to
file then the function Clsdat and Clsdef have to be used.
D.3.2

New functions

The following functions are added to NEFIS version 3.10:
Name
Cldfnf
Cldtnf

D.4
D.4.1

Definition
Does NOT write buffers to the definition file and close the file (consequence:
timestamp does not change).
Does NOT write buffers to the definition file and close the file (consequence:
timestamp does not change).

Differences between Version 3.00 and 2.00
Improvements

Performance improvement for reading and writing data to the files when using the functions
PUTELT and GETELT. The improvement depends on the chosen structure. Depending on
the structure the performance reach from several percents to factors (upto factor 13 in some
tests).

56 of 60

Deltares

Release notes

D.4.2

New functions
The following functions are added to NEFIS version 3.00:

Gethdf
Gethdt
Inqfia
Inqfra
Inqfsa
Inqmxi
Inqnia

D.4.3

DR
AF

Inqnra
Inqnsa
Putelt

Definition
Replaces the GETELM function. GETELT outperforms GETELM which is now
outdated. The GETELM and GETELT functions can be used interchangeable
for data groups without variable dimension.
This function gives information from the header of a NEFIS definition file.
Give information from the header of a NEFIS data file.
Give the first name and value of an integer attribute of a data group.
Like INQFIA, but here for the real attributes.
Like INQFIA, but here for the real attributes.
Give the maximum used index of the free dimension of a data group.
This function gives the next name and value of an integer attribute of a data
group (see INQFIA function).
Like INQNIA, but here for the real attributes.
Like INQNIA, but here for the real attributes.
Outperforms PUTELM and replaces it. As a result, PUTELM is considered to
be outdated. However, PUTELM and PUTELT can be used interchangeable
for data groups without variable dimension.

T

Name
Getelt

Outdated functions

The next functions are still available in NEFIS but are not supported anymore:
Name
Getelm
Putelm

Deltares

Definition
Replaced by function Getelt.
Replaced by function Putelt.

57 of 60

DR
AF

T

NEFIS Library, User Manual

58 of 60

Deltares

DR
AF
T

T
DR
AF
PO Box 177
2600 MH Delft
Rotterdamseweg 185
2629 HD Delft
The Netherlands

+31 (0)88 335 81 88
sales@deltaressystems.nl
www.deltaressystems.nl



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.5
Linearized                      : No
Page Count                      : 68
Page Mode                       : UseOutlines
Author                          : Deltares
Title                           : NEFIS Programming Manual
Subject                         : 
Creator                         : LaTeX hyperref
Producer                        : ps2pdf
Keywords                        : Deltares, Programming, Manual, NEFIS
Create Date                     : 2018:04:18 06:08:24+02:00
Modify Date                     : 2018:04:18 06:08:24+02:00
Trapped                         : False
PTEX Fullbanner                 : This is MiKTeX-pdfTeX 2.9.6588 (1.40.18)
EXIF Metadata provided by EXIF.tools

Navigation menu