ExodusII  5.15
ex_utils.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "exodusII.h"
#include "exodusII_int.h"

Defines

#define MAGIC_NUMBER_LEN   4
#define EX_QSORT_CUTOFF   12

Functions

int ex_check_file_type (const char *path, int *type)
int ex_set_max_name_length (int exoid, int length)
void ex_update_max_name_length (int exoid, int length)
int ex_put_names_internal (int exoid, int varid, size_t num_entity, char **names, ex_entity_type obj_type, const char *subtype, const char *routine)
int ex_put_name_internal (int exoid, int varid, size_t index, const char *name, ex_entity_type obj_type, const char *subtype, const char *routine)
int ex_get_names_internal (int exoid, int varid, size_t num_entity, char **names, ex_entity_type obj_type, const char *routine)
int ex_get_name_internal (int exoid, int varid, size_t index, char *name, int name_size, ex_entity_type obj_type, const char *routine)
void ex_trim_internal (char *name)
char * ex_catstr (const char *string, int num)
char * ex_catstr2 (const char *string1, int num1, const char *string2, int num2)
char * ex_name_of_object (ex_entity_type obj_type)
ex_entity_type ex_var_type_to_ex_entity_type (char var_type)
char * ex_dim_num_objects (ex_entity_type obj_type)
char * ex_dim_num_entries_in_object (ex_entity_type obj_type, int idx)
char * ex_name_var_of_object (ex_entity_type obj_type, int i, int j)
char * ex_name_of_map (ex_entity_type map_type, int map_index)
int ex_id_lkup (int exoid, ex_entity_type id_type, ex_entity_id num)
struct obj_statsex_get_stat_ptr (int exoid, struct obj_stats **obj_ptr)
void ex_rm_stat_ptr (int exoid, struct obj_stats **obj_ptr)
struct list_item ** ex_get_counter_list (ex_entity_type obj_type)
int ex_inc_file_item (int exoid, struct list_item **list_ptr)
int ex_get_file_item (int exoid, struct list_item **list_ptr)
void ex_rm_file_item (int exoid, struct list_item **list_ptr)
int ex_get_num_props (int exoid, ex_entity_type obj_type)
int ex_get_cpu_ws (void)
static void ex_swap (int v[], int i, int j)
static void ex_swap64 (int64_t v[], int64_t i, int64_t j)
static int ex_int_median3 (int v[], int iv[], int left, int right)
static int64_t ex_int_median3_64 (int64_t v[], int64_t iv[], int64_t left, int64_t right)
static void ex_int_iqsort (int v[], int iv[], int left, int right)
static void ex_int_iqsort64 (int64_t v[], int64_t iv[], int64_t left, int64_t right)
static void ex_int_iisort (int v[], int iv[], int N)
static void ex_int_iisort64 (int64_t v[], int64_t iv[], int64_t N)
void ex_iqsort (int v[], int iv[], int N)
void ex_iqsort64 (int64_t v[], int64_t iv[], int64_t N)
int ex_large_model (int exoid)
int ex_get_dimension (int exoid, const char *DIMENSION, const char *label, size_t *count, int *dimid, const char *routine)
size_t ex_header_size (int exoid)
void ex_compress_variable (int exoid, int varid, int type)

Variables

struct obj_statsexoII_eb = 0
struct obj_statsexoII_ed = 0
struct obj_statsexoII_fa = 0
struct obj_statsexoII_ns = 0
struct obj_statsexoII_es = 0
struct obj_statsexoII_fs = 0
struct obj_statsexoII_ss = 0
struct obj_statsexoII_els = 0
struct obj_statsexoII_em = 0
struct obj_statsexoII_edm = 0
struct obj_statsexoII_fam = 0
struct obj_statsexoII_nm = 0
static char ret_string [10 *(MAX_VAR_NAME_LENGTH+1)]
static char * cur_string = &ret_string[0]
static struct list_itemed_ctr_list = 0
static struct list_itemfa_ctr_list = 0
static struct list_itemeb_ctr_list = 0
static struct list_itemns_ctr_list = 0
static struct list_itemes_ctr_list = 0
static struct list_itemfs_ctr_list = 0
static struct list_itemss_ctr_list = 0
static struct list_itemels_ctr_list = 0
static struct list_itemnm_ctr_list = 0
static struct list_itemedm_ctr_list = 0
static struct list_itemfam_ctr_list = 0
static struct list_itemem_ctr_list = 0

