1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <cstring> 4 #include <string> 5 #include <sstream> 6 #include "phIO.h" 7 #include "phComm.h" 8 #include "phio_base.h" 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 void phio_readheader( 15 phio_fp f, 16 const char keyphrase[], 17 void* valueArray, 18 int* nItems, 19 const char datatype[], 20 const char iotype[] ) { 21 f->ops->readheader(f->file, keyphrase, valueArray, 22 nItems, datatype, iotype); 23 } 24 void phio_writeheader( 25 phio_fp f, 26 const char keyphrase[], 27 const void* valueArray, 28 const int* nItems, 29 const int* ndataItems, 30 const char datatype[], 31 const char iotype[] ) { 32 f->ops->writeheader(f->file, keyphrase, valueArray, 33 nItems, ndataItems, datatype, iotype); 34 } 35 void phio_readdatablock( 36 phio_fp f, 37 const char keyphrase[], 38 void* valueArray, 39 int* nItems, 40 const char datatype[], 41 const char iotype[] ) { 42 f->ops->readdatablock(f->file, keyphrase, valueArray, 43 nItems, datatype, iotype); 44 } 45 void phio_writedatablock( 46 phio_fp f, 47 const char keyphrase[], 48 const void* valueArray, 49 const int* nItems, 50 const char datatype[], 51 const char iotype[]) { 52 f->ops->writedatablock(f->file, keyphrase, valueArray, 53 nItems, datatype, iotype); 54 } 55 56 void phio_constructName( 57 phio_format format, 58 const char inName[], 59 char* outName) { 60 std::string fullname(inName); 61 std::string gname("geombc"); 62 //sync restart and geombc gets '-dat' 63 if( format == PHIO_SYNC ) 64 fullname.append("-dat"); 65 //posix geombc gets '.dat' 66 else if( format == PHIO_POSIX && 67 fullname.find(gname) != std::string::npos ) 68 fullname.append(".dat"); 69 //posix restart gets nothing 70 sprintf(outName, "%s", fullname.c_str()); 71 } 72 73 void phio_openfile( 74 const char filename[], 75 phio_fp f) { 76 f->ops->openfile(filename, f); 77 } 78 79 void phio_closefile(phio_fp f) { 80 f->ops->closefile(f); 81 } 82 83 void phio_appendStep(char* dest, int v) { 84 std::stringstream ss; 85 ss << dest << v << '.'; 86 std::string s = ss.str(); 87 strcpy(dest, s.c_str()); 88 } 89 90 #ifdef __cplusplus 91 } 92 #endif 93