From c10f3748b00aa248b113ab8f7c5059286aa61bcc Mon Sep 17 00:00:00 2001 From: mlee03 Date: Thu, 14 Sep 2023 13:17:38 -0400 Subject: [PATCH 01/13] add separate create_xgrid_acc file --- tools/fregrid/conserve_interp.c | 10 +- tools/libfrencutils/create_xgrid_acc.c | 204 +++++++++++++++++++++++++ tools/libfrencutils/create_xgrid_acc.h | 30 ++++ 3 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 tools/libfrencutils/create_xgrid_acc.c create mode 100644 tools/libfrencutils/create_xgrid_acc.h diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index d6c2e1e0..0adc43a7 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -26,6 +26,7 @@ #include "constant.h" #include "globals.h" #include "create_xgrid.h" +#include "create_xgrid_acc.h" #include "create_xgrid_util.h" #include "mosaic_util.h" #include "conserve_interp.h" @@ -131,16 +132,21 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles for(i=0; i. + **********************************************************************/ +#include +#include +#include +#include "mosaic_util.h" +#include "create_xgrid.h" +#include "create_xgrid_util.h" +#include "constant.h" + +#define AREA_RATIO_THRESH (1.e-6) +#define MASK_THRESH (0.5) +#define EPSLN8 (1.e-8) +#define EPSLN30 (1.0e-30) +#define EPSLN10 (1.0e-10) + +/******************************************************************************* + create_xgrid_2dx2d_order2 OPENACC version +*******************************************************************************/ +int create_xgrid_2dx2d_order2_acc(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, + const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out, + const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out, + double *xgrid_area, double *xgrid_clon, double *xgrid_clat) +{ + +#define MAX_V 8 + int nx1, nx2, ny1, ny2, nx1p, nx2p, nxgrid; + double *area_in, *area_out; + int ij, i1, j1; + double *lon_out_min_list,*lon_out_max_list,*lon_out_avg,*lat_out_min_list,*lat_out_max_list; + double *lon_out_list, *lat_out_list; + int *n2_list; + int mxxgrid; + + nx1 = *nlon_in; + ny1 = *nlat_in; + nx2 = *nlon_out; + ny2 = *nlat_out; + nx1p = nx1 + 1; + nx2p = nx2 + 1; + mxxgrid = get_maxxgrid(); + + area_in = (double *)malloc(nx1*ny1*sizeof(double)); + area_out = (double *)malloc(nx2*ny2*sizeof(double)); + get_grid_area(nlon_in, nlat_in, lon_in, lat_in, area_in); + get_grid_area(nlon_out, nlat_out, lon_out, lat_out, area_out); + + lon_out_min_list = (double *)malloc(nx2*ny2*sizeof(double)); + lon_out_max_list = (double *)malloc(nx2*ny2*sizeof(double)); + lat_out_min_list = (double *)malloc(nx2*ny2*sizeof(double)); + lat_out_max_list = (double *)malloc(nx2*ny2*sizeof(double)); + lon_out_avg = (double *)malloc(nx2*ny2*sizeof(double)); + n2_list = (int *)malloc(nx2*ny2*sizeof(int)); + lon_out_list = (double *)malloc(MAX_V*nx2*ny2*sizeof(double)); + lat_out_list = (double *)malloc(MAX_V*nx2*ny2*sizeof(double)); + nxgrid = 0; +#pragma acc kernels copyin(lon_out[0:(nx2+1)*(ny2+1)], lat_out[0:(nx2+1)*(ny2+1)], mask_in[0:nx1*ny1], \ + area_in[0:nx1*ny1], area_out[0:nx2*ny2], \ + lon_in[0:(nx1+1)*(ny1+1)], lat_in[0:(nx1+1)*(ny1+1)], \ + nx1, ny1, nx2, ny2, nx1p, nx2p) \ + create(lon_out_list[0:MAX_V*nx2*ny2], lat_out_list[0:MAX_V*nx2*ny2], \ + lat_out_min_list[0:nx2*ny2], lat_out_max_list[0:nx2*ny2], \ + lon_out_min_list[0:nx2*ny2], lon_out_max_list[0:nx2*ny2], \ + lon_out_avg[0:nx2*ny2], n2_list[0:nx2*ny2]) \ + copyout(xgrid_area[0:mxxgrid], xgrid_clon[0:mxxgrid], xgrid_clat[0:mxxgrid], \ + i_in[0:mxxgrid], j_in[0:mxxgrid], i_out[0:mxxgrid],j_out[0:mxxgrid])\ + copy(nxgrid) +{ +#pragma acc loop independent + for(ij=0; ij MAX_V) error_handler("create_xgrid.c: n2_in is greater than MAX_V"); + lon_out_min_list[n] = minval_double(n2_in, x2_in); + lon_out_max_list[n] = maxval_double(n2_in, x2_in); + lon_out_avg[n] = avgval_double(n2_in, x2_in); + n2_list[n] = n2_in; +#pragma acc loop independent + for(l=0; l MASK_THRESH ) { + int n0, n1, n2, n3, n1_in; + double lat_in_min,lat_in_max,lon_in_min,lon_in_max,lon_in_avg; + double x1_in[MV], y1_in[MV]; + n0 = j1*nx1p+i1; n1 = j1*nx1p+i1+1; + n2 = (j1+1)*nx1p+i1+1; n3 = (j1+1)*nx1p+i1; + x1_in[0] = lon_in[n0]; y1_in[0] = lat_in[n0]; + x1_in[1] = lon_in[n1]; y1_in[1] = lat_in[n1]; + x1_in[2] = lon_in[n2]; y1_in[2] = lat_in[n2]; + x1_in[3] = lon_in[n3]; y1_in[3] = lat_in[n3]; + lat_in_min = minval_double(4, y1_in); + lat_in_max = maxval_double(4, y1_in); + n1_in = fix_lon(x1_in, y1_in, 4, M_PI); + lon_in_min = minval_double(n1_in, x1_in); + lon_in_max = maxval_double(n1_in, x1_in); + lon_in_avg = avgval_double(n1_in, x1_in); +#pragma acc loop independent //reduction(+:nxgrid) + for(ij=0; ij= lat_in_max || lat_out_max_list[ij] <= lat_in_min ) continue; + /* adjust x2_in according to lon_in_avg*/ + n2_in = n2_list[ij]; +#pragma acc loop seq + for(l=0; l M_PI) { + lon_out_min -= TPI; + lon_out_max -= TPI; +#pragma acc loop seq + for (l=0; l= lon_in_max || lon_out_max <= lon_in_min ) continue; + n_out = 1; + if ( (n_out = clip_2dx2d( x1_in, y1_in, n1_in, x2_in, y2_in, n2_in, x_out, y_out )) > 0) { + double min_area; + xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1]; + min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]); + if( xarea/min_area > AREA_RATIO_THRESH ) { + xgrid_area[nxgrid] = xarea; + xgrid_clon[nxgrid] = poly_ctrlon(x_out, y_out, n_out, lon_in_avg); + xgrid_clat[nxgrid] = poly_ctrlat (x_out, y_out, n_out ); + i_in[nxgrid] = i1; + j_in[nxgrid] = j1; + i_out[nxgrid] = i2; + j_out[nxgrid] = j2; +#pragma atomic update + nxgrid++; + } + } + } + } + } + + + free(area_in); + free(area_out); + free(lon_out_min_list); + free(lon_out_max_list); + free(lat_out_min_list); + free(lat_out_max_list); + free(lon_out_avg); + free(n2_list); + free(lon_out_list); + free(lat_out_list); + + return nxgrid; + +};/* get_xgrid_2Dx2D_order2 */ diff --git a/tools/libfrencutils/create_xgrid_acc.h b/tools/libfrencutils/create_xgrid_acc.h new file mode 100644 index 00000000..f370fd3e --- /dev/null +++ b/tools/libfrencutils/create_xgrid_acc.h @@ -0,0 +1,30 @@ +/*********************************************************************** + * GNU Lesser General Public License + * + * This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools). + * + * FRE-NCtools is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * FRE-NCtools 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FRE-NCTools. If not, see + * . + **********************************************************************/ +#ifndef CREATE_XGRID_ACC_H_ +#define CREATE_XGRID_ACC_H_ +#endif + +#define MV 50 +/* this value is small compare to earth area */ + +int create_xgrid_2dx2d_order2_acc(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, + const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out, + const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out, + double *xgrid_area, double *xgrid_clon, double *xgrid_clat); From 64060660f9a19bb8124d2f90cfec57eeb3cf15fa Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 08:16:09 -0400 Subject: [PATCH 02/13] add create_xgrid_arrays to conserve_interp_util.h --- tools/fregrid/conserve_interp_util.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/fregrid/conserve_interp_util.h b/tools/fregrid/conserve_interp_util.h index f87643fd..27b18879 100644 --- a/tools/fregrid/conserve_interp_util.h +++ b/tools/fregrid/conserve_interp_util.h @@ -24,5 +24,7 @@ void read_remap_file( int ntiles_in, int ntiles_out, Grid_config *grid_out, Interp_config *interp, unsigned int opcode); +void malloc_xgrid_arrays( int nsize, int **i_in, int **j_in, int **i_out, int **j_out, + double **xgrid_area, double **xgrid_clon, double **xgrid_clat ); #endif From 24fed4f4e51b068f3547a86e55f00aefe3f58f00 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 08:55:27 -0400 Subject: [PATCH 03/13] fix Makefile --- tools/libfrencutils/Makefile.am | 44 +++-- tools/libfrencutils/create_xgrid_acc.c | 204 -------------------- tools/libfrencutils/create_xgrid_acc.h | 30 --- tools/libfrencutils/create_xgrid_util.c | 242 ++++++++++++------------ 4 files changed, 144 insertions(+), 376 deletions(-) delete mode 100644 tools/libfrencutils/create_xgrid_acc.c delete mode 100644 tools/libfrencutils/create_xgrid_acc.h diff --git a/tools/libfrencutils/Makefile.am b/tools/libfrencutils/Makefile.am index 54e3838e..b6e55955 100644 --- a/tools/libfrencutils/Makefile.am +++ b/tools/libfrencutils/Makefile.am @@ -30,27 +30,29 @@ endif AM_CFLAGS = $(NETCDF_CFLAGS) libfrencutils_a_SOURCES = affinity.c \ - constant.h \ - create_xgrid.c \ - create_xgrid.h \ - create_xgrid_util.c \ - create_xgrid_util.h \ - gradient_c2l.c \ - gradient_c2l.h \ - interp.c \ - interp.h \ - mosaic_util.c \ - mosaic_util.h \ - mpp_domain.c \ - mpp_domain.h \ - mpp_io.c \ - mpp_io.h \ - mpp.c \ - mpp.h \ - read_mosaic.c \ - read_mosaic.h \ - tool_util.c \ - tool_util.h + constant.h \ + create_xgrid.c \ + create_xgrid.h \ + create_xgrid_util.c \ + create_xgrid_util.h \ + create_xgrid_acc.c \ + create_xgrid_acc.h \ + gradient_c2l.c \ + gradient_c2l.h \ + interp.c \ + interp.h \ + mosaic_util.c \ + mosaic_util.h \ + mpp_domain.c \ + mpp_domain.h \ + mpp_io.c \ + mpp_io.h \ + mpp.c \ + mpp.h \ + read_mosaic.c \ + read_mosaic.h \ + tool_util.c \ + tool_util.h libfrencutils_mpi_a_SOURCES = $(libfrencutils_a_SOURCES) libfrencutils_mpi_a_CFLAGS = -Duse_libMPI $(MPI_CFLAGS) $(AM_CFLAGS) diff --git a/tools/libfrencutils/create_xgrid_acc.c b/tools/libfrencutils/create_xgrid_acc.c deleted file mode 100644 index 80661597..00000000 --- a/tools/libfrencutils/create_xgrid_acc.c +++ /dev/null @@ -1,204 +0,0 @@ -/*********************************************************************** - * GNU Lesser General Public License - * - * This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools). - * - * FRE-NCtools is free software: you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * FRE-NCtools 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. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FRE-NCTools. If not, see - * . - **********************************************************************/ -#include -#include -#include -#include "mosaic_util.h" -#include "create_xgrid.h" -#include "create_xgrid_util.h" -#include "constant.h" - -#define AREA_RATIO_THRESH (1.e-6) -#define MASK_THRESH (0.5) -#define EPSLN8 (1.e-8) -#define EPSLN30 (1.0e-30) -#define EPSLN10 (1.0e-10) - -/******************************************************************************* - create_xgrid_2dx2d_order2 OPENACC version -*******************************************************************************/ -int create_xgrid_2dx2d_order2_acc(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, - const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out, - const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out, - double *xgrid_area, double *xgrid_clon, double *xgrid_clat) -{ - -#define MAX_V 8 - int nx1, nx2, ny1, ny2, nx1p, nx2p, nxgrid; - double *area_in, *area_out; - int ij, i1, j1; - double *lon_out_min_list,*lon_out_max_list,*lon_out_avg,*lat_out_min_list,*lat_out_max_list; - double *lon_out_list, *lat_out_list; - int *n2_list; - int mxxgrid; - - nx1 = *nlon_in; - ny1 = *nlat_in; - nx2 = *nlon_out; - ny2 = *nlat_out; - nx1p = nx1 + 1; - nx2p = nx2 + 1; - mxxgrid = get_maxxgrid(); - - area_in = (double *)malloc(nx1*ny1*sizeof(double)); - area_out = (double *)malloc(nx2*ny2*sizeof(double)); - get_grid_area(nlon_in, nlat_in, lon_in, lat_in, area_in); - get_grid_area(nlon_out, nlat_out, lon_out, lat_out, area_out); - - lon_out_min_list = (double *)malloc(nx2*ny2*sizeof(double)); - lon_out_max_list = (double *)malloc(nx2*ny2*sizeof(double)); - lat_out_min_list = (double *)malloc(nx2*ny2*sizeof(double)); - lat_out_max_list = (double *)malloc(nx2*ny2*sizeof(double)); - lon_out_avg = (double *)malloc(nx2*ny2*sizeof(double)); - n2_list = (int *)malloc(nx2*ny2*sizeof(int)); - lon_out_list = (double *)malloc(MAX_V*nx2*ny2*sizeof(double)); - lat_out_list = (double *)malloc(MAX_V*nx2*ny2*sizeof(double)); - nxgrid = 0; -#pragma acc kernels copyin(lon_out[0:(nx2+1)*(ny2+1)], lat_out[0:(nx2+1)*(ny2+1)], mask_in[0:nx1*ny1], \ - area_in[0:nx1*ny1], area_out[0:nx2*ny2], \ - lon_in[0:(nx1+1)*(ny1+1)], lat_in[0:(nx1+1)*(ny1+1)], \ - nx1, ny1, nx2, ny2, nx1p, nx2p) \ - create(lon_out_list[0:MAX_V*nx2*ny2], lat_out_list[0:MAX_V*nx2*ny2], \ - lat_out_min_list[0:nx2*ny2], lat_out_max_list[0:nx2*ny2], \ - lon_out_min_list[0:nx2*ny2], lon_out_max_list[0:nx2*ny2], \ - lon_out_avg[0:nx2*ny2], n2_list[0:nx2*ny2]) \ - copyout(xgrid_area[0:mxxgrid], xgrid_clon[0:mxxgrid], xgrid_clat[0:mxxgrid], \ - i_in[0:mxxgrid], j_in[0:mxxgrid], i_out[0:mxxgrid],j_out[0:mxxgrid])\ - copy(nxgrid) -{ -#pragma acc loop independent - for(ij=0; ij MAX_V) error_handler("create_xgrid.c: n2_in is greater than MAX_V"); - lon_out_min_list[n] = minval_double(n2_in, x2_in); - lon_out_max_list[n] = maxval_double(n2_in, x2_in); - lon_out_avg[n] = avgval_double(n2_in, x2_in); - n2_list[n] = n2_in; -#pragma acc loop independent - for(l=0; l MASK_THRESH ) { - int n0, n1, n2, n3, n1_in; - double lat_in_min,lat_in_max,lon_in_min,lon_in_max,lon_in_avg; - double x1_in[MV], y1_in[MV]; - n0 = j1*nx1p+i1; n1 = j1*nx1p+i1+1; - n2 = (j1+1)*nx1p+i1+1; n3 = (j1+1)*nx1p+i1; - x1_in[0] = lon_in[n0]; y1_in[0] = lat_in[n0]; - x1_in[1] = lon_in[n1]; y1_in[1] = lat_in[n1]; - x1_in[2] = lon_in[n2]; y1_in[2] = lat_in[n2]; - x1_in[3] = lon_in[n3]; y1_in[3] = lat_in[n3]; - lat_in_min = minval_double(4, y1_in); - lat_in_max = maxval_double(4, y1_in); - n1_in = fix_lon(x1_in, y1_in, 4, M_PI); - lon_in_min = minval_double(n1_in, x1_in); - lon_in_max = maxval_double(n1_in, x1_in); - lon_in_avg = avgval_double(n1_in, x1_in); -#pragma acc loop independent //reduction(+:nxgrid) - for(ij=0; ij= lat_in_max || lat_out_max_list[ij] <= lat_in_min ) continue; - /* adjust x2_in according to lon_in_avg*/ - n2_in = n2_list[ij]; -#pragma acc loop seq - for(l=0; l M_PI) { - lon_out_min -= TPI; - lon_out_max -= TPI; -#pragma acc loop seq - for (l=0; l= lon_in_max || lon_out_max <= lon_in_min ) continue; - n_out = 1; - if ( (n_out = clip_2dx2d( x1_in, y1_in, n1_in, x2_in, y2_in, n2_in, x_out, y_out )) > 0) { - double min_area; - xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1]; - min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]); - if( xarea/min_area > AREA_RATIO_THRESH ) { - xgrid_area[nxgrid] = xarea; - xgrid_clon[nxgrid] = poly_ctrlon(x_out, y_out, n_out, lon_in_avg); - xgrid_clat[nxgrid] = poly_ctrlat (x_out, y_out, n_out ); - i_in[nxgrid] = i1; - j_in[nxgrid] = j1; - i_out[nxgrid] = i2; - j_out[nxgrid] = j2; -#pragma atomic update - nxgrid++; - } - } - } - } - } - - - free(area_in); - free(area_out); - free(lon_out_min_list); - free(lon_out_max_list); - free(lat_out_min_list); - free(lat_out_max_list); - free(lon_out_avg); - free(n2_list); - free(lon_out_list); - free(lat_out_list); - - return nxgrid; - -};/* get_xgrid_2Dx2D_order2 */ diff --git a/tools/libfrencutils/create_xgrid_acc.h b/tools/libfrencutils/create_xgrid_acc.h deleted file mode 100644 index f370fd3e..00000000 --- a/tools/libfrencutils/create_xgrid_acc.h +++ /dev/null @@ -1,30 +0,0 @@ -/*********************************************************************** - * GNU Lesser General Public License - * - * This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools). - * - * FRE-NCtools is free software: you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * FRE-NCtools 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. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FRE-NCTools. If not, see - * . - **********************************************************************/ -#ifndef CREATE_XGRID_ACC_H_ -#define CREATE_XGRID_ACC_H_ -#endif - -#define MV 50 -/* this value is small compare to earth area */ - -int create_xgrid_2dx2d_order2_acc(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, - const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out, - const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out, - double *xgrid_area, double *xgrid_clon, double *xgrid_clat); diff --git a/tools/libfrencutils/create_xgrid_util.c b/tools/libfrencutils/create_xgrid_util.c index ee84a562..06e1e0e9 100644 --- a/tools/libfrencutils/create_xgrid_util.c +++ b/tools/libfrencutils/create_xgrid_util.c @@ -190,7 +190,7 @@ void get_grid_area_no_adjust(const int *nlon, const int *nlat, const double *lon *******************************************************************************/ int clip(const double lon_in[], const double lat_in[], int n_in, double ll_lon, double ll_lat, - double ur_lon, double ur_lat, double lon_out[], double lat_out[]) + double ur_lon, double ur_lat, double lon_out[], double lat_out[]) { double x_tmp[MV], y_tmp[MV], x_last, y_last; int i_in, i_out, n_out, inside_last, inside; @@ -299,8 +299,8 @@ int clip(const double lon_in[], const double lat_in[], int n_in, double ll_lon, #pragma acc routine seq #endif int clip_2dx2d(const double lon1_in[], const double lat1_in[], int n1_in, - const double lon2_in[], const double lat2_in[], int n2_in, - double lon_out[], double lat_out[]) + const double lon2_in[], const double lat2_in[], int n2_in, + double lon_out[], double lat_out[]) { double lon_tmp[MV], lat_tmp[MV]; double x1_0, y1_0, x1_1, y1_1, x2_0, y2_0, x2_1, y2_1; @@ -308,7 +308,7 @@ int clip_2dx2d(const double lon1_in[], const double lat1_in[], int n1_in, int i_out, n_out, inside_last, inside, i1, i2; // used by pimod update double lon2_tmp[MV], lat2_tmp[MV]; - int gttwopi=0; + int gttwopi=0; /* clip polygon with each boundary of the polygon */ /* We treat lon1_in/lat1_in as clip polygon and lon2_in/lat2_in as subject polygon */ @@ -350,26 +350,26 @@ int clip_2dx2d(const double lon1_in[], const double lat1_in[], int n1_in, /* there is intersection, the line between and should not parallel to the line between and may need to consider truncation error */ - dy1 = y1_1-y1_0; - dy2 = y2_1-y2_0; - dx1 = x1_1-x1_0; - dx2 = x2_1-x2_0; - ds1 = y1_0*x1_1 - y1_1*x1_0; - ds2 = y2_0*x2_1 - y2_1*x2_0; - determ = dy2*dx1 - dy1*dx2; + dy1 = y1_1-y1_0; + dy2 = y2_1-y2_0; + dx1 = x1_1-x1_0; + dx2 = x2_1-x2_0; + ds1 = y1_0*x1_1 - y1_1*x1_0; + ds2 = y2_0*x2_1 - y2_1*x2_0; + determ = dy2*dx1 - dy1*dx2; if(fabs(determ) < EPSLN30) { // TODO error handling needs to be openacc friendly //error_handler("the line between and should not parallel to " // "the line between and "); - } - lon_out[i_out] = (dx2*ds1 - dx1*ds2)/determ; - lat_out[i_out++] = (dy2*ds1 - dy1*ds2)/determ; + } + lon_out[i_out] = (dx2*ds1 - dx1*ds2)/determ; + lat_out[i_out++] = (dy2*ds1 - dy1*ds2)/determ; } if(inside) { - lon_out[i_out] = x1_1; - lat_out[i_out++] = y1_1; + lon_out[i_out] = x1_1; + lat_out[i_out++] = y1_1; } x1_0 = x1_1; y1_0 = y1_1; @@ -410,8 +410,8 @@ void pimod(double x[],int nn) *******************************************************************************/ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const double z1_in[], int n1_in, - const double x2_in[], const double y2_in[], const double z2_in [], int n2_in, - double x_out[], double y_out[], double z_out[]) + const double x2_in[], const double y2_in[], const double z2_in [], int n2_in, + double x_out[], double y_out[], double z_out[]) { struct Node *grid1List=NULL; struct Node *grid2List=NULL; @@ -553,47 +553,47 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do #endif if( line_intersect_2D_3D(p1_0, p1_1, p2_0, p2_1, p2_2, intersect, &u1, &u2, &inbound) ) { - /* from the value of u1, u2 and inbound, we can partially decide if a point is inside or outside of polygon */ - - /* add the intersection into intersetList, The intersection might already be in - intersectList and will be taken care addIntersect - */ - if(addIntersect(intersectList, intersect[0], intersect[1], intersect[2], 1, u1, u2, inbound, i1, i1p, i2, i2p)) { - /* add the intersection into the grid1List */ - - if(u1 == 1) { - insertIntersect(grid1List, intersect[0], intersect[1], intersect[2], 0.0, u2, inbound, p1_1[0], p1_1[1], p1_1[2]); - } - else - insertIntersect(grid1List, intersect[0], intersect[1], intersect[2], u1, u2, inbound, p1_0[0], p1_0[1], p1_0[2]); - /* when u1 == 0 or 1, need to adjust the vertice to intersect value for roundoff error */ - if(u1==1) { - p1_1[0] = intersect[0]; - p1_1[1] = intersect[1]; - p1_1[2] = intersect[2]; - } - else if(u1 == 0) { - p1_0[0] = intersect[0]; - p1_0[1] = intersect[1]; - p1_0[2] = intersect[2]; - } - /* add the intersection into the grid2List */ - if(u2==1) - insertIntersect(grid2List, intersect[0], intersect[1], intersect[2], 0.0, u1, 0, p2_1[0], p2_1[1], p2_1[2]); - else - insertIntersect(grid2List, intersect[0], intersect[1], intersect[2], u2, u1, 0, p2_0[0], p2_0[1], p2_0[2]); - /* when u2 == 0 or 1, need to adjust the vertice to intersect value for roundoff error */ - if(u2==1) { - p2_1[0] = intersect[0]; - p2_1[1] = intersect[1]; - p2_1[2] = intersect[2]; - } - else if(u2 == 0) { - p2_0[0] = intersect[0]; - p2_0[1] = intersect[1]; - p2_0[2] = intersect[2]; - } - } + /* from the value of u1, u2 and inbound, we can partially decide if a point is inside or outside of polygon */ + + /* add the intersection into intersetList, The intersection might already be in + intersectList and will be taken care addIntersect + */ + if(addIntersect(intersectList, intersect[0], intersect[1], intersect[2], 1, u1, u2, inbound, i1, i1p, i2, i2p)) { + /* add the intersection into the grid1List */ + + if(u1 == 1) { + insertIntersect(grid1List, intersect[0], intersect[1], intersect[2], 0.0, u2, inbound, p1_1[0], p1_1[1], p1_1[2]); + } + else + insertIntersect(grid1List, intersect[0], intersect[1], intersect[2], u1, u2, inbound, p1_0[0], p1_0[1], p1_0[2]); + /* when u1 == 0 or 1, need to adjust the vertice to intersect value for roundoff error */ + if(u1==1) { + p1_1[0] = intersect[0]; + p1_1[1] = intersect[1]; + p1_1[2] = intersect[2]; + } + else if(u1 == 0) { + p1_0[0] = intersect[0]; + p1_0[1] = intersect[1]; + p1_0[2] = intersect[2]; + } + /* add the intersection into the grid2List */ + if(u2==1) + insertIntersect(grid2List, intersect[0], intersect[1], intersect[2], 0.0, u1, 0, p2_1[0], p2_1[1], p2_1[2]); + else + insertIntersect(grid2List, intersect[0], intersect[1], intersect[2], u2, u1, 0, p2_0[0], p2_0[1], p2_0[2]); + /* when u2 == 0 or 1, need to adjust the vertice to intersect value for roundoff error */ + if(u2==1) { + p2_1[0] = intersect[0]; + p2_1[1] = intersect[1]; + p2_1[2] = intersect[2]; + } + else if(u2 == 0) { + p2_0[0] = intersect[0]; + p2_0[1] = intersect[1]; + p2_0[2] = intersect[2]; + } + } } } } @@ -679,44 +679,44 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do iter2 = 0; /* Loop until find the next intersection */ while( iter2 < maxiter2 ) { - int temp2IsIntersect; - - temp2IsIntersect = 0; - if( isIntersect( *temp2 ) ) { /* copy the point and switch to the grid2List */ - struct Node *temp3; - - /* first check if temp2 is the firstIntersect */ - if( sameNode( *temp2, *firstIntersect) ) { - found1 = 1; - break; - } - - temp3 = temp2->Next; - if( temp3 == NULL) temp3 = curList; - if( temp3 == NULL) error_handler("creat_xgrid.c: temp3 can not be NULL"); - found2 = 1; - /* if next node is inside or an intersection, - need to keep on curList - */ - temp2IsIntersect = 1; - if( isIntersect(*temp3) || (temp3->isInside == 1) ) found2 = 0; - } - if(found2) { - copyNode(curIntersect, *temp2); - break; - } - else { - addNode(polyList, *temp2); + int temp2IsIntersect; + + temp2IsIntersect = 0; + if( isIntersect( *temp2 ) ) { /* copy the point and switch to the grid2List */ + struct Node *temp3; + + /* first check if temp2 is the firstIntersect */ + if( sameNode( *temp2, *firstIntersect) ) { + found1 = 1; + break; + } + + temp3 = temp2->Next; + if( temp3 == NULL) temp3 = curList; + if( temp3 == NULL) error_handler("creat_xgrid.c: temp3 can not be NULL"); + found2 = 1; + /* if next node is inside or an intersection, + need to keep on curList + */ + temp2IsIntersect = 1; + if( isIntersect(*temp3) || (temp3->isInside == 1) ) found2 = 0; + } + if(found2) { + copyNode(curIntersect, *temp2); + break; + } + else { + addNode(polyList, *temp2); #ifdef debug_test_create_xgrid - printNode(polyList, "polyList at stage 2"); + printNode(polyList, "polyList at stage 2"); #endif - if(temp2IsIntersect) { - nintersect--; - } - } - temp2 = temp2->Next; - if( temp2 == NULL ) temp2 = curList; - iter2 ++; + if(temp2IsIntersect) { + nintersect--; + } + } + temp2 = temp2->Next; + if( temp2 == NULL ) temp2 = curList; + iter2 ++; } if(found1) break; @@ -724,8 +724,8 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do /* if find the first intersection, the poly found */ if( sameNode( *curIntersect, *firstIntersect) ) { - found1 = 1; - break; + found1 = 1; + break; } /* add curIntersect to polyList and remove it from intersectList and curList */ @@ -738,12 +738,12 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do /* switch curList */ if( curListNum == 0) { - curList = grid2List; - curListNum = 1; + curList = grid2List; + curListNum = 1; } else { - curList = grid1List; - curListNum = 0; + curList = grid1List; + curListNum = 0; } iter1++; } @@ -780,9 +780,9 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do while(temp) { if(temp->intersect != 1) { #ifdef debug_test_create_xgrid - printf("grid1->isInside = %d\n", temp->isInside); + printf("grid1->isInside = %d\n", temp->isInside); #endif - if( temp->isInside == 1) n1in2++; + if( temp->isInside == 1) n1in2++; } temp = getNextNode(temp); } @@ -791,9 +791,9 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do n = 0; temp = grid1List; while( temp ) { - getCoordinate(*temp, &x_out[n], &y_out[n], &z_out[n]); - n++; - temp = getNextNode(temp); + getCoordinate(*temp, &x_out[n], &y_out[n], &z_out[n]); + n++; + temp = getNextNode(temp); } } if(n_out>0) return n_out; @@ -811,9 +811,9 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do while(temp) { if(temp->intersect != 1) { #ifdef debug_test_create_xgrid - printf("grid2->isInside = %d\n", temp->isInside); + printf("grid2->isInside = %d\n", temp->isInside); #endif - if( temp->isInside == 1) n2in1++; + if( temp->isInside == 1) n2in1++; } temp = getNextNode(temp); } @@ -823,9 +823,9 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do n = 0; temp = grid2List; while( temp ) { - getCoordinate(*temp, &x_out[n], &y_out[n], &z_out[n]); - n++; - temp = getNextNode(temp); + getCoordinate(*temp, &x_out[n], &y_out[n], &z_out[n]); + n++; + temp = getNextNode(temp); } } @@ -845,7 +845,7 @@ int clip_2dx2d_great_circle(const double x1_in[], const double y1_in[], const do */ int line_intersect_2D_3D(double *a1, double *a2, double *q1, double *q2, double *q3, - double *intersect, double *u_a, double *u_q, int *inbound){ + double *intersect, double *u_a, double *u_q, int *inbound){ /* Do this intersection by reprsenting the line a1 to a2 as a plane through the two line points and the origin of the sphere (0,0,0). This is the @@ -1133,13 +1133,13 @@ double poly_ctrlon(const double x[], const double y[], int n, double clon) } else { if(dphi1 > 0.0) - fac = M_PI; + fac = M_PI; else - fac = -M_PI; + fac = -M_PI; fint = f1 + (f2-f1)*(fac-dphi1)/fabs(dphi); ctrlon -= 0.5*dphi1*(dphi1-fac)*f1 - 0.5*dphi2*(dphi2+fac)*f2 - + 0.5*fac*(dphi1+dphi2)*fint; - } + + 0.5*fac*(dphi1+dphi2)*fint; + } } return (ctrlon*RADIUS*RADIUS); @@ -1201,12 +1201,12 @@ double box_ctrlon(double ll_lon, double ll_lat, double ur_lon, double ur_lat, do } else { if(dphi1 > 0.0) - fac = M_PI; + fac = M_PI; else - fac = -M_PI; + fac = -M_PI; fint = f1 + (f2-f1)*(fac-dphi1)/fabs(dphi); ctrlon -= 0.5*dphi1*(dphi1-fac)*f1 - 0.5*dphi2*(dphi2+fac)*f2 - + 0.5*fac*(dphi1+dphi2)*fint; + + 0.5*fac*(dphi1+dphi2)*fint; } } return (ctrlon*RADIUS*RADIUS); @@ -1237,12 +1237,12 @@ double grid_box_radius(const double *x, const double *y, const double *z, int n) /******************************************************************************* double dist_between_boxes(const double *x1, const double *y1, const double *z1, int n1, - const double *x2, const double *y2, const double *z2, int n2); + const double *x2, const double *y2, const double *z2, int n2); Find the distance between any two grid boxes. The distance is defined by the maximum distance between any vertices of these two box *******************************************************************************/ double dist_between_boxes(const double *x1, const double *y1, const double *z1, int n1, - const double *x2, const double *y2, const double *z2, int n2) + const double *x2, const double *y2, const double *z2, int n2) { double dist; int i, j; From 7726c1b05809cb34e81e4a0b11233f2b45c08877 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 08:56:00 -0400 Subject: [PATCH 04/13] git issues --- tools/libfrencutils/create_xgrid_acc.c | 205 +++++++++++++++++++++++++ tools/libfrencutils/create_xgrid_acc.h | 27 ++++ 2 files changed, 232 insertions(+) create mode 100644 tools/libfrencutils/create_xgrid_acc.c create mode 100644 tools/libfrencutils/create_xgrid_acc.h diff --git a/tools/libfrencutils/create_xgrid_acc.c b/tools/libfrencutils/create_xgrid_acc.c new file mode 100644 index 00000000..ff73b34c --- /dev/null +++ b/tools/libfrencutils/create_xgrid_acc.c @@ -0,0 +1,205 @@ +/*********************************************************************** + * GNU Lesser General Public License + * + * This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools). + * + * FRE-NCtools is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * FRE-NCtools 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FRE-NCTools. If not, see + * . + **********************************************************************/ +#include +#include +#include +#include "mosaic_util.h" +#include "create_xgrid.h" +#include "create_xgrid_util.h" +#include "create_xgrid_acc.h" +#include "constant.h" + +#define AREA_RATIO_THRESH (1.e-6) +#define MASK_THRESH (0.5) +#define EPSLN8 (1.e-8) +#define EPSLN30 (1.0e-30) +#define EPSLN10 (1.0e-10) + +/******************************************************************************* + create_xgrid_2dx2d_order2 OPENACC version +*******************************************************************************/ +int create_xgrid_2dx2d_order2_acc(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, + const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out, + const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out, + double *xgrid_area, double *xgrid_clon, double *xgrid_clat) +{ + +#define MAX_V 8 + int nx1, nx2, ny1, ny2, nx1p, nx2p, nxgrid; + double *area_in, *area_out; + int ij, i1, j1; + double *lon_out_min_list,*lon_out_max_list,*lon_out_avg,*lat_out_min_list,*lat_out_max_list; + double *lon_out_list, *lat_out_list; + int *n2_list; + int mxxgrid; + + nx1 = *nlon_in; + ny1 = *nlat_in; + nx2 = *nlon_out; + ny2 = *nlat_out; + nx1p = nx1 + 1; + nx2p = nx2 + 1; + mxxgrid = get_maxxgrid(); + + area_in = (double *)malloc(nx1*ny1*sizeof(double)); + area_out = (double *)malloc(nx2*ny2*sizeof(double)); + get_grid_area(nlon_in, nlat_in, lon_in, lat_in, area_in); + get_grid_area(nlon_out, nlat_out, lon_out, lat_out, area_out); + + lon_out_min_list = (double *)malloc(nx2*ny2*sizeof(double)); + lon_out_max_list = (double *)malloc(nx2*ny2*sizeof(double)); + lat_out_min_list = (double *)malloc(nx2*ny2*sizeof(double)); + lat_out_max_list = (double *)malloc(nx2*ny2*sizeof(double)); + lon_out_avg = (double *)malloc(nx2*ny2*sizeof(double)); + n2_list = (int *)malloc(nx2*ny2*sizeof(int)); + lon_out_list = (double *)malloc(MAX_V*nx2*ny2*sizeof(double)); + lat_out_list = (double *)malloc(MAX_V*nx2*ny2*sizeof(double)); + nxgrid = 0; +#pragma acc kernels copyin(lon_out[0:(nx2+1)*(ny2+1)], lat_out[0:(nx2+1)*(ny2+1)], mask_in[0:nx1*ny1], \ + area_in[0:nx1*ny1], area_out[0:nx2*ny2], \ + lon_in[0:(nx1+1)*(ny1+1)], lat_in[0:(nx1+1)*(ny1+1)], \ + nx1, ny1, nx2, ny2, nx1p, nx2p) \ + create(lon_out_list[0:MAX_V*nx2*ny2], lat_out_list[0:MAX_V*nx2*ny2], \ + lat_out_min_list[0:nx2*ny2], lat_out_max_list[0:nx2*ny2], \ + lon_out_min_list[0:nx2*ny2], lon_out_max_list[0:nx2*ny2], \ + lon_out_avg[0:nx2*ny2], n2_list[0:nx2*ny2]) \ + copyout(xgrid_area[0:mxxgrid], xgrid_clon[0:mxxgrid], xgrid_clat[0:mxxgrid], \ + i_in[0:mxxgrid], j_in[0:mxxgrid], i_out[0:mxxgrid],j_out[0:mxxgrid])\ + copy(nxgrid) +{ +#pragma acc loop independent + for(ij=0; ij MAX_V) error_handler("create_xgrid.c: n2_in is greater than MAX_V"); + lon_out_min_list[n] = minval_double(n2_in, x2_in); + lon_out_max_list[n] = maxval_double(n2_in, x2_in); + lon_out_avg[n] = avgval_double(n2_in, x2_in); + n2_list[n] = n2_in; +#pragma acc loop independent + for(l=0; l MASK_THRESH ) { + int n0, n1, n2, n3, n1_in; + double lat_in_min,lat_in_max,lon_in_min,lon_in_max,lon_in_avg; + double x1_in[MV], y1_in[MV]; + n0 = j1*nx1p+i1; n1 = j1*nx1p+i1+1; + n2 = (j1+1)*nx1p+i1+1; n3 = (j1+1)*nx1p+i1; + x1_in[0] = lon_in[n0]; y1_in[0] = lat_in[n0]; + x1_in[1] = lon_in[n1]; y1_in[1] = lat_in[n1]; + x1_in[2] = lon_in[n2]; y1_in[2] = lat_in[n2]; + x1_in[3] = lon_in[n3]; y1_in[3] = lat_in[n3]; + lat_in_min = minval_double(4, y1_in); + lat_in_max = maxval_double(4, y1_in); + n1_in = fix_lon(x1_in, y1_in, 4, M_PI); + lon_in_min = minval_double(n1_in, x1_in); + lon_in_max = maxval_double(n1_in, x1_in); + lon_in_avg = avgval_double(n1_in, x1_in); +#pragma acc loop independent //reduction(+:nxgrid) + for(ij=0; ij= lat_in_max || lat_out_max_list[ij] <= lat_in_min ) continue; + /* adjust x2_in according to lon_in_avg*/ + n2_in = n2_list[ij]; +#pragma acc loop seq + for(l=0; l M_PI) { + lon_out_min -= TPI; + lon_out_max -= TPI; +#pragma acc loop seq + for (l=0; l= lon_in_max || lon_out_max <= lon_in_min ) continue; + n_out = 1; + if ( (n_out = clip_2dx2d( x1_in, y1_in, n1_in, x2_in, y2_in, n2_in, x_out, y_out )) > 0) { + double min_area; + xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1]; + min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]); + if( xarea/min_area > AREA_RATIO_THRESH ) { + xgrid_area[nxgrid] = xarea; + xgrid_clon[nxgrid] = poly_ctrlon(x_out, y_out, n_out, lon_in_avg); + xgrid_clat[nxgrid] = poly_ctrlat (x_out, y_out, n_out ); + i_in[nxgrid] = i1; + j_in[nxgrid] = j1; + i_out[nxgrid] = i2; + j_out[nxgrid] = j2; +#pragma atomic update + nxgrid++; + } + } + } + } + } + + + free(area_in); + free(area_out); + free(lon_out_min_list); + free(lon_out_max_list); + free(lat_out_min_list); + free(lat_out_max_list); + free(lon_out_avg); + free(n2_list); + free(lon_out_list); + free(lat_out_list); + + return nxgrid; + +};/* get_xgrid_2Dx2D_order2 */ diff --git a/tools/libfrencutils/create_xgrid_acc.h b/tools/libfrencutils/create_xgrid_acc.h new file mode 100644 index 00000000..ac52e3fb --- /dev/null +++ b/tools/libfrencutils/create_xgrid_acc.h @@ -0,0 +1,27 @@ +/*********************************************************************** + * GNU Lesser General Public License + * + * This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools). + * + * FRE-NCtools is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * FRE-NCtools 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FRE-NCTools. If not, see + * . + **********************************************************************/ +#ifndef CREATE_XGRID_VER_H_ +#define CREATE_XGRID_VER_H_ + +int create_xgrid_2dx2d_order2_acc(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, + const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out, + const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out, + double *xgrid_area, double *xgrid_clon, double *xgrid_clat); +#endif From 1b2805c48e49a86a46a907267b8c08e3d722b2ab Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 11:25:03 -0400 Subject: [PATCH 05/13] phase 1 of openacc to create_xgrid_2dx2d_order2 --- tools/fregrid/conserve_interp.c | 27 ++-- tools/libfrencutils/create_xgrid_acc.c | 181 +++++++++++------------- tools/libfrencutils/create_xgrid_util.c | 169 +++++++++++++++++----- tools/libfrencutils/create_xgrid_util.h | 16 ++- 4 files changed, 239 insertions(+), 154 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index 0adc43a7..abad3862 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -70,19 +70,6 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles read_remap_file(ntiles_in,ntiles_out, grid_out, interp, opcode); } else { - cell_in = (CellStruct *)malloc(ntiles_in * sizeof(CellStruct)); - for(m=0; m MAX_V) error_handler("create_xgrid.c: n2_in is greater than MAX_V"); - lon_out_min_list[n] = minval_double(n2_in, x2_in); - lon_out_max_list[n] = maxval_double(n2_in, x2_in); - lon_out_avg[n] = avgval_double(n2_in, x2_in); - n2_list[n] = n2_in; -#pragma acc loop independent - for(l=0; l MASK_THRESH ) { int n0, n1, n2, n3, n1_in; @@ -132,73 +110,74 @@ int create_xgrid_2dx2d_order2_acc(const int *nlon_in, const int *nlat_in, const lon_in_avg = avgval_double(n1_in, x1_in); #pragma acc loop independent //reduction(+:nxgrid) for(ij=0; ij= lat_in_max || lat_out_max_list[ij] <= lat_in_min ) continue; - /* adjust x2_in according to lon_in_avg*/ - n2_in = n2_list[ij]; + if(lat_out_min_list[ij] >= lat_in_max || lat_out_max_list[ij] <= lat_in_min ) continue; + /* adjust x2_in according to lon_in_avg*/ + n2_in = n2_list[ij]; #pragma acc loop seq - for(l=0; l M_PI) { - lon_out_min -= TPI; - lon_out_max -= TPI; + lon_out_min -= TPI; + lon_out_max -= TPI; #pragma acc loop seq - for (l=0; l= lon_in_max || lon_out_max <= lon_in_min ) continue; - n_out = 1; - if ( (n_out = clip_2dx2d( x1_in, y1_in, n1_in, x2_in, y2_in, n2_in, x_out, y_out )) > 0) { + for (l=0; l= lon_in_max || lon_out_max <= lon_in_min ) continue; + n_out = 1; + if ( (n_out = clip_2dx2d( x1_in, y1_in, n1_in, x2_in, y2_in, n2_in, x_out, y_out )) > 0) { double min_area; - xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1]; - min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]); - if( xarea/min_area > AREA_RATIO_THRESH ) { - xgrid_area[nxgrid] = xarea; - xgrid_clon[nxgrid] = poly_ctrlon(x_out, y_out, n_out, lon_in_avg); - xgrid_clat[nxgrid] = poly_ctrlat (x_out, y_out, n_out ); - i_in[nxgrid] = i1; - j_in[nxgrid] = j1; - i_out[nxgrid] = i2; - j_out[nxgrid] = j2; + xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1]; + min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]); + if( xarea/min_area > AREA_RATIO_THRESH ) { + xgrid_area[nxgrid] = xarea; + xgrid_clon[nxgrid] = poly_ctrlon(x_out, y_out, n_out, lon_in_avg); + xgrid_clat[nxgrid] = poly_ctrlat (x_out, y_out, n_out ); + i_in[nxgrid] = i1; + j_in[nxgrid] = j1; + i_out[nxgrid] = i2; + j_out[nxgrid] = j2; #pragma atomic update - nxgrid++; - } - } + nxgrid++; + } + } } } } +#pragma acc exit data delete(lon_out_list[0:MAX_V*nx2*ny2], lat_out_list[0:MAX_V*nx2*ny2], \ + lat_out_min_list[0:nx2*ny2], lat_out_max_list[0:nx2*ny2], \ + lon_out_min_list[0:nx2*ny2], lon_out_max_list[0:nx2*ny2], \ + lon_out_avg[0:nx2*ny2], n2_list[0:nx2*ny2]) + + n=0; + malloc_minmaxavg_lists(n, &lon_out_min_list, &lon_out_max_list, + &lat_out_min_list, &lat_out_max_list, &n2_list, + &lon_out_avg, &lon_out_list, &lat_out_list); free(area_in); free(area_out); - free(lon_out_min_list); - free(lon_out_max_list); - free(lat_out_min_list); - free(lat_out_max_list); - free(lon_out_avg); - free(n2_list); - free(lon_out_list); - free(lat_out_list); return nxgrid; diff --git a/tools/libfrencutils/create_xgrid_util.c b/tools/libfrencutils/create_xgrid_util.c index 06e1e0e9..03224195 100644 --- a/tools/libfrencutils/create_xgrid_util.c +++ b/tools/libfrencutils/create_xgrid_util.c @@ -29,13 +29,112 @@ #define EPSLN8 (1.e-8) #define EPSLN30 (1.0e-30) #define EPSLN10 (1.0e-10) +#define MAX_V 8 +#define MV 50 + double grid_box_radius(const double *x, const double *y, const double *z, int n); double dist_between_boxes(const double *x1, const double *y1, const double *z1, int n1, - const double *x2, const double *y2, const double *z2, int n2); + const double *x2, const double *y2, const double *z2, int n2); int inside_edge(double x0, double y0, double x1, double y1, double x, double y); int line_intersect_2D_3D(double *a1, double *a2, double *q1, double *q2, double *q3, - double *intersect, double *u_a, double *u_q, int *inbound); + double *intersect, double *u_a, double *u_q, int *inbound); + +/******************************************************************************* + void malloc_minmaxavg_lists + allocates lists to hold min, max, avg values of lat/lon coordinates +*******************************************************************************/ +void malloc_minmaxavg_lists(const int n, + double **lon_min_list, double **lon_max_list, double **lat_min_list, double **lat_max_list, + int **n_list, double **lon_avg, double **lon_list, double **lat_list) +{ + + if(*lon_min_list!=NULL){ + free(*lon_min_list) ; *lon_min_list=NULL; + } + if(*lon_max_list!=NULL){ + free(*lon_max_list) ; *lon_max_list=NULL; + } + if(*lat_min_list!=NULL){ + free(*lat_min_list) ; *lat_min_list=NULL; + } + if(*lat_max_list!=NULL){ + free(*lat_max_list) ; *lat_max_list=NULL; + } + if(*n_list!=NULL){ + free(*n_list) ; *n_list=NULL; + } + if(*lon_avg!=NULL){ + free(*lon_avg) ; *lon_avg=NULL; + } + if(*lon_list!=NULL){ + free(*lon_list) ; *lon_list=NULL; + } + if(*lat_list!=NULL){ + free(*lat_list) ; *lat_list=NULL; + } + + if(n>0){ + *lon_min_list=(double *)malloc(n*sizeof(double)); + *lon_max_list=(double *)malloc(n*sizeof(double)); + *lat_min_list=(double *)malloc(n*sizeof(double)); + *lat_max_list=(double *)malloc(n*sizeof(double)); + *n_list=(int *)malloc(n*sizeof(int)); + *lon_avg=(double *)malloc(n*sizeof(double)); + *lon_list=(double *)malloc(MAX_V*n*sizeof(double)); + *lat_list=(double *)malloc(MAX_V*n*sizeof(double)); + } +}//malloc_minmaxavg_lists + +/******************************************************************************* + void get_minmaxavg_lists + computes lists to hold min, max, avg values of lat/lon coordinates +*******************************************************************************/ +void get_minmaxavg_lists(const int nx, const int ny, const double *lon, const double *lat, + double *lon_min_list, double *lon_max_list, double *lat_min_list, double *lat_max_list, + int *n_list, double *lon_avg, double *lon_list, double *lat_list) +{ + + int nxp, nyp; + + nxp = nx+1; + nyp = ny+1; + +#pragma acc data present(lon[0:nxp*nyp], lat[0:nxp*nyp], lon_min_list[0:nx*ny], lon_max_list[0:nx*ny],\ + lat_min_list[0:nx*ny], lat_max_list[0:nx*ny], n_list[0:nx*ny],\ + lon_avg[0:nx*ny], lon_list[0:MAX_V*nx*ny], lat_list[0:MAX_V*nx*ny]) +#pragma acc parallel loop independent + for(int ij=0; ij MAX_V) error_handler("create_xgrid.c: n_in is greater than MAX_V"); + lon_min_list[n] = minval_double(n_in, x_in); + lon_max_list[n] = maxval_double(n_in, x_in); + lon_avg[n] = avgval_double(n_in, x_in); + n_list[n] = n_in; +#pragma acc loop independent + for(l=0; l Date: Mon, 18 Sep 2023 12:43:35 -0400 Subject: [PATCH 06/13] phase2 of openacc to create_xgrid_2dx2d_order2 --- tools/fregrid/conserve_interp.c | 106 +++++++++++++++++------- tools/libfrencutils/create_xgrid_acc.c | 46 +++------- tools/libfrencutils/create_xgrid_acc.h | 3 + tools/libfrencutils/create_xgrid_util.c | 41 ++++++--- 4 files changed, 117 insertions(+), 79 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index abad3862..961932de 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -49,12 +49,10 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles Grid_config *grid_out, Interp_config *interp, unsigned int opcode) { int n, m, i, ii, jj, nx_in, ny_in, nx_out, ny_out, tile; - size_t nxgrid, nxgrid2, nxgrid_prev; + size_t nxgrid, nxgrid_prev; int *i_in=NULL, *j_in=NULL, *i_out=NULL, *j_out=NULL; - int *tmp_t_in=NULL, *tmp_i_in=NULL, *tmp_j_in=NULL, *tmp_i_out=NULL, *tmp_j_out=NULL; - double *xgrid_area=NULL, *tmp_area=NULL, *xgrid_clon=NULL, *xgrid_clat=NULL; - int mxxgrid; - int zero=0; + double *xgrid_area=NULL, *xgrid_clon=NULL, *xgrid_clat=NULL; + int mxxgrid, zero=0; typedef struct{ double *area; @@ -70,24 +68,64 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles read_remap_file(ntiles_in,ntiles_out, grid_out, interp, opcode); } else { + cell_in = (CellStruct *)malloc(ntiles_in * sizeof(CellStruct)); + for(m=0; m 0 } else mpp_error("conserve_interp: interp_method should be CONSERVE_ORDER1 or CONSERVE_ORDER2"); } //opcode CONSERVE_ORDER2 - free(mask); + +//for all opcodes if(nxgrid > 0) { nxgrid_prev = interp[n].nxgrid; interp[n].nxgrid += nxgrid; @@ -224,25 +273,18 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles } } } /* if(nxgrid>0) */ + malloc_xgrid_arrays(zero, &i_in, &j_in, &i_out, &j_out, &xgrid_area, &xgrid_clon , &xgrid_clat); +#pragma acc exit data delete(grid_in[m].latc, grid_in[m].lonc) } // ntiles_in + free_minmaxavg_lists(&lon_out_min_list, &lon_out_max_list, + &lat_out_min_list, &lat_out_max_list, &n2_list, + &lon_out_avg, &lon_out_list, &lat_out_list); +#pragma acc exit data delete(grid_out[n].latc, grid_out[n].lonc) } // ntimes_out + if(DEBUG) print_time("time_nxgrid", time_nxgrid); if(opcode & CONSERVE_ORDER2) { - - cell_in = (CellStruct *)malloc(ntiles_in * sizeof(CellStruct)); - for(m=0; m MASK_THRESH ) { @@ -166,16 +152,6 @@ get_minmaxavg_lists(nx2, ny2, lon_out, lat_out, } } -#pragma acc exit data delete(lon_out_list[0:MAX_V*nx2*ny2], lat_out_list[0:MAX_V*nx2*ny2], \ - lat_out_min_list[0:nx2*ny2], lat_out_max_list[0:nx2*ny2], \ - lon_out_min_list[0:nx2*ny2], lon_out_max_list[0:nx2*ny2], \ - lon_out_avg[0:nx2*ny2], n2_list[0:nx2*ny2]) - - n=0; - malloc_minmaxavg_lists(n, &lon_out_min_list, &lon_out_max_list, - &lat_out_min_list, &lat_out_max_list, &n2_list, - &lon_out_avg, &lon_out_list, &lat_out_list); - free(area_in); free(area_out); diff --git a/tools/libfrencutils/create_xgrid_acc.h b/tools/libfrencutils/create_xgrid_acc.h index ac52e3fb..823faf18 100644 --- a/tools/libfrencutils/create_xgrid_acc.h +++ b/tools/libfrencutils/create_xgrid_acc.h @@ -22,6 +22,9 @@ int create_xgrid_2dx2d_order2_acc(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out, + const double *lon_out_min_list, const double *lon_out_max_list, const double *lon_out_avg, + const double *lat_out_min_list, const double *lat_out_max_list, const int *n2_list, + const double *lon_out_list, const double *lat_out_list, const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out, double *xgrid_area, double *xgrid_clon, double *xgrid_clat); #endif diff --git a/tools/libfrencutils/create_xgrid_util.c b/tools/libfrencutils/create_xgrid_util.c index 03224195..a0797b84 100644 --- a/tools/libfrencutils/create_xgrid_util.c +++ b/tools/libfrencutils/create_xgrid_util.c @@ -48,6 +48,32 @@ void malloc_minmaxavg_lists(const int n, int **n_list, double **lon_avg, double **lon_list, double **lat_list) { + if(n>0){ + *lon_min_list=(double *)malloc(n*sizeof(double)); + *lon_max_list=(double *)malloc(n*sizeof(double)); + *lat_min_list=(double *)malloc(n*sizeof(double)); + *lat_max_list=(double *)malloc(n*sizeof(double)); + *n_list=(int *)malloc(n*sizeof(int)); + *lon_avg=(double *)malloc(n*sizeof(double)); + *lon_list=(double *)malloc(MAX_V*n*sizeof(double)); + *lat_list=(double *)malloc(MAX_V*n*sizeof(double)); + } + +#pragma acc enter data create(lon_list[0:MAX_V*n], lat_list[0:MAX_V*n], \ + lat_min_list[0:n], lat_max_list[0:n], \ + lon_min_list[0:n], lon_max_list[0:n], \ + lon_avg[0:n], n_list[0:n]) + +}//malloc_minmaxavg_lists + +/******************************************************************************* + void free_minmaxavg_lists + free lists that hold min, max, avg values of lat/lon coordinates +*******************************************************************************/ +void free_minmaxavg_lists(double **lon_min_list, double **lon_max_list, double **lat_min_list, double **lat_max_list, + int **n_list, double **lon_avg, double **lon_list, double **lat_list) +{ + if(*lon_min_list!=NULL){ free(*lon_min_list) ; *lon_min_list=NULL; } @@ -72,19 +98,10 @@ void malloc_minmaxavg_lists(const int n, if(*lat_list!=NULL){ free(*lat_list) ; *lat_list=NULL; } +#pragma acc exit data delete(lon_min_list, lon_max_list, lat_min_list, \ + lat_max_list, n_list, lon_avg, lon_list, lat_list) - if(n>0){ - *lon_min_list=(double *)malloc(n*sizeof(double)); - *lon_max_list=(double *)malloc(n*sizeof(double)); - *lat_min_list=(double *)malloc(n*sizeof(double)); - *lat_max_list=(double *)malloc(n*sizeof(double)); - *n_list=(int *)malloc(n*sizeof(int)); - *lon_avg=(double *)malloc(n*sizeof(double)); - *lon_list=(double *)malloc(MAX_V*n*sizeof(double)); - *lat_list=(double *)malloc(MAX_V*n*sizeof(double)); - } - -}//malloc_minmaxavg_lists +} /******************************************************************************* void get_minmaxavg_lists From f9863889fda719edaa9b4399da4458ab43694659 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 13:38:21 -0400 Subject: [PATCH 07/13] copy/free lists on gpu --- tools/fregrid/conserve_interp.c | 17 +++++++--- tools/libfrencutils/create_xgrid_util.c | 41 ++++++++----------------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index 961932de..f3f5cbe9 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -101,6 +101,12 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles &lat_out_min_list, &lat_out_max_list, &n2_list, &lon_out_avg, &lon_out_list, &lat_out_list); +#define MAX_V 8 +#pragma acc enter data create(lon_out_list[0:MAX_V*nx_out*ny_out], lat_out_list[0:MAX_V*nx_out*ny_out], \ + lat_out_min_list[0:nx_out*ny_out], lat_out_max_list[0:nx_out*ny_out], \ + lon_out_min_list[0:nx_out*ny_out], lon_out_max_list[0:nx_out*ny_out], \ + lon_out_avg[0:nx_out*ny_out], n2_list[0:nx_out*ny_out]) + //compute the list values get_minmaxavg_lists(nx_out, ny_out, grid_out[n].lonc, grid_out[n].latc, lon_out_min_list, lon_out_max_list, lat_out_min_list, lat_out_max_list, @@ -131,6 +137,7 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles mask, i_in, j_in, i_out, j_out, xgrid_area, xgrid_clon, xgrid_clat); } else { + y_min = minval_double((nx_out+1)*(ny_out+1), grid_out[n].latc); y_max = maxval_double((nx_out+1)*(ny_out+1), grid_out[n].latc); jstart = ny_in; jend = -1; @@ -155,7 +162,7 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles grid_in[m].latc+jstart*(nx_in+1), grid_out[n].lonc, grid_out[n].latc, mask, i_in, j_in, i_out, j_out, xgrid_area); for(i=0; i0){ - *lon_min_list=(double *)malloc(n*sizeof(double)); - *lon_max_list=(double *)malloc(n*sizeof(double)); - *lat_min_list=(double *)malloc(n*sizeof(double)); - *lat_max_list=(double *)malloc(n*sizeof(double)); - *n_list=(int *)malloc(n*sizeof(int)); - *lon_avg=(double *)malloc(n*sizeof(double)); - *lon_list=(double *)malloc(MAX_V*n*sizeof(double)); - *lat_list=(double *)malloc(MAX_V*n*sizeof(double)); - } - -#pragma acc enter data create(lon_list[0:MAX_V*n], lat_list[0:MAX_V*n], \ - lat_min_list[0:n], lat_max_list[0:n], \ - lon_min_list[0:n], lon_max_list[0:n], \ - lon_avg[0:n], n_list[0:n]) - -}//malloc_minmaxavg_lists - -/******************************************************************************* - void free_minmaxavg_lists - free lists that hold min, max, avg values of lat/lon coordinates -*******************************************************************************/ -void free_minmaxavg_lists(double **lon_min_list, double **lon_max_list, double **lat_min_list, double **lat_max_list, - int **n_list, double **lon_avg, double **lon_list, double **lat_list) -{ - if(*lon_min_list!=NULL){ free(*lon_min_list) ; *lon_min_list=NULL; } @@ -98,10 +72,19 @@ void free_minmaxavg_lists(double **lon_min_list, double **lon_max_list, double * if(*lat_list!=NULL){ free(*lat_list) ; *lat_list=NULL; } -#pragma acc exit data delete(lon_min_list, lon_max_list, lat_min_list, \ - lat_max_list, n_list, lon_avg, lon_list, lat_list) -} + if(n>0){ + *lon_min_list=(double *)malloc(n*sizeof(double)); + *lon_max_list=(double *)malloc(n*sizeof(double)); + *lat_min_list=(double *)malloc(n*sizeof(double)); + *lat_max_list=(double *)malloc(n*sizeof(double)); + *n_list=(int *)malloc(n*sizeof(int)); + *lon_avg=(double *)malloc(n*sizeof(double)); + *lon_list=(double *)malloc(MAX_V*n*sizeof(double)); + *lat_list=(double *)malloc(MAX_V*n*sizeof(double)); + } + +}//malloc_minmaxavg_lists /******************************************************************************* void get_minmaxavg_lists From cd98ce70df9ab4e8ddf9530506f83525877fa755 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 13:45:16 -0400 Subject: [PATCH 08/13] remove HELLO --- tools/fregrid/conserve_interp.c | 4 +--- tools/libfrencutils/Makefile.am | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index f3f5cbe9..ec3cb737 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -96,7 +96,7 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles #pragma acc enter data copyin(grid_out[n].lonc[0:(nx_out+1)*(ny_out+1)], \ grid_out[n].latc[0:(nx_out+1)*(ny_out+1)]) - //allocate memory for the lists; creates space on GPU + //allocate memory for the lists malloc_minmaxavg_lists(nx_out*ny_out, &lon_out_min_list, &lon_out_max_list, &lat_out_min_list, &lat_out_max_list, &n2_list, &lon_out_avg, &lon_out_list, &lat_out_list); @@ -117,8 +117,6 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles double *mask, y_min, y_max, yy; int jstart, jend, ny_now, j; - printf("HERE\n"); - nx_in = grid_in[m].nx; ny_in = grid_in[m].ny; diff --git a/tools/libfrencutils/Makefile.am b/tools/libfrencutils/Makefile.am index b6e55955..b30a0d9e 100644 --- a/tools/libfrencutils/Makefile.am +++ b/tools/libfrencutils/Makefile.am @@ -19,20 +19,20 @@ #*********************************************************************** noinst_LIBRARIES = libfrencutils.a if WITH_MPI - noinst_LIBRARIES += libfrencutils_mpi.a + noinst_LIBRARIES += libfrencutils_mpi.a endif if WITH_OPENACC - noinst_LIBRARIES += libfrencutils_gpu.a - libfrencutils_gpu_a_SOURCES = $(libfrencutils_a_SOURCES) - libfrencutils_gpu_a_CFLAGS = $(CC_OPENACC_FLAGS) $(AM_CFLAGS) + noinst_LIBRARIES += libfrencutils_gpu.a + libfrencutils_gpu_a_SOURCES = $(libfrencutils_a_SOURCES) + libfrencutils_gpu_a_CFLAGS = $(CC_OPENACC_FLAGS) $(AM_CFLAGS) endif AM_CFLAGS = $(NETCDF_CFLAGS) libfrencutils_a_SOURCES = affinity.c \ - constant.h \ - create_xgrid.c \ - create_xgrid.h \ + constant.h \ + create_xgrid.c \ + create_xgrid.h \ create_xgrid_util.c \ create_xgrid_util.h \ create_xgrid_acc.c \ @@ -46,11 +46,11 @@ libfrencutils_a_SOURCES = affinity.c \ mpp_domain.c \ mpp_domain.h \ mpp_io.c \ - mpp_io.h \ + mpp_io.h \ mpp.c \ - mpp.h \ + mpp.h \ read_mosaic.c \ - read_mosaic.h \ + read_mosaic.h \ tool_util.c \ tool_util.h From e09a6b3145f4766d4184ed9449150ba22123d768 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 13:48:05 -0400 Subject: [PATCH 09/13] makefile.am spacings --- tools/libfrencutils/Makefile.am | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tools/libfrencutils/Makefile.am b/tools/libfrencutils/Makefile.am index b30a0d9e..97d3ee28 100644 --- a/tools/libfrencutils/Makefile.am +++ b/tools/libfrencutils/Makefile.am @@ -30,29 +30,29 @@ endif AM_CFLAGS = $(NETCDF_CFLAGS) libfrencutils_a_SOURCES = affinity.c \ - constant.h \ - create_xgrid.c \ - create_xgrid.h \ - create_xgrid_util.c \ - create_xgrid_util.h \ - create_xgrid_acc.c \ - create_xgrid_acc.h \ - gradient_c2l.c \ - gradient_c2l.h \ - interp.c \ - interp.h \ - mosaic_util.c \ - mosaic_util.h \ - mpp_domain.c \ - mpp_domain.h \ - mpp_io.c \ - mpp_io.h \ - mpp.c \ - mpp.h \ - read_mosaic.c \ - read_mosaic.h \ - tool_util.c \ - tool_util.h + constant.h \ + create_xgrid.c \ + create_xgrid.h \ + create_xgrid_util.c \ + create_xgrid_util.h \ + create_xgrid_acc.c \ + create_xgrid_acc.h \ + gradient_c2l.c \ + gradient_c2l.h \ + interp.c \ + interp.h \ + mosaic_util.c \ + mosaic_util.h \ + mpp_domain.c \ + mpp_domain.h \ + mpp_io.c \ + mpp_io.h \ + mpp.c \ + mpp.h \ + read_mosaic.c \ + read_mosaic.h \ + tool_util.c \ + tool_util.h libfrencutils_mpi_a_SOURCES = $(libfrencutils_a_SOURCES) libfrencutils_mpi_a_CFLAGS = -Duse_libMPI $(MPI_CFLAGS) $(AM_CFLAGS) From 9c9bcef2e805e4c7efaf3a2ce5cde2c822c2f194 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 13:49:57 -0400 Subject: [PATCH 10/13] makefile.am spacing --- tools/libfrencutils/Makefile.am | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tools/libfrencutils/Makefile.am b/tools/libfrencutils/Makefile.am index 97d3ee28..67d73d45 100644 --- a/tools/libfrencutils/Makefile.am +++ b/tools/libfrencutils/Makefile.am @@ -30,29 +30,29 @@ endif AM_CFLAGS = $(NETCDF_CFLAGS) libfrencutils_a_SOURCES = affinity.c \ - constant.h \ - create_xgrid.c \ - create_xgrid.h \ - create_xgrid_util.c \ - create_xgrid_util.h \ - create_xgrid_acc.c \ - create_xgrid_acc.h \ - gradient_c2l.c \ - gradient_c2l.h \ - interp.c \ - interp.h \ - mosaic_util.c \ - mosaic_util.h \ - mpp_domain.c \ - mpp_domain.h \ - mpp_io.c \ - mpp_io.h \ - mpp.c \ - mpp.h \ - read_mosaic.c \ - read_mosaic.h \ - tool_util.c \ - tool_util.h + constant.h \ + create_xgrid.c \ + create_xgrid.h \ + create_xgrid_util.c \ + create_xgrid_util.h \ + create_xgrid_acc.c \ + create_xgrid_acc.h \ + gradient_c2l.c \ + gradient_c2l.h \ + interp.c \ + interp.h \ + mosaic_util.c \ + mosaic_util.h \ + mpp_domain.c \ + mpp_domain.h \ + mpp_io.c \ + mpp_io.h \ + mpp.c \ + mpp.h \ + read_mosaic.c \ + read_mosaic.h \ + tool_util.c \ + tool_util.h libfrencutils_mpi_a_SOURCES = $(libfrencutils_a_SOURCES) libfrencutils_mpi_a_CFLAGS = -Duse_libMPI $(MPI_CFLAGS) $(AM_CFLAGS) From 66391cad105ebf07fade90ed543111ff41154536 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 13:52:43 -0400 Subject: [PATCH 11/13] makefile spacing again --- tools/libfrencutils/Makefile.am | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tools/libfrencutils/Makefile.am b/tools/libfrencutils/Makefile.am index 67d73d45..607a8a53 100644 --- a/tools/libfrencutils/Makefile.am +++ b/tools/libfrencutils/Makefile.am @@ -30,29 +30,29 @@ endif AM_CFLAGS = $(NETCDF_CFLAGS) libfrencutils_a_SOURCES = affinity.c \ - constant.h \ - create_xgrid.c \ - create_xgrid.h \ - create_xgrid_util.c \ - create_xgrid_util.h \ - create_xgrid_acc.c \ - create_xgrid_acc.h \ - gradient_c2l.c \ - gradient_c2l.h \ - interp.c \ - interp.h \ - mosaic_util.c \ - mosaic_util.h \ - mpp_domain.c \ - mpp_domain.h \ - mpp_io.c \ - mpp_io.h \ - mpp.c \ - mpp.h \ - read_mosaic.c \ - read_mosaic.h \ - tool_util.c \ - tool_util.h + constant.h \ + create_xgrid.c \ + create_xgrid.h \ + create_xgrid_util.c \ + create_xgrid_util.h \ + create_xgrid_acc.c \ + create_xgrid_acc.h \ + gradient_c2l.c \ + gradient_c2l.h \ + interp.c \ + interp.h \ + mosaic_util.c \ + mosaic_util.h \ + mpp_domain.c \ + mpp_domain.h \ + mpp_io.c \ + mpp_io.h \ + mpp.c \ + mpp.h \ + read_mosaic.c \ + read_mosaic.h \ + tool_util.c \ + tool_util.h libfrencutils_mpi_a_SOURCES = $(libfrencutils_a_SOURCES) libfrencutils_mpi_a_CFLAGS = -Duse_libMPI $(MPI_CFLAGS) $(AM_CFLAGS) From bc5aea5d168b017ea09e19657c9fde123717ee46 Mon Sep 17 00:00:00 2001 From: MiKyung Lee <58964324+mlee03@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:31:04 -0400 Subject: [PATCH 12/13] makefile.am spacings --- tools/libfrencutils/Makefile.am | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tools/libfrencutils/Makefile.am b/tools/libfrencutils/Makefile.am index 607a8a53..8be45e25 100644 --- a/tools/libfrencutils/Makefile.am +++ b/tools/libfrencutils/Makefile.am @@ -30,29 +30,29 @@ endif AM_CFLAGS = $(NETCDF_CFLAGS) libfrencutils_a_SOURCES = affinity.c \ - constant.h \ - create_xgrid.c \ - create_xgrid.h \ - create_xgrid_util.c \ - create_xgrid_util.h \ - create_xgrid_acc.c \ - create_xgrid_acc.h \ - gradient_c2l.c \ - gradient_c2l.h \ - interp.c \ - interp.h \ - mosaic_util.c \ - mosaic_util.h \ - mpp_domain.c \ - mpp_domain.h \ - mpp_io.c \ - mpp_io.h \ - mpp.c \ - mpp.h \ - read_mosaic.c \ - read_mosaic.h \ - tool_util.c \ - tool_util.h + constant.h \ + create_xgrid.c \ + create_xgrid.h \ + create_xgrid_util.c \ + create_xgrid_util.h \ + create_xgrid_acc.c \ + create_xgrid_acc.h \ + gradient_c2l.c \ + gradient_c2l.h \ + interp.c \ + interp.h \ + mosaic_util.c \ + mosaic_util.h \ + mpp_domain.c \ + mpp_domain.h \ + mpp_io.c \ + mpp_io.h \ + mpp.c \ + mpp.h \ + read_mosaic.c \ + read_mosaic.h \ + tool_util.c \ + tool_util.h libfrencutils_mpi_a_SOURCES = $(libfrencutils_a_SOURCES) libfrencutils_mpi_a_CFLAGS = -Duse_libMPI $(MPI_CFLAGS) $(AM_CFLAGS) From c1519f9d4635343d7adecc4f49372d7564aa51ee Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 18 Sep 2023 14:43:45 -0400 Subject: [PATCH 13/13] spacing omg --- tools/libfrencutils/Makefile.am | 54 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tools/libfrencutils/Makefile.am b/tools/libfrencutils/Makefile.am index 8be45e25..c0afb12f 100644 --- a/tools/libfrencutils/Makefile.am +++ b/tools/libfrencutils/Makefile.am @@ -19,40 +19,40 @@ #*********************************************************************** noinst_LIBRARIES = libfrencutils.a if WITH_MPI - noinst_LIBRARIES += libfrencutils_mpi.a + noinst_LIBRARIES += libfrencutils_mpi.a endif if WITH_OPENACC - noinst_LIBRARIES += libfrencutils_gpu.a - libfrencutils_gpu_a_SOURCES = $(libfrencutils_a_SOURCES) - libfrencutils_gpu_a_CFLAGS = $(CC_OPENACC_FLAGS) $(AM_CFLAGS) + noinst_LIBRARIES += libfrencutils_gpu.a + libfrencutils_gpu_a_SOURCES = $(libfrencutils_a_SOURCES) + libfrencutils_gpu_a_CFLAGS = $(CC_OPENACC_FLAGS) $(AM_CFLAGS) endif AM_CFLAGS = $(NETCDF_CFLAGS) libfrencutils_a_SOURCES = affinity.c \ - constant.h \ - create_xgrid.c \ - create_xgrid.h \ - create_xgrid_util.c \ - create_xgrid_util.h \ - create_xgrid_acc.c \ - create_xgrid_acc.h \ - gradient_c2l.c \ - gradient_c2l.h \ - interp.c \ - interp.h \ - mosaic_util.c \ - mosaic_util.h \ - mpp_domain.c \ - mpp_domain.h \ - mpp_io.c \ - mpp_io.h \ - mpp.c \ - mpp.h \ - read_mosaic.c \ - read_mosaic.h \ - tool_util.c \ - tool_util.h + constant.h \ + create_xgrid.c \ + create_xgrid.h \ + create_xgrid_util.c \ + create_xgrid_util.h \ + create_xgrid_acc.c \ + create_xgrid_acc.h \ + gradient_c2l.c \ + gradient_c2l.h \ + interp.c \ + interp.h \ + mosaic_util.c \ + mosaic_util.h \ + mpp_domain.c \ + mpp_domain.h \ + mpp_io.c \ + mpp_io.h \ + mpp.c \ + mpp.h \ + read_mosaic.c \ + read_mosaic.h \ + tool_util.c \ + tool_util.h libfrencutils_mpi_a_SOURCES = $(libfrencutils_a_SOURCES) libfrencutils_mpi_a_CFLAGS = -Duse_libMPI $(MPI_CFLAGS) $(AM_CFLAGS)