shiba
 All Data Structures Files Functions Variables Macros Pages
Macros | Functions
io.c File Reference

Input, output, error and memory allocation functions More...

#include <mxml.h>
#include "shiba.h"
Include dependency graph for io.c:

Go to the source code of this file.

Functions

void readXML ()
 Open file and parse XML.
 
void printIndata ()
 Output matrices for checking by user.
 
void error (char *error_msg)
 Basic error output and exit function.
 
double * mem1d_d (int dimx)
 Dimensions an initialized 1-D array of doubles.
 
int * mem1d_i (int dimx)
 Dimensions an initialized 1-D array of int.
 
int ** mem2d1_i (int dimx)
 Dimensions a initialized 1-D array of int pointers, ready to be allocated using mem1d_i() .
 
void free2d1_i (int **ptr, int dimx)
 Frees the ragged array allocated by mem2d1_i().
 
char ** mem2d1_c (int dimx)
 Dimensions a initialized 1-D array of character pointers, ready to be allocated using asprintf.
 
void free2d1_c (char **ptr, int dimx)
 Frees the ragged array allocated by mem2d1_c().
 
int ** mem2d_i (int dimx, int dimy)
 Dimensions an initialized 2-D array of int.
 
void free2d_i (int **ptr, int dimx)
 
double ** mem2d_d (int dimx, int dimy)
 Dimensions an initialized 2-D array of doubles.
 
void free2d_d (double **ptr, int dimx)
 
double *** mem3d_d (int dimx, int dimy, int dimz)
 Dimensions an initialized 3-D array of doubles.
 
void free3d_d (double ***ptr, int dimx, int dimy)
 
int *** mem3d_i (int dimx, int dimy, int dimz)
 Dimensions an initialized 3-D array of int.
 
void free3d_i (int ***ptr, int dimx, int dimy)
 
void help ()
 Default help output.
 

Detailed Description

Input, output, error and memory allocation functions

Definition in file io.c.

Function Documentation

void error ( char *  error_msg)

Basic error output and exit function.

Note that no freeing is done, possibly leading to memory leaks.

Parameters
error_msgthe error message

Definition at line 612 of file io.c.

Referenced by main(), mem1d_d(), mem1d_i(), mem2d1_c(), mem2d1_i(), mem2d_d(), mem2d_i(), mem3d_d(), mem3d_i(), parseNewick(), phyloToLineage(), readArgs(), and readXML().

void free2d1_c ( char **  ptr,
int  dimx 
)

Frees the ragged array allocated by mem2d1_c().

Parameters
dimxThe dimensions of the vector

Definition at line 700 of file io.c.

Referenced by main(), and readXML().

void free2d1_i ( int **  ptr,
int  dimx 
)

Frees the ragged array allocated by mem2d1_i().

Parameters
dimxThe dimensions of the vector

Definition at line 670 of file io.c.

Referenced by main().

double* mem1d_d ( int  dimx)

Dimensions an initialized 1-D array of doubles.

To free, just use free().

Parameters
dimxThe dimensions of the vector
Returns
A pointer to an array of doubles

Definition at line 628 of file io.c.

References error().

Referenced by parseNewick(), and readXML().

Here is the call graph for this function:

int* mem1d_i ( int  dimx)

Dimensions an initialized 1-D array of int.

To free, just use free().

Parameters
dimxThe dimensions of the vector
Returns
A pointer to an array of ints

Definition at line 643 of file io.c.

References error().

Referenced by parseNewick(), phyloToLineage(), and readXML().

Here is the call graph for this function:

char** mem2d1_c ( int  dimx)

Dimensions a initialized 1-D array of character pointers, ready to be allocated using asprintf.

The result will be a `ragged' matrix. To free, use free2d1_c() .

Parameters
dimxThe dimensions of the vector
Returns
A pointer to an array of character pointers

Definition at line 685 of file io.c.

References error().

Referenced by parseNewick(), and readXML().

Here is the call graph for this function:

int** mem2d1_i ( int  dimx)

Dimensions a initialized 1-D array of int pointers, ready to be allocated using mem1d_i() .

The result will be a `ragged' matrix. To free, use free2d1_i() .

Parameters
dimxThe dimensions of the vector
Returns
A pointer to an array of int pointers

Definition at line 658 of file io.c.

References error().

Referenced by phyloToLineage().

Here is the call graph for this function:

double** mem2d_d ( int  dimx,
int  dimy 
)

Dimensions an initialized 2-D array of doubles.

Free with free2d_d()

Definition at line 736 of file io.c.

References error().

Referenced by readXML().

Here is the call graph for this function:

int** mem2d_i ( int  dimx,
int  dimy 
)

Dimensions an initialized 2-D array of int.

Free with free2d_i()

Definition at line 712 of file io.c.

References error().

Referenced by phyloToLineage().

Here is the call graph for this function:

double*** mem3d_d ( int  dimx,
int  dimy,
int  dimz 
)

Dimensions an initialized 3-D array of doubles.

Free with free3d_d()

Definition at line 760 of file io.c.

References error().

Referenced by readXML().

Here is the call graph for this function:

int*** mem3d_i ( int  dimx,
int  dimy,
int  dimz 
)

Dimensions an initialized 3-D array of int.

Free with free3d_i()

Definition at line 793 of file io.c.

References error().

Referenced by phyloToLineage(), and readXML().

Here is the call graph for this function:

void readXML ( )

Open file and parse XML.

Derived from mini-xml website examples.

Todo:
Remove the constraint of having to have the ages included in the XML file in decreasing order. Will need a sorting stage

Definition at line 13 of file io.c.

References Area, Cfg, DataFile, Dist, error(), Extant, free2d1_c(), mem1d_d(), mem1d_i(), mem2d1_c(), mem2d_d(), mem3d_d(), mem3d_i(), Phylo, Phylos, RealTime, RUN_BATCH, Sasprintf, SpaceName, Spaces, config::startSpace, Taxa, Taxon, and Times.

Referenced by main().

Here is the call graph for this function: