Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
2bda30cf
Commit
2bda30cf
authored
9 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Removed file as it exits in the tests/ directory now.
parent
aeb19b59
No related branches found
No related tags found
1 merge request
!129
Parameter file
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/testParser.c
+39
-1
39 additions, 1 deletion
src/testParser.c
with
39 additions
and
1 deletion
src/testParser.c
+
39
−
1
View file @
2bda30cf
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (C) 2016 James Willis (james.s.willis@durham.ac.uk).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include
"parser.h"
#include
"parser.h"
#include
<assert.h>
#include
<string.h>
#include
<math.h>
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
input_file
=
argv
[
1
];
const
char
*
input_file
=
argv
[
1
];
/* Create a structure to read file into. */
struct
swift_params
param_file
;
struct
swift_params
param_file
;
/* Create variables that will be set from the parameter file. */
int
no_of_threads
=
0
;
int
no_of_threads
=
0
;
int
no_of_time_steps
=
0
;
int
no_of_time_steps
=
0
;
float
max_h
=
0
.
0
f
;
float
max_h
=
0
.
0
f
;
char
ic_file
[
MAX_LINE_SIZE
];
char
ic_file
[
PARSER_
MAX_LINE_SIZE
];
/* Read the parameter file. */
parser_read_file
(
input_file
,
&
param_file
);
parser_read_file
(
input_file
,
&
param_file
);
/* Print the contents of the structure. */
parser_print_params
(
&
param_file
);
parser_print_params
(
&
param_file
);
/* Retrieve parameters and store them in variables defined above.
* Have to specify the name of the parameter as it appears in the
* input file: testParserInput.yaml.*/
parser_get_param_int
(
&
param_file
,
"no_of_threads"
,
&
no_of_threads
);
parser_get_param_int
(
&
param_file
,
"no_of_threads"
,
&
no_of_threads
);
parser_get_param_int
(
&
param_file
,
"no_of_time_steps"
,
&
no_of_time_steps
);
parser_get_param_int
(
&
param_file
,
"no_of_time_steps"
,
&
no_of_time_steps
);
parser_get_param_float
(
&
param_file
,
"max_h"
,
&
max_h
);
parser_get_param_float
(
&
param_file
,
"max_h"
,
&
max_h
);
parser_get_param_string
(
&
param_file
,
"ic_file"
,
ic_file
);
parser_get_param_string
(
&
param_file
,
"ic_file"
,
ic_file
);
/* Print the variables to check their values are correct. */
printf
(
"no_of_threads: %d, no_of_time_steps: %d, max_h: %f, ic_file: %s
\n
"
,
no_of_threads
,
no_of_time_steps
,
max_h
,
ic_file
);
printf
(
"no_of_threads: %d, no_of_time_steps: %d, max_h: %f, ic_file: %s
\n
"
,
no_of_threads
,
no_of_time_steps
,
max_h
,
ic_file
);
assert
(
no_of_threads
==
16
);
assert
(
no_of_time_steps
==
10
);
assert
(
fabs
(
max_h
-
1
.
1255
)
<
0
.
00001
);
assert
(
strcmp
(
ic_file
,
"ic_file.ini"
)
==
0
);
/*strcmp returns 0 if correct.*/
return
0
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment