-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadConfigFile.cpp
More file actions
67 lines (50 loc) · 4 KB
/
Copy pathLoadConfigFile.cpp
File metadata and controls
67 lines (50 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "ResumCLASS.h"
static YesNo GetAnswer (const string & Answer) {
if (Answer == "Y" || Answer == "y" || Answer == "yes" || Answer == "Yes" || Answer == "YES") return 1 ;
if (Answer == "N" || Answer == "n" || Answer == "no" || Answer == "No" || Answer == "NO") return 0 ;
else return 1 ;
}
void LoadConfigFile (char * ConfigFile, double & nbar, double & km, double & knl, redshift & z0, ParametersCosmology & cosmo, string & PathToFolder, string & PathToFolderRD,string & PathToFolderCosmoRef, string & PathToLinearPowerSpectrum, YesNo & ComputePowerSpectrum, YesNo & UseRef, YesNo & ImportM, YesNo & ExportM, PrecisionIntegr & Eps) {
///// Reading ini file /////
ifstream inFile (ConfigFile) ;
char line[1024] ;
char delim[] = " =" ;
char * token ;
bool physical_b = false, physical_cdm = false ;
if (!inFile.is_open()) {
cout << "Could not open the input file: " << ConfigFile << endl ;
exit(EXIT_FAILURE) ;
}
while (inFile) {
inFile.getline(line, 1024) ;
if (strlen(line) == 0 or line[0]=='#' or line[0] == '[') continue ;
token = strtok(line, delim) ;
if (strcmp(token, "PathToFolderOutput") == 0) while ((token = strtok(NULL, delim)) != NULL) PathToFolder = token ;
else if (strcmp(token, "PathToFolderRD") == 0) while ((token = strtok(NULL, delim)) != NULL) PathToFolderRD = token ;
else if (strcmp(token, "PathToFolderCosmoRef") == 0) while ((token = strtok(NULL, delim)) != NULL) PathToFolderCosmoRef = token ;
else if (strcmp(token, "PathToLinearPowerSpectrum") == 0) while ((token = strtok(NULL, delim)) != NULL) PathToLinearPowerSpectrum = token ;
else if (strcmp(token, "knl") == 0) while ((token = strtok(NULL, delim)) != NULL) knl = atof(token) ;
else if (strcmp(token, "km") == 0) while ((token = strtok(NULL, delim)) != NULL) km = atof(token) ;
else if (strcmp(token, "nbar") == 0) while ((token = strtok(NULL, delim)) != NULL) nbar = atof(token) ;
else if (strcmp(token, "ComputePowerSpectrum") == 0) while ((token = strtok(NULL, delim)) != NULL) ComputePowerSpectrum = GetAnswer(token) ;
else if (strcmp(token, "UseCosmoRef") == 0) while ((token = strtok(NULL, delim)) != NULL) UseRef = GetAnswer(token) ;
else if (strcmp(token, "ImportResummationMatrix") == 0) while ((token = strtok(NULL, delim)) != NULL) ImportM = GetAnswer(token) ;
else if (strcmp(token, "ExportResummationMatrix") == 0) while ((token = strtok(NULL, delim)) != NULL) ExportM = GetAnswer(token) ;
else if (strcmp(token, "z_pk") == 0) while ((token = strtok(NULL, delim)) != NULL) z0 = atof(token) ;
else if (strcmp(token, "ln10^{10}A_s") == 0) while ((token = strtok(NULL, delim)) != NULL) cosmo[0] = atof(token) ;
else if (strcmp(token, "n_s") == 0) while ((token = strtok(NULL, delim)) != NULL) cosmo[1] = atof(token) ;
else if (strcmp(token, "h") == 0) while ((token = strtok(NULL, delim)) != NULL) cosmo[2] = atof(token) ;
else if (strcmp(token, "Omega_b") == 0) while ((token = strtok(NULL, delim)) != NULL) cosmo[3] = atof(token) ;
else if (strcmp(token, "Omega_cdm") == 0) while ((token = strtok(NULL, delim)) != NULL) cosmo[4] = atof(token) ;
else if (strcmp(token, "omega_b") == 0) while ((token = strtok(NULL, delim)) != NULL) { physical_b = true ; cosmo[3] = atof(token) ; }
else if (strcmp(token, "omega_cdm") == 0) while ((token = strtok(NULL, delim)) != NULL) { physical_cdm = true ; cosmo[4] = atof(token) ; }
else if (strcmp(token, "EpsAbs_NoCosmoRef") == 0) while ((token = strtok(NULL, delim)) != NULL) Eps[0][0] = atof(token) ;
else if (strcmp(token, "EpsRel_NoCosmoRef") == 0) while ((token = strtok(NULL, delim)) != NULL) Eps[0][1] = atof(token) ;
else if (strcmp(token, "EpsAbs_YesCosmoRef") == 0) while ((token = strtok(NULL, delim)) != NULL) Eps[1][0] = atof(token) ;
else if (strcmp(token, "EpsRel_YesCosmoRef") == 0) while ((token = strtok(NULL, delim)) != NULL) Eps[1][1] = atof(token) ;
}
inFile.close() ;
// Taking care of both fractional and physical densities
if (physical_b == true) cosmo[3]/pow(cosmo[2],2) ;
if (physical_cdm == true) cosmo[4]/pow(cosmo[2],2) ;
}