Commit 108d96b6 authored by Giacomo Mulas's avatar Giacomo Mulas
Browse files

Merge branch 'trapping_debug' into 'master'

Trapping debug

See merge request giacomo.mulas/np_tmcode!13
parents f8e84eb6 1afc31f6
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -62,6 +62,16 @@ The default behaviour of `np_sphere` is to take the same input files as `edfb` a

### trapping

The execution of trapping programs requires at least one of the previous programs to have produced a complete output set. The working assumption is that the `frfme` program is a pre-requisite to `lffft`.
The execution of trapping programs requires at least one of the previous programs to have produced a complete output set. A light-weight trapping calculation has been configured with input and legacy output files stored in the `../../test_data/trapping/` folder. Since the FORTRAN code assumes the input and output to be defined within the program, it is not yet possible to run the *FORTRAN* version on this case, unless the source code is modified accordingly. Conversely, the *C++* version can be executed without the need to modfy and re-compile the code. The work-flow to test trapping is described below.

*TODO:* Define a common format for binary I/O operations on the TTMS file.
1. cd to the `build/sphere` folder.
2. run `np_sphere` with arguments to take input from the trapping tast and write output in the trapping folder:

   > ./np_sphere ../../test_data/trapping/DEDFB ../../test_data/trapping/DSPH ../trapping

3. cd to the trapping folder.
4. run `np_trapping`

   > ./np_trapping ../../test_data/trapping/DFRFME ../../test_data/trapping/DLFFT .

5. Check the consistency between `np_trapping` output files (`c_out66.txt` and `c_out67.txt`) and the legacy *FORTRAN* output for this case (the files named, respectively, `fort.66` and `fort.67` in the `test_data/trapping/` folder).
+2 −3
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ void ffrt(

  ctqce = new complex<double>[3]();
  ctqcs = new complex<double>[3]();
  for (int l60 = 1; l60 < cil->le; l60++) {
  for (int l60 = 1; l60 <= cil->le; l60++) {
    int lpo = l60 + 1;
    int il = l60 * lpo;
    int ltpo = l60 + lpo;
@@ -438,7 +438,6 @@ void wamff(
    un[0] = -sph;
    un[1] = cph;
    un[2] = 0.0;
    // Would call PWMALP(W,UP,UN,YLM,LM)
    pwmalp(w, up, un, ylm, lm);
    double apfa = sth * apfafa;
    if (spd > 0.0) {
@@ -446,7 +445,7 @@ void wamff(
      double cthl = sqrt(1.0 - sthl * sthl);
      double arg = spd * (z - (r / rir) * cthl);
      cfam = (tra * std::exp(-apfa * apfa) / sqrt(cthl)) * std::exp(uim * arg);
      if (lmode == 0) { // CHECK: Computed GO TO, not sure what happens with LMODE = 0
      if (lmode == 0) {
	if (sth == 0.0) { // label 45
	  ftc1 = ftcn;
	  ftc2 = ftcn;
+11 −4
Original line number Diff line number Diff line
@@ -294,10 +294,17 @@ void sphere(string config_file, string data_file, string output_path) {
	    ttms.write(reinterpret_cast<char *>(&vk), sizeof(double));
	    ttms.write(reinterpret_cast<char *>(&exri), sizeof(double));
	    for (int lmi = 0; lmi < gconf->l_max; lmi++) {
	      complex<double> element1 = -1.0 / c1->rmi[0][lmi];
	      complex<double> element2 = -1.0 / c1->rei[0][lmi];
	      ttms.write(reinterpret_cast<char *>(&element1), sizeof(complex<double>));
	      ttms.write(reinterpret_cast<char *>(&element2), sizeof(complex<double>));
	      complex<double> element1 = -1.0 / c1->rmi[lmi][0];
	      complex<double> element2 = -1.0 / c1->rei[lmi][0];
	      double vreal, vimag;
	      vreal = element1.real();
	      vimag = element1.imag();
	      ttms.write(reinterpret_cast<char *>(&vreal), sizeof(double));
	      ttms.write(reinterpret_cast<char *>(&vimag), sizeof(double));
	      vreal = element2.real();
	      vimag = element2.imag();
	      ttms.write(reinterpret_cast<char *>(&vreal), sizeof(double));
	      ttms.write(reinterpret_cast<char *>(&vimag), sizeof(double));
	    }
	    ttms.write(reinterpret_cast<char *>(&(sconf->radii_of_spheres[0])), sizeof(double));
	    ttms.close();
+80 −81
Original line number Diff line number Diff line
@@ -217,7 +217,6 @@ void lffft(string data_file, string output_path) {
	  // label 155
	  if (!goto160) {
	    if (jss != 1) {
	      // Would open the ITT file.
	      string tlfft_name = output_path + "/c_TLFFT";
	      tlfft.open(tlfft_name.c_str(), ios::out | ios::binary);
	      if (tlfft.is_open()) {
@@ -275,6 +274,7 @@ void lffft(string data_file, string output_path) {
		      ws[ie] = wsl[iel];
		    } // i175 loop
		  }
		} // i loop
		// label 180
		if (is != 2222) {
		  if (is != 1111) {
@@ -371,7 +371,6 @@ void lffft(string data_file, string output_path) {
		  delete[] ffte;
		  delete[] ffts;
		}
		} // i loop
	      } // ix475 loop
	    } // iy475 loop
	  } // iz475 loop
+8 −0
Original line number Diff line number Diff line
    1  0
 1.765736D00  3.0D8   1.000000D00  0     1  0  3
 785.0000000D-09
    1
  1   0.200000D-06
 1.000000D00
 (2.89D00,   0.03D00)
0
Loading