MACSio  0.9
Multi-purpose, Application-Centric, Scalable I/O Proxy App
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
macsio_utils.h
Go to the documentation of this file.
1 #ifndef MACSIO_UTILS_H
2 #define MACSIO_UTILS_H
3 /*
4 Copyright (c) 2015, Lawrence Livermore National Security, LLC.
5 Produced at the Lawrence Livermore National Laboratory.
6 Written by Mark C. Miller
7 
8 LLNL-CODE-676051. All rights reserved.
9 
10 This file is part of MACSio
11 
12 Please also read the LICENSE file at the top of the source code directory or
13 folder hierarchy.
14 
15 This program is free software; you can redistribute it and/or modify it under
16 the terms of the GNU General Public License (as published by the Free Software
17 Foundation) version 2, dated June 1991.
18 
19 This program is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS
21 FOR A PARTICULAR PURPOSE. See the terms and conditions of the GNU General
22 Public License for more details.
23 
24 You should have received a copy of the GNU General Public License along with
25 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
26 Place, Suite 330, Boston, MA 02111-1307 USA
27 */
28 
29 #include <json-c/json.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #define MU_MAX(A,B) (((A)>(B))?(A):(B))
36 
37 /* Short-hand for commonly used functions */
38 #define MU_SeqIdx3(i,j,k,Ni,Nj) MACSIO_UTILS_LogicalIJKIndexToSequentialIndex(i,j,k,Ni,Nj)
39 #define MU_SeqIdx2(i,j,Ni) MACSIO_UTILS_LogicalIJIndexToSequentialIndex (i,j, Ni )
40 #define MU_SeqIdx1(i) MACSIO_UTILS_LogicalIIndexToSequentialIndex (i )
41 #define MU_LogIdx3(s,Ni,Nj,a,b,c) \
42 { int q0,q1,q2; \
43  MACSIO_UTILS_SequentialIndexToLogicalIJKIndex(s,Ni,Nj,&q0,&q1,&q2); \
44  a=q0;b=q1;c=q2; \
45 }
46 #define MU_LogIdx2(s,Ni,a,b) \
47 { int q0,q1; \
48  MACSIO_UTILS_SequentialIndexToLogicalIJIndex(s,Ni, &q0,&q1 ); \
49  a=q0;b=q1; \
50 }
51 #define MU_LogIdx1(s,a) \
52 { int q0; \
53  MACSIO_UTILS_SequentialIndexToLogicalIIndex(s, &q0 ); \
54  a=q0; \
55 }
56 
57 #define MU_PrByts(B,FMT,STR,N) MACSIO_UTILS_PrintBytes(B,FMT,STR,N)
58 #define MU_PrSecs(S,FMT,STR,N) MACSIO_UTILS_PrintSeconds(S,FMT,STR,N)
59 #define MU_PrBW(B,S,FMT,STR,N) MACSIO_UTILS_PrintBandwidth(B,S,FMT,STR,N)
60 
61 extern char MACSIO_UTILS_UnitsPrefixSystem[32];
62 
63 extern unsigned int MACSIO_UTILS_BJHash(const unsigned char *k, unsigned int length, unsigned int initval);
64 extern int MACSIO_UTILS_Best2DFactors(int val, int *x, int *y);
65 extern int MACSIO_UTILS_Best3DFactors(int val, int *x, int *y, int *z);
66 extern int MACSIO_UTILS_LogicalIJKIndexToSequentialIndex(int i,int j,int k,int Ni,int Nj);
67 extern int MACSIO_UTILS_LogicalIJIndexToSequentialIndex (int i,int j, int Ni );
69 extern void MACSIO_UTILS_SequentialIndexToLogicalIJKIndex(int s,int Ni,int Nj,int *i,int *j,int *k);
70 extern void MACSIO_UTILS_SequentialIndexToLogicalIJIndex(int s,int Ni,int *i,int *j);
71 extern void MACSIO_UTILS_SequentialIndexToLogicalIIndex(int s,int *i);
72 
73 extern void MACSIO_UTILS_SetDims(int *dims, int nx, int ny, int nz);
74 extern int MACSIO_UTILS_XDim(int const *dims);
75 extern int MACSIO_UTILS_YDim(int const *dims);
76 extern int MACSIO_UTILS_ZDim(int const *dims);
77 extern void MACSIO_UTILS_SetBounds(double *bounds,
78  double xmin, double ymin, double zmin,
79  double xmax, double ymax, double zmax);
80 extern double MACSIO_UTILS_XRange(double const *bounds);
81 extern double MACSIO_UTILS_YRange(double const *bounds);
82 extern double MACSIO_UTILS_ZRange(double const *bounds);
83 extern double MACSIO_UTILS_XMin(double const *bounds);
84 extern double MACSIO_UTILS_YMin(double const *bounds);
85 extern double MACSIO_UTILS_ZMin(double const *bounds);
86 extern double MACSIO_UTILS_XMax(double const *bounds);
87 extern double MACSIO_UTILS_YMax(double const *bounds);
88 extern double MACSIO_UTILS_ZMax(double const *bounds);
89 extern double MACSIO_UTILS_XDelta(int const *dims, double const *bounds);
90 extern double MACSIO_UTILS_YDelta(int const *dims, double const *bounds);
91 extern double MACSIO_UTILS_ZDelta(int const *dims, double const *bounds);
92 extern json_object * MACSIO_UTILS_MakeDimsJsonArray(int ndims, const int *dims);
93 extern json_object * MACSIO_UTILS_MakeBoundsJsonArray(double const * bounds);
94 
95 extern char const *MACSIO_UTILS_PrintBytes(unsigned long long bytes, char const *fmt, char *str, int n);
96 extern char const *MACSIO_UTILS_PrintSeconds(double seconds, char const *fmt, char *str, int n);
97 extern char const *MACSIO_UTILS_PrintBandwidth(unsigned long long bytes, double seconds,
98  char const *fmt, char *str, int n);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif
void MACSIO_UTILS_SequentialIndexToLogicalIJKIndex(int s, int Ni, int Nj, int *i, int *j, int *k)
Definition: macsio_utils.c:184
double MACSIO_UTILS_ZMax(double const *bounds)
Definition: macsio_utils.c:230
double MACSIO_UTILS_ZRange(double const *bounds)
Definition: macsio_utils.c:224
void MACSIO_UTILS_SequentialIndexToLogicalIJIndex(int s, int Ni, int *i, int *j)
Definition: macsio_utils.c:190
double MACSIO_UTILS_ZMin(double const *bounds)
Definition: macsio_utils.c:227
int MACSIO_UTILS_Best3DFactors(int val, int *x, int *y, int *z)
Definition: macsio_utils.c:121
double MACSIO_UTILS_ZDelta(int const *dims, double const *bounds)
Definition: macsio_utils.c:241
int MACSIO_UTILS_LogicalIJIndexToSequentialIndex(int i, int j, int Ni)
Definition: macsio_utils.c:181
double MACSIO_UTILS_XMin(double const *bounds)
Definition: macsio_utils.c:225
char const * MACSIO_UTILS_PrintBandwidth(unsigned long long bytes, double seconds, char const *fmt, char *str, int n)
Definition: macsio_utils.c:370
unsigned int MACSIO_UTILS_BJHash(const unsigned char *k, unsigned int length, unsigned int initval)
Definition: macsio_utils.c:62
double MACSIO_UTILS_YDelta(int const *dims, double const *bounds)
Definition: macsio_utils.c:236
double MACSIO_UTILS_XMax(double const *bounds)
Definition: macsio_utils.c:228
int MACSIO_UTILS_Best2DFactors(int val, int *x, int *y)
Definition: macsio_utils.c:101
double MACSIO_UTILS_YMin(double const *bounds)
Definition: macsio_utils.c:226
void MACSIO_UTILS_SequentialIndexToLogicalIIndex(int s, int *i)
Definition: macsio_utils.c:195
void MACSIO_UTILS_SetDims(int *dims, int nx, int ny, int nz)
Definition: macsio_utils.c:200
json_object * MACSIO_UTILS_MakeBoundsJsonArray(double const *bounds)
Definition: macsio_utils.c:261
int MACSIO_UTILS_XDim(int const *dims)
Definition: macsio_utils.c:206
double MACSIO_UTILS_YMax(double const *bounds)
Definition: macsio_utils.c:229
int MACSIO_UTILS_ZDim(int const *dims)
Definition: macsio_utils.c:208
double MACSIO_UTILS_XRange(double const *bounds)
Definition: macsio_utils.c:222
double MACSIO_UTILS_XDelta(int const *dims, double const *bounds)
Definition: macsio_utils.c:231
double MACSIO_UTILS_YRange(double const *bounds)
Definition: macsio_utils.c:223
char const * MACSIO_UTILS_PrintSeconds(double seconds, char const *fmt, char *str, int n)
Definition: macsio_utils.c:376
char const * MACSIO_UTILS_PrintBytes(unsigned long long bytes, char const *fmt, char *str, int n)
Definition: macsio_utils.c:365
int MACSIO_UTILS_YDim(int const *dims)
Definition: macsio_utils.c:207
int MACSIO_UTILS_LogicalIIndexToSequentialIndex(int i)
Definition: macsio_utils.c:182
void MACSIO_UTILS_SetBounds(double *bounds, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
Definition: macsio_utils.c:210
int MACSIO_UTILS_LogicalIJKIndexToSequentialIndex(int i, int j, int k, int Ni, int Nj)
Definition: macsio_utils.c:180
json_object * MACSIO_UTILS_MakeDimsJsonArray(int ndims, const int *dims)
Definition: macsio_utils.c:248
char MACSIO_UTILS_UnitsPrefixSystem[32]
Definition: macsio_utils.c:34