Commit 82289b37 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Merge branch 'optimize_code' into 'master'

Optimize code

See merge request giacomo.mulas/np_tmcode!8
parents 8406adaf 5ca9582e
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -27,9 +27,13 @@ This section describes the use of the pre-existing programs, once the binaries h

   > ./np_cluster

*NOTE:* The C++ version does not need to run a configuration program because all configuration operations are handled by the code at run-time.
*NOTE:* The *C++* version does not need to run a configuration program because all configuration operations are handled by the code at run-time.

5. Check the consistency between the output files (the default output file for the FORTRAN code is named `OCLU`, while the corresponding C++ output has the default name of `c_OCLU`).
5. Check the consistency between the output files (the default output file for the *FORTRAN* code is named `OCLU`, while the corresponding *C++* output has the default name of `c_OCLU`).

The default behaviour of `np_cluster` is to take the same input files as `edfb` and `clu` and to write the output in the current folder. If needed, different input and output paths can be given as command-line arguments:

   > ./np_cluster PATH_TO_DEDFB PATH_TO_DCLU OUTPUT_PATH

### sphere

@@ -48,9 +52,13 @@ This section describes the use of the pre-existing programs, once the binaries h

   > ./np_sphere

*NOTE:* The C++ version does not need to run a configuration program because all configuration operations are handled by the code at run-time.
*NOTE:* The *C++* version does not need to run a configuration program because all configuration operations are handled by the code at run-time.

5. Check the consistency between the output files (the default output file for the *FORTRAN* code is named `OSPH`, while the corresponding *C++* output has the default name of `c_OSPH`).

The default behaviour of `np_sphere` is to take the same input files as `edfb` and `sph` and to write the output in the current folder. If needed, different input and output paths can be given as command-line arguments:

5. Check the consistency between the output files (the default output file for the FORTRAN code is named `OSPH`, while the corresponding C++ output has the default name of `c_OSPH`).
   > ./np_sphere PATH_TO_DEDFB PATH_TO_DSPH OUTPUT_PATH

### trapping

+9 −6
Original line number Diff line number Diff line
# Folder instructions

This directory contains the material to build the project documentation with `doxygen`.
This directory contains the material to build the project documentation with *doxygen*.

## Instructions

The project documentation is managed by `doxygen`, a documentation generator that is able to extract documents directly from properly formatted comment sections of the source code. To build a local instance of project documents, make sure that you have `doxygen` installed, then `cd` into the document source folder (the folder containing the `conf.dox` file, specifically `np_tmcode/doc/src`) and finally run:
```
doxygen conf.dox
```
The project documentation is managed by *doxygen*, a documentation generator that is able to extract documents directly from properly formatted comment sections of the source code. To build a local instance of project documents, make sure that you have *doxygen* installed, then `cd` into the document source folder (the folder containing the `conf.dox` file, specifically `np_tmcode/doc/src`) and finally run:

`doxygen` will automatically build the HTML structure to cover all the documented source code and it will additionally provide the fundamental structure to prepare a LaTeX formatted version of the documents. These two outputs will be placed, respectively, under the folders `np_tmcode/doc/build/html` and `np_tmcode/doc/build/latex`.
 No newline at end of file
> doxygen conf.dox

Alternatively, you can use `make` from the project `src` folder (named `np_tmcode/src`) and just issue:

> make docs

*doxygen* will automatically build the HTML structure to cover all the documented source code and it will additionally provide the fundamental structure to prepare a LaTeX formatted version of the documents. These two outputs will be placed, respectively, under the folders `np_tmcode/doc/build/html` and `np_tmcode/doc/build/latex`.
 No newline at end of file
