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
cdo
Commits
e081697a
Commit
e081697a
authored
Mar 25, 2012
by
Uwe Schulzweida
Browse files
cdiwrite: added support for memtype float
parent
f043066e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/CDIwrite.c
View file @
e081697a
...
...
@@ -85,6 +85,7 @@ off_t filesize(const char *filename)
void
*
CDIwrite
(
void
*
argument
)
{
int
memtype
=
MEMTYPE_DOUBLE
;
int
nvars
=
10
,
nlevs
=
0
,
ntimesteps
=
30
;
char
*
defaultgrid
=
"global_.2"
;
int
operatorID
;
...
...
@@ -103,6 +104,7 @@ void *CDIwrite(void *argument)
double
tw
,
t0
;
double
*
levels
=
NULL
;
double
***
vars
=
NULL
;
float
*
farray
=
NULL
;
extern
int
timer_write
;
srand
(
seed
);
...
...
@@ -149,6 +151,8 @@ void *CDIwrite(void *argument)
}
}
if
(
memtype
==
MEMTYPE_FLOAT
)
farray
=
(
float
*
)
malloc
(
gridsize
*
sizeof
(
float
));
vlistID
=
vlistCreate
();
for
(
i
=
0
;
i
<
nvars
;
++
i
)
...
...
@@ -188,8 +192,17 @@ void *CDIwrite(void *argument)
for
(
levelID
=
0
;
levelID
<
nlevs
;
levelID
++
)
{
streamDefRecord
(
streamID
,
varID
,
levelID
);
streamWriteRecord
(
streamID
,
vars
[
varID
][
levelID
],
0
);
data_size
+=
gridsize
*
8
;
if
(
memtype
==
MEMTYPE_FLOAT
)
{
for
(
i
=
0
;
i
<
gridsize
;
++
i
)
farray
[
i
]
=
vars
[
varID
][
levelID
][
i
];
streamWriteRecordFloat
(
streamID
,
farray
,
0
);
data_size
+=
gridsize
*
4
;
}
else
{
streamWriteRecord
(
streamID
,
vars
[
varID
][
levelID
],
0
);
data_size
+=
gridsize
*
8
;
}
}
}
...
...
@@ -206,7 +219,10 @@ void *CDIwrite(void *argument)
tw
=
timer_val
(
timer_write
);
data_size
/=
1024
.
*
1024
.
*
1024
.;
cdoPrint
(
"Wrote %.1f GB of 64 bit floats to %s %s"
,
data_size
,
datatypestr
(
datatype
),
filetypestr
(
filetype
));
if
(
memtype
==
MEMTYPE_FLOAT
)
cdoPrint
(
"Wrote %.1f GB of 32 bit floats to %s %s"
,
data_size
,
datatypestr
(
datatype
),
filetypestr
(
filetype
));
else
cdoPrint
(
"Wrote %.1f GB of 64 bit floats to %s %s"
,
data_size
,
datatypestr
(
datatype
),
filetypestr
(
filetype
));
fsize
=
filesize
(
cdoStreamName
(
0
));
file_size
=
fsize
;
...
...
@@ -222,6 +238,8 @@ void *CDIwrite(void *argument)
}
free
(
vars
);
if
(
farray
)
free
(
farray
);
cdoFinish
();
return
(
0
);
...
...
src/cdo_int.h
View file @
e081697a
...
...
@@ -2,7 +2,7 @@
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-201
1
Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-201
2
Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
...
...
@@ -104,9 +104,11 @@ char *strdup(const char *s);
#define IX2D(y,x,nx) ((y)*(nx)+(x))
#define MEMTYPE_DOUBLE 1
#define MEMTYPE_FLOAT 2
#define CDO_EXP_LOCAL 1
#define CDO_EXP_REMOTE 2
#define
CDO_EXP_LOCAL 1
#define
CDO_EXP_REMOTE 2
enum
{
DATE_FIRST
,
DATE_LAST
,
DATE_MIDDLE
};
...
...
src/pstream.c
View file @
e081697a
...
...
@@ -1214,6 +1214,36 @@ void pstreamWriteRecord(int pstreamID, double *data, int nmiss)
}
void
pstreamWriteRecordFloat
(
int
pstreamID
,
float
*
data
,
int
nmiss
)
{
pstream_t
*
pstreamptr
;
if
(
data
==
NULL
)
cdoAbort
(
"Data pointer not allocated (pstreamWriteRecord)!"
);
pstreamptr
=
pstream_to_pointer
(
pstreamID
);
#if defined (HAVE_LIBPTHREAD)
if
(
pstreamptr
->
ispipe
)
{
cdoAbort
(
"pipeWriteRecord not implemented for memtype float!"
);
//pipeWriteRecord(pstreamptr, data, nmiss);
}
else
#endif
{
int
varID
=
pstreamptr
->
varID
;
timer_start
(
timer_write
);
/*
if ( pstreamptr->varlist )
if ( pstreamptr->varlist[varID].check_datarange )
pstreamCheckDatarange(pstreamptr, varID, data, nmiss);
*/
streamWriteRecordFloat
(
pstreamptr
->
fileID
,
data
,
nmiss
);
timer_stop
(
timer_write
);
}
}
int
pstreamInqTimestep
(
int
pstreamID
,
int
tsID
)
{
int
nrecs
=
0
;
...
...
src/pstream.h
View file @
e081697a
...
...
@@ -2,7 +2,7 @@
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-20
09
Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-20
12
Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
...
...
@@ -18,24 +18,25 @@
#ifndef _PSTREAM_H
#define _PSTREAM_H
#define streamOpenWrite pstreamOpenWrite
#define streamOpenRead pstreamOpenRead
#define streamOpenAppend pstreamOpenAppend
#define streamClose pstreamClose
#define streamOpenWrite
pstreamOpenWrite
#define streamOpenRead
pstreamOpenRead
#define streamOpenAppend
pstreamOpenAppend
#define streamClose
pstreamClose
#define streamInqFiletype pstreamInqFiletype
#define streamInqFiletype
pstreamInqFiletype
#define streamInqVlist pstreamInqVlist
#define streamDefVlist pstreamDefVlist
#define streamInqVlist
pstreamInqVlist
#define streamDefVlist
pstreamDefVlist
#define streamDefTimestep pstreamDefTimestep
#define streamInqTimestep pstreamInqTimestep
#define streamDefTimestep
pstreamDefTimestep
#define streamInqTimestep
pstreamInqTimestep
#define streamDefRecord pstreamDefRecord
#define streamInqRecord pstreamInqRecord
#define streamDefRecord
pstreamDefRecord
#define streamInqRecord
pstreamInqRecord
#define streamWriteRecord pstreamWriteRecord
#define streamReadRecord pstreamReadRecord
#define streamWriteRecord pstreamWriteRecord
#define streamWriteRecordFloat pstreamWriteRecordFloat
#define streamReadRecord pstreamReadRecord
/*
#define streamCopyRecord pstreamCopyRecord
*/
...
...
@@ -57,6 +58,7 @@ void pstreamDefRecord(int pstreamID, int varID, int levelID);
int
pstreamInqRecord
(
int
pstreamID
,
int
*
varID
,
int
*
levelID
);
void
pstreamWriteRecord
(
int
pstreamID
,
double
*
data
,
int
nmiss
);
void
pstreamWriteRecordFloat
(
int
pstreamID
,
float
*
data
,
int
nmiss
);
void
pstreamReadRecord
(
int
pstreamID
,
double
*
data
,
int
*
nmiss
);
void
pstreamCopyRecord
(
int
pstreamIDdest
,
int
pstreamIDsrc
);
...
...
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