Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
a0d4d519
Commit
a0d4d519
authored
Oct 21, 2013
by
Uwe Schulzweida
Browse files
splitmon: added optional parameter to set the format string for the month
parent
593e5f16
Changes
6
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
a0d4d519
...
...
@@ -5,6 +5,7 @@
2013-10-21 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* splitmon: added optional parameter to set the format string for the month [Feature #4131]
* Sort: added support for multi level variables (bug fix) [report: Irina Fast]
2013-10-18 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
...
...
NEWS
View file @
a0d4d519
...
...
@@ -6,6 +6,7 @@ Version 1.6.2 (27 September 2013):
New features:
* select: added support for key >timestep_of_year<
* mastrfu: added missing value support
* splitmon: added optional parameter to set the format string for the month
Fixed bugs:
* selyear: wrong result for negative years [Bug #3836]
...
...
OPERATORS
View file @
a0d4d519
...
...
@@ -54,9 +54,9 @@ Operator catalog:
Split splittabnum Split parameter table numbers
Splittime splithour Split hours
Splittime splitday Split days
Splittime splitmon Split months
Splittime splitseas Split seasons
Splittime splityear Split years
Splittime splitmon Split months
Splitsel splitsel Split time selection
-------------------------------------------------------------
Selection
...
...
doc/tex/mod/Splittime
View file @
a0d4d519
...
...
@@ -5,7 +5,7 @@
@Section = File operations
@Class = File operation
@Arguments = ifile obase
@Operators = splithour splitday
splitmon
splitseas splityear
@Operators = splithour splitday splitseas splityear
splitmon
@BeginDescription
This module splits @file{ifile} into timesteps pieces. The output files will be named
...
...
@@ -37,6 +37,7 @@ Splits a file into pieces, one for each different day.
@BeginOperator_splitmon
@Title = Split months
@Parameter = [format]
@BeginDescription
Splits a file into pieces, one for each different month.
...
...
@@ -65,6 +66,12 @@ Splits a file into pieces, one for each different year.
@EndOperator
@BeginParameter
@Item = format
STRING C-style format for strftime() (e.g. \%B for the full month name)
@EndParameter
@BeginEnvironment
@Item = CDO_FILE_SUFFIX
This environment variable can be used to set the default file suffix. This suffix will be
...
...
src/Splittime.c
View file @
a0d4d519
...
...
@@ -30,9 +30,29 @@
#include
"pstream.h"
#include
"util.h"
#include
<time.h>
#define MAX_STREAMS 32
struct
tm
datetime_to_tm
(
int
date
,
int
time
)
{
int
year
,
month
,
day
,
hour
,
minute
,
second
;
cdiDecodeDate
(
date
,
&
year
,
&
month
,
&
day
);
cdiDecodeTime
(
time
,
&
hour
,
&
minute
,
&
second
);
struct
tm
stime
;
memset
(
&
stime
,
0
,
sizeof
(
struct
tm
));
stime
.
tm_sec
=
second
;
stime
.
tm_min
=
minute
;
stime
.
tm_hour
=
hour
;
stime
.
tm_mday
=
day
;
stime
.
tm_mon
=
month
-
1
;
stime
.
tm_year
=
year
-
1900
;
return
stime
;
}
void
*
Splittime
(
void
*
argument
)
{
int
SPLITHOUR
,
SPLITDAY
,
SPLITMON
,
SPLITSEAS
;
...
...
@@ -62,6 +82,7 @@ void *Splittime(void *argument)
field_t
**
vars
=
NULL
;
int
season_start
;
const
char
*
seas_name
[
4
];
const
char
*
format
=
NULL
;
cdoInitialize
(
argument
);
...
...
@@ -76,6 +97,11 @@ void *Splittime(void *argument)
if
(
UNCHANGED_RECORD
)
lcopy
=
TRUE
;
if
(
operatorID
==
SPLITMON
)
{
if
(
operatorArgc
()
==
1
)
format
=
operatorArgv
()[
0
];
}
season_start
=
get_season_start
();
get_season_name
(
seas_name
);
...
...
@@ -188,9 +214,22 @@ void *Splittime(void *argument)
}
else
{
sprintf
(
filename
+
nchars
,
"%02d"
,
index
);
char
oformat
[
32
];
strcpy
(
oformat
,
"%02d"
);
if
(
operatorID
==
SPLITMON
&&
format
)
{
size_t
slen
;
char
sbuf
[
32
];
struct
tm
stime
=
datetime_to_tm
(
vdate
,
vtime
);
slen
=
strftime
(
sbuf
,
32
,
format
,
&
stime
);
if
(
slen
)
strcpy
(
oformat
,
sbuf
);
}
sprintf
(
filename
+
nchars
,
oformat
,
index
);
if
(
filesuffix
[
0
]
)
sprintf
(
filename
+
nchars
+
2
,
"%s"
,
filesuffix
);
sprintf
(
filename
+
nchars
+
strlen
(
oformat
)
,
"%s"
,
filesuffix
);
}
if
(
cdoVerbose
)
cdoPrint
(
"create file %s"
,
filename
);
...
...
src/operator_help.h
View file @
a0d4d519
...
...
@@ -329,11 +329,12 @@ static char *SplitHelp[] = {
static
char
*
SplittimeHelp
[]
=
{
"NAME"
,
" splithour, splitday,
splitmon,
splitseas, splityear - "
,
" splithour, splitday, splitseas, splityear
, splitmon
- "
,
" Split timesteps of a dataset"
,
""
,
"SYNOPSIS"
,
" <operator> ifile obase"
,
" splitmon[,format] ifile obase"
,
""
,
"DESCRIPTION"
,
" This module splits ifile into timesteps pieces. The output files will be named"
,
...
...
@@ -347,15 +348,18 @@ static char *SplittimeHelp[] = {
" splitday Split days"
,
" Splits a file into pieces, one for each different day."
,
" xxx will have two digits with the day."
,
" splitmon Split months"
,
" Splits a file into pieces, one for each different month."
,
" xxx will have two digits with the month."
,
" splitseas Split seasons"
,
" Splits a file into pieces, one for each different season."
,
" xxx will have three characters with the season."
,
" splityear Split years"
,
" Splits a file into pieces, one for each different year."
,
" xxx will have four digits with the year."
,
" splitmon Split months"
,
" Splits a file into pieces, one for each different month."
,
" xxx will have two digits with the month."
,
""
,
"PARAMETER"
,
" format STRING C-style format for strftime() (e.g. %B for the full month name)"
,
""
,
"ENVIRONMENT"
,
" CDO_FILE_SUFFIX"
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment