Skip to content

Commit b4a2788

Browse files
author
naokin
committed
fixed inconsistency in the spatial NPDM binary file format.
1 parent 4ec2e3d commit b4a2788

File tree

6 files changed

+37
-13
lines changed

6 files changed

+37
-13
lines changed

makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
BOOSTINCLUDE = /opt/local/include
1010

1111
#specify boost and lapack-blas library locations
12-
BOOSTLIB = -L/opt/local/lib -lboost_system-mt -lboost_filesystem-mt -lboost_serialization-mt
12+
BOOSTLIB = -L/opt/local/lib -lboost_system -lboost_filesystem -lboost_serialization
1313
#BOOSTLIB = -lboost_serialization -lboost_system -lboost_filesystem
1414
LAPACKBLAS = /usr/lib/liblapack.dylib /usr/lib/libblas.dylib
1515

@@ -24,7 +24,7 @@ USE_MPI = no
2424
USE_MKL = no
2525

2626
# change to icpc for Intel
27-
CXX = clang++
27+
CXX = icpc
2828
MPICXX = mpiicpc
2929
export CXX
3030
export MPICXX
@@ -43,13 +43,13 @@ MOLCAS = no
4343
OPENMP = no
4444

4545
ifeq ($(USE_MKL), yes)
46-
MKLLIB = /opt/intel/compilers_and_libraries_2016.0.109/linux/mkl/lib/intel64
46+
MKLLIB = /opt/intel/compilers_and_libraries/linux/mkl/lib/intel64
4747
ifeq ($(OPENMP), yes)
4848
LAPACKBLAS = -L${MKLLIB} -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core
4949
else
5050
LAPACKBLAS = -L${MKLLIB} -lmkl_intel_lp64 -lmkl_sequential -lmkl_core
5151
endif
52-
MKLFLAGS = /opt/intel/compilers_and_libraries_2016.0.109/linux/mkl/include
52+
MKLFLAGS = /opt/intel/compilers_and_libraries/linux/mkl/include
5353
MKLOPT = -D_HAS_INTEL_MKL
5454
else
5555
MKLFLAGS = .
@@ -83,6 +83,10 @@ ifeq ($(MOLPRO), yes)
8383
MOLPRO_BLOCK= -DMOLPRO
8484
endif
8585

86+
ifeq ($(MOLCAS), yes)
87+
MOLCAS_BLOCK= -DMOLCAS
88+
endif
89+
8690
FLAGS = -I${MKLFLAGS} -I$(INCLUDE1) -I$(INCLUDE2) -I$(NEWMATINCLUDE) -I$(BOOSTINCLUDE) \
8791
-I$(HOME)/modules/generate_blocks/ -I$(HOME)/modules/onepdm -I$(HOME)/modules/twopdm/ \
8892
-I$(HOME)/modules/npdm -I$(HOME)/modules/two_index_ops -I$(HOME)/modules/three_index_ops -I$(HOME)/modules/four_index_ops -std=c++0x \
@@ -133,7 +137,7 @@ ifeq ($(USE_MPI), yes)
133137
endif
134138

135139

136-
OPT += $(OPENMP_FLAGS) -DBLAS -DUSELAPACK $(MPI_OPT) $(I8) $(B56) $(MOLPRO_BLOCK) -DFAST_MTP -D_HAS_CBLAS -D_HAS_INTEL_MKL ${MKLOPT} ${UNITTEST} -fPIC
140+
OPT += $(OPENMP_FLAGS) -DBLAS -DUSELAPACK $(MPI_OPT) $(I8) $(B56) $(MOLPRO_BLOCK) $(MOLCAS_BLOCK) -DFAST_MTP -D_HAS_CBLAS -D_HAS_INTEL_MKL ${MKLOPT} ${UNITTEST} -fPIC
137141

138142
SRC_genetic = genetic/CrossOver.C genetic/Evaluate.C genetic/GAInput.C genetic/GAOptimize.C genetic/Generation.C genetic/Mutation.C genetic/RandomGenerator.C genetic/ReadIntegral.C
139143

modules/npdm/onepdm_container.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,16 @@ void Onepdm_container::save_spatial_npdm_binary(const int &i, const int &j)
121121
{
122122
char file[5000];
123123
sprintf (file, "%s%s%d.%d%s", dmrginp.save_prefix().c_str(),"/spatial_onepdm.", i, j,".bin");
124+
#ifndef MOLCAS
124125
std::ofstream ofs(file, std::ios::binary);
125126
boost::archive::binary_oarchive save(ofs);
126127
save << spatial_onepdm;
127128
ofs.close();
129+
#else
130+
FILE* f = fopen(file,"wb");
131+
fwrite(spatial_onepdm.data(),sizeof(double),spatial_onepdm.size(),f);
132+
fclose(f);
133+
#endif
128134
}
129135
}
130136

