From 31c6e0a301deaed32fb97a9b704bd10bb78a4168 Mon Sep 17 00:00:00 2001
From: carlocamilloni <carlo.camilloni@gmail.com>
Date: Thu, 30 Nov 2017 09:21:06 +0100
Subject: [PATCH] isdb: removed warnings

---
 src/isdb/CS2Backbone.cpp       | 28 ++++++++++++++--------------
 src/isdb/Jcoupling.cpp         |  2 +-
 src/isdb/Metainference.cpp     |  2 +-
 src/isdb/MetainferenceBase.cpp |  2 +-
 src/isdb/MetainferenceBase.h   |  8 ++++----
 src/isdb/RDC.cpp               |  5 ++---
 6 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/src/isdb/CS2Backbone.cpp b/src/isdb/CS2Backbone.cpp
index f49730a96..2970b6ff3 100644
--- a/src/isdb/CS2Backbone.cpp
+++ b/src/isdb/CS2Backbone.cpp
@@ -771,9 +771,9 @@ void CS2Backbone::read_cs(const string &file, const string &nucl) {
     string tok;
     tok = *iter; ++iter;
     if(tok[0]=='#') { ++iter; continue;}
-    unsigned p = atoi(tok.c_str());
+    int p = atoi(tok.c_str());
     p = p - 1;
-    const unsigned seg = frag_segment(p);
+    const int seg = frag_segment(p);
     p = frag_relitive_index(p,seg);
     if(oldp==-1) oldp=p;
     if(oldseg==-1) oldseg=seg;
@@ -1160,7 +1160,7 @@ void CS2Backbone::calculate()
       }
     }
     #pragma omp critical
-    if(camshift) for(int i=0; i<getPositions().size(); i++) setAtomsDerivatives(getPntrToValue(),i,omp_deriv[i]);
+    if(camshift) for(unsigned i=0; i<getPositions().size(); i++) setAtomsDerivatives(getPntrToValue(),i,omp_deriv[i]);
   }
 
   if(getDoScore()) {
@@ -2145,7 +2145,7 @@ void CS2Backbone::debug_report() {
   printf("\t -------------------------------\n");
   printf("\t Number of segments: %u\n", static_cast<unsigned>(atom.size()));
   printf("\t Segments size:      ");
-  for(unsigned i=0; i<atom.size(); i++) printf("%u ", static_cast<unsigned>(atom[i].size())); printf("\n");
+  for(unsigned i=0; i<atom.size(); i++) {printf("%u ", static_cast<unsigned>(atom[i].size()));} printf("\n");
   printf("\t%8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s \n",
          "Seg","N","AA","Prev","Curr","Next","SC","XD1","XD2","Phi","Psi","Chi1");
   for(unsigned i=0; i<atom.size(); i++) {
@@ -2163,15 +2163,15 @@ void CS2Backbone::debug_report() {
              (unsigned)atom[i][j].psi.size(),
              (unsigned)atom[i][j].chi1.size());
 
-      for(unsigned k=0; k<atom[i][j].prev.size(); k++) printf("%8i ", atom[i][j].prev[k]); printf("\n");
-      for(unsigned k=0; k<atom[i][j].curr.size(); k++) printf("%8i ", atom[i][j].curr[k]); printf("\n");
-      for(unsigned k=0; k<atom[i][j].next.size(); k++) printf("%8i ", atom[i][j].next[k]); printf("\n");
-      for(unsigned k=0; k<atom[i][j].side_chain.size(); k++) printf("%8i ", atom[i][j].side_chain[k]); printf("\n");
-      for(unsigned k=0; k<atom[i][j].xd1.size(); k++) printf("%8i ", atom[i][j].xd1[k]); printf("\n");
-      for(unsigned k=0; k<atom[i][j].xd2.size(); k++) printf("%8i ", atom[i][j].xd2[k]); printf("\n");
-      for(unsigned k=0; k<atom[i][j].phi.size(); k++) printf("%8i ", atom[i][j].phi[k]); printf("\n");
-      for(unsigned k=0; k<atom[i][j].psi.size(); k++) printf("%8i ", atom[i][j].psi[k]); printf("\n");
-      for(unsigned k=0; k<atom[i][j].chi1.size(); k++) printf("%8i ", atom[i][j].chi1[k]); printf("\n");
+      for(unsigned k=0; k<atom[i][j].prev.size(); k++) { printf("%8i ", atom[i][j].prev[k]);} printf("\n");
+      for(unsigned k=0; k<atom[i][j].curr.size(); k++) { printf("%8i ", atom[i][j].curr[k]);} printf("\n");
+      for(unsigned k=0; k<atom[i][j].next.size(); k++) { printf("%8i ", atom[i][j].next[k]);} printf("\n");
+      for(unsigned k=0; k<atom[i][j].side_chain.size(); k++) { printf("%8i ", atom[i][j].side_chain[k]);} printf("\n");
+      for(unsigned k=0; k<atom[i][j].xd1.size(); k++) { printf("%8i ", atom[i][j].xd1[k]);} printf("\n");
+      for(unsigned k=0; k<atom[i][j].xd2.size(); k++) { printf("%8i ", atom[i][j].xd2[k]);} printf("\n");
+      for(unsigned k=0; k<atom[i][j].phi.size(); k++) { printf("%8i ", atom[i][j].phi[k]);} printf("\n");
+      for(unsigned k=0; k<atom[i][j].psi.size(); k++) { printf("%8i ", atom[i][j].psi[k]);} printf("\n");
+      for(unsigned k=0; k<atom[i][j].chi1.size(); k++) { printf("%8i ", atom[i][j].chi1[k]);} printf("\n");
 
     }
   }
@@ -2182,7 +2182,7 @@ void CS2Backbone::debug_report() {
   printf("\t%8s %8s %8s %8s\n", "Num","Type","RType","N.atoms");
   for(unsigned i=0; i<ringInfo.size(); i++) {
     printf("\t%8u %8u %8u \n",i+1,ringInfo[i].rtype,ringInfo[i].numAtoms);
-    for(unsigned j=0; j<ringInfo[i].numAtoms; j++) printf("%8u ", ringInfo[i].atom[j]); printf("\n");
+    for(unsigned j=0; j<ringInfo[i].numAtoms; j++) {printf("%8u ", ringInfo[i].atom[j]);} printf("\n");
   }
 }
 
diff --git a/src/isdb/Jcoupling.cpp b/src/isdb/Jcoupling.cpp
index da0df77d2..bb0651e5f 100644
--- a/src/isdb/Jcoupling.cpp
+++ b/src/isdb/Jcoupling.cpp
@@ -169,7 +169,7 @@ JCoupling::JCoupling(const ActionOptions&ao):
   ncoupl_ = atoms.size()/6;
 
   // Parse J-Coupling type, this will determine the Karplus parameters
-  unsigned jtype_;
+  unsigned jtype_ = CUSTOM;
   string string_type;
   parse("TYPE", string_type);
   if(string_type == "HAN") {
diff --git a/src/isdb/Metainference.cpp b/src/isdb/Metainference.cpp
index f9ea30eff..5bdf32c13 100644
--- a/src/isdb/Metainference.cpp
+++ b/src/isdb/Metainference.cpp
@@ -1085,7 +1085,7 @@ void Metainference::doMonteCarlo(const vector<double> &mean_)
     }
 
     // calculate new energy
-    double new_energy;
+    double new_energy = 0.;
     switch(noise_type_) {
     case GAUSS:
       new_energy = getEnergyGJ(mean_,new_sigma,scale_,offset_);
diff --git a/src/isdb/MetainferenceBase.cpp b/src/isdb/MetainferenceBase.cpp
index 36f2493ff..c192a199c 100644
--- a/src/isdb/MetainferenceBase.cpp
+++ b/src/isdb/MetainferenceBase.cpp
@@ -889,7 +889,7 @@ void MetainferenceBase::doMonteCarlo(const vector<double> &mean_)
     }
 
     // calculate new energy
-    double new_energy;
+    double new_energy=0.;
     switch(noise_type_) {
     case GAUSS:
       new_energy = getEnergyGJ(mean_,new_sigma,scale_,offset_);
diff --git a/src/isdb/MetainferenceBase.h b/src/isdb/MetainferenceBase.h
index f5b3f686f..5fc1affa8 100644
--- a/src/isdb/MetainferenceBase.h
+++ b/src/isdb/MetainferenceBase.h
@@ -277,7 +277,7 @@ void MetainferenceBase::setDerivatives() {
 
   // Resize all derivative arrays
   forces.resize( nder ); forcesToApply.resize( nder );
-  for(unsigned i=0; i<getNumberOfComponents(); ++i) getPntrToComponent(i)->resizeDerivatives(nder);
+  for(int i=0; i<getNumberOfComponents(); ++i) getPntrToComponent(i)->resizeDerivatives(nder);
 }
 
 inline
@@ -312,11 +312,11 @@ void MetainferenceBase::calculateNumericalDerivatives( ActionWithValue* a ) {
   }
   if( getNumberOfAtoms()>0 ) {
     Matrix<double> save_derivatives( getNumberOfComponents(), getNumberOfArguments() );
-    for(unsigned j=0; j<getNumberOfComponents(); ++j) {
+    for(int j=0; j<getNumberOfComponents(); ++j) {
       for(unsigned i=0; i<getNumberOfArguments(); ++i) if(getPntrToComponent(j)->hasDerivatives()) save_derivatives(j,i)=getPntrToComponent(j)->getDerivative(i);
     }
     calculateAtomicNumericalDerivatives( a, getNumberOfArguments() );
-    for(unsigned j=0; j<getNumberOfComponents(); ++j) {
+    for(int j=0; j<getNumberOfComponents(); ++j) {
       for(unsigned i=0; i<getNumberOfArguments(); ++i) if(getPntrToComponent(j)->hasDerivatives()) getPntrToComponent(j)->addDerivative( i, save_derivatives(j,i) );
     }
   }
@@ -325,7 +325,7 @@ void MetainferenceBase::calculateNumericalDerivatives( ActionWithValue* a ) {
 inline
 void MetainferenceBase::apply() {
   bool wasforced=false; forcesToApply.assign(forcesToApply.size(),0.0);
-  for(unsigned i=0; i<getNumberOfComponents(); ++i) {
+  for(int i=0; i<getNumberOfComponents(); ++i) {
     if( getPntrToComponent(i)->applyForce( forces ) ) {
       wasforced=true;
       for(unsigned i=0; i<forces.size(); ++i) forcesToApply[i]+=forces[i];
diff --git a/src/isdb/RDC.cpp b/src/isdb/RDC.cpp
index 8827c8d38..c871c3800 100644
--- a/src/isdb/RDC.cpp
+++ b/src/isdb/RDC.cpp
@@ -228,10 +228,9 @@ RDC::RDC(const ActionOptions&ao):
 
   const double RDCConst = 0.3356806;
   const double PCSConst = 1.0;
-  bool rdc = true;
 
-  if( getName().find("RDC")!=std::string::npos) { Const *= RDCConst; rdc=true;}
-  else if( getName().find("PCS")!=std::string::npos) { Const *= PCSConst; rdc=false;}
+  if( getName().find("RDC")!=std::string::npos) { Const *= RDCConst; }
+  else if( getName().find("PCS")!=std::string::npos) { Const *= PCSConst; }
 
   // Read in the atoms
   vector<AtomNumber> t, atoms;
-- 
GitLab