+5 −5
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ The original code is contained in the folders named `cluster`, `sphere` and `tra

In all cases, build commands executed through `make` will output the object files and the linked binaries in the proper folders under the build directory.

## FORTRAN code setup and execution (requires `gfortran` and GNU `make`)
## *FORTRAN* code setup and execution (requires `gfortran` and GNU `make`)

1. cd to the `src` folder.
2. Run `make` as:
@@ -16,13 +16,13 @@ In all cases, build commands executed through `make` will output the object file
   > make

3. cd to the `build/sphere` folder.
4. Run `sph` following the instructions given in `build\README.md`
4. Run `sph` following the instructions given in `build/README.md`
5. cd to the `build/cluster` folder.
6. Run `clu` following the instructions given in `build\README.md`
6. Run `clu` following the instructions given in `build/README.md`

## C++ code setup and execution (requires `g++` and GNU `make`)
## *C++* code setup and execution (requires `g++` and GNU `make`)

1. Follow the FORTRAN code setup steps (this builds the C++ version too).
1. Follow the *FORTRAN* code setup steps (these build the *C++* version too).
2. cd to the `build/sphere` folder.
3. Run `np_sphere`:

+2 −29
Original line number Diff line number Diff line
@@ -330,12 +330,8 @@ C 1", arg =",ARG
      GO TO 490
 132  CONTINUE
      CALL CMS(AM)
      CALL SUMMAT(AM,CCSAM)
      PRINT *,"DEBUG: after CMS CCSAM =",CCSAM
      NDIT=2*NSPH*NLIM
      CALL LUCIN(AM,MXNDM,NDIT,JER)
      CALL SUMMAT(AM,CCSAM)
      PRINT *,"DEBUG: after LUCIN CCSAM =",CCSAM
      IF(JER.EQ.1)GO TO 495
      CALL ZTM(AM)

@@ -358,7 +354,6 @@ C
  158 WRITE(IW,6061)
  160 CS0=0.25D0*VK*VK*VK/DACOS(C0)
      CALL SCR0(VK,EXRI)
      PRINT *,"DEBUG: after SCR0 TFSAS =",TFSAS
      SQK=VK*VK*EXDC
      CALL APS(ZPV,LI,NSPH,IOG,RMI,REI,SQK,GAPS)
      CALL RABAS(INPOL,LI,NSPH,IOG,RMI,REI,TQSE,TQSPE,TQSS,TQSPS)
@@ -639,6 +634,7 @@ C
  482 IF(ISAM.LE.1)THSL=THSL+THSSTP
  484 PH=PH+PHSTP
  486 TH=TH+THSTP
      PRINT *,"INFO: done scale iteration ",JXI
  488 CONTINUE
      GO TO 500
  490 WRITE(IW,6550)JER,LCALC,ARG
@@ -650,6 +646,7 @@ C
      CLOSE(IW)
      CLOSE(IT)
      CLOSE(ITIN)
      PRINT *,"INFO: output written to OCLU."
      STOP
      END
      SUBROUTINE RABAS(INPOL,LI,NSPH,IOG,RMI,REI,TQSE,TQSPE,TQSS,TQSPS)
@@ -3504,28 +3501,4 @@ CCC DIMENSION AV(NDDMST*NDDMST)
 3    CDTP=CDTP+AV((J-1)*ISTEP+I)*AV(J+IR)
      RETURN
      END
      SUBROUTINE SUMMAT(AM,RSLT)
      DIMENSION AM(921600)
      COMPLEX*16 AM,CC0,RSLT
      CC0=(0.0D0,0.0D0)
      RSLT=CC0
      DO 4 I=1,921600
 4    RSLT=RSLT+AM(I)
      RETURN
      END
      SUBROUTINE LOGMAT(AM)
      DIMENSION AM(960,960)
      COMPLEX*16 AM
      IL=36
      OPEN(IL,FILE="matrix.log",STATUS="UNKNOWN")
      DO 5 I=1,960
      DO 6 J=1,960
      WRITE(IL,9901)I,J,DREAL(AM(I,J))
 6    WRITE(IL,9902)I,J,DIMAG(AM(I,J))
 5    CONTINUE
      CLOSE(IL)
 9901 FORMAT("R:",1I3,",",1I3,",",1D15.7)
 9902 FORMAT("I:",1I3,",",1I3,",",1D15.7)
      RETURN
      END
CCC
+934 −934
Original line number Diff line number Diff line
@@ -248,7 +248,7 @@ void cluster(string config_file, string data_file, string output_path) {
	fprintf(output, " \n");
      }
      for (int jxi488 = 1; jxi488 <= nxi; jxi488++) {
				printf("INFO: running scale iteration...\n");
	printf("INFO: running scale iteration %d...", jxi488);
	int jaw = 1;
	fprintf(output, "========== JXI =%3d ====================\n", jxi488);
	double xi = sconf->scale_vec[jxi488 - 1];
@@ -298,15 +298,15 @@ void cluster(string config_file, string data_file, string output_path) {
	  }
	  if (jer != 0) break;
	} // i132 loop
				printf("INFO: initializing matrix...");
	//printf("INFO: initializing matrix...");
	cms(am, c1, c1ao, c4, c6);
				printf(" done.\n");
	//printf(" done.\n");
	//ccsam = summat(am, 960, 960);
	//printf("DEBUG: after CMS CCSAM = (%lE,%lE)\n", ccsam.real(), ccsam.imag());
	int ndit = 2 * nsph * c4->nlim;
				printf("INFO: inverting matrix...");
	//printf("INFO: inverting matrix...");
	lucin(am, mxndm, ndit, jer);
				printf(" done.\n");
	//printf(" done.\n");
	//ccsam = summat(am, 960, 960);
	//printf("DEBUG: after LUCIN CCSAM = (%lE,%lE)\n", ccsam.real(), ccsam.imag());
	if (jer != 0) break; // jxi488 loop: goes to memory clean
@@ -334,7 +334,7 @@ void cluster(string config_file, string data_file, string output_path) {
	      }
	      ttms_file.close();
	    } else { // Could not open TM file. Should never occur.
							printf("ERROR: failed to open TTMS file.\n");
	      printf("\nERROR: failed to open TTMS file.\n");
	      break;
	    }
	  }
@@ -881,11 +881,11 @@ void cluster(string config_file, string data_file, string output_path) {
	  } // jph484 loop
	  th += thstp;
	} // jth486 loop
				printf("INFO: done scale.\n");
	printf(" done.\n");
      } // jxi488 loop
      tppoan.close();
    } else { // In case TPPOAN could not be opened. Should never happen.
			printf("ERROR: failed to open TPPOAN file.\n");
      printf("\nERROR: failed to open TPPOAN file.\n");
    }
    fclose(output);
    // Clean memory
Loading