示例#1
0
void get_structure(t_atoms *atoms, const char *IndexFile,
                   const char *StructureFile, struct edix *edx, int nfit,
                   atom_id ifit[], int nav, atom_id index[])
{
    atom_id *igro; /*index corresponding to target or origin structure*/
    int      ngro;
    int      ntar;
    rvec    *xtar;
    char     title[STRLEN];
    char   * grpname;


    ntar = read_conffile(StructureFile, title, &xtar);
    printf("Select an index group of %d elements that corresponds to the atoms in the structure file %s\n",
           ntar, StructureFile);
    get_index(atoms, IndexFile, 1, &ngro, &igro, &grpname);
    if (ngro != ntar)
    {
        gmx_fatal(FARGS, "You selected an index group with %d elements instead of %d", ngro, ntar);
    }
    init_edx(edx);
    filter2edx(edx, nfit, ifit, ngro, igro, xtar, StructureFile);

    /* If average and reference/fitting structure differ, append the average structure as well */
    if (ifit != index) /*if fit structure is different append these coordinates, too -- don't mind duplicates*/
    {
        filter2edx(edx, nav, index, ngro, igro, xtar, StructureFile);
    }
}
示例#2
0
/**
 * This is the main entry point of the program
 * 
 * @param   argc  The number of elements in `argv`
 * @param   argv  Command line arguments
 * @return        Zero on success
 */
int main(int argc, char** argv)
{
  int continuous = 0;
  int quickly = 0;
  int i;
  FILE* f;
  conffile_t* data;
  conffile_t* data_;
  char* env;
  struct passwd* pw;
  
  for (i = 0; i < argc; i++)
    {
      char* arg = *(argv + i);
      
      #define __(opt)  (!strcmp(arg, opt))
      
      if (__("-c") || __("-cq") || __("-qc") || __("--continuous"))
	continuous = 1;
      if (__("-q") || __("-cq") || __("-qc") || __("--quickly"))
	quickly = 1;
      
      #undef __
    }
  
  if ((env = getenv("HOME")) && *env && !chdir(env));
  else if ((pw = getpwuid(getuid())) && pw->pw_dir)
    if (chdir(pw->pw_dir))
      fprintf(stderr, "%s: cannot change directory to your home directory", *argv);
  
retry:
  init_coordination(continuous, quickly);
  
  f = get_conffile(NULL);
  if (f != NULL)
    {
      data_ = data = read_conffile(f);
      fclose(f);
    }
  else
    {
      /* If there are not configurion use use: */
      
      data_ = data = malloc(3 * sizeof(conffile_t));
      
      #define __use1(INDEX, METHOD)							\
	({										\
	  data[INDEX].argc = 1;								\
	  data[INDEX].argv = malloc(sizeof(char*));					\
	  data[INDEX].argv[0] = malloc(strlen(METHOD ".") * sizeof(char));		\
	  memcpy(data[INDEX].argv[0], METHOD, strlen(METHOD ".") * sizeof(char));	\
	})
      #define __use2(INDEX, METHOD, ARGV1)						\
	({										\
	  data[INDEX].argc = 2;								\
	  data[INDEX].argv = malloc(2 * sizeof(char*));					\
	  data[INDEX].argv[0] = malloc(strlen(METHOD ".") * sizeof(char));		\
	  memcpy(data[INDEX].argv[0], METHOD, strlen(METHOD ".") * sizeof(char));	\
	  data[INDEX].argv[1] = malloc(strlen(METHOD ".") * sizeof(char));		\
	  memcpy(data[INDEX].argv[1], ARGV1, strlen(ARGV1 ".") * sizeof(char));		\
	})
      
      __use1(0, "cache");
      __use2(1, "read", ".config/geolocation");
      __use2(2, "read", "/etc/geolocation");
      __use1(3, "timezone-offset");
      
      #undef __use1
      #undef __use2
      
      data[4].argc = -1;
      data[4].argv = NULL;
    }
  for (; data->argc > 0; data++)
    run(data->argc, data->argv);
  free(data_);
  
  if (already_done())
    abort_coordination();
  
  if (!term_coordination())
    {
      if (quickly && !continuous)
	return 1;
      quickly = 1;
      continuous = 0;
      goto retry;
    }
  return 0;
}