From a857aed262f8f7056db0af00203f90ab5bce1dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20H=C3=A9nin?= Date: Wed, 16 Jan 2019 12:56:42 +0100 Subject: [PATCH] More checks on PBCs, bump version to 1.3 --- Makefile | 15 +++++++++------ pkgIndex.tcl | 12 ------------ qwrap.cpp | 14 +++++++++++--- 3 files changed, 20 insertions(+), 21 deletions(-) delete mode 100644 pkgIndex.tcl diff --git a/Makefile b/Makefile index ba11900..4a81b53 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,26 @@ -VERSION=1.2 -TCLINC=/usr/include/tcl +VERSION=1.3 +TCLINC=/usr/include/tcl8.6 PLUGINDIR=${HOME}/lib/vmd/plugins/LINUXAMD64/tcl CPP=g++ #CPPFLAGS=-fpic -g -I${TCLINC} -CPPFLAGS=-fpic -O3 -I${TCLINC} +CPPFLAGS=-fpic -O3 -I${TCLINC} -DVERSION=\"${VERSION}\" -all: qwrap.so qwrap.tar.gz +all: qwrap.so pkgIndex.tcl qwrap.so: qwrap.o $(CPP) -shared qwrap.o -o qwrap.so -qwrap.tar.gz: qwrap.cpp Makefile +qwrap.tar.gz: qwrap.cpp Makefile pkgIndex.tcl tar czf qwrap${VERSION}.tar.gz qwrap.cpp Makefile pkgIndex.tcl +pkgIndex.tcl: qwrap.so + tclsh mkindex.tcl + clean: rm *.o *.so *.tar.gz -install: +install: all mkdir -p ${PLUGINDIR}/qwrap${VERSION} && \ rsync -av qwrap.so pkgIndex.tcl ${PLUGINDIR}/qwrap${VERSION}/. diff --git a/pkgIndex.tcl b/pkgIndex.tcl deleted file mode 100644 index 7c926eb..0000000 --- a/pkgIndex.tcl +++ /dev/null @@ -1,12 +0,0 @@ -# Tcl package index file, version 1.1 -# This file is generated by the "pkg_mkIndex" command -# and sourced either when an application starts up or -# by a "package unknown" script. It invokes the -# "package ifneeded" command to set up package-related -# information so that packages will be loaded automatically -# in response to "package require" commands. When this -# script is sourced, the variable $dir must contain the -# full path name of this file's directory. - -package ifneeded qwrap 1.2 [list load [file join $dir qwrap.so ]] - diff --git a/qwrap.cpp b/qwrap.cpp index 0bc6686..9cdb7d9 100644 --- a/qwrap.cpp +++ b/qwrap.cpp @@ -337,17 +337,25 @@ static int do_qwrap(ClientData data, Tcl_Interp *interp, int argc, Tcl_Obj * con // except if unwrapping and at first frame, then it's not needed if (!(unwrap && frame == first_frame)) { - Tcl_Obj *get_abc = Tcl_ObjPrintf ("molinfo top get {a b c}"); + Tcl_Obj *get_abc = Tcl_ObjPrintf ("molinfo top get {a b c alpha beta gamma}"); result = Tcl_EvalObjEx(interp, get_abc, TCL_EVAL_DIRECT); if (result != TCL_OK) { return TCL_ERROR; } object = Tcl_GetObjResult(interp); { int num = parse_vector(object, PBC, interp); - if (num != 3 || PBC[0]*PBC[1]*PBC[2] == 0.0) { + if (num != 6) { Tcl_SetResult(interp, (char *) "qwrap: error parsing PBC", TCL_STATIC); return TCL_ERROR; } + if (PBC[0]*PBC[1]*PBC[2] == 0.0) { + Tcl_SetResult(interp, (char *) "qwrap: error: at least one PBC box length is zero", TCL_STATIC); + return TCL_ERROR; + } + if (PBC[3] != 90. || PBC[4] != 90. || PBC[5] != 90.) { + Tcl_SetResult(interp, (char *) "qwrap: non-orthorhombic cell detected, unsupported by qwrap; use PbcTools for this system", TCL_STATIC); + return TCL_ERROR; + } } } @@ -499,7 +507,7 @@ extern "C" { (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "qunwrap", obj_qunwrap, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); - Tcl_EvalEx(interp, "package provide qwrap 1.2", -1, 0); + Tcl_EvalEx(interp, "package provide qwrap " VERSION, -1, 0); return TCL_OK; } }