ExodusII  6.05
ex_utils.c File Reference
#include <ctype.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "exodusII.h"
#include "exodusII_int.h"

Macros

#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[], int64_t left, int64_t 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)
 
void * ex_safe_free (void *array)
 

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
 

Macro Definition Documentation

◆ EX_QSORT_CUTOFF

#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.

NOTE: The 'int' implementation below assumes that both the items being sorted and the number of items being sorted are both representable as 'int'.

◆ MAGIC_NUMBER_LEN

#define MAGIC_NUMBER_LEN   4

Function Documentation

◆ ex_catstr()

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

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

◆ ex_catstr2()

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

ex_catstr2 - concatenate string1num1string2num2

◆ ex_check_file_type()

int ex_check_file_type ( const char *  path,
int *  type 
)

◆ ex_compress_variable()

void ex_compress_variable ( int  exoid,
int  varid,
int  type 
)

◆ ex_dim_num_entries_in_object()

char* ex_dim_num_entries_in_object ( ex_entity_type  obj_type,
int  idx 
)

◆ ex_dim_num_objects()

char* ex_dim_num_objects ( ex_entity_type  obj_type)

◆ ex_get_counter_list()

struct list_item** ex_get_counter_list ( ex_entity_type  obj_type)

◆ ex_get_cpu_ws()

int ex_get_cpu_ws ( void  )

◆ ex_get_dimension()

int ex_get_dimension ( int  exoid,
const char *  DIMENSION,
const char *  label,
size_t *  count,
int *  dimid,
const char *  routine 
)

◆ ex_get_file_item()

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().

◆ ex_get_name_internal()

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 
)

◆ ex_get_names_internal()

int ex_get_names_internal ( int  exoid,
int  varid,
size_t  num_entity,
char **  names,
ex_entity_type  obj_type,
const char *  routine 
)

◆ ex_get_stat_ptr()

struct obj_stats* ex_get_stat_ptr ( int  exoid,
struct obj_stats **  obj_ptr 
)

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

◆ ex_id_lkup()

int ex_id_lkup ( int  exoid,
ex_entity_type  id_type,
ex_entity_id  num 
)

◆ ex_inc_file_item()

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().

◆ ex_int_iisort()

static void ex_int_iisort ( int  v[],
int  iv[],
int  N 
)
static

◆ ex_int_iisort64()

static void ex_int_iisort64 ( int64_t  v[],
int64_t  iv[],
int64_t  N 
)
static

◆ ex_int_iqsort()

static void ex_int_iqsort ( int  v[],
int  iv[],
int  left,
int  right 
)
static

◆ ex_int_iqsort64()

static void ex_int_iqsort64 ( int64_t  v[],
int64_t  iv[],
int64_t  left,
int64_t  right 
)
static

◆ ex_int_median3()

static int ex_int_median3 ( int  v[],
int  iv[],
int64_t  left,
int64_t  right 
)
static

◆ ex_int_median3_64()

static int64_t ex_int_median3_64 ( int64_t  v[],
int64_t  iv[],
int64_t  left,
int64_t  right 
)
static

◆ ex_iqsort()

void ex_iqsort ( int  v[],
int  iv[],
int  N 
)

◆ ex_iqsort64()

void ex_iqsort64 ( int64_t  v[],
int64_t  iv[],
int64_t  N 
)

◆ ex_name_of_map()

char* ex_name_of_map ( ex_entity_type  map_type,
int  map_index 
)

◆ ex_name_var_of_object()

char* ex_name_var_of_object ( ex_entity_type  obj_type,
int  i,
int  j 
)

◆ ex_put_name_internal()

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 
)

◆ ex_put_names_internal()

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 
)

◆ ex_rm_file_item()

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().

◆ ex_rm_stat_ptr()

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

◆ ex_safe_free()

void* ex_safe_free ( void *  array)

◆ ex_swap()

static void ex_swap ( int  v[],
int  i,
int  j 
)
static

◆ ex_swap64()

static void ex_swap64 ( int64_t  v[],
int64_t  i,
int64_t  j 
)
static

◆ ex_trim_internal()

void ex_trim_internal ( char *  name)

◆ ex_update_max_name_length()

void ex_update_max_name_length ( int  exoid,
int  length 
)

Variable Documentation

◆ cur_string

char* cur_string = &ret_string[0]
static

◆ eb_ctr_list

struct list_item* eb_ctr_list = 0
static

◆ ed_ctr_list

struct list_item* ed_ctr_list = 0
static

◆ edm_ctr_list

struct list_item* edm_ctr_list = 0
static

◆ els_ctr_list

struct list_item* els_ctr_list = 0
static

◆ em_ctr_list

struct list_item* em_ctr_list = 0
static

◆ es_ctr_list

struct list_item* es_ctr_list = 0
static

◆ exoII_eb

struct obj_stats* exoII_eb = 0

◆ exoII_ed

struct obj_stats* exoII_ed = 0

◆ exoII_edm

struct obj_stats* exoII_edm = 0

◆ exoII_els

struct obj_stats* exoII_els = 0

◆ exoII_em

struct obj_stats* exoII_em = 0

◆ exoII_es

struct obj_stats* exoII_es = 0

◆ exoII_fa

struct obj_stats* exoII_fa = 0

◆ exoII_fam

struct obj_stats* exoII_fam = 0

◆ exoII_fs

struct obj_stats* exoII_fs = 0

◆ exoII_nm

struct obj_stats* exoII_nm = 0

◆ exoII_ns

struct obj_stats* exoII_ns = 0

◆ exoII_ss

struct obj_stats* exoII_ss = 0

◆ fa_ctr_list

struct list_item* fa_ctr_list = 0
static

◆ fam_ctr_list

struct list_item* fam_ctr_list = 0
static

◆ fs_ctr_list

struct list_item* fs_ctr_list = 0
static

◆ nm_ctr_list

struct list_item* nm_ctr_list = 0
static

◆ ns_ctr_list

struct list_item* ns_ctr_list = 0
static

◆ ret_string

char ret_string[10 *(MAX_VAR_NAME_LENGTH+1)]
static

◆ ss_ctr_list

struct list_item* ss_ctr_list = 0
static