Commit 7002255c authored by Giacomo Mulas's avatar Giacomo Mulas
Browse files

Merge branch 'code_profiling' into 'master'

Enable Continuous Integration gitLab pipeline

See merge request giacomo.mulas/np_tmcode!10
parents c97527b5 37740c39
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+103 −0
Original line number Diff line number Diff line
# CI pipeline configuration

default:
  image: gcc

# Switch from branch pipelines to merge request pipelines when a merge request is created
workflow:
  rules:
    # Ensures next rules do not block triggered pipelines
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
      when: never
    # always run for merge requests
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    # never run a branch pipeline if there is an open merge request for that branch
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    # the only allowed branch pipeline is that on the default branch
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

stages:
   - build
   - run
   - test

building_stage:
   stage: build
   allow_failure: false
   #artifacts:
   #   paths:
   #      - build/cluster/*
   #      - build/sphere/*
   #      - build/trapping/*
   #   exclude:
   #      - ".git*"
   #      - ".git/**/*"
   #   expire_in: 2 hours
   script:
      # bash commands to be executed
      - pwd
      - hostname
      - echo $CI_COMMIT_SHA
      - echo $CI_COMMIT_BRANCH
      - cd src
      - echo "Running make (ONLY C++ CODE)"
      #- make conly

running_stage:
   stage: run
   allow_failure: false
   needs:
      - job: building_stage
   #artifacts:
   #   paths:
   #      - build/cluster/*
   #      - build/sphere/*
   #      - build/trapping/*
   #   exclude:
   #      - ".git*"
   #      - ".git/**/*"
   #   expire_in: 2 hours
   script:
      # bash commands to be executed
      - pwd
      - hostname
      - echo $CI_COMMIT_SHA
      - echo $CI_COMMIT_BRANCH
      - cd build/sphere
      - echo "Running np_sphere"
      #- chmod +x np_sphere
      #- ./np_sphere
      - cd ../cluster
      - echo "Running np_cluster"
      #- chmod +x np_cluster
      #- ./np_cluster
      
testing_stage:
   stage: test
   allow_failure: true
   needs:
      - job: running_stage
   #artifacts:
   #   paths:
   #      - build/cluster/pycompare.html
   #      - build/sphere/pycompare.html
   #   exclude:
   #      - ".git*"
   #      - ".git/**/*"
   #   expire_in: 2 hours
   script:
      # bash commands to be executed
      - pwd
      - hostname
      - echo $CI_COMMIT_SHA
      - echo $CI_COMMIT_BRANCH
      - cd build/sphere
      #- cp ../../test_data/sphere/OSPH .
      - echo "Comparing output of SPHERE"
      #- python3 ../../src/scripts/pycompare.py --ffile=OSPH --cfile=c_OSPH --html
      - cd ../cluster
      - echo "Comparing output of CLUSTER"
      #- cp ../../test_data/cluster/OCLU .
      #- python3 ../../src/scripts/pycompare.py --ffile=OCLU --cfile=c_OCLU --html
      
+1 −1
Original line number Diff line number Diff line
@@ -6,4 +6,4 @@ The aim of the project, funded by PNRR-CNS, is to refactor the original, very ol

The current implementation offers a set of elementary tests to check that the original FORTRAN code can be compiled and executed on a limited set of pre-defined input data. The functionality of this initial stage can be verified by cloning the gitLab repository on a local machine and building the binaries from the `src` folder.

*NOTE:* The building process requires a working installation of the GNU Compiler Collection (GCC), of the GNU FORTRAN compiler (gfortran) and of the GNU make builder.
*NOTE:* The building process requires a working installation of the GNU Compiler Collection (`gcc`), of the GNU FORTRAN compiler (`gfortran`) and of the GNU `make` builder.
+19 −4
Original line number Diff line number Diff line
@@ -24,10 +24,25 @@ using namespace std;
 */
