diff --git a/src/Afterburner.c b/src/Afterburner.c index 98bc46f8c50ab2a930a4a9484bf1a5555930f810..a40e705fa7a4f5b6263c857ebbbdda11cb95f50e 100644 --- a/src/Afterburner.c +++ b/src/Afterburner.c @@ -1,4 +1,4 @@ -#if defined (HAVE_CONFIG_H) +#if defined(HAVE_CONFIG_H) #include "config.h" #endif @@ -7,8 +7,7 @@ #if defined(CDO) #include "cdo.h" #include "cdo_int.h" -//#include "pstream.h" -#include "util.h" +#include "pstream_write.h" #endif #if defined(AFTERBURNER) @@ -78,6 +77,8 @@ static char *ifile = NULL; static char *ofile = NULL; static char *ofile2 = NULL; +static int ofileidx = 0; + static int specGridID = -1; static int gaussGridID = -1; static int iVertID = -1; @@ -1942,8 +1943,12 @@ void after_processing(struct Control *globs, struct Variable *vars) { int i; + //#if defined(_PSTREAM_H) + // globs->istreamID = streamOpenRead(cdoStreamName(0)); + //#else globs->istreamID = streamOpenRead(ifile); if ( globs->istreamID < 0 ) cdiError(globs->istreamID, "Open failed on %s", ifile); + //#endif globs->ivlistID = streamInqVlist(globs->istreamID); globs->taxisID = vlistInqTaxis(globs->ivlistID); @@ -1951,8 +1956,12 @@ void after_processing(struct Control *globs, struct Variable *vars) if ( globs->Mean != 2 ) { - globs->ostreamID = streamOpenWrite(ofile, ofiletype); +#if defined(_PSTREAM_WRITE_H) + globs->ostreamID = streamOpenWrite(cdoStreamName(ofileidx), ofiletype); +#else + globs->ostreamID = streamOpenWrite(ofile, ofiletype); if ( globs->ostreamID < 0 ) cdiError(globs->ostreamID, "Open failed on %s", ofile); +#endif if ( globs->Szip ) streamDefCompType(globs->ostreamID, COMPRESS_SZIP); @@ -2085,8 +2094,13 @@ void after_processing(struct Control *globs, struct Variable *vars) after_control(globs, vars); +#if defined(_PSTREAM_WRITE_H) + if ( globs->ostreamID2 != CDI_UNDEFID ) pstreamClose(globs->ostreamID2); + if ( globs->ostreamID != CDI_UNDEFID ) pstreamClose(globs->ostreamID); +#else if ( globs->ostreamID2 != CDI_UNDEFID ) streamClose(globs->ostreamID2); if ( globs->ostreamID != CDI_UNDEFID ) streamClose(globs->ostreamID); +#endif streamClose(globs->istreamID); if ( globs->rcoslat ) free(globs->rcoslat); @@ -2311,6 +2325,8 @@ void *Afterburner(void *argument) int streamCnt = cdoStreamCnt(); int nfiles = streamCnt - 1; + ofileidx = nfiles; + ifile = cdoStreamName(0)->args; ofile = cdoStreamName(nfiles)->args; diff --git a/src/Makefile.am b/src/Makefile.am index ac5742740257fef9c55357c195082de5632c14b7..04219dc3585802a12efc1c8b1e6cd70c679c2306 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -97,6 +97,7 @@ libcdo_la_SOURCES = \ process.h \ pstream.c \ pstream.h \ + pstream_write.h \ pstream_int.h \ pthread_debug.c \ pthread_debug.h \ diff --git a/src/Makefile.in b/src/Makefile.in index d9f2d7b532b061dec14aae3fd92efc0f9430e9cd..d10468d5a3a06bb73ef71b0b76db6a3ab9de0f19 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -560,10 +560,10 @@ libcdo_la_SOURCES = cdo_int.h compare.h cdo_pthread.c cdo_vlist.c \ nth_element.h operator_help.h par_io.c par_io.h percentiles.c \ percentiles.h pipe.c pipe.h pragma_omp_atomic_update.h \ printinfo.h process.c process.h pstream.c pstream.h \ - pstream_int.h pthread_debug.c pthread_debug.h readline.c \ - realtime.c remap.h remaplib.c remapsort.c remap_scrip_io.c \ - remap_search_reg2d.c remap_search_latbins.c remap_store_link.c \ - remap_store_link.h remap_store_link_cnsrv.c \ + pstream_write.h pstream_int.h pthread_debug.c pthread_debug.h \ + readline.c realtime.c remap.h remaplib.c remapsort.c \ + remap_scrip_io.c remap_search_reg2d.c remap_search_latbins.c \ + remap_store_link.c remap_store_link.h remap_store_link_cnsrv.c \ remap_store_link_cnsrv.h remap_conserv.c remap_conserv_scrip.c \ remap_distwgt_scrip.c remap_bicubic_scrip.c \ remap_bilinear_scrip.c stdnametable.c stdnametable.h \ diff --git a/src/afterburnerlib.c b/src/afterburnerlib.c index bc2091c3137083788c156631876a160991a639c0..c3b3fa7717c326feaf9ea6dfc183ed8ac1d368f0 100644 --- a/src/afterburnerlib.c +++ b/src/afterburnerlib.c @@ -3,6 +3,14 @@ #include "cdi.h" +#if defined(HAVE_CONFIG_H) +#include "config.h" +#if defined(CDO) +#include "cdo_int.h" +#include "pstream_write.h" +#endif +#endif + #include "error.h" #include "afterburner.h" #include "constants.h" diff --git a/src/pstream.h b/src/pstream.h index ff2e212548d041ca290d74ab475d31658a2b676a..4550d4b6cbf984a7a937cfb0d6ae973c4770fe84 100644 --- a/src/pstream.h +++ b/src/pstream.h @@ -18,9 +18,10 @@ #ifndef _PSTREAM_H #define _PSTREAM_H +#include "pstream_write.h" + #include <sys/types.h> /* off_t */ -#define streamOpenWrite pstreamOpenWrite #define streamOpenRead pstreamOpenRead #define streamOpenAppend pstreamOpenAppend #define streamClose pstreamClose @@ -29,16 +30,11 @@ #define streamInqByteorder pstreamInqByteorder #define streamInqVlist pstreamInqVlist -#define streamDefVlist pstreamDefVlist -#define streamDefTimestep pstreamDefTimestep #define streamInqTimestep pstreamInqTimestep -#define streamDefRecord pstreamDefRecord #define streamInqRecord pstreamInqRecord -#define streamWriteRecord pstreamWriteRecord -#define streamWriteRecordF pstreamWriteRecordF #define streamReadRecord pstreamReadRecord #define streamCopyRecord pstreamCopyRecord @@ -48,7 +44,6 @@ #define vlistCopyFlag cdoVlistCopyFlag -int pstreamOpenWrite(const argument_t *argument, int filetype); int pstreamOpenRead(const argument_t *argument); int pstreamOpenAppend(const argument_t *argument); void pstreamClose(int pstreamID); @@ -56,17 +51,12 @@ void pstreamClose(int pstreamID); int pstreamInqFiletype(int pstreamID); int pstreamInqByteorder(int pstreamID); -void pstreamDefVlist(int pstreamID, int vlistID); int pstreamInqVlist(int pstreamID); -void pstreamDefTimestep(int pstreamID, int tsID); int pstreamInqTimestep(int pstreamID, int tsID); -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 pstreamWriteRecordF(int pstreamID, float *data, int nmiss); void pstreamReadRecord(int pstreamID, double *data, int *nmiss); void pstreamCopyRecord(int pstreamIDdest, int pstreamIDsrc); @@ -74,6 +64,4 @@ void pstreamInqGRIBinfo(int pstreamID, int *intnum, float *fltnum, off_t *big void cdoVlistCopyFlag(int vlistID2, int vlistID1); - - #endif /* _PSTREAM_H */