From 7ed854ce0c1d7d1ec2769dd72c2cc27b6eee6ec1 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 13 Nov 2023 12:01:10 -0500 Subject: [PATCH 1/7] group interp with conserves together --- tools/fregrid/conserve_interp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index e363ea7f..2fecc889 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -134,6 +134,10 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles nxgrid = create_xgrid_great_circle(&nx_in, &ny_in, &nx_out, &ny_out, grid_in[m].lonc, grid_in[m].latc, grid_out[n].lonc, grid_out[n].latc, mask, i_in, j_in, i_out, j_out, xgrid_area, xgrid_clon, xgrid_clat); + get_interp( opcode, nxgrid, interp, m, n, i_in, j_in, i_out, j_out, + xgrid_clon, xgrid_clat, xgrid_area ); + malloc_xgrid_arrays(zero, &i_in, &j_in, &i_out, &j_out, &xgrid_area, &xgrid_clon , &xgrid_clat); + } else { @@ -148,7 +152,10 @@ 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); for(i=0; i Date: Mon, 13 Nov 2023 13:45:23 -0500 Subject: [PATCH 2/7] saving work for now --- tools/fregrid/conserve_interp.c | 200 ++++++++++++++++++++------------ tools/fregrid/conserve_interp.h | 10 +- 2 files changed, 132 insertions(+), 78 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index 2fecc889..86838a71 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -59,6 +59,16 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles double time_nxgrid=0; clock_t time_start, time_end; + Minmaxavg_lists out_minmaxavg_lists; + out_minmaxavg_lists.lon_list=NULL; + out_minmaxavg_lists.lat_list=NULL; + out_minmaxavg_lists.lon_min_list=NULL; + out_minmaxavg_lists.lat_min_list=NULL; + out_minmaxavg_lists.lon_max_list=NULL; + out_minmaxavg_lists.lat_max_list=NULL; + out_minmaxavg_lists.n_list=NULL; + out_minmaxavg_lists.lon_avg=NULL; + if( opcode & READ) { read_remap_file(ntiles_in,ntiles_out, grid_out, interp, opcode); } @@ -77,16 +87,6 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles //START NTILES_OUT for(n=0; n Date: Mon, 13 Nov 2023 15:07:58 -0500 Subject: [PATCH 3/7] working? --- tools/fregrid/conserve_interp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index 86838a71..45cbc249 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -135,10 +135,10 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles } else { if(opcode & CONSERVE_ORDER1) { - do_create_xgrid_order1; + do_create_xgrid_order1(n, m, grid_in, grid_out, interp, opcode); } else if(opcode & CONSERVE_ORDER2) { - do_create_xgrid_order2; + do_create_xgrid_order2(n, m, grid_in, grid_out, cell_in, interp, opcode); } else mpp_error("conserve_interp: interp_method should be CONSERVE_ORDER1 or CONSERVE_ORDER2"); From 6ec268be18076d40b8b9fc22fa27bdb72cc422d0 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 13 Nov 2023 15:32:56 -0500 Subject: [PATCH 4/7] for now --- tools/fregrid/conserve_interp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index 45cbc249..3dd5da65 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -114,8 +114,7 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles //START NTILES_IN for(m=0; m Date: Tue, 14 Nov 2023 11:04:45 -0500 Subject: [PATCH 5/7] grid circle function --- tools/fregrid/conserve_interp.c | 45 +++++++++++++++++++++++---------- tools/fregrid/conserve_interp.h | 2 ++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index 3dd5da65..2846f8e7 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -114,23 +114,12 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles //START NTILES_IN for(m=0; m Date: Tue, 14 Nov 2023 14:06:58 -0500 Subject: [PATCH 6/7] pass in minmaxavglists --- tools/fregrid/conserve_interp.c | 11 ++++------- tools/fregrid/conserve_interp.h | 3 ++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/fregrid/conserve_interp.c b/tools/fregrid/conserve_interp.c index 2846f8e7..c05b5035 100644 --- a/tools/fregrid/conserve_interp.c +++ b/tools/fregrid/conserve_interp.c @@ -50,8 +50,6 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles { int n, m, i, ii, jj, nx_in, ny_in, nx_out, ny_out, tile; size_t nxgrid, nxgrid_prev; - int *i_in=NULL, *j_in=NULL, *i_out=NULL, *j_out=NULL; - double *xgrid_area=NULL, *xgrid_clon=NULL, *xgrid_clat=NULL; int mxxgrid, zero=0; CellStruct *cell_in; @@ -126,7 +124,7 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles do_create_xgrid_order1(n, m, grid_in, grid_out, interp, opcode); } else if(opcode & CONSERVE_ORDER2) { - do_create_xgrid_order2(n, m, grid_in, grid_out, cell_in, interp, opcode); + do_create_xgrid_order2(n, m, grid_in, grid_out, &out_minmaxavg_lists, cell_in, interp, opcode); } else mpp_error("conserve_interp: interp_method should be CONSERVE_ORDER1 or CONSERVE_ORDER2"); @@ -314,8 +312,6 @@ void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles } - malloc_xgrid_arrays(zero, &i_in, &j_in, &i_out, &j_out, &xgrid_area, &xgrid_clon, &xgrid_clat); - }; /* setup_conserve_interp */ @@ -867,7 +863,8 @@ void do_create_xgrid_order1( const int n, const int m, } void do_create_xgrid_order2( const int n, const int m, const Grid_config *grid_in, const Grid_config *grid_out, - CellStruct *cell_in, Interp_config *interp, unsigned int opcode ) + Minmaxavg_lists *out_minmaxavg_lists, CellStruct *cell_in, Interp_config *interp, + unsigned int opcode ) { int *i_in=NULL, *j_in=NULL, *i_out=NULL, *j_out=NULL ; @@ -905,7 +902,7 @@ void do_create_xgrid_order2( const int n, const int m, const Grid_config *grid_i #ifdef _OPENACC nxgrid = create_xgrid_2dx2d_order2_acc(&nx_in, &ny_now, &nx_out, &ny_out, grid_in[m].lonc+jstart*(nx_in+1), grid_in[m].latc+jstart*(nx_in+1), grid_out[n].lonc, grid_out[n].latc, - &out_minmaxavg_lists, mask, i_in, j_in, i_out, j_out, + out_minmaxavg_lists, mask, i_in, j_in, i_out, j_out, xgrid_area, xgrid_clon, xgrid_clat); #else nxgrid = create_xgrid_2dx2d_order2(&nx_in, &ny_now, &nx_out, &ny_out, grid_in[m].lonc+jstart*(nx_in+1), diff --git a/tools/fregrid/conserve_interp.h b/tools/fregrid/conserve_interp.h index 93e0fc89..b32af592 100644 --- a/tools/fregrid/conserve_interp.h +++ b/tools/fregrid/conserve_interp.h @@ -33,7 +33,8 @@ void do_create_xgrid_order1( const int n, const int m, const Grid_config *grid_in, const Grid_config *grid_out, Interp_config *interp, unsigned int opcode ) ; void do_create_xgrid_order2( const int n, const int m, const Grid_config *grid_in, const Grid_config *grid_out, - CellStruct *cell_in, Interp_config *interp, unsigned int opcode ) ; + Minmaxavg_lists *out_minmaxavg_lists, CellStruct *cell_in, Interp_config *interp, + unsigned int opcode ) ; void do_great_circle( const int n, const int m, const Grid_config *grid_in, const Grid_config *grid_out, Interp_config *interp, unsigned int opcode); From 3d8a643744a5502f8a67e6a791fa1cdea64b212d Mon Sep 17 00:00:00 2001 From: mlee03 Date: Fri, 15 Dec 2023 14:43:49 -0500 Subject: [PATCH 7/7] move globals.h to libfrenctools --- tools/cubic_utils/Makefile.am | 4 ++-- tools/{fregrid => libfrencutils}/globals.h | 0 tools/make_coupler_mosaic/Makefile.am | 4 ++-- tools/make_hgrid/Makefile.am | 2 +- tools/make_quick_mosaic/Makefile.am | 2 +- tools/make_topog/Makefile.am | 2 +- tools/river_regrid/Makefile.am | 2 +- tools/runoff_regrid/Makefile.am | 2 +- tools/transfer_to_mosaic_grid/Makefile.am | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) rename tools/{fregrid => libfrencutils}/globals.h (100%) diff --git a/tools/cubic_utils/Makefile.am b/tools/cubic_utils/Makefile.am index eeda2c21..dde339a5 100644 --- a/tools/cubic_utils/Makefile.am +++ b/tools/cubic_utils/Makefile.am @@ -20,8 +20,8 @@ bin_PROGRAMS = make_remap_file AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) \ - -I$(top_srcdir)/tools/fregrid + $(NETCDF_CFLAGS) + LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a \ $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) diff --git a/tools/fregrid/globals.h b/tools/libfrencutils/globals.h similarity index 100% rename from tools/fregrid/globals.h rename to tools/libfrencutils/globals.h diff --git a/tools/make_coupler_mosaic/Makefile.am b/tools/make_coupler_mosaic/Makefile.am index e55a3718..d20a842c 100644 --- a/tools/make_coupler_mosaic/Makefile.am +++ b/tools/make_coupler_mosaic/Makefile.am @@ -23,8 +23,8 @@ if WITH_MPI endif AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) \ - -I$(top_srcdir)/tools/fregrid + $(NETCDF_CFLAGS) + LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) make_coupler_mosaic_SOURCES = make_coupler_mosaic.c diff --git a/tools/make_hgrid/Makefile.am b/tools/make_hgrid/Makefile.am index 9bce281b..4cbf7bc3 100644 --- a/tools/make_hgrid/Makefile.am +++ b/tools/make_hgrid/Makefile.am @@ -24,7 +24,7 @@ endif AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid + $(NETCDF_CFLAGS) LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) make_hgrid_SOURCES = create_conformal_cubic_grid.c \ diff --git a/tools/make_quick_mosaic/Makefile.am b/tools/make_quick_mosaic/Makefile.am index 5f5dd756..148805cb 100644 --- a/tools/make_quick_mosaic/Makefile.am +++ b/tools/make_quick_mosaic/Makefile.am @@ -20,7 +20,7 @@ bin_PROGRAMS = make_quick_mosaic AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid + $(NETCDF_CFLAGS) LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a \ $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) diff --git a/tools/make_topog/Makefile.am b/tools/make_topog/Makefile.am index b0826015..169ebc18 100644 --- a/tools/make_topog/Makefile.am +++ b/tools/make_topog/Makefile.am @@ -23,7 +23,7 @@ if WITH_MPI endif AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid + $(NETCDF_CFLAGS) LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) make_topog_SOURCES = make_topog.c \ diff --git a/tools/river_regrid/Makefile.am b/tools/river_regrid/Makefile.am index 6fcd6c76..2e29d1bd 100644 --- a/tools/river_regrid/Makefile.am +++ b/tools/river_regrid/Makefile.am @@ -20,7 +20,7 @@ bin_PROGRAMS = river_regrid AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid + $(NETCDF_CFLAGS) LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a \ $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) diff --git a/tools/runoff_regrid/Makefile.am b/tools/runoff_regrid/Makefile.am index fd18f175..df9a87d7 100644 --- a/tools/runoff_regrid/Makefile.am +++ b/tools/runoff_regrid/Makefile.am @@ -23,7 +23,7 @@ if WITH_MPI endif AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid + $(NETCDF_CFLAGS) LDADD = $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS) runoff_regrid_SOURCES = runoff_regrid.c diff --git a/tools/transfer_to_mosaic_grid/Makefile.am b/tools/transfer_to_mosaic_grid/Makefile.am index e073af98..42d62063 100644 --- a/tools/transfer_to_mosaic_grid/Makefile.am +++ b/tools/transfer_to_mosaic_grid/Makefile.am @@ -20,7 +20,7 @@ bin_PROGRAMS = transfer_to_mosaic_grid AM_CFLAGS = -I$(top_srcdir)/tools/libfrencutils \ - $(NETCDF_CFLAGS) -I$(top_srcdir)/tools/fregrid + $(NETCDF_CFLAGS) LDADD = $(top_builddir)/tools/libfrencutils/libfrencutils.a \ $(NETCDF_LDFLAGS) $(NETCDF_LIBS) $(RPATH_FLAGS)