pipe.h 2.01 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
4
/*
  This file is part of CDO. CDO is a collection of Operators to
  manipulate and analyse Climate model Data.

Uwe Schulzweida's avatar
Uwe Schulzweida committed
5
  Copyright (C) 2003-2017 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
6
7
8
9
10
11
12
13
14
15
16
17
  See COPYING file for copying and redistribution conditions.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 2 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
*/

18
19
#ifndef PIPE_H
#define PIPE_H
Uwe Schulzweida's avatar
Uwe Schulzweida committed
20

Uwe Schulzweida's avatar
Uwe Schulzweida committed
21
#if defined(HAVE_CONFIG_H)
22
#include "config.h"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
23
24
#endif

25
#include <stdbool.h>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
26
#include <sys/types.h>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
27

Uwe Schulzweida's avatar
Uwe Schulzweida committed
28
#if defined(HAVE_LIBPTHREAD)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
29
30

#include <pthread.h>
Uwe Schulzweida's avatar
cleanup    
Uwe Schulzweida committed
31
#include "pthread_debug.h"
32
#include "pstream.h"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
33
34
35

#endif

Uwe Schulzweida's avatar
Uwe Schulzweida committed
36
#if defined(HAVE_LIBPTHREAD)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
37

Oliver Heidmann's avatar
Oliver Heidmann committed
38
39
40
41
42
43
44
45
46
struct pipe_s
{
  bool EOP;
  bool usedata;
  short hasdata;
  int nrecs;
  int varID, levelID;
  int recIDr, recIDw, tsIDr, tsIDw;
  int nmiss;
47
  double *data;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
48
  pstream_t *pstreamptr_in;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
49
  /* unsigned long */ off_t nvals;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
50
51
52
53
54
55
  pthread_mutex_t *mutex;
  pthread_cond_t *tsDef, *tsInq, *vlistDef, *isclosed;
  pthread_cond_t *recDef, *recInq;
  pthread_cond_t *writeCond, *readCond;
};

Uwe Schulzweida's avatar
Uwe Schulzweida committed
56
typedef struct pipe_s pipe_t;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
57

Uwe Schulzweida's avatar
Uwe Schulzweida committed
58
pipe_t *pipeNew(void);
Oliver Heidmann's avatar
Oliver Heidmann committed
59
void pipeDelete(pipe_t *pipe);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
60

Oliver Heidmann's avatar
Oliver Heidmann committed
61
void pipeDebug(int debug);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
62

Oliver Heidmann's avatar
Oliver Heidmann committed
63
64
void pipeDefVlist(pstream_t *pstreamptr, int vlistID);
int pipeInqVlist(pstream_t *pstreamptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
65

Oliver Heidmann's avatar
Oliver Heidmann committed
66
67
void pipeDefTimestep(pstream_t *pstreamptr, int tsID);
int pipeInqTimestep(pstream_t *pstreamptr, int tsID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
68

Oliver Heidmann's avatar
Oliver Heidmann committed
69
70
void pipeDefRecord(pstream_t *pstreamptr, int varID, int levelID);
int pipeInqRecord(pstream_t *pstreamptr, int *varID, int *levelID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
71

Oliver Heidmann's avatar
Oliver Heidmann committed
72
73
74
void pipeReadRecord(pstream_t *pstreamptr, double *data, int *nmiss);
void pipeWriteRecord(pstream_t *pstreamptr, double *data, int nmiss);
void pipeCopyRecord(pstream_t *pstreamptr_dest, pstream_t *pstreamptr_src);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
75
76
77

#endif

Oliver Heidmann's avatar
Oliver Heidmann committed
78
#endif /* PIPE_H */