Line data Source code
1 : ! This file is part of ELPA.
2 : !
3 : ! The ELPA library was originally created by the ELPA consortium,
4 : ! consisting of the following organizations:
5 : !
6 : ! - Max Planck Computing and Data Facility (MPCDF), formerly known as
7 : ! Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
8 : ! - Bergische Universität Wuppertal, Lehrstuhl für angewandte
9 : ! Informatik,
10 : ! - Technische Universität München, Lehrstuhl für Informatik mit
11 : ! Schwerpunkt Wissenschaftliches Rechnen ,
12 : ! - Fritz-Haber-Institut, Berlin, Abt. Theorie,
13 : ! - Max-Plack-Institut für Mathematik in den Naturwissenschaften,
14 : ! Leipzig, Abt. Komplexe Strukutren in Biologie und Kognition,
15 : ! and
16 : ! - IBM Deutschland GmbH
17 : !
18 : !
19 : ! More information can be found here:
20 : ! http://elpa.mpcdf.mpg.de/
21 : !
22 : ! ELPA is free software: you can redistribute it and/or modify
23 : ! it under the terms of the version 3 of the license of the
24 : ! GNU Lesser General Public License as published by the Free
25 : ! Software Foundation.
26 : !
27 : ! ELPA is distributed in the hope that it will be useful,
28 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : ! GNU Lesser General Public License for more details.
31 : !
32 : ! You should have received a copy of the GNU Lesser General Public License
33 : ! along with ELPA. If not, see <http://www.gnu.org/licenses/>
34 : !
35 : ! ELPA reflects a substantial effort on the part of the original
36 : ! ELPA consortium, and we ask you to respect the spirit of the
37 : ! license that we chose: i.e., please contribute any changes you
38 : ! may have back to the original ELPA library distribution, and keep
39 : ! any derivatives of ELPA under the same license that we chose for
40 : ! the original distribution, the GNU Lesser General Public License.
41 : !
42 : !
43 : #include "config-f90.h"
44 : module test_read_input_parameters
45 : use elpa
46 : use elpa_utilities, only : error_unit
47 :
48 : use test_util
49 : use test_output_type
50 :
51 : implicit none
52 :
53 : type input_options_t
54 : integer :: datatype
55 : integer :: na, nev, nblk
56 : type(output_t) :: write_to_file
57 : integer :: this_real_kernel, this_complex_kernel
58 : logical :: realKernelIsSet, complexKernelIsSet
59 : integer :: useQrIsSet, useGPUIsSet
60 : logical :: doSolveTridi, do1stage, do2stage, justHelpMessage, &
61 : doCholesky, doInvertTrm, doTransposeMultiply
62 : end type
63 :
64 : interface read_input_parameters
65 : module procedure read_input_parameters_general
66 : module procedure read_input_parameters_traditional
67 : end interface
68 :
69 : contains
70 :
71 0 : subroutine parse_arguments(command_line_argument, input_options)
72 : implicit none
73 :
74 : type(input_options_t) :: input_options
75 : character(len=128) :: command_line_argument
76 : integer :: error
77 :
78 0 : if (command_line_argument == "--help") then
79 0 : print *,"usage: elpa_tests [--help] [datatype={real|complex}] [na=number] [nev=number] "
80 0 : print *," [nblk=size of block cyclic distribution] [--output_eigenvalues]"
81 0 : print *," [--output_eigenvectors] [--real-kernel=name_of_kernel]"
82 0 : print *," [--complex-kernel=name_of_kernel] [--use-gpu={0|1}]"
83 : print *," [--use-qr={0,1}] [--tests={all|solve-tridi|1stage|2stage|cholesky&
84 0 : &|invert-triangular|transpose-mulitply}]"
85 0 : input_options%justHelpMessage=.true.
86 0 : return
87 : endif
88 :
89 :
90 0 : if (command_line_argument(1:11) == "--datatype=") then
91 0 : if (command_line_argument(12:15) == "real") then
92 0 : input_options%datatype=1
93 : else
94 0 : if (command_line_argument(12:18) == "complex") then
95 0 : input_options%datatype=2
96 : else
97 0 : print *,"datatype unknown! use either --datatype=real or --datatpye=complex"
98 0 : stop 1
99 : endif
100 : endif
101 : endif
102 :
103 0 : if (command_line_argument(1:3) == "na=") then
104 0 : read(command_line_argument(4:), *) input_options%na
105 : endif
106 0 : if (command_line_argument(1:4) == "nev=") then
107 0 : read(command_line_argument(5:), *) input_options%nev
108 : endif
109 0 : if (command_line_argument(1:5) == "nblk=") then
110 0 : read(command_line_argument(6:), *) input_options%nblk
111 : endif
112 :
113 0 : if (command_line_argument(1:21) == "--output_eigenvectors") then
114 0 : input_options%write_to_file%eigenvectors = .true.
115 : endif
116 :
117 0 : if (command_line_argument(1:20) == "--output_eigenvalues") then
118 0 : input_options%write_to_file%eigenvalues = .true.
119 : endif
120 :
121 0 : if (command_line_argument(1:14) == "--real-kernel=") then
122 0 : input_options%this_real_kernel = elpa_int_string_to_value("real_kernel", command_line_argument(15:), error)
123 0 : if (error /= ELPA_OK) then
124 0 : print *, "Invalid argument for --real-kernel"
125 0 : stop 1
126 : endif
127 0 : print *,"Setting ELPA2 real kernel to ", elpa_int_value_to_string("real_kernel", input_options%this_real_kernel)
128 0 : input_options%realKernelIsSet = .true.
129 : endif
130 :
131 0 : if (command_line_argument(1:17) == "--complex-kernel=") then
132 0 : input_options%this_complex_kernel = elpa_int_string_to_value("complex_kernel", command_line_argument(18:), error)
133 0 : if (error /= ELPA_OK) then
134 0 : print *, "Invalid argument for --complex-kernel"
135 0 : stop 1
136 : endif
137 0 : print *,"Setting ELPA2 complex kernel to ", elpa_int_value_to_string("complex_kernel", input_options%this_complex_kernel)
138 0 : input_options%complexKernelIsSet = .true.
139 : endif
140 :
141 0 : if (command_line_argument(1:9) == "--use-qr=") then
142 0 : read(command_line_argument(10:), *) input_options%useQrIsSet
143 : endif
144 :
145 0 : if (command_line_argument(1:10) == "--use-gpu=") then
146 0 : read(command_line_argument(11:), *) input_options%useGPUIsSet
147 : endif
148 :
149 0 : if (command_line_argument(1:8) == "--tests=") then
150 0 : if (command_line_argument(9:11) == "all") then
151 0 : input_options%doSolveTridi=.true.
152 0 : input_options%do1stage=.true.
153 0 : input_options%do2stage=.true.
154 0 : input_options%doCholesky=.true.
155 0 : input_options%doInvertTrm=.true.
156 0 : input_options%doTransposeMultiply=.true.
157 0 : else if (command_line_argument(9:19) == "solve-tride") then
158 0 : input_options%doSolveTridi=.true.
159 0 : input_options%do1stage=.false.
160 0 : input_options%do2stage=.false.
161 0 : input_options%doCholesky=.false.
162 0 : input_options%doInvertTrm=.false.
163 0 : input_options%doTransposeMultiply=.false.
164 0 : else if (command_line_argument(9:14) == "1stage") then
165 0 : input_options%doSolveTridi=.false.
166 0 : input_options%do1stage=.true.
167 0 : input_options%do2stage=.false.
168 0 : input_options%doCholesky=.false.
169 0 : input_options%doInvertTrm=.false.
170 0 : input_options%doTransposeMultiply=.false.
171 0 : else if (command_line_argument(9:14) == "2stage") then
172 0 : input_options%doSolveTridi=.false.
173 0 : input_options%do1stage=.false.
174 0 : input_options%do2stage=.true.
175 0 : input_options%doCholesky=.false.
176 0 : input_options%doInvertTrm=.false.
177 0 : input_options%doTransposeMultiply=.false.
178 0 : else if (command_line_argument(9:16) == "cholesky") then
179 0 : input_options%doSolveTridi=.false.
180 0 : input_options%do1stage=.false.
181 0 : input_options%do2stage=.false.
182 0 : input_options%doCholesky=.true.
183 0 : input_options%doInvertTrm=.false.
184 0 : input_options%doTransposeMultiply=.false.
185 0 : else if (command_line_argument(9:25) == "invert-triangular") then
186 0 : input_options%doSolveTridi=.false.
187 0 : input_options%do1stage=.false.
188 0 : input_options%do2stage=.false.
189 0 : input_options%doCholesky=.false.
190 0 : input_options%doInvertTrm=.true.
191 0 : input_options%doTransposeMultiply=.false.
192 0 : else if (command_line_argument(9:26) == "transpose-multiply") then
193 0 : input_options%doSolveTridi=.false.
194 0 : input_options%do1stage=.false.
195 0 : input_options%do2stage=.false.
196 0 : input_options%doCholesky=.false.
197 0 : input_options%doInvertTrm=.false.
198 0 : input_options%doTransposeMultiply=.true.
199 : else
200 0 : print *,"unknown test specified"
201 0 : stop 1
202 : endif
203 : endif
204 :
205 : end subroutine
206 :
207 0 : subroutine read_input_parameters_general(input_options)
208 : implicit none
209 :
210 : type(input_options_t) :: input_options
211 :
212 : ! Command line arguments
213 : character(len=128) :: arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10
214 : integer(kind=ik) :: mpierr
215 :
216 : ! default parameters
217 0 : input_options%datatype = 1
218 0 : input_options%na = 500
219 0 : input_options%nev = 150
220 0 : input_options%nblk = 16
221 :
222 0 : input_options%write_to_file%eigenvectors = .false.
223 0 : input_options%write_to_file%eigenvalues = .false.
224 :
225 0 : input_options%this_real_kernel = ELPA_2STAGE_REAL_DEFAULT
226 0 : input_options%this_complex_kernel = ELPA_2STAGE_COMPLEX_DEFAULT
227 0 : input_options%realKernelIsSet = .false.
228 0 : input_options%complexKernelIsSet = .false.
229 :
230 0 : input_options%useQrIsSet = 0
231 :
232 0 : input_options%useGPUIsSet = 0
233 :
234 0 : input_options%do1Stage = .true.
235 0 : input_options%do2Stage = .true.
236 0 : input_options%doSolveTridi = .true.
237 0 : input_options%doCholesky=.true.
238 0 : input_options%doInvertTrm=.true.
239 0 : input_options%doTransposeMultiply=.true.
240 0 : input_options%justHelpMessage=.false.
241 :
242 : ! test na=1500 nev=50 nblk=16 --help --kernel --output_eigenvectors --output_eigenvalues
243 0 : if (COMMAND_ARGUMENT_COUNT() .gt. 8) then
244 0 : write(error_unit, '(a,i0,a)') "Invalid number (", COMMAND_ARGUMENT_COUNT(), ") of command line arguments!"
245 0 : stop 1
246 : endif
247 :
248 0 : if (COMMAND_ARGUMENT_COUNT() .gt. 0) then
249 :
250 0 : call get_COMMAND_ARGUMENT(1, arg1)
251 :
252 0 : call parse_arguments(arg1, input_options)
253 :
254 :
255 :
256 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 2) then
257 : ! argument 2
258 0 : call get_COMMAND_ARGUMENT(2, arg2)
259 :
260 0 : call parse_arguments(arg2, input_options)
261 : endif
262 :
263 : ! argument 3
264 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 3) then
265 :
266 0 : call get_COMMAND_ARGUMENT(3, arg3)
267 :
268 0 : call parse_arguments(arg3, input_options)
269 : endif
270 :
271 : ! argument 4
272 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 4) then
273 :
274 0 : call get_COMMAND_ARGUMENT(4, arg4)
275 :
276 0 : call parse_arguments(arg4, input_options)
277 :
278 : endif
279 :
280 : ! argument 5
281 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 5) then
282 :
283 0 : call get_COMMAND_ARGUMENT(5, arg5)
284 :
285 0 : call parse_arguments(arg5, input_options)
286 : endif
287 :
288 : ! argument 6
289 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 6) then
290 :
291 0 : call get_COMMAND_ARGUMENT(6, arg6)
292 :
293 0 : call parse_arguments(arg6, input_options)
294 : endif
295 :
296 : ! argument 7
297 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 7) then
298 :
299 0 : call get_COMMAND_ARGUMENT(7, arg7)
300 :
301 0 : call parse_arguments(arg7, input_options)
302 :
303 : endif
304 :
305 : ! argument 8
306 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 8) then
307 :
308 0 : call get_COMMAND_ARGUMENT(8, arg8)
309 :
310 0 : call parse_arguments(arg8, input_options)
311 :
312 : endif
313 :
314 : ! argument 9
315 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 9) then
316 :
317 0 : call get_COMMAND_ARGUMENT(9, arg9)
318 :
319 0 : call parse_arguments(arg8, input_options)
320 :
321 : endif
322 :
323 : ! argument 10
324 0 : if (COMMAND_ARGUMENT_COUNT() .ge. 10) then
325 :
326 0 : call get_COMMAND_ARGUMENT(10, arg10)
327 :
328 0 : call parse_arguments(arg8, input_options)
329 :
330 : endif
331 :
332 : endif
333 :
334 0 : if (input_options%useQrIsSet .eq. 1 .and. input_options%datatype .eq. 2) then
335 0 : print *,"You cannot use QR-decomposition in complex case"
336 0 : stop 1
337 : endif
338 :
339 0 : end subroutine
340 :
341 15744 : subroutine read_input_parameters_traditional(na, nev, nblk, write_to_file)
342 : implicit none
343 :
344 : integer(kind=ik), intent(out) :: na, nev, nblk
345 :
346 : type(output_t), intent(out) :: write_to_file
347 :
348 : ! Command line arguments
349 : character(len=128) :: arg1, arg2, arg3, arg4, arg5
350 : integer(kind=ik) :: mpierr
351 :
352 : ! default parameters
353 15744 : na = 5000
354 15744 : nev = 150
355 15744 : nblk = 16
356 15744 : write_to_file%eigenvectors = .false.
357 15744 : write_to_file%eigenvalues = .false.
358 :
359 15744 : if (.not. any(COMMAND_ARGUMENT_COUNT() == [0, 3, 4, 5])) then
360 0 : write(error_unit, '(a,i0,a)') "Invalid number (", COMMAND_ARGUMENT_COUNT(), ") of command line arguments!"
361 : write(error_unit, *) "Expected: program [ [matrix_size num_eigenvalues block_size] &
362 0 : ""output_eigenvalues"" ""output_eigenvectors""]"
363 0 : stop 1
364 : endif
365 :
366 15744 : if (COMMAND_ARGUMENT_COUNT() == 3) then
367 15744 : call GET_COMMAND_ARGUMENT(1, arg1)
368 15744 : call GET_COMMAND_ARGUMENT(2, arg2)
369 15744 : call GET_COMMAND_ARGUMENT(3, arg3)
370 :
371 15744 : read(arg1, *) na
372 15744 : read(arg2, *) nev
373 15744 : read(arg3, *) nblk
374 : endif
375 :
376 15744 : if (COMMAND_ARGUMENT_COUNT() == 4) then
377 0 : call GET_COMMAND_ARGUMENT(1, arg1)
378 0 : call GET_COMMAND_ARGUMENT(2, arg2)
379 0 : call GET_COMMAND_ARGUMENT(3, arg3)
380 0 : call GET_COMMAND_ARGUMENT(4, arg4)
381 0 : read(arg1, *) na
382 0 : read(arg2, *) nev
383 0 : read(arg3, *) nblk
384 :
385 0 : if (arg4 .eq. "output_eigenvalues") then
386 0 : write_to_file%eigenvalues = .true.
387 : else
388 0 : write(error_unit, *) "Invalid value for output flag! Must be ""output_eigenvalues"" or omitted"
389 0 : stop 1
390 : endif
391 :
392 : endif
393 :
394 15744 : if (COMMAND_ARGUMENT_COUNT() == 5) then
395 0 : call GET_COMMAND_ARGUMENT(1, arg1)
396 0 : call GET_COMMAND_ARGUMENT(2, arg2)
397 0 : call GET_COMMAND_ARGUMENT(3, arg3)
398 0 : call GET_COMMAND_ARGUMENT(4, arg4)
399 0 : call GET_COMMAND_ARGUMENT(5, arg5)
400 0 : read(arg1, *) na
401 0 : read(arg2, *) nev
402 0 : read(arg3, *) nblk
403 :
404 0 : if (arg4 .eq. "output_eigenvalues") then
405 0 : write_to_file%eigenvalues = .true.
406 : else
407 0 : write(error_unit, *) "Invalid value for output flag! Must be ""output_eigenvalues"" or omitted"
408 0 : stop 1
409 : endif
410 :
411 0 : if (arg5 .eq. "output_eigenvectors") then
412 0 : write_to_file%eigenvectors = .true.
413 : else
414 0 : write(error_unit, *) "Invalid value for output flag! Must be ""output_eigenvectors"" or omitted"
415 0 : stop 1
416 : endif
417 :
418 : endif
419 15744 : end subroutine
420 :
421 : end module
|