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

json removed, drivers compile with clang++ and g++

parent e04ae75b
......@@ -3,7 +3,6 @@ All rights reserved
[PsimagLite, Version 1.0.0]
[by G.A. and M.S., Oak Ridge National Laboratory]
[Json Parser written by M.S., Oak Ridge National Laboratory]
UT Battelle Open Source Software License 11242008
......
......@@ -70,10 +70,6 @@ ChebyshevSolver
SparseRow <-- slower, consumes less memory
SparseRowCached <-- faster, consumes more memory
[JSON]
JSON directory.
Json support (taken from M.S.'s new implementation which doesn't depend on anything at all)
[Io] Input output support
IoSimple
ChebyshevSerializer
......
......@@ -14,12 +14,12 @@ testLapack.o: ./testLapack.cpp Makefile Makefile.dep
testLapack: testLapack.o Makefile Makefile.dep
$(CXX) -o testLapack testLapack.o $(LDFLAGS)
Makefile.dep: ./integrator.cpp ./sparseSolverTest.cpp ./testCRSMatrix.cpp ./combineContinuedFraction.cpp ./continuedFractionCollection.cpp ./gitrev.cpp ./jsonExample.cpp ./range.cpp ./kernelPolynomial.cpp ./linearPrediction.cpp ./options.cpp ./randomTest.cpp ./svd.cpp ./testLapack.cpp ./threads.cpp ./loadImbalance.cpp ./testIsClass.cpp ./testMemResolv1.cpp ./sumDecomposition.cpp ./calculator.cpp ./closuresTest.cpp ./base64test.cpp ./checkRunId.cpp ./testLanczos.cpp
$(CXX) $(CPPFLAGS) -I../src -I.. -MM ./integrator.cpp ./sparseSolverTest.cpp ./testCRSMatrix.cpp ./combineContinuedFraction.cpp ./continuedFractionCollection.cpp ./gitrev.cpp ./jsonExample.cpp ./range.cpp ./kernelPolynomial.cpp ./linearPrediction.cpp ./options.cpp ./randomTest.cpp ./svd.cpp ./testLapack.cpp ./threads.cpp ./loadImbalance.cpp ./testIsClass.cpp ./testMemResolv1.cpp ./sumDecomposition.cpp ./calculator.cpp ./closuresTest.cpp ./base64test.cpp ./checkRunId.cpp ./testLanczos.cpp > Makefile.dep
Makefile.dep: ./integrator.cpp ./sparseSolverTest.cpp ./testCRSMatrix.cpp ./combineContinuedFraction.cpp ./continuedFractionCollection.cpp ./gitrev.cpp ./range.cpp ./kernelPolynomial.cpp ./linearPrediction.cpp ./options.cpp ./randomTest.cpp ./svd.cpp ./testLapack.cpp ./threads.cpp ./loadImbalance.cpp ./testIsClass.cpp ./testMemResolv1.cpp ./sumDecomposition.cpp ./calculator.cpp ./closuresTest.cpp ./base64test.cpp ./checkRunId.cpp ./testLanczos.cpp
$(CXX) $(CPPFLAGS) -I../src -I.. -MM ./integrator.cpp ./sparseSolverTest.cpp ./testCRSMatrix.cpp ./combineContinuedFraction.cpp ./continuedFractionCollection.cpp ./gitrev.cpp ./range.cpp ./kernelPolynomial.cpp ./linearPrediction.cpp ./options.cpp ./randomTest.cpp ./svd.cpp ./testLapack.cpp ./threads.cpp ./loadImbalance.cpp ./testIsClass.cpp ./testMemResolv1.cpp ./sumDecomposition.cpp ./calculator.cpp ./closuresTest.cpp ./base64test.cpp ./checkRunId.cpp ./testLanczos.cpp > Makefile.dep
.PHONY: clean
clean: Makefile.dep
rm -f core* *.o *.dep *.a integrator sparseSolverTest testCRSMatrix combineContinuedFraction continuedFractionCollection gitrev jsonExample range kernelPolynomial linearPrediction options randomTest svd testLapack threads loadImbalance testIsClass testMemResolv1 sumDecomposition calculator closuresTest base64test checkRunId testLanczos
rm -f core* *.o *.dep *.a integrator sparseSolverTest testCRSMatrix combineContinuedFraction continuedFractionCollection gitrev range kernelPolynomial linearPrediction options randomTest svd testLapack threads loadImbalance testIsClass testMemResolv1 sumDecomposition calculator closuresTest base64test checkRunId testLanczos
include Makefile.dep
......@@ -40,7 +40,7 @@ sub createMakefile
local *FH = $fh;
my @units = qw(integrator sparseSolverTest testCRSMatrix combineContinuedFraction
continuedFractionCollection gitrev jsonExample range kernelPolynomial
continuedFractionCollection gitrev range kernelPolynomial
linearPrediction options randomTest svd testLapack threads loadImbalance testIsClass
testMemResolv1 sumDecomposition calculator closuresTest base64test checkRunId
testLanczos);
......
//-*-C++-*-
/** \ingroup main.JsonParser */
/*@{*/
/*! \file jsonParser.cpp
*
*
*
*/
#include "JSON/JsonReader.h"
#include "JSON/JsonParser/DefaultContext.h"
#include <wchar.h>
#include <iostream>
#include <fstream>
int main(int argc,char *argv[]) {
if (argc < 2) {
std::cout << "Usage: "<<argv[0]<<" inputFileName\n";
return -1;
}
PsimagLite::String fileName(argv[1]);
/* std::wifstream file;
file.open(fileName.c_str());*/
// JsonParser::JsonParser<JsonParser::DefaultContext> parser;
// parser.filename = fileName;
// while(parser.parseChar(file));
dca::JsonReader reader(fileName);
int totalBins =0;
totalBins <= reader["programSpecific"]["DCA"]["control"]["totalBins"];
std::wcout <<" totalBins = "<<totalBins<<"\n";
int numPointInBath = 0;
numPointInBath <= reader.searchFor("numPointsInBath");
std::wcout <<" numPointsInBath = "<<numPointInBath<<"\n";
//std::wcout << parser.ctx;
return 0;
}
/*@}*/
......@@ -30,7 +30,6 @@ public:
MyHelper(SizeType ntasks, SizeType nthreads)
: weight_(ntasks),
nthreads_(nthreads),
x_(nthreads,0)
{
srand48(1234);
......@@ -67,7 +66,6 @@ public:
private:
VectorSizeType weight_;
SizeType nthreads_;
VectorSizeType x_;
}; // class MyHelper
......
......@@ -7,7 +7,7 @@ use lib '../scripts';
use Make;
my @drivers = ("integrator","sparseSolverTest", "testCRSMatrix", "rungeKuttaTest", "combineContinuedFraction",
"continuedFractionCollection", "gitrev", "jsonExample", "range",
"continuedFractionCollection", "gitrev", "range",
"kernelPolynomial", "linearPrediction", "options", "randomTest", "svd", "testLapack", "threads",
"testIsClass","testMemResolv1","sumDecomposition","calculator","closuresTest","base64test");
......
......@@ -2,9 +2,9 @@
*
* Serial version:
*
* g++ -g3 -DNDEBUG -Werror -Wall -I../src -I../src/JSON \
* -I../src/JSON/JsonParser -lm -lpthread range.cpp -o range \
* -lblas -llapack
* g++ -g3 -DNDEBUG -Werror -Wall -I../src \
* -lm -lpthread range.cpp -o range \
* -lblas -llapack
*
* And run it with:
*
......@@ -12,9 +12,9 @@
*
* Parallel version:
*
* mpicxx -DUSE_MPI -g3 -DNDEBUG -Werror -Wall -I../src -I../src/JSON \
* -I../src/JSON/JsonParser -lm -lpthread range.cpp -o range \
* -lblas -llapack
* mpicxx -DUSE_MPI -g3 -DNDEBUG -Werror -Wall -I../src \
* -lm -lpthread range.cpp -o range \
* -lblas -llapack
*
* And run it with:
*
......@@ -33,9 +33,8 @@ class MyLoop {
public:
MyLoop(SizeType nthreads,SizeType total)
: nthreads_(nthreads),
sum_(ConcurrencyType::storageSize(nthreads)),
MyLoop(SizeType nthreads, SizeType total)
: sum_(ConcurrencyType::storageSize(nthreads)),
v_(total,0)
{}
......@@ -79,7 +78,6 @@ public:
private:
SizeType nthreads_;
PsimagLite::Vector<SizeType>::Type sum_;
PsimagLite::Vector<SizeType>::Type v_;
};
......
Michael S. Summers
//-*-C++-*-
/** \ingroup DCA */
/*@{*/
/*! \file JSN_Writer.h
Author: Michael S. Summers
*/
#ifndef dca_JSN_Writer_H
#define dca_JSN_Writer_H
#include "VectorLike.h"
namespace dca {
using namespace psimag::VectorLike;
template<typename T> class PrintArrayWidth {public: enum {value=7 }; };
template<> class PrintArrayWidth<double> {public: enum {value=13}; };
template<template<typename,typename> class MapType=std::map>
class JSN {
public:
typedef enum {First,Middle,Last} Position;
typedef JSN<MapType> ThisType;
//======================================================================
JSN(SizeType offset_=0):
offset (offset_),
precis (10),
printedFirstLine(false)
{}
//======================================================================
class KeyReference {
public:
JSN& writer;
String key;
KeyReference(String k, JSN& w):
writer(w),
key (k)
{}
template<typename T>
void operator= (const T& val) {
writer.add(key,val);
}
operator JSN& () {
return writer;
}
KeyReference operator[](String subKey) { return writer.getComponentWriter(key)[subKey]; }
};
//======================================================================
KeyReference operator[](String key) { return KeyReference(key,*this); }
//======================================================================
ThisType& getComponentWriter(String key) { return writers[key]; }
//======================================================================
mutable int offset;
int precis;
mutable bool printedFirstLine;
MapType<String, bool> bools;
MapType<String, String> strings;
MapType<String, double> numbers;
MapType<String, typename Vector<double>::Type > vectors;
MapType<String, typename Vector<int>::Type > intvectors;
MapType<String, typename Vector<SizeType>::Type > sizetvectors;
MapType<String, typename Vector<String>::Type > stringLists;
MapType<String, const psimag::Matrix<int>*> intMatrices;
MapType<String, const psimag::Matrix<double>*> dblMatrices;
MapType<String, const psimag::Matrix<std::complex<double> >*> cMatrices;
MapType<String, ThisType> writers;
//======================================================================
void add(String key, const bool& b) { bools [key] = b; }
void add(String key, const char* str) { strings[key] = str; }
void add(String key, const String& str) { strings[key] = str; }
void add(String key, const SizeType& val) { numbers[key] = val; }
void add(String key, const int& val) { numbers[key] = val; }
void add(String key, const double& val) { numbers[key] = val; }
void add(String key, const typename Vector<double>::Type& vals) { vectors[key] = vals; }
void add(String key, const typename Vector<int>::Type& vals) { intvectors[key] = vals; }
void add(String key, const typename Vector<SizeType>::Type& vals) { sizetvectors[key]= vals; }
void add(String key, const psimag::Matrix<int>& mat ) { intMatrices[key] = &mat; }
void add(String key, const psimag::Matrix<double>& mat ) { dblMatrices[key] = &mat; }
//======================================================================
template<class T>
void add(String key, const T& obj){
obj.toJSN(getComponentWriter(key));
}
//======================================================================
template<typename T>
void add(String key, const Map<String, T>::Type& map) {
typedef typename Map<String, T>::Type::const_iterator itr;
ThisType& writer = writers[key];
for(itr i=map.begin(); i!= map.end(); i++)
writer.add(i->first,i->second);
}
//======================================================================
template<typename ValType>
static
int maxKeyWidth( const MapType<String, ValType>& map) {
SizeType result = 0;
typedef typename MapType<String, ValType>::const_iterator itr;
for(itr i=map.begin(); i!= map.end(); i++)
if( i->first.length() > result)
result = i->first.length();
return result+2;
}
//======================================================================
int maxKeyWidth() const {
int result = 0;
int maxKeyLen = 0;
maxKeyLen = maxKeyWidth(strings);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(bools);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(numbers);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(vectors);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(intvectors);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(sizetvectors);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(stringLists);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(writers);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(intMatrices);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(dblMatrices);
if (maxKeyLen > result) result = maxKeyLen;
maxKeyLen = maxKeyWidth(cMatrices);
if (maxKeyLen > result) result = maxKeyLen;
return result;
}
//======================================================================
template<typename ValType>
void printLines(std::ostream& os,
const MapType<String, ValType>& map,
int offset,
int keyWidth,
Position position=Middle) const {
typedef typename MapType<String, ValType>::const_iterator itr;
for(itr i=map.begin(); i!= map.end(); i++) {
printLine(os,i->first,i->second,offset,keyWidth,printedFirstLine);
printedFirstLine = true;
}
}
//======================================================================
template<typename ValType>
static
void printLine(std::ostream& os,
const String& key,
const ValType& val,
int offset,
int keyWidth,
bool printedFirstLine_,
bool printVal=true) {
if (printedFirstLine_)
os << ",\n" << String(offset,' ') ;
os << std::setw(keyWidth) << std::left << quoted(key);
os << " : ";
if (printVal)
valString(os,offset,keyWidth,val) ;
}
//======================================================================
//======================================================================
template<typename T>
static
void valString(std::ostream& os,int offset, int keyWidth,
const T& val) {
os << val;
}
template<typename T>
static
void valString(std::ostream& os,int offset, int keyWidth,
const psimag::Matrix<T>* val) {
const psimag::Matrix<T>& matrix(*val);
int kWidth = 6;
int newOffset = offset + keyWidth + 4;
os << "{";
printLine(os,"rows", matrix.n_row(), newOffset, kWidth, false);
printLine(os,"cols", matrix.n_col(), newOffset, kWidth, true );
printLine(os,"data", 0, newOffset, kWidth, true, false);
psimag::MatrixLike::printArray(matrix,os,PrintArrayWidth<T>::value,newOffset+8);
os << "}";
}
static
void valString(std::ostream& os, int offset, int keyWidth,
const String& val) {
os << quoted(val);
}
static
void valString(std::ostream& os,int offset, int keyWidth,
const ThisType& val) {
val.print(os, offset + keyWidth + 4);
}
template<typename T>
static
void valString(std::ostream& os, int offset, int keyWidth,
const typename Vector<T>::Type& val) {
SizeType width = maxElementStringWidth(val);
printList(val,os,',',width);
}
//======================================================================
void print(std::ostream& os,int off=1,bool printLastBrace=true) const {
offset = off;
printedFirstLine = false;
int keyWidth = maxKeyWidth();
os << "{";
printLines(os,strings, offset, keyWidth);
printLines(os,bools, offset, keyWidth);
printLines(os,numbers, offset, keyWidth);
printLines(os,vectors, offset, keyWidth);
printLines(os,sizetvectors,offset, keyWidth);
printLines(os,intvectors, offset, keyWidth);
printLines(os,stringLists, offset, keyWidth);
printLines(os,intMatrices, offset, keyWidth);
printLines(os,dblMatrices, offset, keyWidth);
printLines(os,cMatrices, offset, keyWidth);
printLines(os,writers, offset, keyWidth);
if (printLastBrace)
os << "}";
}
//======================================================================
static
String toString(const Map<String, String>::Type& map) {
PsimagLite::OstringStream buff;
buff << "{";
Map<String,String>::Type::const_iterator itr;
for (itr = map.begin(); itr != map.end(); itr++) {
if (itr != map.begin())
buff << ",";
buff << " \"" << itr->first << "\": \"" << itr->second << "\"";
}
buff << "}";
return buff.str();
}
template<typename T>
static
String toString(const Map<String, T>::Type& map) {
typedef Map<String,T>::Type MapType;
typedef typename MapType::const_iterator CITR;
PsimagLite::OstringStream buff;
buff << "{";
for (CITR itr = map.begin(); itr != map.end(); itr++) {
if (itr != map.begin())
buff << ",";
buff << " \"" << itr->first << "\": " << itr->second;
}
buff << "}";
return buff.str();
}
template<typename T>
String toString(const Map<String, typename Vector<T> >::Type::Type& map) {
typedef Map<String,T>::Type MapType;
typedef typename MapType::const_iterator CITR;
PsimagLite::OstringStream buff;
buff << "{";
for (CITR itr = map.begin(); itr != map.end(); itr++) {
if (itr != map.begin())
buff << ",";
buff << " \"" << itr->first << "\": " << psimag::VectorLike::toString(itr->second);
}
buff << "}";
return buff.str();
}
template<class T>
inline
void printVector(typename Vector<T>::Type vec,
String title,
std::ostream& os) {
os.precision(precis);
os << std::fixed; // scientific;
os << "{ "
<< " \'tile\': \'" << title << "\', \n"
<< " \'type\': \'Function1D', \n"
<< " \'size\': " << vec.size() << ", \n";
os << " \'data\': ";
os << "array([[";
for(SizeType j=0; j<vec.size(); j++)
os << " " << std::setw(precis) << vec[j] << ",\n";
os << "]])\n";
os << "}";
}
//======================================================================
static
String quoted(String str) {
PsimagLite::OstringStream result;
result << "\"" << str << "\"";
return result.str();
}
//======================================================================
};
} // end namespace DCA
/*@}*/
#endif
//-*-C++-*-
/** \ingroup JsonParser */
/*@{*/
// Author: Michael S. Summers (ORNL)
/*! \file ActionsMixin.h
*
*
*
*/
#ifndef JsonParser_ActionsMixin_H
#define JsonParser_ActionsMixin_H
namespace JsonParser {
class ActionsMixin {
public:
/* The state and action codes. */
typedef enum actions {
Consume, /* Consume the character */
BeginObject, /* BeginObject */
BeginArray, /* BeginArray */
BeginMatrix, /* BeginMatrix */
EndObject, /* endObject */
EndArray, /* EndArray */
EndMatrix, /* EndMatrix */
DoNext, /* DoNext */
RecordKey, /* RecordKey */
RecordChar, /* RecordChar */
RecordString, /* RecordString */
RecordInteger, /* RecordInteger */
RecordFloat, /* RecordFloat */
RecordTrue, /* RecordTrue */
RecordFalse, /* RecordFalse */
RecordNull, /* RecordNull */
EndFile, /* EndFile */
Abort, /* Abort Parsing */
NR_ACTIONS
} ActionType;
static PsimagLite::String actionName(ActionType action) {
switch (action) {
case Consume: return " Consume the character ";
case BeginObject: return " BeginObject ";
case BeginArray: return " BeginArray ";
case BeginMatrix: return " BeginMatrix ";
case EndObject: return " endObject ";
case EndArray: return " EndArray ";
case EndMatrix: return " EndMatrix ";
case DoNext: return " DoNext ";
case RecordKey: return " RecordKey ";
case RecordChar: return " RecordChar ";
case RecordString: return " RecordString ";
case RecordInteger: return " RecordInteger ";
case RecordFloat: return " RecordFloat ";
case RecordTrue: return " RecordTrue ";
case RecordFalse: return " RecordFalse ";
case RecordNull: return " RecordNull ";
case EndFile: return " EndFile ";
case Abort: return " Abort Parsing ";