Skip to content

Commit

Permalink
Merge pull request #1 from ccsb-scripps/boost_upgrade
Browse files Browse the repository at this point in the history
Remove deprecated Boost features and improve compiling for newer Boost versions
  • Loading branch information
atillack authored Apr 28, 2020
2 parents cef1806 + 3097cd4 commit 537c5ee
Show file tree
Hide file tree
Showing 81 changed files with 9,140 additions and 9,131 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.o
6 changes: 3 additions & 3 deletions build/linux/debug/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
BASE=/usr/local
BOOST_VERSION=1_41
BASE=/usr
BOOST_VERSION=
BOOST_INCLUDE = $(BASE)/include
C_PLATFORM=-static -pthread
GPP=/usr/local/bin/g++
GPP=/usr/bin/g++
C_OPTIONS= -g
BOOST_LIB_VERSION=

Expand Down
6 changes: 3 additions & 3 deletions build/linux/release/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
BASE=/usr/local
BOOST_VERSION=1_41
BASE=/usr
BOOST_VERSION=
BOOST_INCLUDE = $(BASE)/include
C_PLATFORM=-static -pthread
GPP=/usr/local/bin/g++
GPP=/usr/bin/g++
C_OPTIONS= -O3 -DNDEBUG
BOOST_LIB_VERSION=

Expand Down
6 changes: 3 additions & 3 deletions build/mac/debug/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
BASE=/usr/local
BOOST_VERSION=1_41
BOOST_VERSION=1_71
BOOST_INCLUDE = $(BASE)/include
C_PLATFORM=-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4
GPP=/usr/bin/g++
C_PLATFORM=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
GPP=clang++
C_OPTIONS= -g
BOOST_LIB_VERSION=

Expand Down
8 changes: 4 additions & 4 deletions build/mac/release/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
BASE=/usr/local
BOOST_VERSION=1_41
BOOST_VERSION=1_71
BOOST_INCLUDE = $(BASE)/include
C_PLATFORM=-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4
GPP=/usr/bin/g++
C_OPTIONS= -O3 -DNDEBUG
C_PLATFORM=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
GPP=clang++
C_OPTIONS= -O2 -DNDEBUG
BOOST_LIB_VERSION=

include ../../makefile_common
11 changes: 10 additions & 1 deletion build/makefile_common
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ CC = ${GPP} ${C_PLATFORM} -ansi -Wno-long-long ${C_OPTIONS} $(INCFLAGS)

LDFLAGS = -L$(BASE)/lib -L.

LIBS = -l boost_system${BOOST_LIB_VERSION} -l boost_thread${BOOST_LIB_VERSION} -l boost_serialization${BOOST_LIB_VERSION} -l boost_filesystem${BOOST_LIB_VERSION} -l boost_program_options${BOOST_LIB_VERSION}#-l pthread
# test if boost_thread-mt exists, this is
# necessary as some versions of boost only
# install libboost_thread-mt, but not
# libboost_thread (e.g. macOS)
$(shell echo "int main(){ return 0; }" > linktest.cpp)
$(shell $(GPP) $(LDFLAGS) -l boost_thread-mt linktest.cpp -o linktest >/dev/null 2>&1)
threadmt:=$(shell if [ -f ./linktest ]; then echo "-mt"; rm ./linktest; fi;)
$(shell rm ./linktest.cpp)

LIBS = -l boost_system${BOOST_LIB_VERSION} -l boost_thread${threadmt}${BOOST_LIB_VERSION} -l boost_serialization${BOOST_LIB_VERSION} -l boost_filesystem${BOOST_LIB_VERSION} -l boost_program_options${BOOST_LIB_VERSION}#-l pthread

.SUFFIXES: .cpp .o

Expand Down
154 changes: 77 additions & 77 deletions src/lib/array3d.h
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
/*
Copyright (c) 2006-2010, The Scripps Research Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: Dr. Oleg Trott <ot14@columbia.edu>,
The Olson Lab,
The Scripps Research Institute
*/

#ifndef VINA_ARRAY3D_H
#define VINA_ARRAY3D_H

#include <exception> // std::bad_alloc
#include "common.h"

inline sz checked_multiply(sz i, sz j) {
if(i == 0 || j == 0) return 0;
const sz tmp = i * j;
if(tmp < i || tmp < j || tmp / i != j)
throw std::bad_alloc(); // can't alloc if the size makes sz wrap around
return tmp;
}

inline sz checked_multiply(sz i, sz j, sz k) {
return checked_multiply(checked_multiply(i, j), k);
}

template<typename T>
class array3d {
sz m_i, m_j, m_k;
std::vector<T> m_data;
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive& ar, const unsigned version) {
ar & m_i;
ar & m_j;
ar & m_k;
ar & m_data;
}
public:
array3d() : m_i(0), m_j(0), m_k(0) {}
array3d(sz i, sz j, sz k) : m_i(i), m_j(j), m_k(k), m_data(checked_multiply(i, j, k)) {}
sz dim0() const { return m_i; }
sz dim1() const { return m_j; }
sz dim2() const { return m_k; }
sz dim(sz i) const {
switch(i) {
case 0: return m_i;
case 1: return m_j;
case 2: return m_k;
default: assert(false); return 0; // to get rid of the warning
}
}
void resize(sz i, sz j, sz k) { // data is essentially garbled
m_i = i;
m_j = j;
m_k = k;
m_data.resize(checked_multiply(i, j, k));
}
T& operator()(sz i, sz j, sz k) { return m_data[i + m_i*(j + m_j*k)]; }
const T& operator()(sz i, sz j, sz k) const { return m_data[i + m_i*(j + m_j*k)]; }
};

