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->writedatablock(f->file, keyphrase, valueArray, 29 nItems, 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 const int* fileDescriptor, 43 const char keyphrase[], 44 const void* valueArray, 45 const int* nItems, 46 const char datatype[], 47 const char iotype[]) { 48 } 49 void phio_openfile_read( 50 const char filename[], 51 int* numFiles, 52 phio_fp* fileDescriptor) { 53 std::string fn(filename); 54 std::string syncSuffix("-dat"); 55 std::string posixSuffix(".dat"); 56 if( fn.find(syncSuffix) != std::string::npos ) 57 sync_openfile_read(filename, numFiles, fileDescriptor); 58 else if( fn.find(posixSuffix) != std::string::npos ) 59 posix_openfile_read(filename, fileDescriptor); 60 else { 61 fprintf(stderr, 62 "type of file %s is unknown... exiting\n", filename); 63 exit(1); 64 } 65 } 66 void phio_openfile_write( 67 const char filename[], 68 int* numFiles, 69 int* numFields, 70 int* numPPF, 71 phio_fp* fileDescriptor) { 72 std::string fn(filename); 73 std::string syncSuffix("-dat"); 74 std::string posixSuffix(".dat"); 75 if( fn.find(syncSuffix) != std::string::npos ) 76 sync_openfile_write(filename, numFiles, numFields, numPPF, fileDescriptor); 77 else if( fn.find(posixSuffix) != std::string::npos ) 78 posix_openfile_write(filename, fileDescriptor); 79 else { 80 fprintf(stderr, 81 "type of file %s is unknown... exiting\n", filename); 82 exit(1); 83 } 84 } 85 void phio_restartname(int* step, char* filename) { 86 } 87 void phio_closefile_read(phio_fp f) { 88 f->ops->closefile_read(f); 89 } 90 void phio_closefile_write(phio_fp f) { 91 f->ops->closefile_write(f); 92 } 93 94