Commit 1f21b6a0 authored by Mulas, Giacomo's avatar Mulas, Giacomo
Browse files

Correct some bugs in parallelised scr2

parent f1b1bf1a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2109,6 +2109,7 @@ void scr2(
  double cfsq = 4.0 / (pi4sq * ccs * ccs);
  cph = uim * exri * vkarg;
  int ls = (c4->li < c4->le) ? c4->li : c4->le;
  int kmax = (ls+1)*(ls+1)-1;
  c3->tsas[0][0] = cc0;
  c3->tsas[1][0] = cc0;
  c3->tsas[0][1] = cc0;
@@ -2119,7 +2120,7 @@ void scr2(
#ifdef USE_NVTX
  nvtxRangePush("scr2 outer loop 1");
#endif
#pragma omp parallel for
  //#pragma omp parallel for
  for (int i14 = 1; i14 <= c4->nsph; i14++) {
    int i = i14 - 1;
    int iogi = c1->iog[i14 - 1];
@@ -2137,7 +2138,6 @@ void scr2(
      // but if it results im = 0, then we set l10 = l10-1 and im10 = 2*l10+1
      // furthermore if it results im10 > 2*l10+1, then we set
      // im10 = im10 -(2*l10+1) and l10 = l10+1 (there was a rounding error in a nearly exact root)
      int kmax = (ls+1)*(ls+1)-1;
#ifdef USE_NVTX
  nvtxRangePush("scr2 inner loop 1");
#endif
@@ -2190,7 +2190,7 @@ void scr2(
      c1->sas[i][1][1] = s22 * csam;
    }
    // label 12
    phas = cexp(cph * (duk[0] * c1->rxx[i] + duk[1] * c1->ryy[i] + duk[2] * c1->rzz[i]));
    dcomplex phas = cexp(cph * (duk[0] * c1->rxx[i] + duk[1] * c1->ryy[i] + duk[2] * c1->rzz[i]));
    c3->tsas[0][0] += (c1->sas[iogi - 1][0][0] * phas);
    c3->tsas[1][0] += (c1->sas[iogi - 1][1][0] * phas);
    c3->tsas[0][1] += (c1->sas[iogi - 1][0][1] * phas);
@@ -2211,7 +2211,7 @@ void scr2(
#ifdef USE_NVTX
  nvtxRangePush("scr2 inner loop 2");
#endif
#pragma omp target parallel for collapse(4)
#pragma omp target teams distribute parallel for simd collapse(4)
      for (int ipo1 = 1; ipo1 <=2; ipo1++) {
	for (int jpo1 = 1; jpo1 <= 2; jpo1++) {
	  // cc = dconjg(c1->sas[i24 - 1][jpo1 - 1][ipo1 - 1]);