1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string> 4 #include "phIO.h" 5 #include "phComm.h" 6 #include "phio_base.h" 7 #include "phio_sync.h" 8 #include "phio_posix.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 void phio_openfile_read( 52 const char filename[], 53 int* numFiles, 54 phio_fp* fileDescriptor) { 55 std::string fn(filename); 56 std::string syncSuffix("-dat"); 57 std::string posixSuffix(".dat"); 58 if( fn.find(syncSuffix) != std::string::npos ) 59 sync_openfile_read(filename, numFiles, fileDescriptor); 60 else if( fn.find(posixSuffix) != std::string::npos ) 61 posix_openfile_read(filename, fileDescriptor); 62 else { 63 fprintf(stderr, 64 "type of file %s is unknown... exiting\n", filename); 65 exit(1); 66 } 67 } 68 void phio_openfile_write( 69 const char filename[], 70 int* numFiles, 71 int* numFields, 72 int* numPPF, 73 phio_fp* fileDescriptor) { 74 std::string fn(filename); 75 std::string syncSuffix("-dat"); 76 std::string posixSuffix(".dat"); 77 if( fn.find(syncSuffix) != std::string::npos ) 78 sync_openfile_write(filename, numFiles, numFields, numPPF, fileDescriptor); 79 else if( fn.find(posixSuffix) != std::string::npos ) 80 posix_openfile_write(filename, fileDescriptor); 81 else { 82 fprintf(stderr, 83 "type of file %s is unknown... exiting\n", filename); 84 exit(1); 85 } 86 } 87 void phio_restartname(int* step, char* filename) { 88 } 89 void phio_closefile_read(phio_fp f) { 90 f->ops->closefile_read(f); 91 } 92 void phio_closefile_write(phio_fp f) { 93 f->ops->closefile_write(f); 94 } 95 96