---
name: "gd_spf"
section: "3"
platform: "linux"
package: "libgetdata-doc"
version: "0.11.0-15"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/gd_spf"
---

# gd\_spf(3)

returns the samples per frame for a field in a dirfile

## NAME

gd\_spf — returns the samples per frame for a field in a dirfile

## SYNOPSIS

**#include \<getdata.h\>**

**unsigned int gd\_spf(DIRFILE \****dirfile***, const char \****field\_code***);**

## DESCRIPTION

The **gd\_spf**() function queries a [dirfile(5)](/dirfile/5.md) database specified by *dirfile* and determines the number of samples per frame for the field *field\_code*. This information is also available from [**gd\_entry**(3)](/gd_entry/3.md).

The  *dirfile* argument must point to a valid DIRFILE object previously created by a call to [**gd\_open**(3)](/gd_open/3.md).

## RETURN VALUE

Upon successful completion, **gd\_spf**() returns a positive integer indicating the number of samples per frame for the field specified.  On error, it returns zero and stores a negative-valued error code in the **DIRFILE** object which may be retrieved by a subsequent call to [**gd\_error**(3)](/gd_error/3.md). Possible error codes are:\
  .TP 8 **GD\_E\_BAD\_CODE** The field specified by *field\_code* was not found in the database.\
  .TP 8 **GD\_E\_BAD\_DIRFILE** The supplied dirfile was invalid.\
  .TP 8 **GD\_E\_DIMENSION** A scalar field was found where a vector field was expected.\
  .TP 8 **GD\_E\_INTERNAL\_ERROR** An internal error occurred in the library while trying to perform the task. This indicates a bug in the library.  Please report the incident to the maintainer.\
  .TP 8 **GD\_E\_RECURSE\_LEVEL** Too many levels of recursion were encountered while trying to resolve *field\_code*. This usually indicates a circular dependency in field specification in the dirfile.

A descriptive error string for the error may be obtained by calling [**gd\_error\_string**(3)](/gd_error_string/3.md).

## HISTORY

The **get\_spf**() function appeared in GetData-0.3.0.

In GetData-0.7.0, this function was renamed to **gd\_spf**().

In GetData-0.10.0, the error return from this function changed from -1 to a negative-valued error code.

## SEE ALSO

[**gd\_entry**(3)](/gd_entry/3.md), [**gd\_error**(3)](/gd_error/3.md), [**gd\_error\_string**(3)](/gd_error_string/3.md), [**gd\_open**(3)](/gd_open/3.md), [dirfile(5)](/dirfile/5.md)