modules/npdm/threepdm_container.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,16 @@ void Threepdm_container::save_spatial_npdm_binary(const int &i, const int &j)
328328
{
329329
char file[5000];
330330
sprintf (file, "%s%s%d.%d%s", dmrginp.save_prefix().c_str(),"/spatial_threepdm.",i,j,".bin");
331+
#ifndef MOLCAS
331332
std::ofstream ofs(file, std::ios::binary);
332333
boost::archive::binary_oarchive save(ofs);
333334
save << spatial_threepdm;
334335
ofs.close();
336+
#else
337+
FILE* f = fopen(file,"wb");
338+
fwrite(spatial_threepdm.data(),sizeof(double),spatial_threepdm.size(),f);
339+
fclose(f);
340+
#endif
335341
}
336342
}
337343
/*

modules/npdm/twopdm_container.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,16 @@ void Twopdm_container::save_spatial_npdm_binary(const int &i, const int &j)
134134
{
135135
char file[5000];
136136
sprintf (file, "%s%s%d.%d%s", dmrginp.save_prefix().c_str(),"/spatial_twopdm.", i, j,".bin");
137+
#ifndef MOLCAS
137138
std::ofstream ofs(file, std::ios::binary);
138139
boost::archive::binary_oarchive save(ofs);
139140
save << spatial_twopdm;
140141
ofs.close();
142+
#else
143+
FILE* f = fopen(file,"wb");
144+
fwrite(spatial_twopdm.data(),sizeof(double),spatial_twopdm.size(),f);
145+
fclose(f);
146+
#endif
141147
}
142148
}
143149

molcas/block_calldmrg.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ void block_calldmrg (
176176
switch (N_pdm) {
177177
case 1:
178178
fcon << "onepdm" << endl;
179+
fcon << "new_npdm_code" << endl;
179180
break;
180181
case 2:
181182
fcon << "twopdm" << endl;
183+
fcon << "new_npdm_code" << endl;
182184
break;
183185
case 3:
184186
fcon << "threepdm" << endl;

molcas/sortNpdm.C

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void sort1pdm (FORTINT N_act, FORTINT iRoot, FORTINT jRoot)
1212
if(mpigetrank() == 0) {
1313

1414
std::ostringstream ifname;
15-
ifname << "./node0/spatial_binary_onepdm." << iRoot << "." << jRoot << ".bin";
15+
ifname << "./node0/spatial_onepdm." << iRoot << "." << jRoot << ".bin";
1616

1717
std::ostringstream ofname;
1818
ofname << "./SORTED1PDM." << iRoot << "." << jRoot << ".0";
@@ -30,9 +30,9 @@ void sort1pdm (FORTINT N_act, FORTINT iRoot, FORTINT jRoot)
3030
// sort <i,j> (in row-major) to G(i,j) (in col-major)
3131
// i.e. G(i,j) = <i,j>
3232

33-
int Ndum;
34-
fread(&Ndum,sizeof(int),1,ifp);
35-
assert(Ndum == N_act);
33+
// int Ndum;
34+
// fread(&Ndum,sizeof(int),1,ifp);
35+
// assert(Ndum == N_act);
3636

3737
double *xbuf = new double[N2];
3838
fread(xbuf,sizeof(double),N2,ifp);
@@ -62,7 +62,7 @@ void sort2pdm (FORTINT N_act, FORTINT iRoot, FORTINT jRoot)
6262
if(mpigetrank() == 0) {
6363

6464
std::ostringstream ifname;
65-
ifname << "./node0/spatial_binary_twopdm." << iRoot << "." << jRoot << ".bin";
65+
ifname << "./node0/spatial_twopdm." << iRoot << "." << jRoot << ".bin";
6666

6767
std::ostringstream ofname;
6868
ofname << "./SORTED2PDM." << iRoot << "." << jRoot << ".0";
@@ -82,9 +82,9 @@ void sort2pdm (FORTINT N_act, FORTINT iRoot, FORTINT jRoot)
8282
// sort <i,j,k,l> (in row-major) to G(i,l,j,k) (in col-major)
8383
// i.e. G(i,j,k,l) = <i,k,l,j>
8484

85-
int Ndum;
86-
fread(&Ndum,sizeof(int),1,ifp);
87-
assert(Ndum == N_act);
85+
// int Ndum;
86+
// fread(&Ndum,sizeof(int),1,ifp);
87+
// assert(Ndum == N_act);
8888

8989
double *xbuf = new double[N4];
9090
fread(xbuf,sizeof(double),N4,ifp);

0 commit comments

Comments
 (0)