AcouSTO  version 2.0

◆ read_runinfo()

int read_runinfo ( int  check_dir)
21  {
22  int ltmp;
23  char time_format[MAX_PATH];
24  char today[MAX_PATH];
25  const char* time_format_var = NULL;
26  time_t tt;
27  struct tm *ttmp;
28  int direrr;
29  int staterr;
30  struct stat stat_s;
31  double dtmp;
32 
33 
34  /* INIT RUNINFO */
36  CONFIG_GET_STRING(config, "runinfo.title" , rundetails->title);
37  CONFIG_GET_STRING(config, "runinfo.owner" , rundetails->owner);
38  CONFIG_GET_INT (config, "runinfo.ksymmi", runinfo->ksymmi );
39  CONFIG_GET_INT (config, "runinfo.krow" , runinfo->krow );
40 
41  // evaluating symmetry variables (please refer to user manual for this)
42  // for ksymmi <= 3 - specular w.r.t. ksymmi symmetry planes
43  // for ksymmi > 3 - axially symmetric problem divided into ksymmi "slices"
44  if (runinfo->ksymmi <= 3) {
45  runinfo->nsymm = pow(2, runinfo->ksymmi);
46  } else {
48  }
49  logger(LOG_DEBUG, "runinfo->nsymm=%d\n", runinfo->nsymm);
50 
51  // Checking coherence of symmetry conditions
52  if (runinfo->ksymmi < 0) {
54  return -1;
55  }
56 
57  /* Creation of Output Files Parent Folder */
58  tt = time(NULL);
59  ttmp = localtime(&tt);
60  if(NULL == CONFIG_LOOKUP(config,"runinfo.dirsuffix")){
61  logger(LOG_DEBUG,"Dir suffix defaults to %%F\n");
62  strcpy(time_format,"%F");
63  }else{
64  CONFIG_GET_STRING(config,"runinfo.dirsuffix",time_format_var);
65  logger(LOG_DEBUG,"Dir suffix:%s\n",time_format_var);
66  strcpy(time_format,time_format_var);
67  }
68 
69  strftime(today, sizeof(today), time_format,ttmp);
70 
71  rundetails->out_filedir = calloc(strlen(rundetails->title)+2+strlen(today),sizeof(char));
72  sprintf(rundetails->out_filedir,"%s-%s",rundetails->title,today);
73 
74  rundetails->out_filepath = calloc(strlen(rundetails->cfg_filepath)+strlen(rundetails->out_filedir)+2,sizeof(char));
76 
77 
78  //Checking existence of dir
79  logger(LOG_INFO,"Creating directory %s\n",rundetails->out_filepath);
80  staterr = stat(rundetails->out_filepath,&stat_s);
81  if(-1 == staterr){ // in case of error
82  if(ENOENT == errno){ // doesn't exist
83  //
84  direrr = mkdir(rundetails->out_filepath,0777);
85  if(0==direrr){
86  logger(LOG_INFO,"Output files will be stored in folder %s\n",rundetails->out_filedir);
87  logger(LOG_INFO," under path %s\n",rundetails->cfg_filepath);
88  }else{
89  logger(LOG_ERROR, "Error creating output directory %s\n",rundetails->out_filedir);
90  return -1;
91  }
92  }else{
93  logger(LOG_ERROR, "Error checking directory %s existence: [%d]\n",rundetails->out_filedir,errno);
94  return -1;
95  }
96  }else{
97  if(S_ISDIR(stat_s.st_mode)) {
98  if(1 == check_dir){
99  logger(LOG_ERROR, "Directory %s exists, cannot proceed\n",rundetails->out_filedir);
100  return -1;
101  }else{
102  logger(LOG_WARN, "WARNING! Directory %s exists, existing files will be OVERWRITTEN\n",rundetails->out_filedir);
103  }
104  } else {
105  // exists but is no dir
106  logger(LOG_ERROR, "Path %s exists, cannot proceed\n",rundetails->out_filedir);
107  return -1;
108  }
109  }
110  CONFIG_GET_FLOAT(config, "runinfo.vsound", runinfo->vsound);
111 
112  // getting grid information
113  CONFIG_GET_INT(config, "runinfo.nprows", runinfo->nprows);
114  CONFIG_GET_INT(config, "runinfo.npcols", runinfo->npcols);
115  CONFIG_GET_INT(config, "runinfo.row_block_size", runinfo->row_block_size);
116  CONFIG_GET_INT(config, "runinfo.col_block_size", runinfo->col_block_size);
117  CONFIG_GET_INT(config, "runinfo.mics_block_size", runinfo->mics_block_size);
118 
119  // determining automatically grid size
120  if (runinfo->nprows == 0 || runinfo->npcols == 0) {
121  runinfo->nprows = 1; // defaults to 1 - Umb test
122  runinfo->npcols = size; // defaults to nnodes - Umb test
123  logger(LOG_INFO, "Warning: Grid size was automatically determined as %d x %d\n", runinfo->nprows, runinfo->npcols);
124  logger(LOG_INFO, " This choice is not optimal for large problems and a high number of processes.\n");
125  logger(LOG_INFO, " It may also lead to distribution inconsistencies. \n");
126  }
127 
128  if (runinfo->npcols * runinfo->nprows != size) {
130  return -1;
131  }
132 
133  // choosing a default block size
137 
138 
139  return 0;
140 
141 }
#define CONFIG_GET_INT(config, name, var)
Definition: config.h:47
char * out_filepath
Definition: structs.h:143
struct run_info * runinfo
Definition: globals.h:34
#define DEFAULT_COL_BLOCK_SIZE
Definition: constants.h:32
int npcols
Definition: structs.h:113
#define CONFIG_GET_STRING(config, name, var)
Definition: config.h:48
const char * title
Definition: structs.h:135
DOUBLE vsound
Definition: structs.h:102
#define CONFIG_LOOKUP(config, name)
Definition: config.h:49
const char * owner
Definition: structs.h:133
int nnodes
Definition: structs.h:151
int nprows
Definition: structs.h:111
char * out_filedir
Definition: structs.h:141
int mics_block_size
Definition: structs.h:124
int size
Definition: globals.h:81
#define LOG_INFO
Definition: logger.h:26
char * cfg_filepath
Definition: structs.h:139
#define DEFAULT_ROW_BLOCK_SIZE
Definition: constants.h:31
#define LOG_ERROR
Definition: logger.h:24
struct config_t config
Definition: config.h:61
#define DEFAULT_MICS_BLOCK_SIZE
Definition: constants.h:33
#define LOG_DEBUG
Definition: logger.h:27
#define LOG_WARN
Definition: logger.h:25
int nsymm
Definition: structs.h:97
int ksymmi
Definition: structs.h:91
int col_block_size
Definition: structs.h:121
struct run_details * rundetails
Definition: globals.h:36
int krow
Definition: structs.h:105
#define MSG_CFG_KSYMM_1_ERROR
Definition: messages.h:29
#define MAX_PATH
Definition: constants.h:29
#define CONFIG_GET_FLOAT(config, name, var)
Definition: config.h:44
int row_block_size
Definition: structs.h:119
void logger(int level, char *msg,...)
Definition: logger.c:56
#define calloc(n, size)
Definition: allocation.h:37
#define MSG_CFG_GRIDSIZE
Definition: messages.h:32