From 5ee6fbde578de94ace5a671b3fe0dddb68ea7b85 Mon Sep 17 00:00:00 2001
From: Pradipta Samanta <samanta@dkrz.de>
Date: Fri, 3 Jan 2025 09:31:02 +0100
Subject: [PATCH] changed the way local arrays are defined, it improves the
 performance

fixed a bug
---
 src/support/mo_math_utilities.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/support/mo_math_utilities.cpp b/src/support/mo_math_utilities.cpp
index a8ccce4..f82cd27 100644
--- a/src/support/mo_math_utilities.cpp
+++ b/src/support/mo_math_utilities.cpp
@@ -14,9 +14,8 @@ void tdma_solver_vec(double *a, double *b, double *c, double *d,
     int nrows = endidx - startidx;
     int ncols = elev - slev;
 
-    // Temporary arrays for c-prime and d-prime
-    std::vector<double> cp(nrows * ncols, 0.0);
-    std::vector<double> dp(nrows * ncols, 0.0);
+    double* cp = new double[nrows * ncols];
+    double* dp = new double[nrows * ncols];
 
     // Helper function to access 2D arrays stored as 1D
     auto idx = [&](int row, int col) { return col * nrows + row; };
@@ -68,6 +67,9 @@ void tdma_solver_vec(double *a, double *b, double *c, double *d,
         #pragma acc wait(acc_queue)
     }
 
+    // Free memory at the end
+    delete[] cp;
+    delete[] dp;
     // End timing
     auto end_time = std::chrono::high_resolution_clock::now();
     std::chrono::duration<double> elapsed_time = end_time - start_time;
-- 
GitLab