Commit 83e92d36 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

pctl cleanup

parent 4e6bcb25
2006-11-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* processSelf: lock/unlock NumProcess (bug fix)
* Version 1.0.4 released
2006-11-02 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
......@@ -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-2006 Brockmann Consult
Copyright (C) 2006 Brockmann Consult
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -34,13 +34,6 @@
#include "dmemory.h"
#include "nth_element.h"
typedef struct {
int date;
int time;
int julval;
}
DATETIME;
void *Runpctl(void *argument)
{
......@@ -179,7 +172,7 @@ void *Runpctl(void *argument)
if ( j > 0 )
{
vars1[0][varID][levelID].ptr[i] = nth_element(array, j, ceil(j*(pn/100.0))-1);
vars1[0][varID][levelID].ptr[i] = nth_element(array, j, (int)ceil(j*(pn/100.0))-1);
}
else
{
......
......@@ -40,14 +40,6 @@
#include "dmemory.h"
typedef struct {
int date;
int time;
int julval;
}
DATETIME;
void datetime_avg(int dpy, int ndates, DATETIME *datetime)
{
int vdate, vtime;
......
......@@ -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-2006 Brockmann Consult
Copyright (C) 2006 Brockmann Consult
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -43,7 +43,6 @@ void *Seaspctl(void *argument)
int tsID;
int otsID;
long nsets;
int i;
int year, month, seas, seas0 = 0;
int streamID1, streamID2, streamID3, streamID4;
int vlistID1, vlistID2, vlistID3, vlistID4, taxisID1, taxisID2, taxisID3, taxisID4;
......
......@@ -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-2006 Brockmann Consult
Copyright (C) 2006 Brockmann Consult
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -42,7 +42,7 @@ void *Selpctl(void *argument)
int gridID, varID, levelID, recID;
int tsID;
int otsID;
int nsets;
int nsets = 0;
int i;
int streamID1, streamID2, streamID3, streamID4;
int vlistID1, vlistID2, vlistID3, vlistID4, taxisID1, taxisID2, taxisID3, taxisID4;
......
......@@ -49,7 +49,6 @@ static void timpctl(int operatorID)
int tsID;
int otsID;
long nsets;
int i;
int streamID1, streamID2, streamID3, streamID4;
int vlistID1, vlistID2, vlistID3, vlistID4, taxisID1, taxisID2, taxisID3, taxisID4;
int nmiss;
......@@ -255,7 +254,6 @@ static void timpctl(int operatorID)
void *Timpctl(void *argument)
{
static const char func[] = "Timpctl";
int operatorID;
cdoInitialize(argument);
......@@ -269,6 +267,7 @@ void *Timpctl(void *argument)
operatorID = cdoOperatorID();
timpctl(operatorID);
cdoFinish();
return (0);
......
......@@ -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-2006 Brockmann Consult
Copyright (C) 2006 Brockmann Consult
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -117,7 +117,7 @@ void *Ydaypctl(void *argument)
field.ptr = (double *) malloc(gridsize*sizeof(double));
tsID = 0;
while ( nrecs = streamInqTimestep(streamID2, tsID) )
while ( (nrecs = streamInqTimestep(streamID2, tsID)) )
{
if ( nrecs != streamInqTimestep(streamID3, tsID) )
cdoAbort("Number of records in time step %d of %s and %s are different!", tsID+1, cdoStreamName(1), cdoStreamName(2));
......@@ -191,7 +191,7 @@ void *Ydaypctl(void *argument)
}
tsID = 0;
while ( nrecs = streamInqTimestep(streamID1, tsID) )
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
......
......@@ -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-2006 Brockmann Consult
Copyright (C) 2006 Brockmann Consult
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -39,14 +39,6 @@
#define NDAY 373
typedef struct {
int date;
int time;
int julval;
}
DATETIME;
void *Ydrunpctl(void *argument)
{
static char func[] = "Ydrunpctl";
......@@ -164,7 +156,7 @@ void *Ydrunpctl(void *argument)
}
tsID = 0;
while ( nrecs = streamInqTimestep(streamID2, tsID) )
while ( (nrecs = streamInqTimestep(streamID2, tsID)) )
{
if ( nrecs != streamInqTimestep(streamID3, tsID) )
cdoAbort("Number of records in time step %d of %s and %s are different!", tsID+1, cdoStreamName(1), cdoStreamName(2));
......
......@@ -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-2006 Brockmann Consult
Copyright (C) 2006 Brockmann Consult
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -43,14 +43,6 @@
#define NDAY 373
typedef struct {
int date;
int time;
int julval;
}
DATETIME;
typedef struct {
int vdate[NDAY];
int vtime[NDAY];
......@@ -398,7 +390,8 @@ static void ydstatCreateVars1(YDAY_STATS *stats, int dayoy)
{
static const char func[] = "ydstatCreateVars1";
int varID, levelID, nvars, nlevels;
int gridID, gridsize, missval;
int gridID, gridsize;
double missval;
nvars = vlistNvars(stats->vlist);
......@@ -427,7 +420,8 @@ static void ydstatCreateVars2(YDAY_STATS *stats, int dayoy)
{
static const char func[] = "ydstatCreateVars2";
int varID, levelID, nvars, nlevels;
int gridID, gridsize, missval;
int gridID, gridsize;
double missval;
nvars = vlistNvars(stats->vlist);
......@@ -455,9 +449,8 @@ static void ydstatCreateVars2(YDAY_STATS *stats, int dayoy)
static void ydstatUpdate(YDAY_STATS *stats, int vdate, int vtime,
FIELD **vars1, FIELD **vars2, int nsets, int operfunc)
{
static char func[] = "ydstatUpdate";
int varID, levelID, nvars, nlevels;
int gridID, gridsize;
int gridsize;
int year, month, day, dayoy;
nvars = vlistNvars(stats->vlist);
......
......@@ -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-2006 Brockmann Consult
Copyright (C) 2006 Brockmann Consult
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -116,7 +116,7 @@ void *Ymonpctl(void *argument)
field.ptr = (double *) malloc(gridsize*sizeof(double));
tsID = 0;
while ( nrecs = streamInqTimestep(streamID2, tsID) )
while ( (nrecs = streamInqTimestep(streamID2, tsID)) )
{
if ( nrecs != streamInqTimestep(streamID3, tsID) )
cdoAbort("Number of records in time step %d of %s and %s are different!", tsID+1, cdoStreamName(1), cdoStreamName(2));
......@@ -183,7 +183,7 @@ void *Ymonpctl(void *argument)
}
tsID = 0;
while ( nrecs = streamInqTimestep(streamID1, tsID) )
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
......
......@@ -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-2006 Brockmann Consult
Copyright (C) 2006 Brockmann Consult
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -38,8 +38,6 @@
void *Yseaspctl(void *argument)
{
static char func[] = "Yseaspctl";
int operatorID;
int operfunc;
int gridsize;
int varID;
int recID;
......@@ -118,7 +116,7 @@ void *Yseaspctl(void *argument)
field.ptr = (double *) malloc(gridsize*sizeof(double));
tsID = 0;
while ( nrecs = streamInqTimestep(streamID2, tsID) )
while ( (nrecs = streamInqTimestep(streamID2, tsID)) )
{
if ( nrecs != streamInqTimestep(streamID3, tsID) )
cdoAbort("Number of records in time step %d of %s and %s are different!", tsID+1, cdoStreamName(1), cdoStreamName(2));
......@@ -192,7 +190,7 @@ void *Yseaspctl(void *argument)
}
tsID = 0;
while ( nrecs = streamInqTimestep(streamID1, tsID) )
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
......
......@@ -92,6 +92,15 @@ int ntr2nlat(int ntr);
int ntr2nlat_linear(int ntr);
int compNlon(int nlat);
typedef struct {
int date;
int time;
int julval;
}
DATETIME;
void datetime_avg(int dpy, int ndates, DATETIME *datetime);
void decode_date(int date, int *year, int *month, int *day);
void decode_time(int time, int *hour, int *minute);
double encode_julval(int dpy, int date, int time);
......
......@@ -420,8 +420,8 @@ static MODULES Modules[] =
/* QR */
{ Ydaystat, YdaystatHelp, YdaystatOperators, 1, 1 },
/* RQ */
{ Ydrunpctl, Ydrunpctl, YdrunpctlOperators, 3, 1 },
{ Ydrunstat, Ydrunstat, YdrunstatOperators, 1, 1 },
{ Ydrunpctl, YdrunpctlHelp, YdrunpctlOperators, 3, 1 },
{ Ydrunstat, YdrunstatHelp, YdrunstatOperators, 1, 1 },
/* QR */
{ Ymonarith, YmonarithHelp, YmonarithOperators, 2, 1 },
/* RQ */
......
......@@ -18,6 +18,8 @@
#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include "cdi.h"
#include "cdo.h"
#include "cdo_int.h"
#include "nth_element.h"
......@@ -146,7 +148,7 @@ static double histGetPercentile(const HISTOGRAM *hist, int p)
}
else
{
return nth_element(DBL_PTR(hist->ptr), hist->nsamp, ceil(s) - 1);
return (double)nth_element(DBL_PTR(hist->ptr), hist->nsamp, ceil(s) - 1);
}
}
......@@ -182,7 +184,7 @@ HISTOGRAM_SET *hsetCreate(int nvars)
void hsetCreateVarLevels(HISTOGRAM_SET *hset, int varID, int nlevels, int grid)
{
static const char func[] = "hsetCreateVarLevels";
int i, nvars, nhists, nbins, levelID, histID;
int nvars, nhists, nbins, levelID, histID;
HISTOGRAM *hists;
nbins = histGetEnvNBins();
......
......@@ -127,6 +127,8 @@ int processSelf(void)
#if defined (HAVE_LIBPTHREAD)
int thID = (int) pthread_self();
pthread_mutex_lock(&processMutex);
for ( processID = 0; processID < NumProcess; processID++ )
if ( Process[processID].threadID == thID ) break;
......@@ -137,6 +139,9 @@ int processSelf(void)
else
processID = 0;
}
pthread_mutex_unlock(&processMutex);
#endif
return (processID);
......
Supports Markdown
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