Define Documentation

#define EX_QSORT_CUTOFF   12

The following 'indexed qsort' routine is modified from Sedgewicks algorithm It selects the pivot based on the median of the left, right, and center values to try to avoid degenerate cases ocurring when a single value is chosen. It performs a quicksort on intervals down to the EX_QSORT_CUTOFF size and then performs a final insertion sort on the almost sorted final array. Based on data in Sedgewick, the EX_QSORT_CUTOFF value should be between 5 and 20.

See Sedgewick for further details Define DEBUG_QSORT at the top of this file and recompile to compile in code that verifies that the array is sorted.

#define MAGIC_NUMBER_LEN   4

Function Documentation

char* ex_catstr ( const char *  string,
int  num 
)

ex_catstr - concatenate string/number (where number is converted to ASCII)

char* ex_catstr2 ( const char *  string1,
int  num1,
const char *  string2,
int  num2 
)

ex_catstr2 - concatenate string1num1string2num2

int ex_check_file_type ( const char *  path,
int *  type 
)
void ex_compress_variable ( int  exoid,
int  varid,
int  type 
)
char* ex_dim_num_entries_in_object ( ex_entity_type  obj_type,
int  idx 
)
char* ex_dim_num_objects ( ex_entity_type  obj_type)
struct list_item** ex_get_counter_list ( ex_entity_type  obj_type) [read]
int ex_get_cpu_ws ( void  )
int ex_get_dimension ( int  exoid,
const char *  DIMENSION,
const char *  label,
size_t *  count,
int *  dimid,
const char *  routine 
)
int ex_get_file_item ( int  exoid,
struct list_item **  list_ptr 
)

this routine accesses a structure to track and increment a counter for each open exodus file. it is designed to be used by the routines ex_put_elem_block(), and ex_put_set_param(), to get the number of element blocks, or a type of set, respectively, for an open exodus II file.

The list structure is used as follows:

ptr -----------> list item structure ------------------- exodus file id item value (int) ptr to next (NULL if last)

NOTE: since netCDF reuses its file ids, and a user may open and close any number of files in one application, items must be taken out of the linked lists in each of the above routines. these should be called after ncclose().

int ex_get_name_internal ( int  exoid,
int  varid,
size_t  index,
char *  name,
int  name_size,
ex_entity_type  obj_type,
const char *  routine 
)
int ex_get_names_internal ( int  exoid,
int  varid,
size_t  num_entity,
char **  names,
ex_entity_type  obj_type,
const char *  routine 
)
int ex_get_num_props ( int  exoid,
ex_entity_type  obj_type 
)
struct obj_stats* ex_get_stat_ptr ( int  exoid,
struct obj_stats **  obj_ptr 
) [read]

this routine returns a pointer to a structure containing the ids of element blocks, node sets, or side sets according to exoid; if there is not a structure that matches the exoid, one is created

size_t ex_header_size ( int  exoid)
int ex_id_lkup ( int  exoid,
ex_entity_type  id_type,
ex_entity_id  num 
)
int ex_inc_file_item ( int  exoid,
struct list_item **  list_ptr 
)

this routine sets up a structure to track and increment a counter for each open exodus file. it is designed to be used by the routines ex_put_elem_block() and ex_put_set_param(), to keep track of the number of element blocks, and each type of set, respectively, for each open exodus II file.

The list structure is used as follows:

ptr -----------> list item structure ------------------- exodus file id item value (int) ptr to next (NULL if last)

NOTE: since netCDF reuses its file ids, and a user may open and close any number of files in one application, items must be taken out of the linked lists in each of the above routines. these should be called after ncclose().

