Commit 1642412c authored by Francois Gygi's avatar Francois Gygi
Browse files

Merge branch 'develop'

parents 08fec352 f435eadd
#-------------------------------------------------------------------------------
#
# Copyright (c) 2014 The Regents of the University of California
# Copyright (c) 2014-2022 The Regents of the University of California
#
# This file is part of Qbox
#
......@@ -17,9 +18,11 @@
#
PLT=MacOSX_x86_64
#-------------------------------------------------------------------------------
SCALAPACKDIR=$(HOME)/software/scalapack/scalapack-2.0.2
LAPACKDIR=$(HOME)/software/lapack/lapack-3.5.0
BLASDIR=$(HOME)/software/blas/BLAS
FFTWDIR=$(HOME)/software/fftw/fftw-3.3.4
XERCESCDIR=$(HOME)/software/xerces/xerces-c-3.1.4
SCALAPACKDIR=$(HOME)/software/scalapack/scalapack-2.2.0
LAPACKDIR=$(HOME)/software/lapack/lapack-3.10.0
BLASDIR=$(HOME)/software/blas/BLAS
PLTOBJECTS = readTSC.o
......@@ -28,16 +31,18 @@
PLTFLAGS += -DIA32 -DUSE_MPI -DUSE_FFTW3 -D_LARGEFILE_SOURCE \
-D_FILE_OFFSET_BITS=64 -DADD_ \
-DAPP_NO_THREADS -DXML_USE_NO_THREADS -DUSE_XERCES -DXERCESC_3 \
-DAPP_NO_THREADS -DXML_USE_NO_THREADS -DUSE_XERCES \
-DSCALAPACK -DUSE_UUID
INCLUDE = -I$(FFTWDIR)
INCLUDE = -I$(FFTWDIR)/api -I$(XERCESCDIR)/src
CXXFLAGS= -g -O3 -D$(PLT) $(INCLUDE) $(PLTFLAGS) $(DFLAGS)
LIBPATH = -L$(SCALAPACKDIR) -L$(LAPACKDIR) -L$(BLASDIR)
LIBPATH = -L$(FFTWDIR)/.libs -L$(SCALAPACKDIR) \
-L$(LAPACKDIR) -L$(BLASDIR) -L$(XERCESCDIR)/src/.libs
LIBS = -lfftw3 -lscalapack -llapack -lblas -lm -lgfortran \
LIBS = -lfftw3 -lscalapack -llapack -lblas -lgfortran -lm \
-lxerces-c -lpthread -lstdc++
LDFLAGS = $(LIBPATH) $(LIBS)
......
......@@ -63,18 +63,19 @@ Base64Transcoder::Base64Transcoder()
}
////////////////////////////////////////////////////////////////////////////////
int Base64Transcoder::encode(int nbytes, const byte* const from, char* const to)
int Base64Transcoder::encode(int nbytes, const byte_t* const from,
char* const to)
{
const byte* fptr = from;
const byte_t* fptr = from;
char* tptr = to;
int n3 = nbytes / 3; // number of groups of three bytes
while ( n3-- > 0 )
{
byte ig0 = *fptr++;
byte ig1 = *fptr++;
byte ig2 = *fptr++;
byte_t ig0 = *fptr++;
byte_t ig1 = *fptr++;
byte_t ig2 = *fptr++;
*tptr++ = etable[ig0 >> 2];
*tptr++ = etable[((ig0 & 3) << 4) | (ig1 >> 4)];
......@@ -86,9 +87,9 @@ int Base64Transcoder::encode(int nbytes, const byte* const from, char* const to)
if ( nr == 2 )
{
byte ig0 = *fptr++;
byte ig1 = *fptr++;
byte ig2 = 0;
byte_t ig0 = *fptr++;
byte_t ig1 = *fptr++;
byte_t ig2 = 0;
*tptr++ = etable[ig0 >> 2];
*tptr++ = etable[((ig0 & 3) << 4) | (ig1 >> 4)];
......@@ -97,8 +98,8 @@ int Base64Transcoder::encode(int nbytes, const byte* const from, char* const to)
}
else if ( nr == 1 )
{
byte ig0 = *fptr++;
byte ig1 = 0;
byte_t ig0 = *fptr++;
byte_t ig1 = 0;
*tptr++ = etable[ig0 >> 2];
*tptr++ = etable[((ig0 & 3) << 4) | (ig1 >> 4)];
......@@ -111,7 +112,7 @@ int Base64Transcoder::encode(int nbytes, const byte* const from, char* const to)
////////////////////////////////////////////////////////////////////////////////
int Base64Transcoder::decode(const int nchars, const char* const from,
byte* const to)
byte_t* const to)
{
// Decode Base64 chars in array "from" into bytes in array "to"
// White space and new lines are skipped
......@@ -120,11 +121,11 @@ int Base64Transcoder::decode(const int nchars, const char* const from,
// nchars: number of chars in array "from"
// the number of bytes successfully translated is returned
byte a2,a3,b0,b1,b2,b3;
byte_t a2,a3,b0,b1,b2,b3;
int c;
const char* fptr = from;
const char* const fptr_end = from+nchars+1;
byte* tptr = to;
byte_t* tptr = to;
while ( fptr < fptr_end-4 )
{
......@@ -142,8 +143,8 @@ int Base64Transcoder::decode(const int nchars, const char* const from,
#endif
break;
}
// a0 = (byte) c;
b0 = (byte) dtable[c];
// a0 = (byte_t) c;
b0 = (byte_t) dtable[c];
do
{
......@@ -158,8 +159,8 @@ int Base64Transcoder::decode(const int nchars, const char* const from,
#endif
break;
}
// a1 = (byte) c;
b1 = (byte) dtable[c];
// a1 = (byte_t) c;
b1 = (byte_t) dtable[c];
do
{
......@@ -174,8 +175,8 @@ int Base64Transcoder::decode(const int nchars, const char* const from,
#endif
break;
}
a2 = (byte) c;
b2 = (byte) dtable[c];
a2 = (byte_t) c;
b2 = (byte_t) dtable[c];
do
{
......@@ -190,8 +191,8 @@ int Base64Transcoder::decode(const int nchars, const char* const from,
#endif
break;
}
a3 = (byte) c;
b3 = (byte) dtable[c];
a3 = (byte_t) c;
b3 = (byte_t) dtable[c];
if ((b0|b1|b2|b3) & 0x80)
{
......
......@@ -23,18 +23,18 @@
#include <cstdio>
#include <string>
typedef unsigned char byte;
typedef unsigned char byte_t;
class Base64Transcoder
{
char etable[64]; // encode table
byte dtable[256]; // decode table
byte_t dtable[256]; // decode table
public:
Base64Transcoder();
int encode(int nbytes, const byte* const from, char* const to);
int decode(int nchars, const char* const from, byte* const to);
int encode(int nbytes, const byte_t* const from, char* const to);
int decode(int nchars, const char* const from, byte_t* const to);
void byteswap_double(size_t n, double* const x);
void byteswap_int(size_t n, int* const x);
int print(int nchars, const char* const buf, std::ostream& o);
......
......@@ -187,10 +187,10 @@ void Function3d::print(ostream& os) const
vector<double> tmpval(val);
xcdr.byteswap_double(tmpval.size(),&tmpval[0]);
// transform tmpval to base64 encoding
xcdr.encode(nbytes, (byte *) &tmpval[0], wbuf);
xcdr.encode(nbytes, (byte_t *) &tmpval[0], wbuf);
#else
// transform val to base64 encoding
xcdr.encode(nbytes, (byte *) &val[0], wbuf);
xcdr.encode(nbytes, (byte_t *) &val[0], wbuf);
#endif
os <<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
......
......@@ -202,7 +202,7 @@ void Function3dHandler::endElement(const XMLCh* const uri,
Timer tm;
tm.start();
Base64Transcoder xcdr;
size_t nbytes = xcdr.decode(buf_.size(),buf_.data(),(byte*)&f_.val[0]);
size_t nbytes = xcdr.decode(buf_.size(),buf_.data(),(byte_t*)&f_.val[0]);
assert(nbytes==f_.val.size()*sizeof(double));
buf_.clear();
#if PLT_BIG_ENDIAN
......
......@@ -1504,7 +1504,7 @@ void SlaterDet::print(ostream& os, string encoding, double weight, int ispin,
int outlen = xcdr.nchars(nbytes);
char* b = new char[outlen];
assert(b!=0);
xcdr.encode(nbytes,(byte*) &wftmpr[0],b);
xcdr.encode(nbytes,(byte_t*) &wftmpr[0],b);
// Note: optional x0,y0,z0 attributes not used, default is zero
os << "<grid_function type=\"" << element_type << "\""
<< " nx=\"" << ft.np0()
......@@ -1769,7 +1769,7 @@ void SlaterDet::str(string& sdstr, string encoding, double weight,
int outlen = xcdr.nchars(nbytes);
char* b = new char[outlen];
assert(b!=0);
xcdr.encode(nbytes,(byte*) &tmpr[0],b);
xcdr.encode(nbytes,(byte_t*) &tmpr[0],b);
// Note: optional x0,y0,z0 attributes not used, default is zero
if ( ctxt_.myrow() == 0 )
{
......
......@@ -42,23 +42,6 @@ WavefunctionHandler::WavefunctionHandler(Wavefunction& wf,
////////////////////////////////////////////////////////////////////////////////
WavefunctionHandler::~WavefunctionHandler() {}
////////////////////////////////////////////////////////////////////////////////
void WavefunctionHandler::byteswap_double(size_t n, double* x)
{
if (n==0) return;
unsigned char* c = (unsigned char*) x;
while ( n-- > 0 )
{
unsigned char tmp;
tmp = c[7]; c[7] = c[0]; c[0] = tmp;
tmp = c[6]; c[6] = c[1]; c[1] = tmp;
tmp = c[5]; c[5] = c[2]; c[2] = tmp;
tmp = c[4]; c[4] = c[3]; c[3] = tmp;
c+=8;
}
}
////////////////////////////////////////////////////////////////////////////////
void WavefunctionHandler::startElement(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname,
......
......@@ -42,8 +42,6 @@ class WavefunctionHandler : public StructureHandler
double current_kx, current_ky, current_kz, current_weight;
int current_size, last_size;
void byteswap_double(size_t n, double* x);
public:
// Start of the root element in the structure being handled
......
......@@ -1038,7 +1038,7 @@ int XMLGFPreprocessor::process(const char* const uri,
<< endl;
#endif
int nbytes = xcdr.decode(nchars,buf.data()+seg_start[iseg],
(byte*)&dbuf[iseg][0]);
(byte_t*)&dbuf[iseg][0]);
#if DEBUG
cout << rctxt.mype() << ": iseg=" << iseg << " nbytes=" << nbytes
<< endl;
......
......@@ -19,5 +19,5 @@
#include "release.h"
std::string release(void)
{
return std::string("rel1_74_1");
return std::string("rel1_74_1dev");
}
#!/bin/bash
# get_atomset: extract atomset from a Qbox sample
#
# use: get_atomset sample.xml
# use: get_atomset.sh sample.xml
#
nlines=$(grep /atomset -m 1 -n $1 | cut -f1 -d: - )
head -$nlines $1
......
#!/usr/bin/python
# qbox_dos.py: extract electronic DOS from Qbox output
# generate DOS plot in gnuplot format
# use: qbox_dos.py [-last] emin emax width file.r
# emin, emax: bounds of plot in [eV]
# width: gaussian broadening in [eV]
# use: qbox_dos.py [-last] [mu] emin emax [mu] width file.r
# mu: (optional) chemical potential [eV]
# If omitted, an attempt is made to read the element <mu> from file.r
# The value is 0.0 if <mu> is not found in file.r
# emin, emax: bounds of plot in [eV] relative to chemical potential mu
# width: gaussian broadening width [eV]
# the DOS is accumulated separately for each spin
# With the -last option, only the last <eigenset> is used to compute the DOS
......@@ -11,15 +14,31 @@ import xml.sax
import sys
import math
if (len(sys.argv) != 5) and (len(sys.argv) != 6) :
print "use: ",sys.argv[0]," [-last] emin emax width file.r"
argc=len(sys.argv)
if (argc < 5) or (argc > 7) :
print "use: ",sys.argv[0]," [-last] [mu] emin emax width file.r"
sys.exit()
# default chemical potential mu=0.0
mu=0.0
iarg = 1
lastonly = False
# check for -last option
if (sys.argv[iarg] == "-last") :
lastonly = True
iarg += 1
if (argc < 6):
print "use: ",sys.argv[0]," [-last] [mu] emin emax width file.r"
sys.exit()
# check for mu argument
if ((lastonly and (argc == 7)) or ((not lastonly) and (argc == 6))):
mu = float(sys.argv[iarg])
iarg += 1
if (argc < 6):
print "use: ",sys.argv[0]," [-last] [mu] emin emax width file.r"
sys.exit()
emin = float(sys.argv[iarg])
iarg += 1
......@@ -44,6 +63,7 @@ class QboxOutputHandler(xml.sax.handler.ContentHandler):
self.readData = 0
self.dos_up = [0] * ndos
self.dos_dn = [0] * ndos
self.mu = mu
def startElement(self, name, attributes):
if (name == "eigenset") and (lastonly):
......@@ -58,6 +78,9 @@ class QboxOutputHandler(xml.sax.handler.ContentHandler):
self.buffer = ""
if self.spin == 1:
self.nspin = 2
if name == "mu":
self.readData = 1
self.buffer=""
def characters(self, data):
if self.readData:
......@@ -67,6 +90,9 @@ class QboxOutputHandler(xml.sax.handler.ContentHandler):
if name == "eigenvalues":
self.readData = 0
self.accumulate_dos()
if name == "mu":
self.readData = 0
self.mu = float(self.buffer)
def accumulate_dos(self):
self.e = self.buffer.split()
......@@ -74,22 +100,22 @@ class QboxOutputHandler(xml.sax.handler.ContentHandler):
for i in range(len(self.e)):
for j in range(ndos):
ej = emin + j * de
self.dos_up[j] += gauss(float(self.e[i])-ej, width ) * self.weight
self.dos_up[j] += gauss(float(self.e[i])-self.mu-ej, width ) * self.weight
if self.spin == 1:
for i in range(len(self.e)):
for j in range(ndos):
ej = emin + j * de
self.dos_dn[j] += gauss(float(self.e[i])-ej, width ) * self.weight
self.dos_dn[j] += gauss(float(self.e[i])-self.mu-ej, width ) * self.weight
def print_dos(self):
print "# ",infile," spin=0 width=",width
print "# ",infile," mu=",self.mu," spin=0 width=",width
for j in range(ndos):
ej = emin + j * de
print ej, self.dos_up[j]
if self.nspin == 2:
print
print
print "# ",infile," spin=1 width=",width
print "# ",infile," mu=",mu," spin=1 width=",width
for j in range(ndos):
ej = emin + j * de
print ej, self.dos_dn[j]
......
#!/bin/bash
# reduce qbox restart file to atomset file
# qbox_reduce.sh: Remove wave functions from a restart file
# The original file is modified and contains the <atomset> element only
# use: qbox_reduce.sh file.xml [file.xml ..]
for f in ${*}
do
name=${f%.xml}
atomset_name=${name}_atomset
echo $name.xml "->" $atomset_name.xml
get_atomset $f > $atomset_name.xml
rm $f
tmpfile=qbox_reduce$$
nlines=$(grep /atomset -m 1 -n $f | cut -f1 -d: - )
head -$nlines $f > $tmpfile
echo "</fpmd:sample>" >> $tmpfile
mv $tmpfile $f
done
Supports Markdown
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