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
libcdi
Commits
a7bc5366
Commit
a7bc5366
authored
Aug 06, 2014
by
Thomas Jahns
🤸
Browse files
Merge repeated Fortran record copy code.
parent
aa7a09f0
Changes
9
Hide whitespace changes
Inline
Side-by-side
.gitattributes
View file @
a7bc5366
...
...
@@ -279,6 +279,8 @@ src/stream_cgribex.c -text
src/stream_cgribex.h -text
src/stream_ext.c -text
src/stream_ext.h -text
src/stream_fcommon.c -text
src/stream_fcommon.h -text
src/stream_grb.c -text
src/stream_grb.h -text
src/stream_gribapi.c -text
...
...
src/Makefile.am
View file @
a7bc5366
...
...
@@ -77,6 +77,8 @@ libcdi_la_SOURCES = \
stream_history.c
\
stream_ieg.c
\
stream_ieg.h
\
stream_fcommon.c
\
stream_fcommon.h
\
cdi_int.c
\
cdi_int.h
\
stream_record.c
\
...
...
src/Makefile.in
View file @
a7bc5366
...
...
@@ -150,10 +150,11 @@ am_libcdi_la_OBJECTS = basetime.lo binary.lo calendar.lo cdf.lo \
institution.lo model.lo namespace.lo serialize.lo
\
resource_handle.lo servicelib.lo stream_cdf.lo
\
stream_cgribex.lo stream_ext.lo stream_grb.lo
\
stream_gribapi.lo stream_history.lo stream_ieg.lo cdi_int.lo
\
stream_record.lo stream_srv.lo stream_var.lo table.lo taxis.lo
\
timebase.lo tsteps.lo util.lo varscan.lo version.lo vlist.lo
\
vlist_att.lo vlist_var.lo zaxis.lo stream.lo swap.lo
stream_gribapi.lo stream_history.lo stream_ieg.lo
\
stream_fcommon.lo cdi_int.lo stream_record.lo stream_srv.lo
\
stream_var.lo table.lo taxis.lo timebase.lo tsteps.lo util.lo
\
varscan.lo version.lo vlist.lo vlist_att.lo vlist_var.lo
\
zaxis.lo stream.lo swap.lo
libcdi_la_OBJECTS
=
$(am_libcdi_la_OBJECTS)
AM_V_lt
=
$
(
am__v_lt_@AM_V@
)
am__v_lt_
=
$
(
am__v_lt_@AM_DEFAULT_V@
)
...
...
@@ -497,6 +498,8 @@ libcdi_la_SOURCES = \
stream_history.c
\
stream_ieg.c
\
stream_ieg.h
\
stream_fcommon.c
\
stream_fcommon.h
\
cdi_int.c
\
cdi_int.h
\
stream_record.c
\
...
...
@@ -730,6 +733,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/stream_cdf.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/stream_cgribex.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/stream_ext.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/stream_fcommon.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/stream_grb.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/stream_gribapi.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/stream_history.Plo@am__quote@
...
...
src/make_cdilib
View file @
a7bc5366
...
...
@@ -119,6 +119,7 @@ c="dmemory.c \
stream_history.c
\
stream_cgribex.c
\
stream_gribapi.c
\
stream_fcommon.c
\
stream_grb.c
\
stream_srv.c
\
stream_ext.c
\
...
...
@@ -144,7 +145,7 @@ h="cdi_limits.h resource_handle.h taxis.h dtypes.h file.h service.h extra.h \
tablepar.h table.h gaussgrid.h grid.h zaxis.h varscan.h binary.h swap.h
\
service.h stream_srv.h stream_ext.h stream_ieg.h cdf_int.h
\
cdf.h vlist.h vlist_var.h vlist_att.h model.h institution.h
\
resource_unpack.h serialize.h"
resource_unpack.h serialize.h
stream_fcommon.h
"
#cat $h >> ${PROG}
#cat $c | grep -v '#include' | grep -v '# include' >> ${PROG}
...
...
src/stream_ext.c
View file @
a7bc5366
...
...
@@ -12,6 +12,7 @@
#include
"cdi.h"
#include
"cdi_int.h"
#include
"stream_ext.h"
#include
"stream_fcommon.h"
#include
"varscan.h"
#include
"datetime.h"
#include
"extra.h"
...
...
@@ -166,28 +167,7 @@ void extReadRecord(stream_t *streamptr, double *data, int *nmiss)
void
extCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
)
{
int
fileID1
=
streamptr1
->
fileID
;
int
fileID2
=
streamptr2
->
fileID
;
int
tsID
=
streamptr1
->
curTsID
;
int
vrecID
=
streamptr1
->
tsteps
[
tsID
].
curRecID
;
int
recID
=
streamptr1
->
tsteps
[
tsID
].
recIDs
[
vrecID
];
off_t
recpos
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
position
;
size_t
recsize
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
size
;
if
(
fileSetPos
(
fileID1
,
recpos
,
SEEK_SET
)
!=
0
)
Error
(
"Cannot seek input file for EXTRA record copy!"
);
char
*
buffer
=
xmalloc
(
recsize
);
if
(
fileRead
(
fileID1
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to read record from EXTRA file for copying!"
);
if
(
fileWrite
(
fileID2
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to write record to EXTRA file when copying!"
);
free
(
buffer
);
streamFCopyRecord
(
streamptr2
,
streamptr1
,
"EXTRA"
);
}
...
...
src/stream_fcommon.c
0 → 100644
View file @
a7bc5366
#include
<stdlib.h>
#include
"dmemory.h"
#include
"file.h"
#include
"stream_fcommon.h"
void
streamFCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
,
const
char
*
container_name
)
{
int
fileID1
=
streamptr1
->
fileID
;
int
fileID2
=
streamptr2
->
fileID
;
int
tsID
=
streamptr1
->
curTsID
;
int
vrecID
=
streamptr1
->
tsteps
[
tsID
].
curRecID
;
int
recID
=
streamptr1
->
tsteps
[
tsID
].
recIDs
[
vrecID
];
off_t
recpos
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
position
;
size_t
recsize
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
size
;
if
(
fileSetPos
(
fileID1
,
recpos
,
SEEK_SET
)
!=
0
)
Error
(
"Cannot seek input file for %s record copy!"
,
container_name
);
char
*
buffer
=
xmalloc
(
recsize
);
if
(
fileRead
(
fileID1
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to read record from %s file for copying!"
,
container_name
);
if
(
fileWrite
(
fileID2
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to write record to %s file when copying!"
,
container_name
);
free
(
buffer
);
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
src/stream_fcommon.h
0 → 100644
View file @
a7bc5366
#ifndef STREAM_FCOMMON_H
#define STREAM_FCOMMON_H
#include
"cdi_int.h"
void
streamFCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
,
const
char
*
container_name
);
#endif
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
src/stream_ieg.c
View file @
a7bc5366
...
...
@@ -17,6 +17,7 @@
#include
"varscan.h"
#include
"datetime.h"
#include
"ieg.h"
#include
"stream_fcommon.h"
#include
"stream_ieg.h"
#include
"vlist.h"
...
...
@@ -527,27 +528,7 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
void
iegCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
)
{
int
fileID1
=
streamptr1
->
fileID
;
int
fileID2
=
streamptr2
->
fileID
;
int
tsID
=
streamptr1
->
curTsID
;
int
vrecID
=
streamptr1
->
tsteps
[
tsID
].
curRecID
;
int
recID
=
streamptr1
->
tsteps
[
tsID
].
recIDs
[
vrecID
];
off_t
recpos
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
position
;
size_t
recsize
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
size
;
if
(
fileSetPos
(
fileID1
,
recpos
,
SEEK_SET
)
!=
0
)
Error
(
"Cannot seek input file for IEG record copy!"
);
char
*
buffer
=
xmalloc
(
recsize
);
if
(
fileRead
(
fileID1
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to read record from IEG file for copying!"
);
if
(
fileWrite
(
fileID2
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to write record to IEG file when copying!"
);
free
(
buffer
);
streamFCopyRecord
(
streamptr2
,
streamptr1
,
"IEG"
);
}
...
...
src/stream_srv.c
View file @
a7bc5366
...
...
@@ -15,6 +15,7 @@
#include
"varscan.h"
#include
"datetime.h"
#include
"service.h"
#include
"stream_fcommon.h"
#include
"stream_srv.h"
#include
"vlist.h"
...
...
@@ -145,27 +146,7 @@ void srvReadRecord(stream_t *streamptr, double *data, int *nmiss)
void
srvCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
)
{
int
fileID1
=
streamptr1
->
fileID
;
int
fileID2
=
streamptr2
->
fileID
;
int
tsID
=
streamptr1
->
curTsID
;
int
vrecID
=
streamptr1
->
tsteps
[
tsID
].
curRecID
;
int
recID
=
streamptr1
->
tsteps
[
tsID
].
recIDs
[
vrecID
];
off_t
recpos
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
position
;
size_t
recsize
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
size
;
if
(
fileSetPos
(
fileID1
,
recpos
,
SEEK_SET
)
!=
0
)
Error
(
"Cannot seek input file for SRV record copy!"
);
char
*
buffer
=
xmalloc
(
recsize
);
if
(
fileRead
(
fileID1
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to read record from SRV file for copying!"
);
if
(
fileWrite
(
fileID2
,
buffer
,
recsize
)
!=
recsize
)
Error
(
"Failed to write record to SRV file when copying!"
);
free
(
buffer
);
streamFCopyRecord
(
streamptr2
,
streamptr1
,
"SRV"
);
}
...
...
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