FES C SDK
Programmer's Guide


FES License
This software have been tested on Linux platform and It's provided without any guarantees.

For report bug, please contact:
Fabien Levefvre
CLS
Direction Océanographie Spatiale
8-10, rue Hermès - Parc Technologique du Canal
31526 Ramonville Saint-Agne cedex - France
Tel: +33 (0)5 61 39 37 45 Fax: +33 (0)5 61 39 37 82

Note
This software is based on the former versions developed by Jean-Marc MOLINES and Florent LYARD.

Data type and structure
This chapter describes the data structures and data types used by functions in the FES API.
fesData

fesData is a type of structure representing the internal data. fesData is not completely defined in fes.h because the fields within the structure are not intended to be accessible.

To create and free a fesData structure, call the following functions:
Function reference

This chapter contains a reference to the public functions of the FES C SDK. Along with a detailed description of each function, the function reference details the function header file and syntax, the function parameters, and what the function returns. In many cases an example program is included with the description.

fesNew()

The fesNew function initializes the computation of the tide. You can specify the computation mode (FES_SHORT_TIDE or FES_RADIAL_TIDE).

Syntax
#include <fes.h>
int fesNew(fesData** fes, const int mode, const int shortTide, const char* const dir);


Parameters
This function has the following parameters:

fesData
Internal data handle, which is a pointer to a fesData structure containing information about the tide computation.
shortTide
Computation mode. If mode is equals to FES_SHORT_TIDE, fesCore computes the short tide otherwise she computes the radial tide.
mode
One  of  FES_MEM, FES_IO, FES_ASCII which request loading grids into memory, direct access from binary grids or loading ASCII grids into memory.
dir
Directory containing grids.

Returns
One of the fallowing values:
Example
#include "fes.h"
fesData*    fes;
char* dir ="./data";
...
fesNew(&fes, FES_SHORT_TIDE, FES_IO, dir);
...


fesCore()

Computes tide.

Syntax
#include <fes.h>
int fesCore(fesData* fes, const double lat, const double lon, const double time, double* h, double* hLp);

 
Parameters
This function has the following parameters:
fes
Internal data handle, which is a pointer to a fesData structure containing information about the tide computation.
lat
Latitude in degrees (positive north) for the position at which tide is computed.
lon
Longitude in degrees (positive north) for the position at which tide is computed.
time
Julian day (days since 1950-01-01 00:00:00.000 UTC).
h
Computed height of the diurnal and semi-diunral constituents of the tidal spectrum (in centimeters).
hLp
Computed height of the long period wave constituents of the tidal spectrum (in centimeters). It's always equal to zero for the radial tide.

Returns
One of the fallowing values:
Description

compute elevation for tides and loading effects

Example

...
rc = fesCore(fes, lat, lon, time, &h, &hLp);
if( rc == FES_SUCCESS )
    fprintf(stdout, "Geocentric tide is %8.6lf\n", h + hLp);
else if( rc == FES_NO_DATA )
    fprintf(stdout, "No tide available at this position (land or grid mask)\n");
else
    fprintf(stderr, "An error occurred: %s\n", fessErr2String(rc));
....


fesDelete()


The fesDelete() function frees a fesData structure from memory. Call this function to free any fesData structures that you have allocated by fesNew function call.

Syntax

#include <fes.h>
void fesDelete(fesData* fes);

Parameters
This function has the following parameters:

fes
Pointer to the fesData structure that you want to free.

Example
#include "fes.h"
fesData*    fes;
...
fesDelete(fes);
...


fesErr2String()


The fesErr2String() function returns the corresponding error message for an error code.

Syntax
#include "fes.h"
char* fesErr2String( const int err );


Parameters
This function has the following parameters:

err
Error code that you want interpreted into an error message.

Returns
One of the following values:
Example
...
err_msg = fesErr2String( fesCore(fes, lat, lon, time, &h, &hLp, &hInt) );
...

Result code

This chapter lists the result codes that can be returned by functions in the FES C SDK.

FES_SUCCESS

This result code indicates that the LDAP operation was successful. 

FES_INPUT_ERROR

This result code indicates that an error occurred when FES read a grid. 

FES_ACCESS_ERROR

This result code indicates that the grids are not readable.

FES_GRIDS_CONSTANT

This result code indicates that the Definition of the grids is not constant.

FES_NO_MEMORY

This result code indicates that no memory is available.

FES_NO_DATA

This result code indicates that no data is available.

FES_MODE_ERORR

This result code indicates that the request mode to grids is not allowed.