Commit 23c544d0 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

use cdo_omp_get_thread_num() instead of omp_get_thread_num()

parent 1a410188
......@@ -21,9 +21,6 @@
Detrend detrend Detrend
*/
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
......@@ -94,7 +91,6 @@ void taxisDefDTinfo(int taxisID, dtinfo_t dtinfo)
void *Detrend(void *argument)
{
int ompthID;
int gridsize;
int nrecs;
int gridID, varID, levelID, recID;
......@@ -178,15 +174,12 @@ void *Detrend(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(i, ompthID, tsID)
#pragma omp parallel for default(shared) private(i, tsID)
#endif
for ( i = 0; i < gridsize; i++ )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
for ( tsID = 0; tsID < nts; tsID++ )
ompmem[ompthID].array1[tsID] = vars[tsID][varID][levelID].ptr[i];
......
......@@ -30,9 +30,6 @@
Ensstat enspctl Ensemble percentiles
*/
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
......@@ -56,7 +53,6 @@ void *Ensstat(void *argument)
int vlistID, vlistID1, vlistID2;
int nmiss;
int taxisID1, taxisID2;
int ompthID;
double missval;
double *array2 = NULL;
field_t *field;
......@@ -195,15 +191,12 @@ void *Ensstat(void *argument)
nmiss = 0;
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(i, ompthID, fileID)
#pragma omp parallel for default(shared) private(i, fileID)
#endif
for ( i = 0; i < gridsize; i++ )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
field[ompthID].missval = missval;
field[ompthID].nmiss = 0;
for ( fileID = 0; fileID < nfiles; fileID++ )
......
......@@ -22,9 +22,6 @@
Ensstat3 ensroccurve Ensamble Receiver Operating Characteristics
*/
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
......@@ -68,7 +65,6 @@ void *Ensstat3(void *argument)
int vlistID, vlistID1, vlistID2;
int taxisID1, taxisID2;
int zaxisID2;
int ompthID;
int *varID2;
int time_mode;
int **array2 = NULL;
......@@ -128,13 +124,8 @@ void *Ensstat3(void *argument)
/* ("first touch strategy") */
/* --> #pragma omp parallel for ... */
/* *************************************************** */
#if defined(_OPENMP)
field = (field_t*) malloc(omp_get_max_threads()*sizeof(field_t));
for ( i = 0; i < omp_get_max_threads(); i++ )
#else
field = (field_t*) malloc(1*sizeof(field_t));
for ( i = 0; i < 1; i++ )
#endif
field = (field_t*) malloc(ompNumThreads*sizeof(field_t));
for ( i = 0; i < ompNumThreads; i++ )
{
field_init(&field[i]);
field[i].size = nfiles;
......@@ -300,15 +291,12 @@ void *Ensstat3(void *argument)
array2[binID][0] = 0;
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(i, binID, ompthID, fileID)
#pragma omp parallel for default(shared) private(i, binID, fileID)
#endif
for ( i = 0; i < gridsize; i++ )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
field[ompthID].missval = missval;
field[ompthID].nmiss = 0;
have_miss = 0;
......
......@@ -27,10 +27,6 @@
# include "config.h"
#endif
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
......@@ -126,7 +122,6 @@ void filter_intrinsic(int nts, const int *fmasc, double *array1, double *array2)
void *Filter(void *argument)
{
int ompthID = 1;
enum {BANDPASS, HIGHPASS, LOWPASS};
char *tunits[] = {"second", "minute", "hour", "day", "month", "year"};
int iunits[] = {31536000, 525600, 8760, 365, 12, 1};
......@@ -334,15 +329,12 @@ void *Filter(void *argument)
{
#if defined(HAVE_LIBFFTW3)
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(i, ompthID, tsID)
#pragma omp parallel for default(shared) private(i, tsID)
#endif
for ( i = 0; i < gridsize; i++ )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
for ( tsID = 0; tsID < nts; tsID++ )
{
ompmem[ompthID].in_fft[tsID][0] = vars[tsID][varID][levelID].ptr[i];
......@@ -361,15 +353,12 @@ void *Filter(void *argument)
else
{
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(i, ompthID, tsID)
#pragma omp parallel for default(shared) private(i, tsID)
#endif
for ( i = 0; i < gridsize; i++ )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
for ( tsID = 0; tsID < nts; tsID++ )
ompmem[ompthID].array1[tsID] = vars[tsID][varID][levelID].ptr[i];
......
......@@ -15,9 +15,6 @@
GNU General Public License for more details.
*/
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
......@@ -31,7 +28,6 @@
void *Fourier(void *argument)
{
int ompthID;
int bit, sign;
int gridsize;
int nrecs;
......@@ -131,16 +127,13 @@ void *Fourier(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(i, ompthID, tsID)
#pragma omp parallel for default(shared) private(i, tsID)
#endif
for ( i = 0; i < gridsize; i++ )
{
int lmiss = 0;
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
for ( tsID = 0; tsID < nts; tsID++ )
{
ompmem[ompthID].real[tsID] = vars[tsID][varID][levelID].ptr[2*i];
......
......@@ -27,9 +27,6 @@
Gridboxstat gridboxvar Gridbox variance
*/
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
......@@ -533,7 +530,6 @@ void gridboxstat(field_t *field1, field_t *field2, int xinc, int yinc, int statf
double missval;
long ig, i, j, ii, jj, index;
long gridsize;
long ompthID;
field_t *field;
int isize;
int useWeight = FALSE;
......@@ -570,15 +566,12 @@ void gridboxstat(field_t *field1, field_t *field2, int xinc, int yinc, int statf
nlat2 = gridInqYsize(gridID2);
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(ig, ilat, ilon, j, jj, i, ii, index, isize, ompthID)
#pragma omp parallel for default(shared) private(ig, ilat, ilon, j, jj, i, ii, index, isize)
#endif
for ( ig = 0; ig < nlat2*nlon2; ++ig )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
/*
int lprogress = 1;
#if defined(_OPENMP)
......
......@@ -22,10 +22,6 @@
*/
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
......@@ -62,7 +58,6 @@ void *Timsort(void *argument)
int nmiss;
int nvars, nlevel;
int *vdate = NULL, *vtime = NULL;
int ompthID;
double **sarray = NULL;
field_t ***vars = NULL;
......@@ -128,15 +123,12 @@ void *Timsort(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(i, ompthID, tsID)
#pragma omp parallel for default(shared) private(i, tsID)
#endif
for ( i = 0; i < gridsize; i++ )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
for ( tsID = 0; tsID < nts; tsID++ )
sarray[ompthID][tsID] = vars[tsID][varID][levelID].ptr[i];
......
......@@ -21,10 +21,6 @@
Tstepcount tstepcount Count number of timesteps
*/
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
......@@ -57,7 +53,6 @@ double tstepcount(long nts, double missval1, double *array1, double refval)
void *Tstepcount(void *argument)
{
int ompthID;
int gridsize;
int nrecs;
int gridID, varID, levelID, recID;
......@@ -149,16 +144,13 @@ void *Tstepcount(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
#if defined(_OPENMP)
#pragma omp parallel for default(shared) private(i, ompthID, tsID) \
#pragma omp parallel for default(shared) private(i, tsID) \
schedule(dynamic,1)
#endif
for ( i = 0; i < gridsize; i++ )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
for ( tsID = 0; tsID < nts; tsID++ )
mem[ompthID].array1[tsID] = vars[tsID][varID][levelID].ptr[i];
......
......@@ -82,6 +82,9 @@ extern int cdoDiag;
extern int cdoNumVarnames;
extern char **cdoVarnames;
int cdo_omp_get_thread_num(void);
void cdiError(int cdiErrno, const char *fmt, ...);
void cdoAbort(const char *fmt, ...);
void cdoWarning(const char *fmt, ...);
......@@ -93,6 +96,7 @@ void timer_start(int it);
void timer_stop(int it);
double timer_val(int it);
void operatorInputArg(const char *enter);
int operatorArgc(void);
char **operatorArgv(void);
......
......@@ -14,10 +14,6 @@
GNU General Public License for more details.
*/
#if defined(_OPENMP)
# include <omp.h>
#endif
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
......@@ -384,9 +380,8 @@ int gridGenArea(int gridID, double* area)
for ( i = 0; i < gridsize; ++i )
{
int lprogress = 1;
#if defined(_OPENMP)
if ( omp_get_thread_num() != 0 ) lprogress = 0;
#endif
if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
#if defined(_OPENMP)
#pragma omp atomic
#endif
......
......@@ -730,10 +730,7 @@ void hetaeta(int ltq, int ngp, const int *imiss,
for ( ij = 0; ij < ngp; ++ij )
{
#if defined(_OPENMP)
int ompthID;
long iv;
ompthID = omp_get_thread_num();
int ompthID = omp_get_thread_num();
ph1 = ph1_2[ompthID];
lnph1 = lnph1_2[ompthID];
......@@ -770,7 +767,7 @@ void hetaeta(int ltq, int ngp, const int *imiss,
if ( nvars > 0 )
{
for ( iv = 0; iv < nvars; ++iv )
for ( int iv = 0; iv < nvars; ++iv )
vars_pbl[iv] = vars_pbl_2[ompthID][iv];
}
#endif
......
......@@ -4,9 +4,6 @@
#include "grid.h"
#include "util.h" /* progressStatus */
#if defined(_OPENMP)
#include <omp.h> // omp_get_thread_num()
#endif
#define ZERO 0.0
#define ONE 1.0
......@@ -260,9 +257,7 @@ void intlinarr2(double missval, int lon_is_circular,
long iix;
int lfound;
int lprogress = 1;
#if defined(_OPENMP)
if ( omp_get_thread_num() != 0 ) lprogress = 0;
#endif
if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
field[i] = missval;
......@@ -458,7 +453,7 @@ void intconarr2(double missval, int lon_is_circular,
ndeps = 0;
/*
#if defined(_OPENMP)
if ( omp_get_thread_num() != 0 ) lprogress = 0;
if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
#endif
*/
field[i] = missval;
......
#ifndef _REMAP_H
#define _REMAP_H
#if defined(_OPENMP)
#include <omp.h>
#endif
#include <math.h>
#ifndef M_PI
......
......@@ -202,9 +202,8 @@ void scrip_remap_weights_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
for ( dst_add = 0; dst_add < tgt_grid_size; ++dst_add )
{
int lprogress = 1;
#if defined(_OPENMP)
if ( omp_get_thread_num() != 0 ) lprogress = 0;
#endif
if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
#if defined(_OPENMP)
#pragma omp atomic
#endif
......@@ -336,9 +335,8 @@ void scrip_remap_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const dou
for ( dst_add = 0; dst_add < tgt_grid_size; ++dst_add )
{
int lprogress = 1;
#if defined(_OPENMP)
if ( omp_get_thread_num() != 0 ) lprogress = 0;
#endif
if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
#if defined(_OPENMP)
#pragma omp atomic
#endif
......
......@@ -278,9 +278,8 @@ void scrip_remap_weights_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid,
for ( dst_add = 0; dst_add < tgt_grid_size; ++dst_add )
{
int lprogress = 1;
#if defined(_OPENMP)
if ( omp_get_thread_num() != 0 ) lprogress = 0;
#endif
if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
#if defined(_OPENMP)
#pragma omp atomic
#endif
......@@ -409,9 +408,7 @@ void scrip_remap_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid, const do
for ( dst_add = 0; dst_add < tgt_grid_size; ++dst_add )
{
int lprogress = 1;
#if defined(_OPENMP)
if ( omp_get_thread_num() != 0 ) lprogress = 0;
#endif
if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
if ( !cdoSilentMode )
{
......
......@@ -398,7 +398,7 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
long srch_corners; /* num of corners of srch cells */
double norm_factor = 0; /* factor for normalizing wts */
int* srch_add; /* global address of cells in srch arrays */
int ompthID, i;
int i;
/* Variables necessary if segment manages to hit pole */
double findex = 0;
......@@ -517,17 +517,12 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
rv, cdoVerbose, max_srch_cells2, \
tgt_num_cell_corners, srch_corners, src_grid, tgt_grid, tgt_grid_size, src_grid_size, \
overlap_buffer2, src_grid_cells2, srch_add2, tgt_grid_cell2, findex, sum_srch_cells, sum_srch_cells2) \
private(ompthID, srch_add, tgt_grid_cell, tgt_area, n, k, num_weights, num_srch_cells, max_srch_cells, \
private(srch_add, tgt_grid_cell, tgt_area, n, k, num_weights, num_srch_cells, max_srch_cells, \
partial_areas, partial_weights, overlap_buffer, src_grid_cells, src_grid_add, tgt_grid_add, ioffset)
#endif
for ( tgt_grid_add = 0; tgt_grid_add < tgt_grid_size; ++tgt_grid_add )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
int lprogress = 1;
if ( ompthID != 0 ) lprogress = 0;
......
......@@ -1039,7 +1039,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
long nsrch_corners;
int* srch_add; /* global address of cells in srch arrays */
int* srch_add2[ompNumThreads];
int ompthID, i;
int i;
double *srch_corner_lat; /* lat of each corner of srch cells */
double *srch_corner_lon; /* lon of each corner of srch cells */
......@@ -1162,7 +1162,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
remap_store_link_fast, grid_store, link_add1, link_add2, rv, cdoVerbose, max_subseg, \
srch_corner_lat2, srch_corner_lon2, max_srch_cells2, \
src_num_cell_corners, srch_corners, src_grid, tgt_grid, tgt_grid_size, src_grid_size, srch_add2, findex) \
private(ompthID, srch_add, n, k, num_srch_cells, max_srch_cells, \
private(srch_add, n, k, num_srch_cells, max_srch_cells, \
src_grid_add, tgt_grid_add, ioffset, nsrch_corners, corner, next_corn, beglat, beglon, \
endlat, endlon, lrevers, begseg, lbegin, num_subseg, srch_corner_lat, srch_corner_lon, \
weights, intrsct_lat, intrsct_lon, intrsct_lat_off, intrsct_lon_off, intrsct_x, intrsct_y, \
......@@ -1170,12 +1170,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
#endif
for ( src_grid_add = 0; src_grid_add < src_grid_size; ++src_grid_add )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
int lprogress = 1;
if ( ompthID != 0 ) lprogress = 0;
......@@ -1392,7 +1387,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
remap_store_link_fast, grid_store, link_add1, link_add2, rv, cdoVerbose, max_subseg, \
srch_corner_lat2, srch_corner_lon2, max_srch_cells2, \
tgt_num_cell_corners, srch_corners, src_grid, tgt_grid, tgt_grid_size, src_grid_size, srch_add2, findex) \
private(ompthID, srch_add, n, k, num_srch_cells, max_srch_cells, \
private(srch_add, n, k, num_srch_cells, max_srch_cells, \
src_grid_add, tgt_grid_add, ioffset, nsrch_corners, corner, next_corn, beglat, beglon, \
endlat, endlon, lrevers, begseg, lbegin, num_subseg, srch_corner_lat, srch_corner_lon, \
weights, intrsct_lat, intrsct_lon, intrsct_lat_off, intrsct_lon_off, intrsct_x, intrsct_y, \
......@@ -1400,12 +1395,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
#endif
for ( tgt_grid_add = 0; tgt_grid_add < tgt_grid_size; ++tgt_grid_add )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
#else
ompthID = 0;
#endif
int ompthID = cdo_omp_get_thread_num();
int lprogress = 1;
if ( ompthID != 0 ) lprogress = 0;
......
......@@ -512,9 +512,8 @@ void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remap
for ( dst_add = 0; dst_add < tgt_grid_size; ++dst_add )
{
int lprogress = 1;
#if defined(_OPENMP)
if ( omp_get_thread_num() != 0 ) lprogress = 0;
#endif
if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
#if defined(_OPENMP)
#pragma omp atomic
#endif
......
......@@ -1248,7 +1248,6 @@ void remap_laf(double *restrict dst_array, double missval, long dst_size, long n
#if defined(_OPENMP)
double **src_cls2;
double **src_wts2;
int ompthID;
#endif
for ( i = 0; i < dst_size; ++i ) dst_array[i] = missval;
......@@ -1276,13 +1275,13 @@ void remap_laf(double *restrict dst_array, double missval, long dst_size, long n
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
shared(dst_size, src_cls2, src_wts2, num_links, dst_add, src_add, src_array, map_wts, num_wts, dst_array, max_cls) \
private(i, n, k, ompthID, src_cls, src_wts, ncls, imax, wts) \
private(i, n, k, src_cls, src_wts, ncls, imax, wts) \
schedule(dynamic,1)
#endif
for ( i = 0; i < dst_size; ++i )
{
#if defined(_OPENMP)
ompthID = omp_get_thread_num();
int ompthID = cdo_omp_get_thread_num();
src_cls = src_cls2[ompthID];
src_wts = src_wts2[ompthID];
#endif
......
......@@ -2,6 +2,10 @@
# include "config.h"
#endif
#if defined(_OPENMP)
#include <omp.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
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