static void ex_int_iisort ( int  v[],
int  iv[],
int  N 
) [static]
static void ex_int_iisort64 ( int64_t  v[],
int64_t  iv[],
int64_t  N 
) [static]
static void ex_int_iqsort ( int  v[],
int  iv[],
int  left,
int  right 
) [static]
static void ex_int_iqsort64 ( int64_t  v[],
int64_t  iv[],
int64_t  left,
int64_t  right 
) [static]
static int ex_int_median3 ( int  v[],
int  iv[],
int  left,
int  right 
) [static]
static int64_t ex_int_median3_64 ( int64_t  v[],
int64_t  iv[],
int64_t  left,
int64_t  right 
) [static]
void ex_iqsort ( int  v[],
int  iv[],
int  N 
)
void ex_iqsort64 ( int64_t  v[],
int64_t  iv[],
int64_t  N 
)
int ex_large_model ( int  exoid)

Determine whether the new large model storage is being used in this file, or old method. Basically, the difference is whether the coordinates and nodal variables are stored in a blob (xyz components together) or as a variable per component per nodal_variable.

char* ex_name_of_map ( ex_entity_type  map_type,
int  map_index 
)
char* ex_name_of_object ( ex_entity_type  obj_type)
char* ex_name_var_of_object ( ex_entity_type  obj_type,
int  i,
int  j 
)
int ex_put_name_internal ( int  exoid,
int  varid,
size_t  index,
const char *  name,
ex_entity_type  obj_type,
const char *  subtype,
const char *  routine 
)
int ex_put_names_internal ( int  exoid,
int  varid,
size_t  num_entity,
char **  names,
ex_entity_type  obj_type,
const char *  subtype,
const char *  routine 
)
void ex_rm_file_item ( int  exoid,
struct list_item **  list_ptr 
)

this routine removes a structure to track and increment a counter for each open exodus file.

The list structure is used as follows:

ptr -----------> list item structure ------------------- exodus file id item value (int) ptr to next (NULL if last)

NOTE: since netCDF reuses its file ids, and a user may open and close any number of files in one application, items must be taken out of the linked lists in each of the above routines. these should be called after ncclose().

void ex_rm_stat_ptr ( int  exoid,
struct obj_stats **  obj_ptr 
)

this routine removes a pointer to a structure containing the ids of element blocks, node sets, or side sets according to exoid; this is necessary to clean up because netCDF reuses file ids; should be called from ex_close

int ex_set_max_name_length ( int  exoid,
int  length 
)

Note that the max name length setting is global at this time; not specific to a particular database; however, the exoid option is passed to give flexibility in the future to implement this on a database-by-database basis.

static void ex_swap ( int  v[],
int  i,
int  j 
) [static]
static void ex_swap64 ( int64_t  v[],
int64_t  i,
int64_t  j 
) [static]
void ex_trim_internal ( char *  name)
void ex_update_max_name_length ( int  exoid,
int  length 
)

Variable Documentation

char* cur_string = &ret_string[0] [static]
struct list_item* eb_ctr_list = 0 [static]
struct list_item* ed_ctr_list = 0 [static]
struct list_item* edm_ctr_list = 0 [static]
struct list_item* els_ctr_list = 0 [static]
struct list_item* em_ctr_list = 0 [static]
struct list_item* es_ctr_list = 0 [static]
struct obj_stats* exoII_eb = 0
struct obj_stats* exoII_ed = 0
struct obj_stats* exoII_edm = 0
struct obj_stats* exoII_els = 0
struct obj_stats* exoII_em = 0
struct obj_stats* exoII_es = 0
struct obj_stats* exoII_fa = 0
struct obj_stats* exoII_fam = 0
struct obj_stats* exoII_fs = 0
struct obj_stats* exoII_nm = 0
struct obj_stats* exoII_ns = 0
struct obj_stats* exoII_ss = 0
struct list_item* fa_ctr_list = 0 [static]
struct list_item* fam_ctr_list = 0 [static]
struct list_item* fs_ctr_list = 0 [static]
struct list_item* nm_ctr_list = 0 [static]
struct list_item* ns_ctr_list = 0 [static]
char ret_string[10 *(MAX_VAR_NAME_LENGTH+1)] [static]
struct list_item* ss_ctr_list = 0 [static]
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines