Commit f315f0c7 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

WftStacksOnDisk: in memory works

parent a3da68d8
......@@ -141,13 +141,16 @@ public:
}
template<typename IoOutputType>
void write(PsimagLite::String label1, IoOutputType& io) const
void write(PsimagLite::String label1,
IoOutputType& io,
PsimagLite::IoNgSerializer::WriteMode wM = PsimagLite::IoNgSerializer::NO_OVERWRITE) const
{
io.createGroup(label1);
io.write(isSquare_, label1 + "/isSquare_");
io.write(offsetsRows_, label1 + "/offsetRows_");
io.write(offsetsCols_, label1 + "/offsetCols_");
io.write(data_, label1 + "/data_");
if (wM != PsimagLite::IoNgSerializer::ALLOW_OVERWRITE)
io.createGroup(label1);
io.write(isSquare_, label1 + "/isSquare_", wM);
io.write(offsetsRows_, label1 + "/offsetRows_", wM);
io.write(offsetsCols_, label1 + "/offsetCols_", wM);
io.write(data_, label1 + "/data_", wM);
}
void setTo(ComplexOrRealType value)
......@@ -312,13 +315,16 @@ public:
ioSerializer.read(data_, label + "/data");
}
void write(PsimagLite::String label, PsimagLite::IoSerializer& ioSerializer) const
void write(PsimagLite::String label,
PsimagLite::IoSerializer& ioSerializer,
PsimagLite::IoSerializer::WriteMode wM = PsimagLite::IoSerializer::NO_OVERWRITE) const
{
ioSerializer.createGroup(label);
ioSerializer.write(label + "/isSquare", isSquare_);
ioSerializer.write(label + "/offsetsRows", offsetsRows_);
ioSerializer.write(label + "/offsetsCols", offsetsCols_);
ioSerializer.write(label + "/data", data_);
if (wM != PsimagLite::IoSerializer::ALLOW_OVERWRITE)
ioSerializer.createGroup(label);
ioSerializer.write(label + "/isSquare", isSquare_, wM);
ioSerializer.write(label + "/offsetsRows", offsetsRows_, wM);
ioSerializer.write(label + "/offsetsCols", offsetsCols_, wM);
ioSerializer.write(label + "/data", data_, wM);
}
friend std::ostream& operator<<(std::ostream& os, const BlockDiagonalMatrix& m)
......
......@@ -93,14 +93,34 @@ public:
void read(PsimagLite::String prefix, PsimagLite::IoNgSerializer& io)
{
err("read\n");
if (diskW_) {
assert(diskR_);
err("read\n");
}
io.read(memory_, prefix);
}
void write(PsimagLite::String prefix, PsimagLite::IoNgSerializer& io) const
{
err("write\n");
if (diskW_) {
assert(diskR_);
err("write\n");
}
MemoryStackType m = memory_;
io.write(prefix, m);
}
void write(PsimagLite::String prefix, PsimagLite::IoNgSerializer& io)
{
if (diskW_) {
assert(diskR_);
err("write\n");
}
io.write(prefix, memory_);
}
template<typename StackType1,typename StackType2>
static void loadStack(StackType1& stackInMemory, StackType2& stackInDisk)
......@@ -120,7 +140,7 @@ private:
DiskOrMemoryStack& operator=(const DiskOrMemoryStack&);
MemoryStackType memory_;
mutable MemoryStackType memory_;
DiskStackType *diskW_;
DiskStackType *diskR_;
};
......
......@@ -25,11 +25,14 @@ public:
io.read(extra, str + "/extra");
}
void write(PsimagLite::String str, PsimagLite::IoNgSerializer& io) const
void write(PsimagLite::String str,
PsimagLite::IoNgSerializer& io,
typename PsimagLite::IoNgSerializer::WriteMode wM = PsimagLite::IoNgSerializer::NO_OVERWRITE) const
{
io.createGroup(str);
io.write(str+ "/modalEnum", modalEnum);
io.write(str + "/extra", extra);
if (wM != PsimagLite::IoNgSerializer::ALLOW_OVERWRITE)
io.createGroup(str);
io.write(str+ "/modalEnum", modalEnum, wM);
io.write(str + "/extra", extra, wM);
}
ModalEnum modalEnum;
......@@ -97,7 +100,9 @@ public:
err("Qn::read\n");
}
void write(PsimagLite::String str, PsimagLite::IoNgSerializer& io) const
void write(PsimagLite::String str,
PsimagLite::IoNgSerializer& io,
typename PsimagLite::IoNgSerializer::WriteMode wM = PsimagLite::IoNgSerializer::NO_OVERWRITE) const
{
try {
io.read(modalStruct, "modalStruct");
......@@ -105,13 +110,14 @@ public:
io.write("modalStruct", modalStruct);
}
io.createGroup(str);
io.write(str + "/oddElectrons", oddElectrons);
if (wM != PsimagLite::IoNgSerializer::ALLOW_OVERWRITE)
io.createGroup(str);
io.write(str + "/oddElectrons", oddElectrons, wM);
VectorSizeType otherVector;
other.toStdVector(otherVector);
io.write(str + "/other", otherVector);
io.write(str + "/jmPair", jmPair);
io.write(str + "/flavors", flavors);
io.write(str + "/other", otherVector, wM);
io.write(str + "/jmPair", jmPair, wM);
io.write(str + "/flavors", flavors, wM);
}
void overwrite(PsimagLite::String str, PsimagLite::IoNgSerializer& io) const
......
......@@ -42,17 +42,15 @@ public:
void write(PsimagLite::IoNg::Out& io, PsimagLite::String prefix) const
{
writePartial(io, prefix);
// WftStackType wsStack = wsStack_;
io.write(wsStack_, prefix + "/wsStack");
// WftStackType weStack = weStack_;
io.write(weStack_, prefix + "/weStack");
wsStack_.write(prefix + "/wsStack", io.serializer());
weStack_.write(prefix + "/weStack", io.serializer());
}
void write(PsimagLite::IoNg::Out& io, PsimagLite::String prefix)
{
writePartial(io, prefix);
io.write(wsStack_, prefix + "/wsStack");
io.write(weStack_, prefix + "/weStack");
wsStack_.write(prefix + "/wsStack", io.serializer());
weStack_.write(prefix + "/weStack", io.serializer());
}
void beforeWft(ProgramGlobals::DirectionEnum dir,
......
......@@ -149,11 +149,12 @@ struct WaveStructSvd {
PsimagLite::IoNgSerializer::WriteMode writeMode,
SaveEnum) const
{
io.createGroup(prefix);
io.write(u_, prefix + "/u");
io.write(vts_, prefix + "/vts");
io.write(s_, prefix + "/s");
io.write(qns_, prefix + "/qns");
if (writeMode != PsimagLite::IoNgSerializer::ALLOW_OVERWRITE)
io.createGroup(prefix);
io.write(u_, prefix + "/u", writeMode);
io.write(vts_, prefix + "/vts", writeMode);
io.write(s_, prefix + "/s", writeMode);
io.write(qns_, prefix + "/qns", writeMode);
}
void write(PsimagLite::String prefix, PsimagLite::IoNgSerializer& io) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment