Commit 00d820dc authored by Ryan S. Elliott's avatar Ryan S. Elliott
Browse files

Added support for log.cite to kim_init

parent 63dcd999
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@
#include "universe.h"
#include "input.h"
#include "variable.h"
#include "citeme.h"
#include "fix_store_kim.h"
#include "kim_units.h"

@@ -99,6 +100,8 @@ void KimInit::command(int narg, char **arg)
  char *model_units;
  determine_model_type_and_units(model_name, user_units, &model_units);

  write_log_cite(model_name);

  do_init(model_name, user_units, model_units);
}

@@ -441,3 +444,52 @@ void KimInit::do_variables(char *user_units, char *model_units)
    if ((logfile) && (input->echo_log)) fputs("#\n",logfile);
  }
}

/* ---------------------------------------------------------------------- */

void KimInit::write_log_cite(char * model_name)
{
  KIM_Collections * coll;
  int err = KIM_Collections_Create(&coll);
  if (err) return;

  int extent;
  if (model_type == MO)
  {
    err = KIM_Collections_CacheListOfItemMetadataFiles(
        coll,KIM_COLLECTION_ITEM_TYPE_portableModel,model_name,&extent);
  }
  else if (model_type == SM)
  {
    err = KIM_Collections_CacheListOfItemMetadataFiles(
        coll,KIM_COLLECTION_ITEM_TYPE_simulatorModel,model_name,&extent);
  }
  else
  {
    error->all(FLERR,"Unknown model type.");
  }

  if (err)
  {
    KIM_Collections_Destroy(&coll);
    return;
  }

  for (int i = 0; i < extent;++i)
  {
    char const * fileName;
    int availableAsString;
    char const * fileString;
    err = KIM_Collections_GetItemMetadataFile(
        coll,i,&fileName,NULL,NULL,&availableAsString,&fileString);
    if (err) continue;

    if (0 == strncmp("kimcite-",fileName,8))
    {
      if (lmp->citeme) lmp->citeme->add(fileString);
      break;
    }
  }

  KIM_Collections_Destroy(&coll);
}
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ class KimInit : protected Pointers {
  bool unit_conversion_mode;

  void determine_model_type_and_units(char *, char *, char **);
  void write_log_cite(char *);
  void do_init(char *, char *, char *);
  void do_variables(char*, char*);
  void kim_init_log_delimiter(std::string const begin_end) const;