From 55e106f53db26d12a3c0f91c9ea579a5dd71321c Mon Sep 17 00:00:00 2001 From: vijay gopal chilkuri Date: Sun, 28 Jan 2018 11:16:22 +0100 Subject: [PATCH] now compiles but bug in the calculation of s2 --- .gitignore | 4 ++++ Makefile | 22 ++++++++++++++++--- src/.gitignore | 5 +++++ src/{adrfull.irp.f => adrfull_old} | 0 src/get_dmat.h | 2 +- src/get_s2.c | 2 +- src/get_s2_cyclic.c | 2 +- src/get_s2_mov.c | 2 +- src/get_val_iaa2.c | 34 ++++++++++++++++++++++++++++++ src/get_val_iaa2.h | 8 +++++++ src/stimsyr.h | 5 +++++ 11 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 .gitignore create mode 100644 src/.gitignore rename src/{adrfull.irp.f => adrfull_old} (100%) create mode 100644 src/get_val_iaa2.c create mode 100644 src/get_val_iaa2.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b2aa47 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*bin/* +*/obj/* +*mod.mod* +irpf90.a diff --git a/Makefile b/Makefile index 5982ec1..6624503 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common #CC=gcc #FC = ifort +CLINKER = mpicc -fPIC #-wd1572 -O3 -axAVX,SSE4.2 -fno-alias -no-prec-div -no-prec-sqrt -ip MAKE = /usr/bin/make MKDIR_P = /bin/mkdir -p OBJ_DIR := obj @@ -24,14 +25,29 @@ ${BIN_DIR}: directories: ${OBJ_DIR} ${LIB_DIR} ${BIN_DIR} ${LIB_DIR}/irpf90.a: directories - cd ${SRC_DIR} && irpf90 init && $(MAKE) irpf90.a && cp IRPF90_temp/irpf90.a ../${LIB_DIR} + cd ${SRC_DIR} && irpf90 init && $(MAKE) irpf90.a && cp irpf90.a ../${LIB_DIR} ${OBJ_DIR}/read2.o: ${SRC_DIR}/read2.c directories chkopts ${CC} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -c -o $@ $< ${SLEPC_EPS_LIB} +${OBJ_DIR}/get_s2.o: ${SRC_DIR}/get_s2.c directories chkopts + ${CC} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -c -o $@ $< ${SLEPC_EPS_LIB} + +${OBJ_DIR}/get_s2_cyclic.o: ${SRC_DIR}/get_s2_cyclic.c directories chkopts + ${CC} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -c -o $@ $< ${SLEPC_EPS_LIB} + +${OBJ_DIR}/get_s2_mov.o: ${SRC_DIR}/get_s2_mov.c directories chkopts + ${CC} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -c -o $@ $< ${SLEPC_EPS_LIB} + +${OBJ_DIR}/get_dmat.o: ${SRC_DIR}/get_dmat.c directories chkopts + ${CC} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -c -o $@ $< ${SLEPC_EPS_LIB} + +${OBJ_DIR}/get_val_iaa2.o: ${SRC_DIR}/get_val_iaa2.c directories chkopts + ${CC} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -c -o $@ $< ${SLEPC_EPS_LIB} + ${OBJ_DIR}/ex1.o: ${SRC_DIR}/ex1.c -${CC} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -c -o $@ $< ${SLEPC_EPS_LIB} -${BIN_DIR}/ex1: ${OBJ_DIR}/read2.o ${LIB_DIR}/irpf90.a ${OBJ_DIR}/ex1.o ${SRC_DIR}/read2.h ${SRC_DIR}/stimsyr.h chkopts - -${CLINKER} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -o ${BIN_DIR}/ex1 ${OBJ_DIR}/ex1.o ${OBJ_DIR}/read2.o ${LIB_DIR}/irpf90.a ${SLEPC_EPS_LIB}# -lifcore -lirc -lcomposerxe_gen_helpers_core_2.3 +${BIN_DIR}/ex1: ${OBJ_DIR}/read2.o ${OBJ_DIR}/get_s2_mov.o ${OBJ_DIR}/get_s2_cyclic.o ${OBJ_DIR}/get_s2.o ${OBJ_DIR}/get_dmat.o ${OBJ_DIR}/get_val_iaa2.o ${LIB_DIR}/irpf90.a ${OBJ_DIR}/ex1.o ${SRC_DIR}/read2.h ${SRC_DIR}/stimsyr.h chkopts + -${CLINKER} ${SLEPC_INCLUDE} ${PETSC_CC_INCLUDES} -o ${BIN_DIR}/ex1 ${OBJ_DIR}/ex1.o ${OBJ_DIR}/read2.o ${OBJ_DIR}/get_s2.o ${OBJ_DIR}/get_s2_mov.o ${OBJ_DIR}/get_s2_cyclic.o ${OBJ_DIR}/get_dmat.o ${OBJ_DIR}/get_val_iaa2.o ${LIB_DIR}/irpf90.a ${SLEPC_EPS_LIB}# -lifcore -lirc -lcomposerxe_gen_helpers_core_2.3 # ${RM} ex1.o read2.o diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..7ac9fbf --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,5 @@ +IRPF90_temp/ +IRPF90_man/ +irpf90.make +irpf90_entities +tags \ No newline at end of file diff --git a/src/adrfull.irp.f b/src/adrfull_old similarity index 100% rename from src/adrfull.irp.f rename to src/adrfull_old diff --git a/src/get_dmat.h b/src/get_dmat.h index 29539e5..a60efa7 100644 --- a/src/get_dmat.h +++ b/src/get_dmat.h @@ -6,4 +6,4 @@ #include void get_1rdm(PetscScalar *, PetscInt *, PetscInt *, int *, PetscReal *); -void get_2rdm(PetscScalar *, PetscInt *, PetscInt *, int *, PetscReal *, double ****); +void get_2rdm(PetscScalar *valxr, PetscInt *Istart, PetscInt *Iend, int *natom, PetscReal *trace2rdm, double densmat2[*natom][*natom][*natom][*natom]); diff --git a/src/get_s2.c b/src/get_s2.c index 4fb42f3..087a578 100644 --- a/src/get_s2.c +++ b/src/get_s2.c @@ -676,7 +676,7 @@ void get_s2(Vec xr, PetscInt *Istart, PetscInt *Iend, PetscScalar *valxr, int *n // if(mpiid==3)printf(" ii = %d norm = %18f %18f 3 = %18f 4 = %18f\n", ii, *norm2, *norm3, *xymat2, *xymat3); } - ierr = PetscTime(&tt2);CHKERRQ(ierr); + ierr = PetscTime(&tt2); //printf(" norm = %18f weight = %18f weight/N = %18f tmpwe = %18f\n", *norm2, *weight3, *weight3/(*norm2),tmpwe); //printf(" norm = %18f %18f xymat = %18f %18f\n", *norm2, *norm3, *xymat2, *xymat3); //ierr = PetscPrintf(PETSC_COMM_WORLD," Time used for the s2 loop: %f\n",tt2-tt1);CHKERRQ(ierr); diff --git a/src/get_s2_cyclic.c b/src/get_s2_cyclic.c index 6204863..e2075c0 100644 --- a/src/get_s2_cyclic.c +++ b/src/get_s2_cyclic.c @@ -778,7 +778,7 @@ void get_s2_cyclic(Vec xr, PetscInt *Istart, PetscInt *Iend, PetscScalar *valxr, // if(mpiid==0)printf(" ii = %d xmat3 = %18f xmat4 = %18f diff = %18f\n", ii, xmat3, xmat4, (xmat3-xmat4)); } - ierr = PetscTime(&tt2);CHKERRQ(ierr); + ierr = PetscTime(&tt2); //if(mpiid==0)printf(" norm3 = %18f norm4 = %18f xymat3= %18f xymat4= %18f\n", *norm3, *norm4, *xymat3, *xymat4); //ierr = PetscPrintf(PETSC_COMM_WORLD," Time used for the s2 loop: %f\n",tt2-tt1);CHKERRQ(ierr); } diff --git a/src/get_s2_mov.c b/src/get_s2_mov.c index a7154fa..a7f30ba 100644 --- a/src/get_s2_mov.c +++ b/src/get_s2_mov.c @@ -676,7 +676,7 @@ void get_s2_mov(Vec xr, PetscInt *Istart, PetscInt *Iend, PetscScalar *valxr, in // if(mpiid==3)printf(" ii = %d norm = %18f %18f 3 = %18f 4 = %18f\n", ii, *norm2, *norm3, *xymat2, *xymat3); } - ierr = PetscTime(&tt2);CHKERRQ(ierr); + ierr = PetscTime(&tt2); //printf(" norm = %18f weight = %18f weight/N = %18f tmpwe = %18f\n", *norm2, *weight3, *weight3/(*norm2),tmpwe); //printf(" norm = %18f %18f xymat = %18f %18f\n", *norm2, *norm3, *xymat2, *xymat3); //ierr = PetscPrintf(PETSC_COMM_WORLD," Time used for the s2 loop: %f\n",tt2-tt1);CHKERRQ(ierr); diff --git a/src/get_val_iaa2.c b/src/get_val_iaa2.c new file mode 100644 index 0000000..e88a35f --- /dev/null +++ b/src/get_val_iaa2.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include +#include "get_val_iaa2.h" + +/* + * This function gets vector from a different processor + * xr the full vector + * iaa2 adresse to get value from + * getvaliaa2 the value + */ + +void get_val_iaa2(Vec xr,long int *iaa2,double *getvaliaa2){ + Vec x; /* initial vector, destination vector */ + VecScatter scatter; /* scatter context */ + IS from, to; /* index sets that define the scatter */ + PetscScalar *values; + int idx_from[] = {*iaa2}, idx_to[] = {0}; + VecCreateSeq( PETSC_COMM_SELF,1,&x); + ISCreateGeneral(PETSC_COMM_SELF,1,idx_from,PETSC_COPY_VALUES,&from); + ISCreateGeneral(PETSC_COMM_SELF,1,idx_to, PETSC_COPY_VALUES,&to); + printf("in get_val"); + VecScatterCreate(xr,from,x,to,&scatter); + VecScatterBegin(scatter,xr,x,INSERT_VALUES,SCATTER_FORWARD); + VecScatterEnd(scatter,xr,x, INSERT_VALUES,SCATTER_FORWARD); + VecGetArray(x,&values); + *getvaliaa2 = values[0]; + ISDestroy(&from); + ISDestroy(&to); + VecScatterDestroy(&scatter); +} diff --git a/src/get_val_iaa2.h b/src/get_val_iaa2.h new file mode 100644 index 0000000..f47bcaa --- /dev/null +++ b/src/get_val_iaa2.h @@ -0,0 +1,8 @@ +#include +#include +#include +#include +#include +#include + +void get_val_iaa2(Vec, long int *, double *); diff --git a/src/stimsyr.h b/src/stimsyr.h index 84dc62f..2397381 100644 --- a/src/stimsyr.h +++ b/src/stimsyr.h @@ -1,3 +1,5 @@ +#include + void unit_l1_( long int *, long int *, @@ -11,5 +13,8 @@ void unit_l1_( long int *, long int *, long int *, + long int *, + _Bool *, + long int *, double *);