Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
mpim-sw
libcdi
Commits
6855506c
Commit
6855506c
authored
8 years ago
by
Thomas Jahns
Committed by
Sergey Kosukhin
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Extract calendar test 1.
parent
0261c65b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
src/julian_date.c
+0
-94
0 additions, 94 deletions
src/julian_date.c
tests/Makefile.am
+5
-1
5 additions, 1 deletion
tests/Makefile.am
tests/calendar_test1.c
+107
-0
107 additions, 0 deletions
tests/calendar_test1.c
with
113 additions
and
95 deletions
.gitignore
+
1
−
0
View file @
6855506c
...
...
@@ -102,6 +102,7 @@ Makefile
/examples/pio/collectData2003
/examples/pio/collectDataNStreams
/examples/pio/compareResourcesArray
/tests/calendar_test1
/tests/cksum_read
/tests/cksum_verify
/tests/cksum_write
...
...
This diff is collapsed.
Click to expand it.
src/julian_date.c
+
0
−
94
View file @
6855506c
...
...
@@ -232,100 +232,6 @@ julianDate_to_seconds(JulianDate julianDate)
return
julianDate
.
julianDay
*
86400
.
0
+
julianDate
.
secondOfDay
;
}
#ifdef TEST
int
main
(
void
)
{
int
calendar
=
CALENDAR_STANDARD
;
int
j
=
0
;
// 1 - Check valid range of years
{
int
nmin
=
11000
;
int
vdate0
=
-
80001201
;
int
vtime0
=
120500
;
printf
(
"start time: %8d %4d
\n
"
,
vdate0
,
vtime0
);
CdiDateTime
dt
=
cdiDateTime_set
(
vdate0
,
vtime0
);
for
(
int
i
=
0
;
i
<
nmin
;
i
++
)
{
JulianDate
julianDate
=
julianDate_encode
(
calendar
,
dt
);
dt
=
julianDate_decode
(
calendar
,
julianDate
);
int
vdate
=
(
int
)
cdiDate_get
(
dt
.
date
);
int
vtime
=
cdiTime_get
(
dt
.
time
);
if
(
vdate0
!=
vdate
||
vtime0
!=
vtime
)
printf
(
"%4d %8d %4d %8d %4d %9d %g
\n
"
,
++
j
,
vdate0
,
vtime0
,
vdate
,
vtime
,
(
int
)
julianDate
.
julianDay
,
julianDate
.
secondOfDay
);
dt
.
date
.
year
++
;
julianDate
=
julianDate_encode
(
calendar
,
dt
);
dt
=
julianDate_decode
(
calendar
,
julianDate
);
vdate0
=
(
int
)
cdiDate_get
(
dt
.
date
);
vtime0
=
cdiTime_get
(
dt
.
time
);
}
printf
(
"stop time: %8d %4d
\n
"
,
vdate0
,
vtime0
);
}
// 2 - Check time increment of one minute
{
int
nmin
=
120000
;
int
ijulinc
=
60
;
int
vdate0
=
20001201
;
int
vtime0
=
0
;
printf
(
"start time: %8d %4d
\n
"
,
vdate0
,
vtime0
);
CdiDateTime
dt
=
cdiDateTime_set
(
vdate0
,
vtime0
);
JulianDate
julianDate
=
julianDate_encode
(
calendar
,
dt
);
for
(
int
i
=
0
;
i
<
nmin
;
i
++
)
{
int
year
,
mon
,
day
,
hour
,
minute
,
second
;
cdiDecodeDate
(
vdate0
,
&
year
,
&
mon
,
&
day
);
cdiDecodeTime
(
vtime0
,
&
hour
,
&
minute
,
&
second
);
if
(
++
minute
>=
60
)
{
minute
=
0
;
if
(
++
hour
>=
24
)
{
hour
=
0
;
if
(
++
day
>=
32
)
{
day
=
1
;
if
(
++
mon
>=
13
)
{
mon
=
1
;
year
++
;
}
}
}
}
vdate0
=
cdiEncodeDate
(
year
,
mon
,
day
);
vtime0
=
cdiEncodeTime
(
hour
,
minute
,
second
);
julianDate
=
julianDate_add_seconds
(
julianDate
,
ijulinc
);
dt
=
julianDate_decode
(
calendar
,
julianDate
);
int
vdate
=
(
int
)
cdiDate_get
(
dt
.
date
);
int
vtime
=
cdiTime_get
(
dt
.
time
);
if
(
vdate0
!=
vdate
||
vtime0
!=
vtime
)
printf
(
"%4d %8d %4d %8d %4d %9d %g
\n
"
,
++
j
,
vdate0
,
vtime0
,
vdate
,
vtime
,
(
int
)
julianDate
.
julianDay
,
julianDate
.
secondOfDay
);
}
printf
(
"stop time: %8d %4d
\n
"
,
vdate0
,
vtime0
);
}
return
0
;
}
#endif
#ifdef TEST2
int
main
(
void
)
...
...
This diff is collapsed.
Click to expand it.
tests/Makefile.am
+
5
−
1
View file @
6855506c
...
...
@@ -7,6 +7,7 @@ TESTS = cksum_verify \
test_cksum_nc test_cksum_extra
\
test_cksum_service test_cksum_nc2 test_cksum_nc4 test_cksum_ieg
\
test_chunk_cksum
\
calendar_test1
\
pio_write_run pio_cksum_mpinonb pio_cksum_fpguard
\
pio_cksum_asynch pio_cksum_writer
\
pio_cksum_cdf
\
...
...
@@ -20,7 +21,9 @@ TESTS = cksum_verify \
#test_cdf_const: deactivated (depends on app/cdi)
check_PROGRAMS
=
cksum_verify test_grib cksum_write cksum_read pio_write
\
check_PROGRAMS
=
cksum_verify test_grib cksum_write cksum_read
\
calendar_test1
\
pio_write
\
test_resource_copy cksum_write_chunk pio_write_deco2d test_table
\
test_byteswap
...
...
@@ -37,6 +40,7 @@ cksum_read_SOURCES = cksum_read.c \
var_cksum.c var_cksum.h
\
stream_cksum.c stream_cksum.h
\
ensure_array_size.h ensure_array_size.c
calendar_test1_SOURCES
=
calendar_test1.c
pio_write_SOURCES
=
pio_write.c pio_write.h simple_model.c
\
simple_model_helper.h simple_model_helper.c
\
pio_write_setup_grid.h pio_write_setup_grid.c
...
...
This diff is collapsed.
Click to expand it.
tests/calendar_test1.c
0 → 100644
+
107
−
0
View file @
6855506c
#include
<stdio.h>
#include
<stdlib.h>
#include
"cdi.h"
#include
"julian_date.h"
int
main
(
void
)
{
int
calendar
=
CALENDAR_STANDARD
;
int
j
=
0
;
// 1 - Check valid range of years
{
int
nmin
=
11000
;
int
vdate0
=
-
80001201
;
int
vtime0
=
120500
;
// printf("start time: %8d %4d\n", vdate0, vtime0);
CdiDateTime
dt
=
cdiDateTime_set
(
vdate0
,
vtime0
);
for
(
int
i
=
0
;
i
<
nmin
;
i
++
)
{
JulianDate
julianDate
=
julianDate_encode
(
calendar
,
dt
);
dt
=
julianDate_decode
(
calendar
,
julianDate
);
int
vdate
=
(
int
)
cdiDate_get
(
dt
.
date
);
int
vtime
=
cdiTime_get
(
dt
.
time
);
if
(
vdate0
!=
vdate
||
vtime0
!=
vtime
)
fprintf
(
stderr
,
"%4d %8d %4d %8d %4d %9d %g
\n
"
,
++
j
,
vdate0
,
vtime0
,
vdate
,
vtime
,
(
int
)
julianDate
.
julianDay
,
julianDate
.
secondOfDay
);
dt
.
date
.
year
++
;
julianDate
=
julianDate_encode
(
calendar
,
dt
);
dt
=
julianDate_decode
(
calendar
,
julianDate
);
vdate0
=
(
int
)
cdiDate_get
(
dt
.
date
);
vtime0
=
cdiTime_get
(
dt
.
time
);
}
// printf("stop time: %8d %4d\n", vdate0, vtime0);
}
// 2 - Check time increment of one minute
{
int
nmin
=
120000
;
int
ijulinc
=
60
;
int
vdate0
=
20001201
;
int
vtime0
=
0
;
// printf("start time: %8d %4d\n", vdate0, vtime0);
CdiDateTime
dt
=
cdiDateTime_set
(
vdate0
,
vtime0
);
JulianDate
julianDate
=
julianDate_encode
(
calendar
,
dt
);
for
(
int
i
=
0
;
i
<
nmin
;
i
++
)
{
int
year
,
mon
,
day
,
hour
,
minute
,
second
;
cdiDecodeDate
(
vdate0
,
&
year
,
&
mon
,
&
day
);
cdiDecodeTime
(
vtime0
,
&
hour
,
&
minute
,
&
second
);
if
(
++
minute
>=
60
)
{
minute
=
0
;
if
(
++
hour
>=
24
)
{
hour
=
0
;
if
(
++
day
>=
32
)
{
day
=
1
;
if
(
++
mon
>=
13
)
{
mon
=
1
;
year
++
;
}
}
}
}
vdate0
=
cdiEncodeDate
(
year
,
mon
,
day
);
vtime0
=
cdiEncodeTime
(
hour
,
minute
,
second
);
julianDate
=
julianDate_add_seconds
(
julianDate
,
ijulinc
);
dt
=
julianDate_decode
(
calendar
,
julianDate
);
int
vdate
=
(
int
)
cdiDate_get
(
dt
.
date
);
int
vtime
=
cdiTime_get
(
dt
.
time
);
if
(
vdate0
!=
vdate
||
vtime0
!=
vtime
)
fprintf
(
stderr
,
"%4d %8d %4d %8d %4d %9d %g
\n
"
,
++
j
,
vdate0
,
vtime0
,
vdate
,
vtime
,
(
int
)
julianDate
.
julianDay
,
julianDate
.
secondOfDay
);
}
// printf("stop time: %8d %4d\n", vdate0, vtime0);
}
return
j
==
0
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
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