Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
16295b34
Commit
16295b34
authored
Oct 29, 2012
by
Uwe Schulzweida
Browse files
gridGenXvals/gridGenYvals: recheck xinc/yinc if fi(xfirst+(size-1)*inc) > last
parent
45e092a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/grid.c
View file @
16295b34
...
...
@@ -3,6 +3,7 @@
#endif
#include
<string.h>
#include
<float.h>
/* FLT_EPSILON */
#ifdef USE_MPI
#include
<mpi.h>
...
...
@@ -210,22 +211,27 @@ int gridSize(void)
void
gridGenXvals
(
int
xsize
,
double
xfirst
,
double
xlast
,
double
xinc
,
double
*
xvals
)
{
long
i
;
if
(
(
!
(
fabs
(
xinc
)
>
0
))
&&
xsize
>
1
)
if
(
xsize
>
1
)
{
if
(
xfirst
>=
xlast
)
if
(
(
fabs
(
xinc
)
>
0
)
&&
(
xlast
>
xfirst
)
&&
(
fabs
(
xinc
*
1000
-
NINT
(
xinc
*
1000
))
<=
FLT_EPSILON
)
)
{
while
(
xfirst
>=
xlast
)
xlast
+=
360
;
xinc
=
(
xlast
-
xfirst
)
/
(
xsize
);
if
(
(
xfirst
+
(
xsize
-
1
)
*
xinc
)
>
xlast
)
xinc
=
(
xlast
-
xfirst
)
/
(
xsize
-
1
);
}
else
{
xinc
=
(
xlast
-
xfirst
)
/
(
xsize
-
1
);
if
(
xfirst
>=
xlast
)
{
while
(
xfirst
>=
xlast
)
xlast
+=
360
;
xinc
=
(
xlast
-
xfirst
)
/
(
xsize
);
}
else
{
xinc
=
(
xlast
-
xfirst
)
/
(
xsize
-
1
);
}
}
}
for
(
i
=
0
;
i
<
xsize
;
i
++
)
for
(
int
i
=
0
;
i
<
xsize
;
++
i
)
xvals
[
i
]
=
xfirst
+
i
*
xinc
;
}
...
...
@@ -311,9 +317,13 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
}
}
/* else if ( gridtype == GRID_LONLAT || gridtype == GRID_GENERIC ) */
else
else
if
(
ysize
>
1
)
{
if
(
(
!
(
fabs
(
yinc
)
>
0
))
&&
ysize
>
1
)
if
(
(
fabs
(
yinc
)
>
0
)
&&
(
fabs
(
yinc
*
1000
-
NINT
(
yinc
*
1000
))
<=
FLT_EPSILON
)
)
{
if
(
(
yfirst
+
(
ysize
-
1
)
*
yinc
)
>
ylast
)
yinc
=
(
ylast
-
yfirst
)
/
(
ysize
-
1
);
}
else
{
if
(
IS_EQUAL
(
yfirst
,
ylast
)
&&
IS_NOT_EQUAL
(
yfirst
,
0
)
)
ylast
*=
-
1
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment