/* Copyright (C) 2008 Jiri Pittner or This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #define EPSPRINT .05 #include "la.h" #include "fourindex.h" #include "nonclass.h" #include "basic.h" #include "sifs.h" using namespace LA; #if 0 ssize_t readall(int fd, void *buf, size_t count) { ssize_t r; size_t len=0; do { r=read(fd, ((char *)buf)+len, count-len); cout <<"READ "<= N10) //label is within one word { *lab10bit -= N10; return (tmp>>(*lab10bit)) & MASK(N10); } //else glue it from two words int r; r = tmp & MASK(*lab10bit); //remaining bits from previous word int n = N10- *lab10bit; //thus many we need from next one r <<= n; ++(*lab10word); tmp = lab10[*lab10word]; *lab10bit = 64-n; r |= (tmp>>(*lab10bit)) & MASK(n); //get remaining bits return r; } sifs::sifs(INT f) { fd=f; lseek64(f,0L,SEEK_SET); FREC mark1,mark2; //read first record if(sizeof(FREC)!= readall(f,&mark1,sizeof(FREC))) laerror("cannot read sif file 1a"); if(sizeof(sifs_header)!= readall(f,&header,sizeof(sifs_header))) laerror("cannot read sif file 3a"); if(sizeof(FREC)!= readall(f,&mark2,sizeof(FREC))) laerror("cannot read sif file 2a"); if(mark1!=mark2) { cerr<< mark1<<" "< &x, int &itypea, int &itypeb, int &last, REAL &fcore) { FREC mark1,mark2; REAL buf[s.infos[1]]; off64_t start=lseek64(s.fd,0L,SEEK_CUR); int r; block_header_real h; x.resize(s.header.nbas); x=0.; bool first=1; int nblocks=0; last=0; do { off64_t offset0 = lseek64(s.fd,0L,SEEK_CUR); r=readall(s.fd,&mark1,sizeof(FREC)); if(r<0) return -2; if(r==0) return -1; if(r!=sizeof(FREC)) laerror("inconsistent block"); if(mark1>sizeof(REAL)*s.infos[1]) laerror("unexpectedly large block"); if(mark1!=readall(s.fd,&buf,mark1)) laerror("cannot read block"); h.r=buf[0]; if(first) { cout <<"starting header "<3) laerror("itypea>3 unsupported"); //if(h.h.itypea==2) stored in SMAT but antisymmetric matrix! if(h.h.itypea==3) {s.data2offset=start; lseek64(s.fd,start,SEEK_SET); return -3;} if(h.h.ifmt>2) laerror("unsupported ifmt"); if(h.h.num <0 || h.h.num > s.infos[2]) laerror("excessive number of integrals in block"); //process block fcore = buf[h.h.num+1]; //cout << "test "<x.nrows()) laerror("i index out of range"); if(j<=0||j>x.ncols()) laerror("j index out of range"); x(i-1,j-1) = buf[ii+1]; } } while(!h.h.last); last=h.h.last; return nblocks; }