4 #if __BYTE_ORDER == __LITTLE_ENDIAN 5 #define htobe(x) SF::byte_swap(x) 6 #define betoh(x) SF::byte_swap(x) 9 #define MT_ENDIANNESS 0 13 #define htole(x) SF::byte_swap(x) 14 #define letoh(x) SF::byte_swap(x) 15 #define MT_ENDIANNESS 1 26 char* inp = (
char* ) (& in );
27 char* outp = (
char* ) (& out);
28 size_t size =
sizeof(T);
45 outp[0] = inp[7], outp[1] = inp[6];
46 outp[2] = inp[5], outp[3] = inp[4];
47 outp[4] = inp[3], outp[5] = inp[2];
48 outp[6] = inp[1], outp[7] = inp[0];
52 for(
size_t i=0; i<size; i++)
53 outp[i] = inp[size-1-i];
68 return (access(filename.c_str(), F_OK) == 0);
74 size_t oldpos = ftell(fd);
75 fseek(fd, 0L, SEEK_END);
76 size_t sz = ftell(fd);
77 fseek(fd, oldpos, SEEK_SET);
84 const int errnum,
const bool do_exit,
int rank)
87 fprintf(stderr,
"%s: IO error occured when opening file %s.\n%s\n\n", caller, file,
T byte_swap(T in)
swap the bytes of int, float, doubles, etc..
size_t file_size(FILE *fd)
return file size from a file descriptor
bool fileExists(std::string filename)
Function which checks if a given file exists.
void treat_file_open_error(const char *file, const char *caller, const int errnum, const bool do_exit, int rank)
treat a file open error by displaying the errnum string interpretation and the caller ...