Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YAC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
dkrz-sw
YAC
Commits
c1d52c13
Commit
c1d52c13
authored
8 years ago
by
Moritz Hanke
Browse files
Options
Downloads
Patches
Plain Diff
improves help print output of weights2vtk tool
parent
774339e8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/weights2vtk.c
+54
-21
54 additions, 21 deletions
contrib/weights2vtk.c
with
54 additions
and
21 deletions
contrib/weights2vtk.c
+
54
−
21
View file @
c1d52c13
...
...
@@ -569,11 +569,11 @@ void write_data_to_file(char const * filename, struct grid * src_grid,
free
(
points
);
}
void
interpret_grid_arg
(
struct
grid_config
*
grid_config
,
char
*
arg
,
char
*
str
)
{
int
interpret_grid_arg
(
struct
grid_config
*
grid_config
,
char
*
arg
,
char
*
str
)
{
if
(
arg
==
NULL
)
{
fprintf
(
stderr
,
"-%c argument is missing
\n
"
,
str
[
0
]);
exit
(
EXIT_FAILURE
)
;
return
1
;
}
switch
(
grid_config
->
type
)
{
...
...
@@ -581,7 +581,7 @@ void interpret_grid_arg(struct grid_config * grid_config, char * arg, char * str
grid_config
->
config
.
cube
.
n
=
atoi
(
arg
);
if
(
grid_config
->
config
.
cube
.
n
==
0
)
{
fprintf
(
stderr
,
"invalid N for cubed sphere %s grid
\n
"
,
str
);
exit
(
EXIT_FAILURE
)
;
return
1
;
}
break
;
case
CURVE
:
...
...
@@ -593,12 +593,37 @@ void interpret_grid_arg(struct grid_config * grid_config, char * arg, char * str
case
NONE
:
default:
fprintf
(
stderr
,
"invalid %s grid type
\n
"
,
str
);
exit
(
EXIT_FAILURE
)
;
return
1
;
}
return
0
;
}
void
print_help
(
char
*
command
)
{
fprintf
(
stderr
,
"Usage: %s -S src_grid_type -T tgt_grid_type "
"-s src_filename -t tgt_filename -w weight_filename "
"-o vtk_filename
\n\n
"
" grid_type can have the following values:
\n
"
" 'c', 'C': cubed sphere grid (instead of a "
"filename provide N, where
\n
"
" N = sqrt(n/6), with n being the "
"total number of cells
\n
"
" 'm', 'M': curvilinear grid
\n
"
" 'i', 'I': unstructured grid
\n
"
"
\n
"
"Example:
\n
"
" Configuration:
\n
"
" source grid type: unstructured
\n
"
" source grid file: src_grid.nc
\n
"
" target grid type: cubed sphere
\n
"
" target grid file: 100 (N instead of filename)
\n
"
" weight file name: weight_file.nc
\n
"
" vtk file name: weights.vtk
\n
"
" Command:
\n
"
" %s -S i -T c -s src_grid.nc -t 100 -w weight_file.nc "
"-o weights.vtk
\n
"
,
command
,
command
);
}
void
parse_arguments
(
int
argc
,
char
**
argv
,
struct
grid_config
*
src_grid_config
,
struct
grid_config
*
tgt_grid_config
,
...
...
@@ -610,6 +635,8 @@ void parse_arguments(int argc, char ** argv,
*
weight_filename
=
NULL
;
*
vtk_filename
=
NULL
;
int
error
=
0
;
char
*
src_arg
=
NULL
;
char
*
tgt_arg
=
NULL
;
...
...
@@ -660,32 +687,38 @@ void parse_arguments(int argc, char ** argv,
break
;
case
'?'
:
default:
fprintf
(
stderr
,
"Usage: %s -S src_grid_type -T tgt_grid_type "
"-s src_filename -t tgt_filename -w weight_filename "
"-o vtk_filename
\n\n
"
" grid_type can have the following values:
\n
"
" 'c', 'C': cubed sphere grid (instead of a "
"filename provide N, where
\n
"
" N = sqrt(n/6), with n being the "
"total number of cells
\n
"
" 'm', 'M': curvilinear grid
\n
"
" 'i', 'I': unstructured grid
\n
"
,
argv
[
0
]);
exit
(
EXIT_FAILURE
);
error
=
1
;
}
}
if
(
optind
<
argc
)
{
printf
(
"non-option ARGV-elements: "
);
while
(
optind
<
argc
)
printf
(
"%s "
,
argv
[
optind
++
]);
printf
(
"
\n
"
);
error
=
1
;
}
if
(
argc
==
1
)
error
=
1
;
if
(
*
weight_filename
==
NULL
)
{
if
((
!
error
)
&&
(
*
weight_filename
==
NULL
)
)
{
fputs
(
"weight_filename argument is missing
\n
"
,
stderr
);
e
xit
(
EXIT_FAILURE
)
;
e
rror
=
1
;
}
if
(
*
vtk_filename
==
NULL
)
{
if
((
!
error
)
&&
(
*
vtk_filename
==
NULL
)
)
{
fputs
(
"vtk_filename argument is missing
\n
"
,
stderr
);
e
xit
(
EXIT_FAILURE
)
;
e
rror
=
1
;
}
interpret_grid_arg
(
src_grid_config
,
src_arg
,
"source"
);
interpret_grid_arg
(
tgt_grid_config
,
tgt_arg
,
"target"
);
if
(
!
error
)
error
|=
interpret_grid_arg
(
src_grid_config
,
src_arg
,
"source"
);
if
(
!
error
)
error
|=
interpret_grid_arg
(
tgt_grid_config
,
tgt_arg
,
"target"
);
if
(
error
)
{
print_help
(
argv
[
0
]);
exit
(
EXIT_FAILURE
);
}
}
struct
grid
*
create_grid
(
struct
grid_config
grid_config
)
{
...
...
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