Miscelaneous functions

function chfl_version()

Get the version of the Chemfiles library.

Return:character (len=CHFL_STRING_LENGTH)
CHFL_STRING_LENGTH [integer]

Chemfiles uses fixed length strings, containing at most CHFL_STRING_LENGTH characters. If you need longer strings than the default (1024), you will need to edit the corresponding source code.

Error handling

function chfl_last_error()

Get the last error message emmited by Chemfiles.

Return:character (len=CHFL_STRING_LENGTH)
subroutine chfl_clear_errors([status])

Clear the last error message emmited by Chemfiles.

Options:status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS, use chfl_last_error() to learn more about the error.

All chemfiles functions have an optional status argument which is an integer of kind chfl_status, and can take the following values:

chfl_status [integer]

Kind parameter for subroutine and function optional integer status.

CHFL_SUCCESS [integer(chfl_status)]

Status for successful operations.

CHFL_MEMORY_ERROR [integer(chfl_status)]

Status code for error concerning memory: out of memory, wrong size for pre-allocated buffers, etc.

CHFL_FILE_ERROR [integer(chfl_status)]

Status code for error concerning files: the file do not exist, the user does not have rights to open it, etc.

CHFL_FORMAT_ERROR [integer(chfl_status)]

Status code for error in file formating, i.e. for invalid files.

CHFL_SELECTION_ERROR [integer(chfl_status)]

Status code for invalid selection strings.

CHFL_CONFIGURATION_ERROR [integer(chfl_status)]

Status code for configuration files errors.

CHFL_OUT_OF_BOUNDS [integer(chfl_status)]

Status code for out of bounds indexing.

CHFL_PROPERTY_ERROR [integer(chfl_status)]

Status code for errors related to properties.

CHFL_GENERIC_ERROR [integer(chfl_status)]

Status code for any other error from Chemfiles.

CHFL_CXX_ERROR [integer(chfl_status)]

Status code for error in the C++ standard library.

Warnings

subroutine chfl_set_warning_callback(callback[, status])

Chemfiles sends warning on various events, for example invalid files or errors in the API usage. By default they are printed to the standard error stream, but you can redirect them by setting a callback to be called on each event with the event message. This function set the callback for all warning events.

Parameters:callback [procedure(chfl_warning_callback)] :: warning callback
Options:status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS, use chfl_last_error() to learn more about the error.
subroutine chfl_warning_callback(message)

Interface for the warning callback to be used with chfl_set_warning_callback.

Parameters:message [string] :: The warning message

Configuration files

subroutine chfl_add_configuration(path[, status])

Read configuration data from the file at path.

By default, chemfiles reads configuration from any file named .chemfiles.toml or chemfiles.toml in the current directory or any parent directory. This function can be used to add data from another configuration file.

This function will fail if there is no file at path, or if the file is incorectly formatted. Data from the new configuration file will overwrite any existing data.

Parameters:path [character(len=*)] :: the new configuration file path
Options:status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS, use chfl_last_error() to learn more about the error.