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