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

remapcon: openmp

parent 3649c793
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for cdo 1.3.0beta4.
# Generated by GNU Autoconf 2.61 for cdo 1.3.0.
#
# Report bugs to <Uwe.Schulzweida@zmaw.de>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='cdo'
PACKAGE_TARNAME='cdo'
PACKAGE_VERSION='1.3.0beta4'
PACKAGE_STRING='cdo 1.3.0beta4'
PACKAGE_VERSION='1.3.0'
PACKAGE_STRING='cdo 1.3.0'
PACKAGE_BUGREPORT='Uwe.Schulzweida@zmaw.de'
# Factoring default headers for most tests.
......@@ -1222,7 +1222,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cdo 1.3.0beta4 to adapt to many kinds of systems.
\`configure' configures cdo 1.3.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1293,7 +1293,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdo 1.3.0beta4:";;
short | recursive ) echo "Configuration of cdo 1.3.0:";;
esac
cat <<\_ACEOF
......@@ -1404,7 +1404,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdo configure 1.3.0beta4
cdo configure 1.3.0
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1418,7 +1418,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cdo $as_me 1.3.0beta4, which was
It was created by cdo $as_me 1.3.0, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -2242,7 +2242,7 @@ fi
# Define the identity of the package.
PACKAGE='cdo'
VERSION='1.3.0beta4'
VERSION='1.3.0'
cat >>confdefs.h <<_ACEOF
......@@ -7772,7 +7772,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdo $as_me 1.3.0beta4, which was
This file was extended by cdo $as_me 1.3.0, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -7825,7 +7825,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
cdo config.status 1.3.0beta4
cdo config.status 1.3.0
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
# Process this file with autoconf to produce a configure script.
AC_INIT(cdo, 1.3.0beta4, Uwe.Schulzweida@zmaw.de)
AC_INIT(cdo, 1.3.0, Uwe.Schulzweida@zmaw.de)
CONFIG_ABORT=yes
......
......@@ -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-2008 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2009 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -21,7 +21,7 @@
#include "cdi.h"
#include "cdo.h"
#include "cdo_int.h" /* processSelf */
#include "cdo_int.h"
#include "pstream.h"
#include "error.h"
#include "util.h"
......
......@@ -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-2008 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2009 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......
......@@ -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-2008 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2009 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -39,7 +39,7 @@
#include "cdi.h"
#include "cdo.h"
#include "cdo_int.h" /* processSelf */
#include "cdo_int.h"
#include "pstream.h"
#include "error.h"
#include "util.h"
......
......@@ -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-2008 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2009 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -35,7 +35,7 @@
#include "cdi.h"
#include "cdo.h"
#include "cdo_int.h" /* processSelf */
#include "cdo_int.h"
#include "pstream.h"
#include "error.h"
#include "util.h"
......
......@@ -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-2008 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2009 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......
......@@ -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-2008 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2009 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -206,7 +206,7 @@ static void usage(void)
fprintf(stderr, " Operands:\n");
fprintf(stderr, " The path name of the input/output files for the operator.\n");
fprintf(stderr, "\n");
fprintf(stderr, " CDO version %s, Copyright (C) 2003-2008 Uwe Schulzweida\n", VERSION);
fprintf(stderr, " CDO version %s, Copyright (C) 2003-2009 Uwe Schulzweida\n", VERSION);
fprintf(stderr, " Available from http://www.mpimet.mpg.de/cdo\n");
fprintf(stderr, " This is free software and comes with ABSOLUTELY NO WARRANTY\n");
fprintf(stderr, " Report bugs to Uwe.Schulzweida@zmaw.de\n");
......@@ -580,6 +580,7 @@ int main(int argc, char *argv[])
int lstop = FALSE;
int noff = 0;
int status = 0;
int numThreads = 0;
char *operatorName = NULL;
char *operatorArg = NULL;
char *argument = NULL;
......@@ -603,7 +604,7 @@ int main(int argc, char *argv[])
cdoHaveNC4 = have_netCDF4();
while ( (c = cdoGetopt(argc, argv, "f:b:e:p:g:i:l:m:t:D:z:aBdhRrsTuVvZ")) != -1 )
while ( (c = cdoGetopt(argc, argv, "f:b:e:P:p:g:i:l:m:t:D:z:aBdhRrsTuVvZ")) != -1 )
{
switch (c)
{
......@@ -658,6 +659,9 @@ int main(int argc, char *argv[])
case 'm':
cdiDefMissval(atof(cdoOptarg));
break;
case 'P':
numThreads = atoi(cdoOptarg);
break;
case 'p':
setDefaultDataTypeByte(cdoOptarg);
break;
......@@ -868,9 +872,17 @@ int main(int argc, char *argv[])
}
#if defined (_OPENMP)
if ( numThreads > 0 ) omp_set_num_threads(numThreads);
ompNumThreads = omp_get_max_threads();
fprintf(stderr, " OpenMP: num_procs = %d max_threads = %d\n",
omp_get_num_procs(), omp_get_max_threads());
if ( cdoVerbose )
fprintf(stderr, " OpenMP: num_procs = %d max_threads = %d\n",
omp_get_num_procs(), omp_get_max_threads());
#else
if ( numThreads > 0 )
{
fprintf(stderr, "Option -P failed, OpenMP support not compiled in!\n");
return(-1);
}
#endif
......
......@@ -68,7 +68,7 @@ void faradd(FIELD *field1, FIELD field2)
{
/*
#if defined (_OPENMP)
#pragma omp parallel for default(shared) private(i)
#pragma omp parallel for default(shared)
#endif
*/
for ( i = 0; i < len; i++ )
......
......@@ -49,6 +49,10 @@
# include "config.h"
#endif
#if defined (_OPENMP)
# include <omp.h>
#endif
#include <string.h>
#include <limits.h>
#include <float.h>
......@@ -358,6 +362,11 @@ void boundbox_from_corners(int size, int nc, double *corner_lon, double *corner_
{
int i4, inc, i, j;
#if defined (_OPENMP)
#pragma omp parallel for default(none) \
shared(bound_box, corner_lat, corner_lon, nc, size) \
private(i4, inc, i, j)
#endif
for ( i = 0; i < size; i++ )
{
i4 = i*4;
......@@ -1017,6 +1026,11 @@ void remapGridInit(int map_type, int gridID1, int gridID2, REMAPGRID *rg)
rg->bin_addr2[2*n+1] = 0;
}
#if defined (_OPENMP)
#pragma omp parallel for default(none) \
shared(rg) \
private(nele, nele4, n)
#endif
for ( nele = 0; nele < rg->grid1_size; nele++ )
{
nele4 = nele*4;
......@@ -1029,6 +1043,11 @@ void remapGridInit(int map_type, int gridID1, int gridID2, REMAPGRID *rg)
}
}
#if defined (_OPENMP)
#pragma omp parallel for default(none) \
shared(rg) \
private(nele, nele4, n)
#endif
for ( nele = 0; nele < rg->grid2_size; nele++ )
{
nele4 = nele*4;
......@@ -3828,12 +3847,14 @@ void store_link_cnsrv(REMAPVARS *rv, int add1, int add2, double *weights,
-----------------------------------------------------------------------
*/
#define MASK_TYPE int
void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
{
static char func[] = "remap_conserv";
/* local variables */
int ompthID, i;
int lcheck = TRUE;
int ioffset;
......@@ -3858,7 +3879,8 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
int lrevers; /* flag for reversing direction of segment */
int lbegin; /* flag for first integration of a segment */
int *srch_mask; /* mask for restricting searches */
MASK_TYPE *srch_mask; /* mask for restricting searches */
MASK_TYPE **srch_mask2;
double intrsct_lat, intrsct_lon; /* lat/lon of next intersect */
double beglat, endlat, beglon, endlon; /* endpoints of current seg. */
......@@ -3953,7 +3975,13 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
/* Integrate around each cell on grid1 */
srch_mask = (int *) malloc(grid2_size*sizeof(int));
#if defined (_OPENMP)
srch_mask2 = (MASK_TYPE **) malloc(ompNumThreads*sizeof(MASK_TYPE *));
for ( i = 0; i < ompNumThreads; i++ )
srch_mask2[i] = (MASK_TYPE *) malloc(grid2_size*sizeof(MASK_TYPE));
#else
srch_mask = (MASK_TYPE *) malloc(grid2_size*sizeof(MASK_TYPE));
#endif
lthresh = FALSE;
luse_last = FALSE;
......@@ -3968,8 +3996,22 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
if ( cdoTimer ) timer_start(timer_remap_con2);
#if defined (_OPENMP)
#pragma omp parallel for default(none) \
shared(grid1_centroid_lon, grid1_centroid_lat, link_add2, link_add1, rv, cdoVerbose, max_subseg, grid1_corners, \
srch_corners, rg, grid2_size, grid1_size, func, srch_mask2) \
private(ompthID, srch_mask, min_add, max_add, n, k, num_srch_cells, max_srch_cells, grid1_addm4, grid1_add, grid2_add, grid2_addm4, \
ioffset, nsrch_corners, corner, next_corn, beglat, beglon, endlat, endlon, lrevers, begseg, lbegin, num_subseg, \
srch_add, srch_corner_lat, srch_corner_lon, weights, intrsct_lat, intrsct_lon, intrsct_lat_off, \
intrsct_lon_off, intrsct_x, intrsct_y, luse_last, last_loc, lthresh, avoid_pole_count, avoid_pole_offset, lcoinc)
#endif
for ( grid1_add = 0; grid1_add < grid1_size; grid1_add++ )
{
#if defined (_OPENMP)
ompthID = omp_get_thread_num();
srch_mask = srch_mask2[ompthID];
#endif
/* Restrict searches first using search bins */
min_add = grid2_size - 1;
......@@ -4004,6 +4046,11 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
/* Create search arrays */
#if defined (_OPENMP)
srch_add = (int *) malloc(num_srch_cells*sizeof(int));
srch_corner_lat = (double *) malloc(srch_corners*num_srch_cells*sizeof(double));
srch_corner_lon = (double *) malloc(srch_corners*num_srch_cells*sizeof(double));
#else
if ( num_srch_cells > max_srch_cells )
{
max_srch_cells = num_srch_cells;
......@@ -4011,6 +4058,7 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
srch_corner_lat = (double *) realloc(srch_corner_lat, srch_corners*num_srch_cells*sizeof(double));
srch_corner_lon = (double *) realloc(srch_corner_lon, srch_corners*num_srch_cells*sizeof(double));
}
#endif
n = 0;
/* gather1 */
......@@ -4127,6 +4175,9 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
if ( grid2_add != -1 )
if ( rg->grid1_mask[grid1_add] )
{
#if defined (_OPENMP)
#pragma omp critical
#endif
store_link_cnsrv(rv, grid1_add, grid2_add, weights, link_add1, link_add2);
rg->grid1_frac[grid1_add] += weights[0];
......@@ -4145,28 +4196,48 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
}
/* End of segment */
}
#if defined (_OPENMP)
free(srch_add);
free(srch_corner_lat);
free(srch_corner_lon);
#endif
}
if ( cdoTimer ) timer_stop(timer_remap_con2);
/* finished with all cells: deallocate search arrays */
/* Finished with all cells: deallocate search arrays */
#if ! defined (_OPENMP)
if ( srch_corner_lon ) free(srch_corner_lon);
if ( srch_corner_lat ) free(srch_corner_lat);
if ( srch_add ) free(srch_add);
#endif
#if defined (_OPENMP)
for ( i = 0; i < ompNumThreads; i++ )
free(srch_mask2[i]);
free(srch_mask2);
#else
free(srch_mask);
#endif
/* Integrate around each cell on grid2 */
srch_mask = (int *) malloc(grid1_size*sizeof(int));
#if defined (_OPENMP)
srch_mask2 = (MASK_TYPE **) malloc(ompNumThreads*sizeof(MASK_TYPE *));
for ( i = 0; i < ompNumThreads; i++ )
srch_mask2[i] = (MASK_TYPE *) malloc(grid1_size*sizeof(MASK_TYPE));
#else
srch_mask = (MASK_TYPE *) malloc(grid1_size*sizeof(MASK_TYPE));
#endif
lthresh = FALSE;
luse_last = FALSE;
avoid_pole_count = 0;
avoid_pole_offset = TINY;
srch_corners = grid1_corners;
srch_corners = grid1_corners;
max_srch_cells = 0;
srch_add = NULL;
srch_corner_lat = NULL;
......@@ -4174,8 +4245,22 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
if ( cdoTimer ) timer_start(timer_remap_con3);
#if defined (_OPENMP)
#pragma omp parallel for default(none) \
shared(grid2_centroid_lon, grid2_centroid_lat, link_add2, link_add1, rv, cdoVerbose, max_subseg, grid2_corners, \
srch_corners, rg, grid2_size, grid1_size, func, srch_mask2) \
private(ompthID, srch_mask, min_add, max_add, n, k, num_srch_cells, max_srch_cells, grid1_addm4, grid1_add, grid2_add, grid2_addm4, \
ioffset, nsrch_corners, corner, next_corn, beglat, beglon, endlat, endlon, lrevers, begseg, lbegin, num_subseg, \
srch_add, srch_corner_lat, srch_corner_lon, weights, intrsct_lat, intrsct_lon, intrsct_lat_off, \
intrsct_lon_off, intrsct_x, intrsct_y, luse_last, last_loc, lthresh, avoid_pole_count, avoid_pole_offset, lcoinc)
#endif
for ( grid2_add = 0; grid2_add < grid2_size; grid2_add++ )
{
#if defined (_OPENMP)
ompthID = omp_get_thread_num();
srch_mask = srch_mask2[ompthID];
#endif
/* Restrict searches first using search bins */
min_add = grid1_size - 1;
......@@ -4210,6 +4295,11 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
/* Create search arrays */
#if defined (_OPENMP)
srch_add = (int *) malloc(num_srch_cells*sizeof(int));
srch_corner_lat = (double *) malloc(srch_corners*num_srch_cells*sizeof(double));
srch_corner_lon = (double *) malloc(srch_corners*num_srch_cells*sizeof(double));
#else
if ( num_srch_cells > max_srch_cells )
{
max_srch_cells = num_srch_cells;
......@@ -4217,6 +4307,7 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
srch_corner_lat = (double *) realloc(srch_corner_lat, srch_corners*num_srch_cells*sizeof(double));
srch_corner_lon = (double *) realloc(srch_corner_lon, srch_corners*num_srch_cells*sizeof(double));
}
#endif
n = 0;
/* gather2 */
......@@ -4335,6 +4426,9 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
if ( ! lcoinc && grid1_add != -1 )
if ( rg->grid1_mask[grid1_add] )
{
#if defined (_OPENMP)
#pragma omp critical
#endif
store_link_cnsrv(rv, grid1_add, grid2_add, weights, link_add1, link_add2);
rg->grid1_frac[grid1_add] += weights[0];
......@@ -4353,17 +4447,31 @@ void remap_conserv(REMAPGRID *rg, REMAPVARS *rv)
}
/* End of segment */
}
#if defined (_OPENMP)
free(srch_add);
free(srch_corner_lat);
free(srch_corner_lon);
#endif
}
if ( cdoTimer ) timer_stop(timer_remap_con3);
/* Finished with all cells: deallocate search arrays */
#if ! defined (_OPENMP)
if ( srch_corner_lon ) free(srch_corner_lon);
if ( srch_corner_lat ) free(srch_corner_lat);
if ( srch_add ) free(srch_add);
#endif
#if defined (_OPENMP)
for ( i = 0; i < ompNumThreads; i++ )
free(srch_mask2[i]);
free(srch_mask2);
#else
free(srch_mask);
#endif
/*
Correct for situations where N/S pole not explicitly included in
......
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