Commit 13be8085 authored by Anne Gunn's avatar Anne Gunn
Browse files

T2345: Replace instances of NULL with nullptr

Per guidance from Axel, revert lib/kokkos and lib/colvars
to remove nullptr changes.
parent f1ef7d85
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

colvar::colvar()
{
  runave_os = nullptr;
  runave_os = NULL;

  prev_timestep = -1L;
  after_restart = false;
@@ -62,7 +62,7 @@ int colvar::init(std::string const &conf)
  get_keyval(conf, "name", this->name,
             (std::string("colvar")+cvm::to_str(cv->variables()->size())));

  if ((cvm::colvar_by_name(this->name) != nullptr) &&
  if ((cvm::colvar_by_name(this->name) != NULL) &&
      (cvm::colvar_by_name(this->name) != this)) {
    cvm::error("Error: this colvar cannot have the same name, \""+this->name+
                      "\", as another colvar.\n",
@@ -744,7 +744,7 @@ template<typename def_class_name> int colvar::init_components_type(std::string c
              : ".\n"));
    cvm::increase_depth();
    cvc *cvcp = new def_class_name(def_conf);
    if (cvcp != nullptr) {
    if (cvcp != NULL) {
      cvcs.push_back(cvcp);
      cvcp->check_keywords(def_conf, def_config_key);
      cvcp->config_key = def_config_key;
@@ -994,7 +994,7 @@ int colvar::parse_analysis(std::string const &conf)
      acf_type = acf_vel;
      enable(f_cv_fdiff_velocity);
      colvar *cv2 = cvm::colvar_by_name(acf_colvar_name);
      if (cv2 == nullptr) {
      if (cv2 == NULL) {
        return cvm::error("Error: collective variable \""+acf_colvar_name+
                          "\" is not defined at this time.\n", INPUT_ERROR);
      }
@@ -1215,14 +1215,14 @@ colvar::~colvar()
  for (std::vector<Lepton::CompiledExpression *>::iterator cei = value_evaluators.begin();
       cei != value_evaluators.end();
       ++cei) {
    if (*cei != nullptr) delete (*cei);
    if (*cei != NULL) delete (*cei);
  }
  value_evaluators.clear();

  for (std::vector<Lepton::CompiledExpression *>::iterator gei = gradient_evaluators.begin();
       gei != gradient_evaluators.end();
       ++gei) {
    if (*gei != nullptr) delete (*gei);
    if (*gei != NULL) delete (*gei);
  }
  gradient_evaluators.clear();
#endif
@@ -1972,7 +1972,7 @@ void const *colvar::get_cvc_param_ptr(std::string const &param_name)
  }
  cvm::error("Error: calling colvar::get_cvc_param() for a variable "
             "with more than one component.\n", COLVARS_NOT_IMPLEMENTED);
  return nullptr;
  return NULL;
}


@@ -1983,7 +1983,7 @@ colvarvalue const *colvar::get_cvc_param_grad(std::string const &param_name)
  }
  cvm::error("Error: calling colvar::get_cvc_param_grad() for a variable "
             "with more than one component.\n", COLVARS_NOT_IMPLEMENTED);
  return nullptr;
  return NULL;
}


@@ -2422,7 +2422,7 @@ int colvar::calc_acf()
  // the pointer to each vector is changed at every step

  colvar const *cfcv = cvm::colvar_by_name(acf_colvar_name);
  if (cfcv == nullptr) {
  if (cfcv == NULL) {
    return cvm::error("Error: collective variable \""+acf_colvar_name+
                      "\" is not defined at this time.\n", INPUT_ERROR);
  }
@@ -2660,7 +2660,7 @@ int colvar::calc_runave()

      if ((*x_history_p).size() >= runave_length-1) {

        if (runave_os == nullptr) {
        if (runave_os == NULL) {
          if (runave_outfile.size() == 0) {
            runave_outfile = std::string(cvm::output_prefix()+"."+
                                         this->name+".runave.traj");
+4 −4
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ cvm::atom_group::~atom_group()

  if (fitting_group) {
    delete fitting_group;
    fitting_group = nullptr;
    fitting_group = NULL;
  }

  cvm::main()->unregister_named_atom_group(this);
@@ -217,7 +217,7 @@ int cvm::atom_group::init()
  b_center = false;
  b_rotate = false;
  b_user_defined_fit = false;
  fitting_group = nullptr;
  fitting_group = NULL;

  noforce = false;

@@ -368,7 +368,7 @@ int cvm::atom_group::parse(std::string const &group_conf)

  // Optional group name will let other groups reuse atom definition
  if (get_keyval(group_conf, "name", name)) {
    if ((cvm::atom_group_by_name(this->name) != nullptr) &&
    if ((cvm::atom_group_by_name(this->name) != NULL) &&
        (cvm::atom_group_by_name(this->name) != this)) {
      cvm::error("Error: this atom group cannot have the same name, \""+this->name+
                        "\", as another atom group.\n",
@@ -395,7 +395,7 @@ int cvm::atom_group::parse(std::string const &group_conf)
    std::string atoms_of = "";
    if (get_keyval(group_conf, "atomsOfGroup", atoms_of)) {
      atom_group * ag = atom_group_by_name(atoms_of);
      if (ag == nullptr) {
      if (ag == NULL) {
        cvm::error("Error: cannot find atom group with name " + atoms_of + ".\n");
        return COLVARS_ERROR;
      }
+13 −13
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ int colvarbias::init(std::string const &conf)

    {
      colvarbias *bias_with_name = cvm::bias_by_name(this->name);
      if (bias_with_name != nullptr) {
      if (bias_with_name != NULL) {
        if ((bias_with_name->rank != this->rank) ||
            (bias_with_name->bias_type != this->bias_type)) {
          cvm::error("Error: this bias cannot have the same name, \""+this->name+
@@ -295,8 +295,8 @@ int colvarbias::update()
    colvar_values[i] = colvars[i]->value();
  }

  error_code |= calc_energy(nullptr);
  error_code |= calc_forces(nullptr);
  error_code |= calc_energy(NULL);
  error_code |= calc_forces(NULL);

  return error_code;
}
@@ -547,8 +547,8 @@ colvarbias_ti::colvarbias_ti(char const *key)
  : colvarbias(key)
{
  provide(f_cvb_calc_ti_samples);
  ti_avg_forces = nullptr;
  ti_count = nullptr;
  ti_avg_forces = NULL;
  ti_count = NULL;
}


@@ -560,13 +560,13 @@ colvarbias_ti::~colvarbias_ti()

int colvarbias_ti::clear_state_data()
{
  if (ti_avg_forces != nullptr) {
  if (ti_avg_forces != NULL) {
    delete ti_avg_forces;
    ti_avg_forces = nullptr;
    ti_avg_forces = NULL;
  }
  if (ti_count != nullptr) {
  if (ti_count != NULL) {
    delete ti_count;
    ti_count = nullptr;
    ti_count = NULL;
  }
  return COLVARS_OK;
}
@@ -622,7 +622,7 @@ int colvarbias_ti::init(std::string const &conf)
int colvarbias_ti::init_grids()
{
  if (is_enabled(f_cvb_calc_ti_samples)) {
    if (ti_avg_forces == nullptr) {
    if (ti_avg_forces == NULL) {
      ti_bin.resize(num_variables());
      ti_system_forces.resize(num_variables());
      for (size_t icv = 0; icv < num_variables(); icv++) {
@@ -643,7 +643,7 @@ int colvarbias_ti::init_grids()

int colvarbias_ti::update()
{
  return update_system_forces(nullptr);
  return update_system_forces(NULL);
}


@@ -679,7 +679,7 @@ int colvarbias_ti::update_system_forces(std::vector<colvarvalue> const
          ti_system_forces[i] = variables(i)->total_force();
        } else {
          ti_system_forces[i] = variables(i)->total_force() -
            ((subtract_forces != nullptr) ?
            ((subtract_forces != NULL) ?
             (*subtract_forces)[i] : previous_colvar_forces[i]);
        }
      }
@@ -759,7 +759,7 @@ int colvarbias_ti::write_output_files()

  std::string const ti_output_prefix = cvm::output_prefix()+"."+this->name;

  std::ostream *os = nullptr;
  std::ostream *os = NULL;

  if (is_enabled(f_cvb_write_ti_samples)) {
    std::string const ti_count_file_name(ti_output_prefix+".ti.count");
+2 −2
Original line number Diff line number Diff line
@@ -58,12 +58,12 @@ public:
  virtual int update();

  /// Compute the energy of the bias
  /// Uses the vector of colvar values provided if not nullptr, and the values
  /// Uses the vector of colvar values provided if not NULL, and the values
  /// currently cached in the bias instance otherwise
  virtual int calc_energy(std::vector<colvarvalue> const *values);

  /// Compute the forces due to the bias
  /// Uses the vector of colvar values provided if not nullptr, and the values
  /// Uses the vector of colvar values provided if not NULL, and the values
  /// currently cached in the bias instance otherwise
  virtual int calc_forces(std::vector<colvarvalue> const *values);

+21 −21
Original line number Diff line number Diff line
@@ -18,16 +18,16 @@ colvarbias_abf::colvarbias_abf(char const *key)
    b_UI_estimator(false),
    b_CZAR_estimator(false),
    pabf_freq(0),
    system_force(nullptr),
    gradients(nullptr),
    samples(nullptr),
    pmf(nullptr),
    z_gradients(nullptr),
    z_samples(nullptr),
    czar_gradients(nullptr),
    czar_pmf(nullptr),
    last_gradients(nullptr),
    last_samples(nullptr)
    system_force(NULL),
    gradients(NULL),
    samples(NULL),
    pmf(NULL),
    z_gradients(NULL),
    z_samples(NULL),
    czar_gradients(NULL),
    czar_pmf(NULL),
    last_gradients(NULL),
    last_samples(NULL)
{
}

@@ -261,37 +261,37 @@ colvarbias_abf::~colvarbias_abf()
{
  if (samples) {
    delete samples;
    samples = nullptr;
    samples = NULL;
  }

  if (gradients) {
    delete gradients;
    gradients = nullptr;
    gradients = NULL;
  }

  if (pmf) {
    delete pmf;
    pmf = nullptr;
    pmf = NULL;
  }

  if (z_samples) {
    delete z_samples;
    z_samples = nullptr;
    z_samples = NULL;
  }

  if (z_gradients) {
    delete z_gradients;
    z_gradients = nullptr;
    z_gradients = NULL;
  }

  if (czar_gradients) {
    delete czar_gradients;
    czar_gradients = nullptr;
    czar_gradients = NULL;
  }

  if (czar_pmf) {
    delete czar_pmf;
    czar_pmf = nullptr;
    czar_pmf = NULL;
  }

  // shared ABF
@@ -299,17 +299,17 @@ colvarbias_abf::~colvarbias_abf()
  // but now we can call shared externally
  if (last_samples) {
    delete last_samples;
    last_samples = nullptr;
    last_samples = NULL;
  }

  if (last_gradients) {
    delete last_gradients;
    last_gradients = nullptr;
    last_gradients = NULL;
  }

  if (system_force) {
    delete [] system_force;
    system_force = nullptr;
    system_force = NULL;
  }
}

@@ -488,7 +488,7 @@ int colvarbias_abf::update()
  }

  /// Add the bias energy for 1D ABF
  bias_energy = calc_energy(nullptr);
  bias_energy = calc_energy(NULL);

  return COLVARS_OK;
}
Loading