Commit f09ccad2 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

set units to Pa if changing zaxis to pressure (bug fix)

parent 86436056
2009-11-12 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* set units to "Pa" if changing zaxis to "pressure" (bug fix) [report: ]
2009-11-01 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added support for GRIB2 JPEG compression
......
......@@ -21,6 +21,17 @@ typedef struct {
read_arg_t;
typedef struct {
int varID, levelID, nmiss;
double *array;
int array_size;
int recID, nrecs;
read_arg_t read_arg;
void *iothread;
}
par_io_t;
typedef struct work_st{
void (*routine) (void*);
void *arg;
......@@ -32,7 +43,6 @@ typedef struct {
double *array;
int array_size;
int recID, nrecs;
read_arg_t read_arg;
int shutdown;
int used;
work_t *work;
......@@ -46,23 +56,12 @@ typedef struct {
} iothread_t;
typedef struct {
int varID, levelID, nmiss;
double *array;
int array_size;
int recID, nrecs;
read_arg_t read_arg;
iothread_t *iothread;
}
par_io_t;
void readRecord(void *arg)
{
read_arg_t *read_arg = (read_arg_t *) arg;
int streamID;
int *varID, *levelID, *nmiss;
double *array;
read_arg_t *read_arg = (read_arg_t *) arg;
streamID = read_arg->streamID;
varID = read_arg->varID;
......@@ -153,7 +152,7 @@ iothread_t *create_iothread()
pthread_attr_setdetachstate(&(iothread->attr), PTHREAD_CREATE_JOINABLE);
iothread->shutdown = 0;
iothread->used = 0;
iothread->used = 0;
//make thread
if ( pthread_create(&(iothread->thrID), &(iothread->attr), do_work, (void *)iothread) )
......@@ -168,8 +167,10 @@ iothread_t *create_iothread()
#if defined (HAVE_LIBPTHREAD)
void check_iothread(iothread_t *iothread)
void check_iothread(void *p)
{
iothread_t *iothread = (iothread_t *) p;
pthread_mutex_lock(&(iothread->lock));
while ( iothread->used == 1 )
......@@ -186,8 +187,9 @@ void check_iothread(iothread_t *iothread)
#if defined (HAVE_LIBPTHREAD)
typedef void (*dispatch_fn)(void *);
void dispatch(iothread_t *iothread, dispatch_fn dispatch_to_here, void *arg)
void dispatch(void *p, dispatch_fn dispatch_to_here, void *arg)
{
iothread_t *iothread = (iothread_t *) p;
work_t *work;
//make a work element.
......@@ -203,26 +205,31 @@ void dispatch(iothread_t *iothread, dispatch_fn dispatch_to_here, void *arg)
pthread_mutex_lock(&(iothread->lock));
if ( iothread->used == 0 )
{
iothread->work = work;
pthread_cond_signal(&(iothread->not_empty));
}
if ( iothread->used == 1 )
fprintf(stderr, "dispatch: Internal synchronization problem!\n");
iothread->work = work;
iothread->used = 1;
pthread_cond_signal(&(iothread->not_empty));
pthread_mutex_unlock(&(iothread->lock));
}
#endif
#if defined (HAVE_LIBPTHREAD)
void destroy_iothread(iothread_t *iothread)
void destroy_iothread(void *p)
{
iothread_t *iothread = (iothread_t *) p;
int status;
pthread_mutex_lock(&(iothread->lock));
if ( iothread->used == 1 )
fprintf(stderr, "destroy_iothread: Internal synchronization problem!\n");
iothread->shutdown = 1;
pthread_cond_signal(&(iothread->not_empty));
pthread_mutex_unlock(&(iothread->lock));
status = pthread_join(iothread->thrID, NULL);
......@@ -237,7 +244,7 @@ void destroy_iothread(iothread_t *iothread)
pthread_cond_destroy(&(iothread->not_empty));
pthread_attr_destroy(&(iothread->attr));
//free(iothread);
free(iothread);
}
#endif
......
......@@ -1880,6 +1880,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
{
zaxistype = ZAXIS_PRESSURE;
zaxisChangeType(zaxisID, zaxistype);
zaxisDefUnits(zaxisID, "Pa");
}
ISEC2_NumVCP = 0;
......@@ -1951,7 +1952,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
Warning(func, "Pressure level of %f Pa is below zero!", level);
zaxisInqUnits(zaxisID, units);
if ( memcmp(units, "Pa", 3) != 0 ) level *= 100;
if ( memcmp(units, "Pa", 2) != 0 ) level *= 100;
ilevel = (int) level;
if ( level < 32768 && (level < 100 || modf(level/100, &dum) > 0) )
......
......@@ -1922,6 +1922,7 @@ void gribapiDefLevel(grib_handle *gh, int code, int zaxisID, int levelID)
{
zaxistype = ZAXIS_PRESSURE;
zaxisChangeType(zaxisID, zaxistype);
zaxisDefUnits(zaxisID, "Pa");
}
// ISEC2_NumVCP = 0;
......
......@@ -335,6 +335,7 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
{
leveltype = ZAXIS_PRESSURE;
zaxisChangeType(zaxisID, leveltype);
zaxisDefUnits(zaxisID, "Pa");
}
/* IEG_G_NumVCP(gdb) = 0; */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment