diff --git a/AMDiS/src/BasisFunction.cc b/AMDiS/src/BasisFunction.cc
index b71b642ca0b282096ef4d8d6126a998708915f25..20d5ad0909c5c2610e417ca5947e70dda2164ace 100644
--- a/AMDiS/src/BasisFunction.cc
+++ b/AMDiS/src/BasisFunction.cc
@@ -25,10 +25,10 @@ namespace AMDiS {
     nDOF = NEW DimVec<int>(dim, DEFAULT_VALUE, -1);
     dow = Global::getGeo(WORLD);
 
-    grdTmpVec1.resize(omp_get_num_procs());
-    grdTmpVec2.resize(omp_get_num_procs());
+    grdTmpVec1.resize(omp_get_overall_max_threads());
+    grdTmpVec2.resize(omp_get_overall_max_threads());
 
-    for (int i = 0; i < omp_get_num_procs(); i++) {
+    for (int i = 0; i < omp_get_overall_max_threads(); i++) {
       grdTmpVec1[i] = NEW DimVec<double>(dim, DEFAULT_VALUE, 0.0);
       grdTmpVec2[i] = NEW DimVec<double>(dim, DEFAULT_VALUE, 0.0);
     }
diff --git a/AMDiS/src/BoundaryManager.cc b/AMDiS/src/BoundaryManager.cc
index 416c08de60120c3ab275ea657b2aacd85ee5ea8b..091c39325ab07de1656b267906adec763c45165f 100644
--- a/AMDiS/src/BoundaryManager.cc
+++ b/AMDiS/src/BoundaryManager.cc
@@ -11,7 +11,7 @@ namespace AMDiS {
 
   BoundaryManager::BoundaryManager(const FiniteElemSpace *feSpace)
   {
-    localBounds.resize(omp_get_num_procs());
+    localBounds.resize(omp_get_overall_max_threads());
     allocatedMemoryLocalBounds = feSpace->getBasisFcts()->getNumber();
     for (int i = 0; i < static_cast<int>(localBounds.size()); i++) {
       localBounds[i] = GET_MEMORY(BoundaryType, allocatedMemoryLocalBounds);
diff --git a/AMDiS/src/DOFVector.hh b/AMDiS/src/DOFVector.hh
index 068759d7bf2b3767337e9b91c9c31456b5f43c29..9abc9918404d199e7dbe306d8b922e3643651d0c 100644
--- a/AMDiS/src/DOFVector.hh
+++ b/AMDiS/src/DOFVector.hh
@@ -31,11 +31,11 @@ namespace AMDiS {
     nBasFcts = feSpace->getBasisFcts()->getNumber();
     int dim = feSpace->getMesh()->getDim();
 
-    localIndices.resize(omp_get_num_procs());
-    grdPhis.resize(omp_get_num_procs());
-    D2Phis.resize(omp_get_num_procs());
+    localIndices.resize(omp_get_overall_max_threads());
+    grdPhis.resize(omp_get_overall_max_threads());
+    D2Phis.resize(omp_get_overall_max_threads());
 
-    for (int i = 0; i < omp_get_num_procs(); i++) {
+    for (int i = 0; i < omp_get_overall_max_threads(); i++) {
       localIndices[i] = GET_MEMORY(DegreeOfFreedom, this->nBasFcts);      
       grdPhis[i] = NEW DimVec<double>(dim, DEFAULT_VALUE, 0.0);
       D2Phis[i] = NEW DimMat<double>(dim, NO_INIT);
diff --git a/AMDiS/src/DirichletBC.cc b/AMDiS/src/DirichletBC.cc
index cd67b70d86a3d70b016b0dcfc2772c0ad995ec3c..35421b312ae89571591c8852856941e23e9c2243 100644
--- a/AMDiS/src/DirichletBC.cc
+++ b/AMDiS/src/DirichletBC.cc
@@ -14,7 +14,7 @@ namespace AMDiS {
       f(fct), 
       dofVec(NULL)
   {
-    worldCoords.resize(omp_get_num_procs());
+    worldCoords.resize(omp_get_overall_max_threads());
   };
 
   DirichletBC::DirichletBC(BoundaryType type,
@@ -23,7 +23,7 @@ namespace AMDiS {
       f(NULL), 
       dofVec(vec)
   {
-    worldCoords.resize(omp_get_num_procs());
+    worldCoords.resize(omp_get_overall_max_threads());
   }
 
   void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix,
diff --git a/AMDiS/src/OpenMP.h b/AMDiS/src/OpenMP.h
index 37d351d235e904bda5ba4d8857a437da407e8d76..799c157d38a289b161b21842738a7a7cfa852d49 100644
--- a/AMDiS/src/OpenMP.h
+++ b/AMDiS/src/OpenMP.h
@@ -3,10 +3,15 @@
 
 #ifdef _OPENMP
 
+#include <algorithm>
 #include <omp.h>
 
 const bool amdisHaveOpenMP = true;
 
+inline int omp_get_overall_max_threads() {
+  return std::max(omp_get_max_threads(), omp_get_num_threads());
+}
+
 #else
 
 const bool amdisHaveOpenMP = false;
@@ -27,6 +32,10 @@ inline int omp_get_thread_num() {
   return 0;
 }
 
+inline int omp_get_overall_max_threads() {
+  return 1;
+}
+
 #endif
 
 #endif
diff --git a/AMDiS/src/Operator.cc b/AMDiS/src/Operator.cc
index cedec77092e919c4b869cc617cd383efb1937960..676451a4bc21c5b03a7936f29f59692a51ebb8d2 100644
--- a/AMDiS/src/Operator.cc
+++ b/AMDiS/src/Operator.cc
@@ -180,7 +180,7 @@ namespace AMDiS {
       uhOld(NULL),
       optimized(true)
   {
-    int maxThreads = omp_get_num_procs();
+    int maxThreads = omp_get_overall_max_threads();
 
     assembler.resize(maxThreads);
     secondOrder.resize(maxThreads);
diff --git a/AMDiS/src/Operator.hh b/AMDiS/src/Operator.hh
index d0508f8c8fa11bfeeed02cc79aac4ee215eb75db..ee745836f8c78f7a98a761eed79ca661bf04d887 100644
--- a/AMDiS/src/Operator.hh
+++ b/AMDiS/src/Operator.hh
@@ -6,7 +6,7 @@ namespace AMDiS {
     secondOrder[0].push_back(term);
     term->operat = this;
 
-    for (int i = 1; i < omp_get_num_procs(); i++) {
+    for (int i = 1; i < omp_get_overall_max_threads(); i++) {
       T *newTerm = NEW T(static_cast<const T>(*term));
       secondOrder[i].push_back(newTerm);
     }
@@ -23,7 +23,7 @@ namespace AMDiS {
     }
     term->operat = this;
 
-    for (int i = 1; i < omp_get_num_procs(); i++) {
+    for (int i = 1; i < omp_get_overall_max_threads(); i++) {
       T *newTerm = NEW T(static_cast<const T>(*term));
       if (type == GRD_PSI) {
 	firstOrderGrdPsi[i].push_back(newTerm);
@@ -39,7 +39,7 @@ namespace AMDiS {
     zeroOrder[0].push_back(term);
     term->operat = this;
 
-    for (int i = 1; i < omp_get_num_procs(); i++) {
+    for (int i = 1; i < omp_get_overall_max_threads(); i++) {
       T *newTerm = NEW T(static_cast<const T>(*term));
       zeroOrder[i].push_back(newTerm);
     }
diff --git a/AMDiS/src/ResidualParallelEstimator.cc b/AMDiS/src/ResidualParallelEstimator.cc
index 5176a789afa48ae03c6bd4a6259156c202673a01..6e18ed620d69a3beb1ef66bfda5b49e06ff0eb1c 100644
--- a/AMDiS/src/ResidualParallelEstimator.cc
+++ b/AMDiS/src/ResidualParallelEstimator.cc
@@ -14,9 +14,9 @@ namespace AMDiS {
     GET_PARAMETER(0, name + "->C3", "%f", &C3);
     C3 = C3 > 1.e-25 ? sqr(C3) : 0.0;
 
-    seqEstimators_.resize(omp_get_num_procs());
+    seqEstimators_.resize(omp_get_overall_max_threads());
 
-    for (int i = 0; i < omp_get_num_procs(); i++) {
+    for (int i = 0; i < omp_get_overall_max_threads(); i++) {
       seqEstimators_[i] = NEW ResidualEstimator(name, r);
     }
   }
diff --git a/AMDiS/src/SecondOrderAssembler.cc b/AMDiS/src/SecondOrderAssembler.cc
index 181ef0ca37041b5029299966c0b55a62fdf972c9..90e0329b2c41dd1398de42848187088fc4cb9076 100644
--- a/AMDiS/src/SecondOrderAssembler.cc
+++ b/AMDiS/src/SecondOrderAssembler.cc
@@ -88,8 +88,8 @@ namespace AMDiS {
     q11 = Q11PsiPhi::provideQ11PsiPhi(owner->getRowFESpace()->getBasisFcts(), 
 				      owner->getColFESpace()->getBasisFcts(), 
 				      quadrature);
-    tmpLALt.resize(omp_get_num_procs());
-    for (int i = 0; i < omp_get_num_procs(); i++) {
+    tmpLALt.resize(omp_get_overall_max_threads());
+    for (int i = 0; i < omp_get_overall_max_threads(); i++) {
       tmpLALt[i] = NEW DimMat<double>*;
       *(tmpLALt[i]) = NEW DimMat<double>(dim, NO_INIT);
     }
@@ -163,7 +163,7 @@ namespace AMDiS {
   Quad2::Quad2(Operator *op, Assembler *assembler, Quadrature *quad) 
     : SecondOrderAssembler(op, assembler, quad, true)
   {
-    tmpLALt.resize(omp_get_num_procs());
+    tmpLALt.resize(omp_get_overall_max_threads());
   }
 
   Quad2::~Quad2()
diff --git a/AMDiS/src/SubAssembler.cc b/AMDiS/src/SubAssembler.cc
index 3f8e7fd77f69a198bd5ede0aef532fb75396d7c4..cc9048e34e9726bffeeb103117ae67b615b5ae5c 100644
--- a/AMDiS/src/SubAssembler.cc
+++ b/AMDiS/src/SubAssembler.cc
@@ -34,7 +34,7 @@ namespace AMDiS {
     nRow = psi->getNumber();
     nCol = phi->getNumber();
 
-    int maxThreads = omp_get_num_procs();
+    int maxThreads = omp_get_overall_max_threads();
     terms.resize(maxThreads);
 
     switch (order) {
diff --git a/AMDiS/src/TraverseParallel.cc b/AMDiS/src/TraverseParallel.cc
index 60a627dafa9ae5abc24f3883c7a2a9f3cf316dd1..92afbb17a97d6f291ee66dc79d9a7d98a088857b 100644
--- a/AMDiS/src/TraverseParallel.cc
+++ b/AMDiS/src/TraverseParallel.cc
@@ -9,7 +9,7 @@ namespace AMDiS {
   TraverseParallelStack::TraverseParallelStack(int nThreads)
   {
     if (nThreads == 0) {
-      nThreads_ = omp_get_num_procs();
+      nThreads_ = omp_get_overall_max_threads();
     } else {
       nThreads_ = nThreads;
     }
diff --git a/AMDiS/src/ZeroOrderAssembler.cc b/AMDiS/src/ZeroOrderAssembler.cc
index 5e2b153591db6a054c0b8c00581042e7cff6024e..f51fe81e0332fa5fcbc5add449752a97a2135468 100644
--- a/AMDiS/src/ZeroOrderAssembler.cc
+++ b/AMDiS/src/ZeroOrderAssembler.cc
@@ -227,12 +227,12 @@ namespace AMDiS {
   FastQuadZOA::FastQuadZOA(Operator *op, Assembler *assembler, Quadrature *quad)
     : ZeroOrderAssembler(op, assembler, quad, true)
   {
-    cPtrs.resize(omp_get_num_procs());
+    cPtrs.resize(omp_get_overall_max_threads());
   }
 
   FastQuadZOA::~FastQuadZOA()
   {
-    for (int i = 0; i < omp_get_num_procs(); i++) {
+    for (int i = 0; i < omp_get_overall_max_threads(); i++) {
       FREE_MEMORY(cPtrs[i], double, quadrature->getNumPoints());
     }
   }