-
Notifications
You must be signed in to change notification settings - Fork 4
/
startup.m
145 lines (137 loc) · 6.57 KB
/
startup.m
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
function startup()
%{
startup
Start up the PhreeqcMatlab package. If you have an internet connection, the
package automatically downloads the PhreeqcRM and IPhreeqc libraries for
your operating system (Mac is not supported yet).
%}
% global DATABASE_PATH
try
p = mfilename('fullpath');
file_name = mfilename;
current_path = p(1:end-1-length(file_name));
addpath([current_path '/libs']);
addpath([current_path '/src']);
addpath([current_path '/src/Advection1D']);
addpath([current_path '/src/Transport1D']);
addpath([current_path '/src/Bulk']);
addpath([current_path '/src/Tools']);
addpath([current_path '/database']);
addpath([current_path '/src/FVTool']);
addpath([current_path '/src/classes']);
disp('PhreeqcMatlab is starting. Checking for the PhreeqcRM library ...');
catch
error('Something went wrong with the PhreeqcMatlab start up. Please download the package again, extract it, and run the startup.m file.');
end
% try to download the libraries and header files
time_out = 1000; % [s] time for downloading the libraries
if ispc
% PhreeqcRM lib file download
if ~isfile([current_path '/libs/libphreeqcrm.dll']) % lib files do not exist
options = weboptions('Timeout', time_out);
url = 'https://github.com/simulkade/PhreeqcRM/releases/download/3.7.1/PhreeqcRM.dll';
lib_name = 'libs/libphreeqcrm.dll';
disp('Downloading libphreeqcrm.dll from https://github.com/simulkade/PhreeqcRM. Please wait...');
try
websave(lib_name, url, options);
disp('libphreeqcrm.dll is successfully downloaded.');
catch
disp('Could not download the libphreeqcrm.dll file.')
disp('Please download it from https://github.com/simulkade/PhreeqcRM/releases/download/3.7.1/PhreeqcRM.dll')
disp('rename it to libphreeqcrm.dll, and copy it to the libs folder')
end
else
disp('libphreeqcrm.dll library exists.');
disp('PhreeqcMatlab started successfully');
end
if ~isfile([current_path '/libs/libphreeqcrm.lib']) % lib files do not exist
options = weboptions('Timeout', time_out);
url = 'https://github.com/simulkade/PhreeqcRM/releases/download/3.7.1/PhreeqcRM.lib';
lib_name = 'libs/libphreeqcrm.lib';
disp('Downloading libphreeqcrm.lib from https://github.com/simulkade/PhreeqcRM. Please wait...');
try
websave(lib_name, url, options);
disp('libphreeqcrm.lib is successfully downloaded.');
catch
disp('Could not download the libphreeqcrm.lib file.')
disp('Please download it from https://github.com/simulkade/PhreeqcRM/releases/download/3.7.1/PhreeqcRM.lib')
disp('rename it to libphreeqcrm.lib, and copy it to the libs folder')
end
else
disp('libphreeqcrm.lib library exists.');
disp('PhreeqcMatlab started successfully');
end
% IPhreeqc lib file download
if ~isfile([current_path '/libs/libiphreeqc.dll']) % lib files do not exist
options = weboptions('Timeout', time_out);
url = 'https://github.com/simulkade/PhreeqcRM/releases/download/3.7/IPhreeqcd.dll';
lib_name = 'libs/libiphreeqc.dll';
disp('Downloading libiphreeqc.dll from https://github.com/simulkade/PhreeqcRM. Please wait...');
try
websave(lib_name, url, options);
disp('libiphreeqc.dll is successfully downloaded.');
catch
disp('Could not download the libiphreeqc.dll file (OPTIONAL).')
disp('Please download it from https://github.com/simulkade/PhreeqcRM/releases/download/3.7/IPhreeqcd.dll')
disp('rename it to libiphreeqc.dll, and copy it to the libs folder')
end
else
disp('libiphreeqc.dll library exists.');
disp('IPhreeqc functions are available');
end
if ~isfile([current_path '/libs/libiphreeqc.lib']) % lib files do not exist
options = weboptions('Timeout', time_out);
url = 'https://github.com/simulkade/PhreeqcRM/releases/download/3.7/IPhreeqcd.lib';
lib_name = 'libs/libiphreeqc.lib';
disp('Downloading libiphreeqc.lib from https://github.com/simulkade/PhreeqcRM. Please wait...');
try
websave(lib_name, url, options);
disp('libiphreeqc.dll is successfully downloaded.');
catch
disp('Could not download the libiphreeqc.lib file (OPTIONAL).')
disp('Please download it from https://github.com/simulkade/PhreeqcRM/releases/download/3.7/IPhreeqcd.lib')
disp('rename it to libiphreeqc.lib, and copy it to the libs folder')
end
else
disp('libiphreeqc.lib library exists.');
disp('IPhreeqc functions are available');
end
end
if isunix
% PhreeqcRM lib file download
if ~isfile([current_path '/libs/libphreeqcrm.so']) % lib files do not exist
options = weboptions('Timeout', time_out);
url = 'https://github.com/simulkade/PhreeqcRM/releases/download/3.7.1/libphreeqcrm-3.7.1.so';
lib_name = 'libs/libphreeqcrm.so';
disp('Downloading libphreeqcrm.so from https://github.com/simulkade/PhreeqcRM. Please wait...');
try
websave(lib_name, url, options);
disp('libphreeqcrm.so is successfully downloaded.');
catch
disp('Could not download the libphreeqcrm.so file.')
disp('Please download it from https://github.com/simulkade/PhreeqcRM/releases/download/3.7.1/libphreeqcrm-3.7.1.so')
disp('rename it to libphreeqcrm.so, and copy it to the libs folder')
end
else
disp('libphreeqcrm.so library exists.');
disp('PhreeqcMatlab started successfully');
end
% IPhreeqc lib file download
if ~isfile([current_path '/libs/libiphreeqc.so']) % lib files do not exist
options = weboptions('Timeout', time_out);
url = 'https://github.com/simulkade/PhreeqcRM/releases/download/3.7/libiphreeqc-3.7.0.so';
lib_name = 'libs/libiphreeqc.so';
disp('Downloading libiphreeqc.so from https://github.com/simulkade/PhreeqcRM. Please wait...');
try
websave(lib_name, url, options);
disp('libiphreeqc.so is successfully downloaded.');
catch
disp('Could not download the libiphreeqc.so file.')
disp('Please download it from https://github.com/simulkade/PhreeqcRM/releases/download/3.7/libiphreeqc-3.7.0.so')
disp('rename it to libiphreeqc.so, and copy it to the libs folder')
end
else
disp('libiphreeqc.so library exists.');
disp('IPhreeqc functions are available');
end
end