#endif
/*
Copyright (c) 2006-2010, The Scripps Research Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: Dr. Oleg Trott <ot14@columbia.edu>,
The Olson Lab,
The Scripps Research Institute
*/

#ifndef VINA_ARRAY3D_H
#define VINA_ARRAY3D_H

#include <exception> // std::bad_alloc
#include "common.h"

inline sz checked_multiply(sz i, sz j) {
if(i == 0 || j == 0) return 0;
const sz tmp = i * j;
if(tmp < i || tmp < j || tmp / i != j)
throw std::bad_alloc(); // can't alloc if the size makes sz wrap around
return tmp;
}

inline sz checked_multiply(sz i, sz j, sz k) {
return checked_multiply(checked_multiply(i, j), k);
}

template<typename T>
class array3d {
sz m_i, m_j, m_k;
std::vector<T> m_data;
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive& ar, const unsigned version) {
ar & m_i;
ar & m_j;
ar & m_k;
ar & m_data;
}
public:
array3d() : m_i(0), m_j(0), m_k(0) {}
array3d(sz i, sz j, sz k) : m_i(i), m_j(j), m_k(k), m_data(checked_multiply(i, j, k)) {}
sz dim0() const { return m_i; }
sz dim1() const { return m_j; }
sz dim2() const { return m_k; }
sz dim(sz i) const {
switch(i) {
case 0: return m_i;
case 1: return m_j;
case 2: return m_k;
default: assert(false); return 0; // to get rid of the warning
}
}
void resize(sz i, sz j, sz k) { // data is essentially garbled
m_i = i;
m_j = j;
m_k = k;
m_data.resize(checked_multiply(i, j, k));
}
T& operator()(sz i, sz j, sz k) { return m_data[i + m_i*(j + m_j*k)]; }
const T& operator()(sz i, sz j, sz k) const { return m_data[i + m_i*(j + m_j*k)]; }
};

#endif
156 changes: 78 additions & 78 deletions src/lib/atom.h
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
/*
Copyright (c) 2006-2010, The Scripps Research Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: Dr. Oleg Trott <ot14@columbia.edu>,
The Olson Lab,
The Scripps Research Institute
*/

#ifndef VINA_ATOM_H
#define VINA_ATOM_H

#include "atom_base.h"

struct atom_index {
sz i;
bool in_grid;
atom_index() : i(max_sz), in_grid(false) {}
atom_index(sz i_, bool in_grid_) : i(i_), in_grid(in_grid_) {}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned version) {
ar & i;
ar & in_grid;
}
};

inline bool operator==(const atom_index& i, const atom_index& j) {
return i.i == j.i && i.in_grid == j.in_grid;
}

struct bond {
atom_index connected_atom_index;
fl length;
bool rotatable;
bond() : length(0), rotatable(false) {}
bond(const atom_index& connected_atom_index_, fl length_, bool rotatable_) : connected_atom_index(connected_atom_index_), length(length_), rotatable(rotatable_) {}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned version) {
ar & connected_atom_index;
ar & length;
ar & rotatable;
}
};

struct atom : public atom_base {
vec coords;
std::vector<bond> bonds;
atom() : coords(max_vec) {}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned version) {
ar & boost::serialization::base_object<atom_base>(*this);
ar & coords;
ar & bonds;
}
};

typedef std::vector<atom> atomv;

#endif
/*
Copyright (c) 2006-2010, The Scripps Research Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: Dr. Oleg Trott <ot14@columbia.edu>,
The Olson Lab,
The Scripps Research Institute
*/

#ifndef VINA_ATOM_H
#define VINA_ATOM_H

#include "atom_base.h"

struct atom_index {
sz i;
bool in_grid;
atom_index() : i(max_sz), in_grid(false) {}
atom_index(sz i_, bool in_grid_) : i(i_), in_grid(in_grid_) {}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned version) {
ar & i;
ar & in_grid;
}
};

inline bool operator==(const atom_index& i, const atom_index& j) {
return i.i == j.i && i.in_grid == j.in_grid;
}

struct bond {
atom_index connected_atom_index;
fl length;
bool rotatable;
bond() : length(0), rotatable(false) {}
bond(const atom_index& connected_atom_index_, fl length_, bool rotatable_) : connected_atom_index(connected_atom_index_), length(length_), rotatable(rotatable_) {}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned version) {
ar & connected_atom_index;
ar & length;
ar & rotatable;
}
};

struct atom : public atom_base {
vec coords;
std::vector<bond> bonds;
atom() : coords(max_vec) {}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned version) {
ar & boost::serialization::base_object<atom_base>(*this);
ar & coords;
ar & bonds;
}
};

typedef std::vector<atom> atomv;

#endif
Loading

0 comments on commit 537c5ee

Please sign in to comment.