### 3.4.2. Initialization and Error Routines

The following routines open and close the CFX results file, initialize the Export API, and handle fatal error processing. The first call to any of the API routines must be `cfxExportInit` and the last call should be `cfxExportDone`. For details, see:

- cfxExportInit

- cfxExportDone.

#### 3.4.2.1. cfxExportInit

    int cfxExportInit (char *resfile, int counts[cfxCNT_SIZE])

Opens the CFX results file named `resfile` and initializes the Export API. This should be the first call made to the API.

The routine returns the total number of zones. If the array `counts` is supplied to the routine (that is, it is not `NULL`), the array is filled with values representing the total number of nodes, elements, volumes, regions and variables for all the zones are returned in this array.

#### 3.4.2.2. cfxExportDone

    void cfxExportDone ()

Closes the CFX results file and destroys any internal storage used by the API. This should be the final call made to the Export API.

#### 3.4.2.3. cfxExportError

    void cfxExportError (void (*callback) (char *errmsg))

Specify a callback function that will be executed when a fatal error is generated by a call to `cfxImportFatal` (see cfxImportFatal). The argument, callback, is the function that will be called, it should take an argument that is the error message passed to cfxImportFatal. It is the responsibility of the function to terminate the application if required.

#### 3.4.2.4. cfxExportFatal

    void cfxExportFatal (char *errmsg)

Generate a fatal error message (`errmsg`) and close the ANSYS CFX results file. This routine also calls a callback function, if one has been specified by `cfxExportError` (see cfxExportError). If no callback function has been specified the function also terminates the application. There is no return from this call.

Release 18.2 - © ANSYS, Inc. All rights reserved.