void cluster(string config_file, string data_file, string output_path) {
  printf("INFO: making legacy configuration...");
  ScattererConfiguration *sconf = ScattererConfiguration::from_dedfb(config_file);
  sconf->write_formatted(output_path + "/c_OEDFB_clu");
  sconf->write_binary(output_path + "/c_TEDF_clu");
  GeometryConfiguration *gconf = GeometryConfiguration::from_legacy(data_file);
  ScattererConfiguration *sconf = NULL;
  try {
    sconf = ScattererConfiguration::from_dedfb(config_file);
  } catch(const OpenConfigurationFileException &ex) {
    printf("\nERROR: failed to open scatterer configuration file.\n");
    printf("FILE: %s\n", ex.what());
    exit(1);
  }
  sconf->write_formatted(output_path + "/c_OEDFB");
  sconf->write_binary(output_path + "/c_TEDF");
  GeometryConfiguration *gconf = NULL;
  try {
    gconf = GeometryConfiguration::from_legacy(data_file);
  } catch (const OpenConfigurationFileException &ex) {
    printf("\nERROR: failed to open geometry configuration file.\n");
    printf("FILE: %s\n", ex.what());
    if (sconf) delete sconf;
    exit(1);
  }
  printf(" done.\n");
  if (sconf->number_of_spheres == gconf->number_of_spheres) {
    // Shortcuts to variables stored in configuration objects
+264 −265
Original line number Diff line number Diff line
@@ -28,8 +28,7 @@ public:
   * \brief Exception message.
   */
  virtual const char* what() const throw() {
		std::string message = "Error opening configuration file: " + file_name;
		return message.c_str();
    return file_name.c_str();
  }
};

+1936 −1936
Original line number Diff line number Diff line
@@ -1038,8 +1038,8 @@ void cms(std::complex<double> **am, C1 *c1, C1_AddOns *c1ao, C4 *c4, C6 *c6) {

/*! \brief C++ porting of CRSM1
 *
 * \param vk: `double`
 * \param exri: `double`
 * \param vk: `double` Wave number.
 * \param exri: `double` External medium refractive index.
 * \param c1: `C1 *`
 * \param c1ao: `C1_AddOns *`
 * \param c4: `C4 *`
@@ -1167,10 +1167,10 @@ void crsm1(double vk, double exri, C1 *c1, C1_AddOns *c1ao, C4 *c4, C6 *c6) {

/*! \brief C++ porting of HJV
 *
 * \param exri: `double`
 * \param vk: `double`
 * \param jer: `int &`
 * \param lcalc: `int &`
 * \param exri: `double` External medium refractive index.
 * \param vk: `double` Wave number.
 * \param jer: `int &` Reference to error code flag.
 * \param lcalc: `int &` Reference to the highest order accounted for in calculation.
 * \param arg: `complex\<double\> &`
 * \param c1: `C1 *`
 * \param c1ao: `C1_AddOns *`
@@ -1360,8 +1360,8 @@ void lucin(std::complex<double> **am, const int nddmst, int n, int &ier) {

/*! \brief C++ porting of MEXTC
 *
 * \param vk: `double`
 * \param exri: `double`
 * \param vk: `double` Wave number.
 * \param exri: `double` External medium refractive index.
 * \param fsac: Matrix of complex
 * \param cextlr: `double **`
 * \param cext: `double **`
@@ -1419,8 +1419,8 @@ void mextc(double vk, double exri, std::complex<double> **fsac, double **cextlr,
/*! \brief C++ porting of PCROS
 *
 * This function is intended to evaluate the particle cross-section. QUESTIUON: correct?
 * \param vk: `double`
 * \param exri: `double`
 * \param vk: `double` Wave number.
 * \param exri: `double` External medium refractive index.
 * \param c1: `C1 *`
 * \param c1ao: `C1_AddOns *`
 * \param c4: `C4 *`
@@ -1486,9 +1486,9 @@ void pcros(double vk, double exri, C1 *c1, C1_AddOns *c1ao, C4 *c4) {

/*! \brief C++ porting of PCRSM0
 *
 * \param vk: `double`
 * \param exri: `double`
 * \param inpol: `int`
 * \param vk: `double` Wave number.
 * \param exri: `double` External medium refractive index.
 * \param inpol: `int` Incident field polarization type.
 * \param c1: `C1 *`
 * \param c1ao: `C1_AddOns *`
 * \param c4: `C4 *`
@@ -1561,14 +1561,14 @@ void pcrsm0(double vk, double exri, int inpol, C1 *c1, C1_AddOns *c1ao, C4 *c4)

/*! \brief C++ porting of POLAR
 *
 * \param x: `double`
 * \param y: `double`
 * \param z: `double`
 * \param r: `double &`
 * \param cth: `double &`
 * \param sth: `double &`
 * \param cph: `double &`
 * \param sph: `double &`
 * \param x: `double` X-axis Cartesian coordinate.
 * \param y: `double` Y-axis Cartesian coordinate.
 * \param z: `double` Z-axis Cartesian coordinate.
 * \param r: `double &` Reference to radial vector (output value).
 * \param cth: `double &` Reference to the cosine of the azimuth coordinate (output value).
 * \param sth: `double &` Reference to the sine of the azimuth coordinate (output value).
 * \param cph: `double &` Reference to the cosine of the elevation coordinate (output value).
 * \param sph: `double &` Reference to the sine of the elevation coordinate (output value).
 */
void polar(
	   double x, double y, double z, double &r, double &cth, double &sth,
@@ -1904,8 +1904,8 @@ void rftr(

/*! \brief C++ porting of SCR0
 *
 * \param vk: `double` QUESTION: definition?
 * \param exri: `double` External medium refractive index. QUESTION: correct?
 * \param vk: `double` Wave number
 * \param exri: `double` External medium refractive index.
 * \param c1: `C1 *` Pointer to a C1 instance.
 * \param c1ao: `C1_AddOns *` Pointer to C1_AddOns instance.
 * \param c3: `C3 *` Pointer to a C3 instance.
@@ -1959,9 +1959,9 @@ void scr0(double vk, double exri, C1 *c1, C1_AddOns *c1ao, C3 *c3, C4 * c4) {

/*! \brief C++ porting of SCR2
 *
 * \param vk: `double` QUESTION: definition?
 * \param vk: `double` Wave number.
 * \param vkarg: `double` QUESTION: definition?
 * \param exri: `double` External medium refractive index
 * \param exri: `double` External medium refractive index.
 * \param duk: `double *` QUESTION: definition?
 * \param c1: `C1 *` Pointer to a C1 instance.
 * \param c1ao: `C1_AddOns *` Pointer to C1_AddOns instance.
Loading