Files | |
| file | libpsio/close.cc |
| file | done.cc |
| file | lib/libpsio/error.cc |
| file | get_address.cc |
| file | get_filename.cc |
| file | get_global_address.cc |
| file | get_length.cc |
| file | get_numvols.cc |
| file | get_volpath.cc |
| file | libpsio/init.cc |
| file | open.cc |
| file | open_check.cc |
| file | read.cc |
| file | read_entry.cc |
| file | rw.cc |
| file | tocclean.cc |
| file | toclast.cc |
| file | toclen.cc |
| file | tocprint.cc |
| file | tocread.cc |
| file | tocscan.cc |
| file | tocwrite.cc |
| file | volseek.cc |
| file | write.cc |
| file | write_entry.cc |
Functions | |
| int | psio_done (void) |
| void | psio_error (unsigned int unit, unsigned int errval) |
| psio_address | psio_get_address (psio_address start, ULI shift) |
| psio_address | psio_get_global_address (psio_address entry_start, psio_address rel_address) |
| ULI | psio_get_length (psio_address sadd, psio_address eadd) |
| unsigned int | psio_get_numvols_default (void) |
| int | psio_init (void) |
| int | psio_state () |
| int | psio_open (unsigned int unit, int status) |
| int | psio_open_check (unsigned int unit) |
| void | psi::PSIO::rw (unsigned int unit, char *buffer, psio_address address, ULI size, int wrt) |
| int | psio_read (unsigned int unit, char *key, char *buffer, ULI size, psio_address start, psio_address *end) |
| int | psio_read_entry (unsigned int unit, char *key, char *buffer, ULI size) |
| int | psio_rw (unsigned int unit, char *buffer, psio_address address, ULI size, int wrt) |
| int | psio_tocclean (unsigned int unit, char *key) |
| void | psio_tocprint (unsigned int unit, FILE *output) |
| psio_tocentry * | psio_tocscan (unsigned int unit, char *key) |
| int | psio_tocwrite (unsigned int unit) |
| int | psio_volseek (psio_vol *vol, ULI page, ULI offset, ULI numvols) |
| int | psio_write (unsigned int unit, char *key, char *buffer, ULI size, psio_address start, psio_address *end) |
| int | psio_write_entry (unsigned int unit, char *key, char *buffer, ULI size) |
| int psio_done | ( | void | ) |
| void psio_error | ( | unsigned int | unit, | |
| unsigned int | errval | |||
| ) |
PSIO_ERROR(): Print out an error message for libpsio.
| unit | = file number | |
| errval | = error code (defined symbolically, PSIO_ERROR_XXX) |
Definition at line 23 of file lib/libpsio/error.cc.
References psio_tocwrite().
Referenced by psi::PSIO::close(), psi::PSIO::open(), psi::PSIO::read(), psi::PSIO::rw(), psi::PSIO::tocclean(), psi::PSIO::tocscan(), and psi::PSIO::write().
00023 { 00024 int i; 00025 00026 fprintf(stderr, "PSIO_ERROR: unit = %d\n", unit); 00027 /* Try to save the TOCs for all open units */ 00028 /* psio_tocwrite() does not call psio_error() so this is OK */ 00029 for (i=0; i < PSIO_MAXUNIT; i++) 00030 psio_tocwrite(i); 00031 00032 switch (errval) { 00033 case PSIO_ERROR_INIT: 00034 fprintf(stderr, "PSIO_ERROR: %d (I/O inititalization failed)\n", PSIO_ERROR_INIT); 00035 break; 00036 case PSIO_ERROR_DONE: 00037 fprintf(stderr, "PSIO_ERROR: %d (I/O cleanup failed)\n", PSIO_ERROR_DONE); 00038 break; 00039 case PSIO_ERROR_MAXVOL: 00040 fprintf(stderr, "PSIO_ERROR: %d (maximum number of volumes exceeded)\n", PSIO_ERROR_MAXVOL); 00041 break; 00042 case PSIO_ERROR_NOVOLPATH: 00043 fprintf(stderr, "PSIO_ERROR: %d (no volume path given)\n", PSIO_ERROR_NOVOLPATH); 00044 break; 00045 case PSIO_ERROR_IDENTVOLPATH: 00046 fprintf(stderr, "PSIO_ERROR: %d (two identical volume paths)\n", PSIO_ERROR_IDENTVOLPATH); 00047 break; 00048 case PSIO_ERROR_OPEN: 00049 fprintf(stderr, "PSIO_ERROR: %d (file not open or open call failed)\n", PSIO_ERROR_OPEN); 00050 break; 00051 case PSIO_ERROR_REOPEN: 00052 fprintf(stderr, "PSIO_ERROR: %d (file is already open)\n", PSIO_ERROR_REOPEN); 00053 break; 00054 case PSIO_ERROR_CLOSE: 00055 fprintf(stderr, "PSIO_ERROR: %d (file close failed)\n", PSIO_ERROR_CLOSE); 00056 break; 00057 case PSIO_ERROR_RECLOSE: 00058 fprintf(stderr, "PSIO_ERROR: %d (file is already closed)\n", PSIO_ERROR_RECLOSE); 00059 break; 00060 case PSIO_ERROR_OSTAT: 00061 fprintf(stderr, "PSIO_ERROR: %d (invalid status flag for file open)\n", PSIO_ERROR_OSTAT); 00062 break; 00063 case PSIO_ERROR_LSEEK: 00064 fprintf(stderr, "PSIO_ERROR: %d (lseek failed)\n", PSIO_ERROR_LSEEK); 00065 break; 00066 case PSIO_ERROR_NOTOCENT: 00067 fprintf(stderr, "PSIO_ERROR: %d (no such TOC entry)\n", PSIO_ERROR_NOTOCENT); 00068 break; 00069 case PSIO_ERROR_TOCENTSZ: 00070 fprintf(stderr, "PSIO_ERROR: %d (TOC entry size mismatch)\n", PSIO_ERROR_TOCENTSZ); 00071 break; 00072 case PSIO_ERROR_KEYLEN: 00073 fprintf(stderr, "PSIO_ERROR: %d (TOC key too long)\n", PSIO_ERROR_KEYLEN); 00074 break; 00075 case PSIO_ERROR_BLKSIZ: 00076 fprintf(stderr, "PSIO_ERROR: %d (Requested blocksize invalid)\n", PSIO_ERROR_BLKSIZ); 00077 break; 00078 case PSIO_ERROR_BLKSTART: 00079 fprintf(stderr, "PSIO_ERROR: %d (Incorrect block start address)\n", PSIO_ERROR_BLKSTART); 00080 break; 00081 case PSIO_ERROR_BLKEND: 00082 fprintf(stderr, "PSIO_ERROR: %d (Incorrect block end address)\n", PSIO_ERROR_BLKEND); 00083 break; 00084 case PSIO_ERROR_MAXUNIT: 00085 fprintf(stderr, "PSIO_ERROR: %d (Maximum unit number exceeded)\n", PSIO_ERROR_MAXUNIT); 00086 fprintf(stderr, "Open failed because unit %d exceeds ", unit); 00087 fprintf(stderr, "PSIO_MAXUNIT = %d.\n", PSIO_MAXUNIT); 00088 break; 00089 } 00090 exit(PSIO::_error_exit_code_); 00091 }
| psio_address psio_get_address | ( | psio_address | start, | |
| ULI | shift | |||
| ) |
PSIO_GET_ADDRESS(): Given a starting page/offset and a shift length (in bytes), return the page/offset of the next position in the file.
Definition at line 18 of file get_address.cc.
Referenced by dpd_file4_init_nocache(), iwl_buf_toend(), psi::PSIO::read(), psi::PSIO::tocwrite(), and psi::PSIO::write().
00018 { 00019 psio_address address; 00020 ULI bytes_left; 00021 00022 bytes_left = PSIO_PAGELEN - start.offset; /* Bytes remaining on fpage */ 00023 00024 if (shift >= bytes_left) { /* Shift to later page */ 00025 address.page = start.page + (shift - bytes_left)/PSIO_PAGELEN+ 1; 00026 address.offset = shift - bytes_left -(address.page - start.page- 1) 00027 *PSIO_PAGELEN; 00028 } else { /* Block starts on current page */ 00029 address.page = start.page; 00030 address.offset = start.offset + shift; 00031 } 00032 00033 return address; 00034 }
| psio_address psio_get_global_address | ( | psio_address | entry_start, | |
| psio_address | rel_address | |||
| ) |
PSIO_GET_GLOBAL_ADDRESS(): Given the global starting address for a TOC entry and a relative offset within the entry, compute the global address for the offset.
Definition at line 17 of file get_global_address.cc.
Referenced by psi::PSIO::read(), and psi::PSIO::write().
00018 { 00019 psio_address address; 00020 00021 address.page = entry_start.page + rel_address.page; 00022 address.offset = entry_start.offset + rel_address.offset; 00023 if ((entry_start.offset + rel_address.offset) >= PSIO_PAGELEN) { 00024 address.offset -= PSIO_PAGELEN; 00025 address.page++; 00026 } 00027 00028 return (address); 00029 }
| ULI psio_get_length | ( | psio_address | sadd, | |
| psio_address | eadd | |||
| ) |
PSIO_GET_LENGTH(): Given a start page and offset for two data sets, compute the number of bytes between them. Note that eadd denotes the beginning of the next entry and not the end of the current entry.
Definition at line 17 of file get_length.cc.
Referenced by iwl_buf_toend().
00017 { 00018 00019 ULI full_page_bytes; 00020 00021 /* Number of bytes on fullpages */ 00022 full_page_bytes = (eadd.page - sadd.page- 1)*PSIO_PAGELEN; 00023 00024 if (full_page_bytes < 0) { /* We're on a single page */ 00025 return (eadd.offset - sadd.offset); 00026 } else if (full_page_bytes == 0) { /* We're on the next page */ 00027 return ((PSIO_PAGELEN - sadd.offset) + eadd.offset); 00028 } else { 00029 return ((PSIO_PAGELEN - sadd.offset) + full_page_bytes + eadd.offset); 00030 } 00031 }
| unsigned int psio_get_numvols_default | ( | void | ) |
PSIO_GET_NUMVOLS_DEFAULT(): Get the number of volumes that file number 'unit' is split across.
Definition at line 50 of file get_numvols.cc.
References psi::PSIO::filecfg_kwd().
00050 { 00051 std::string charnum; 00052 00053 charnum = _default_psio_lib_->filecfg_kwd("PSI", "NVOLUME", -1); 00054 if (!charnum.empty()) 00055 return ((unsigned int)atoi(charnum.c_str())); 00056 charnum = _default_psio_lib_->filecfg_kwd("DEFAULT", "NVOLUME", -1); 00057 if (!charnum.empty()) 00058 return ((unsigned int)atoi(charnum.c_str())); 00059 00060 // assume that the default has been provided already 00061 abort(); 00062 }
| int psio_init | ( | void | ) |
PSIO_INIT(): Allocates global memory needed by the I/O routines.
No arguments.
Definition at line 61 of file libpsio/init.cc.
References psi::PSIO::_error_exit_code_.
00061 { 00062 if (!_default_psio_lib_) { 00063 _default_psio_lib_ = new PSIO; 00064 if (_default_psio_lib_ == 0) { 00065 fprintf(stderr,"LIBPSIO::init() -- failed to allocate the memory"); 00066 exit(PSIO::_error_exit_code_); 00067 } 00068 } 00069 00070 return 1; 00071 }
| int psio_open | ( | unsigned int | unit, | |
| int | status | |||
| ) |
PSIO_OPEN(): Opens a multivolume PSI direct access file for reading/writing data.
| unit | = The PSI unit number used to identify the file to all read and write functions. | |
| status | = Indicates if the file is old (PSIO_OPEN_OLD) or new (PSIO_OPEN_NEW). |
Definition at line 127 of file open.cc.
References psi::PSIO::open().
Referenced by ael(), psi::detcas::bfgs_hessian(), psi::detcas::ds_hessian(), iwl_buf_init(), iwl_rdone(), iwl_wrtone(), and main().
00127 { 00128 _default_psio_lib_->open(unit, status); 00129 return 1; 00130 }
| int psio_open_check | ( | unsigned int | unit | ) |
PSIO_OPEN_CHECK(): Check to see if a given PSI direct access file is already open.
| unit | = the PSI unit number. |
Definition at line 32 of file open_check.cc.
References psi::PSIO::open_check().
00032 { 00033 return _default_psio_lib_->open_check(unit); 00034 }
| int psio_read | ( | unsigned int | unit, | |
| char * | key, | |||
| char * | buffer, | |||
| ULI | size, | |||
| psio_address | start, | |||
| psio_address * | end | |||
| ) |
PSIO_READ(): Reads data from within a TOC entry from a PSI file.
| unit | = The PSI unit number used to identify the file to all read and write functions. | |
| key | = The TOC keyword identifying the desired entry. | |
| buffer | = The buffer to store the data as it is read. | |
| size | = The number of bytes to read. | |
| start | = The entry-relative starting page/offset of the desired data. | |
| end | = A pointer to the entry-relative page/offset for the next byte after the end of the read request. |
Definition at line 79 of file read.cc.
References psi::PSIO::read().
Referenced by iwl_buf_fetch(), psio_read_entry(), and stringset_read().
00080 { 00081 _default_psio_lib_->read(unit, key, buffer, size, start, end); 00082 return 1; 00083 }
| int psio_read_entry | ( | unsigned int | unit, | |
| char * | key, | |||
| char * | buffer, | |||
| ULI | size | |||
| ) |
PSIO_READ_ENTRY(): Reads an entire TOC entry from a PSI file.
| unit | = The PSI unit number used to identify the file to all read and write functions. | |
| key | = The TOC keyword identifying the desired entry. | |
| buffer | = The buffer to store the data as it is read. | |
| size | = The number of bytes to read. |
Definition at line 33 of file read_entry.cc.
References psio_read(), and PSIO_ZERO.
Referenced by ael(), psi::detcas::bfgs_hessian(), psi::detcas::ds_hessian(), iwl_rdone(), psi::psimrcc::CCMatrix::read_block_from_disk(), psi::psimrcc::CCMatrix::read_strip_from_disk(), slaterdetset_read(), slaterdetset_read_vect(), and stringset_read().
00033 { 00034 psio_address end; 00035 return psio_read(unit, key, buffer, size, PSIO_ZERO, &end); 00036 }
| int psio_rw | ( | unsigned int | unit, | |
| char * | buffer, | |||
| psio_address | address, | |||
| ULI | size, | |||
| int | wrt | |||
| ) |
PSIO_RW(): Central function for all reads and writes on a PSIO unit.
unit = The PSI unit number. buffer = The buffer containing the bytes for the read/write event. address = the PSIO global address for the start of the read/write. size = The number of bytes to read/write. = Indicates if the call is to read (0) or write (0) the input data.
Definition at line 115 of file rw.cc.
References psi::PSIO::rw().
00116 { 00117 _default_psio_lib_->rw(unit, buffer, address, size, wrt); 00118 return 1; 00119 }
| int psio_state | ( | void | ) |
PSIO_STATE(): Returns state of the library (1=initialized, 0=noninitialized).
No arguments.
Definition at line 81 of file libpsio/init.cc.
References psi::PSIO::state().
00081 { 00082 return _default_psio_lib_->state(); 00083 }
| int psio_tocclean | ( | unsigned int | unit, | |
| char * | key | |||
| ) |
PSIO_TOCCLEAN(): Delete all TOC entries after the given key. If a blank key is given, the entire TOC will be wiped.
Definition at line 54 of file tocclean.cc.
References psi::PSIO::tocclean().
00054 { 00055 _default_psio_lib_->tocclean(unit, key); 00056 return 0; 00057 }
| void psio_tocprint | ( | unsigned int | unit, | |
| FILE * | output | |||
| ) |
PSIO_TOCPRINT(): Print the table of contents for the given unit
Definition at line 44 of file tocprint.cc.
References psi::PSIO::tocprint().
00044 { 00045 return _default_psio_lib_->tocprint(unit, output); 00046 }
| psio_tocentry* psio_tocscan | ( | unsigned int | unit, | |
| char * | key | |||
| ) |
PSIO_TOCSCAN(): Scans the TOC for a particular keyword and returns either a pointer to the entry or NULL to the caller.
Definition at line 40 of file tocscan.cc.
References psi::PSIO::tocscan().
Referenced by psi::detcas::bfgs_hessian(), dpd_buf4_scm(), psi::detcas::ds_hessian(), iwl_buf_init(), and iwl_buf_toend().
00040 { 00041 return _default_psio_lib_->tocscan(unit, key); 00042 }
| int psio_tocwrite | ( | unsigned int | unit | ) |
PSIO_TOCWRITE(): Write the table of contents for file number 'unit'.
| unit | = The PSI unit to which we will write the TOC. |
Definition at line 49 of file tocwrite.cc.
References psi::PSIO::tocwrite().
Referenced by psio_error().
00049 { 00050 _default_psio_lib_->tocwrite(unit); 00051 return 1; 00052 }
| int psio_volseek | ( | psio_vol * | vol, | |
| ULI | page, | |||
| ULI | offset, | |||
| ULI | numvols | |||
| ) |
PSIO_VOLSEEK()
Definition at line 18 of file volseek.cc.
Referenced by psi::PSIO::rw().
00018 { 00019 int stream, errcod; 00020 ULI bignum, total_offset; 00021 00022 bignum = PSIO_BIGNUM*numvols; 00023 00024 stream = vol->stream; 00025 00026 /* Set file pointer to beginning of file */ 00027 errcod = lseek(stream, (ULI) 0, SEEK_SET); 00028 if (errcod == -1) 00029 return (errcod); 00030 00031 /* lseek() through large chunks of the file to avoid offset overflows */ 00032 for (; page > bignum; page -= bignum) { 00033 total_offset = PSIO_BIGNUM * PSIO_PAGELEN; 00034 errcod = lseek(stream, total_offset, SEEK_CUR); 00035 if (errcod == -1) 00036 return (errcod); 00037 } 00038 00039 /* Now compute the final offset including the page-relative term */ 00040 total_offset = (ULI) page/numvols; /* This should truncate */ 00041 total_offset *= PSIO_PAGELEN; 00042 total_offset += offset; /* Add the page-relative term */ 00043 errcod = lseek(stream, total_offset, SEEK_CUR); 00044 if (errcod == -1) 00045 return (errcod); 00046 00047 return (0); 00048 }
| int psio_write | ( | unsigned int | unit, | |
| char * | key, | |||
| char * | buffer, | |||
| ULI | size, | |||
| psio_address | start, | |||
| psio_address * | end | |||
| ) |
PSIO_WRITE(): Writes data to a TOC entry in a PSI file.
| unit | = The PSI unit number used to identify the file to all read and write functions. | |
| key | = The TOC keyword identifying the desired entry. | |
| buffer | = The buffer from which the data is written. | |
| size | = The number of bytes to write. | |
| start | = The entry-relative starting page/offset to write the data. | |
| end | = A pointer to the entry-relative page/offset for the next byte after the end of the write request. |
Definition at line 131 of file write.cc.
References psi::PSIO::write().
Referenced by iwl_buf_put(), and stringset_write().
00132 { 00133 _default_psio_lib_->write(unit, key, buffer, size, start, end); 00134 return 1; 00135 }
| int psio_write_entry | ( | unsigned int | unit, | |
| char * | key, | |||
| char * | buffer, | |||
| ULI | size | |||
| ) |
PSIO_WRITE_ENTRY()
Definition at line 23 of file write_entry.cc.
References psi::PSIO::write_entry().
Referenced by psi::detcas::bfgs_hessian(), psi::detcas::ds_hessian(), iwl_wrtone(), main(), slaterdetset_write(), slaterdetset_write_vect(), stringset_write(), and psi::psimrcc::CCMatrix::write_block_to_disk().
00023 { 00024 _default_psio_lib_->write_entry(unit, key, buffer, size); 00025 return 1; 00026 }
| void PSIO::rw | ( | unsigned int | unit, | |
| char * | buffer, | |||
| psio_address | address, | |||
| ULI | size, | |||
| int | wrt | |||
| ) | [inherited] |
Central function for all reads and writes on a PSIO unit.
unit = The PSI unit number. buffer = The buffer containing the bytes for the read/write event. address = the PSIO global address for the start of the read/write. size = The number of bytes to read/write. = Indicates if the call is to read (0) or write (0) the input data.
Definition at line 13 of file rw.cc.
References psio_error(), psio_volseek(), psi::PSIO::read(), and psi::PSIO::write().
Referenced by psio_rw(), psi::PSIO::read(), psi::PSIO::tocwrite(), and psi::PSIO::write().
00014 { 00015 int errcod; 00016 unsigned int i; 00017 ULI errcod_uli; 00018 ULI page, offset; 00019 ULI buf_offset; 00020 ULI this_page, this_page_max, this_page_total; 00021 unsigned int first_vol, this_vol, numvols; 00022 ULI bytes_left, num_full_pages; 00023 psio_ud *this_unit; 00024 00025 this_unit = &(psio_unit[unit]); 00026 numvols = this_unit->numvols; 00027 page = address.page; 00028 offset = address.offset; 00029 00030 /* Seek all volumes to correct starting positions */ 00031 first_vol = page % numvols; 00032 errcod = psio_volseek(&(this_unit->vol[first_vol]), page, offset, numvols); 00033 if (errcod == -1) 00034 psio_error(unit, PSIO_ERROR_LSEEK); 00035 for (i=1, this_page=page+1; i < numvols; i++, this_page++) { 00036 this_vol = this_page % numvols; 00037 errcod = psio_volseek(&(this_unit->vol[this_vol]), this_page, (ULI) 0, 00038 numvols); 00039 if (errcod == -1) 00040 psio_error(unit, PSIO_ERROR_LSEEK); 00041 } 00042 00043 /* Number of bytes left on the first page */ 00044 this_page_max = PSIO_PAGELEN - offset; 00045 00046 /* If we have enough room on this page, use it */ 00047 if (size <= this_page_max) 00048 this_page_total = size; 00049 else 00050 this_page_total = this_page_max; 00051 00052 buf_offset = 0; 00053 if (wrt) { 00054 errcod_uli =:: write(this_unit->vol[first_vol].stream, &(buffer[buf_offset]), 00055 this_page_total); 00056 if(errcod_uli != this_page_total) psio_error(unit,PSIO_ERROR_WRITE); 00057 } 00058 else { 00059 errcod_uli = ::read(this_unit->vol[first_vol].stream, &(buffer[buf_offset]), 00060 this_page_total); 00061 if(errcod_uli != this_page_total) psio_error(unit,PSIO_ERROR_READ); 00062 } 00063 00064 /* Total number of bytes remaining to be read/written */ 00065 bytes_left = size - this_page_total; 00066 00067 /* Read/Write all the full pages */ 00068 num_full_pages = bytes_left/PSIO_PAGELEN; 00069 buf_offset += this_page_total; 00070 for(i=0,this_page=page+1; i < num_full_pages; i++,this_page++) { 00071 this_vol = this_page % numvols; 00072 this_page_total = PSIO_PAGELEN; 00073 if(wrt) { 00074 errcod_uli = ::write(this_unit->vol[this_vol].stream, &(buffer[buf_offset]), 00075 this_page_total); 00076 if(errcod_uli != this_page_total) psio_error(unit,PSIO_ERROR_WRITE); 00077 } 00078 else { 00079 errcod_uli = ::read(this_unit->vol[this_vol].stream, &(buffer[buf_offset]), 00080 this_page_total); 00081 if(errcod_uli != this_page_total) psio_error(unit,PSIO_ERROR_READ); 00082 } 00083 buf_offset += this_page_total; 00084 } 00085 00086 /* Read/Write the final partial page */ 00087 bytes_left -= num_full_pages * PSIO_PAGELEN; 00088 this_vol = this_page % numvols; 00089 if(bytes_left) { 00090 if(wrt) { 00091 errcod_uli = ::write(this_unit->vol[this_vol].stream, &(buffer[buf_offset]), 00092 bytes_left); 00093 if(errcod_uli != bytes_left) psio_error(unit,PSIO_ERROR_WRITE); 00094 } 00095 else { 00096 errcod_uli = ::read(this_unit->vol[this_vol].stream, &(buffer[buf_offset]), 00097 bytes_left); 00098 if(errcod_uli != bytes_left) psio_error(unit,PSIO_ERROR_READ); 00099 } 00100 } 00101 }
1.5.4