Skip to content

Commit

Permalink
Bugfix #2979 main_v11.1 MTD Grid (#2980)
Browse files Browse the repository at this point in the history
* Per #2979, remove nc_grid.h/.cc and replace it with calls to the read_netcdf_grid(...) and write_netcdf_proj(...) library utility functions. Note that these changes do compile but I haven't tested whether they actually fix the underlying problem. Also note that nc_utils_local.h/.cc can also likely be replaced with calls to common library functions.

* Per #2979, remove references to nc_grid.o from the MTD test code.

* Per #2979, the write_netcdf_proj(...) utility function adds the lat and lon dimensions. Update mtd to NOT define those dimensions prior to calling write_netcdf_proj(...).

* Per #2979, add this issue to the revision history.
  • Loading branch information
JohnHalleyGotway authored Sep 26, 2024
1 parent 5248377 commit c97ff92
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 751 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ test_velocity_LDADD = \
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_partition.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_read_data.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_txt_output.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_grid.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_utils_local.o \
-lvx_pxm \
-lvx_plot_util \
Expand Down
2 changes: 0 additions & 2 deletions internal/test_util/tools/other/mode_time_domain/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ test_velocity_DEPENDENCIES = ${top_builddir}/src/tools/other/mode_time_domain/mt
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_partition.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_read_data.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_txt_output.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_grid.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_utils_local.o \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
test_velocity_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
Expand Down Expand Up @@ -362,7 +361,6 @@ test_velocity_LDADD = \
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_partition.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_read_data.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_txt_output.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_grid.o \
${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_utils_local.o \
-lvx_pxm \
-lvx_plot_util \
Expand Down
1 change: 0 additions & 1 deletion src/tools/other/mode_time_domain/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bin_PROGRAMS = mtd
mtd_SOURCES = mtd.cc \
mtdfiletype_to_string.cc mtdfiletype_to_string.h \
nc_utils_local.cc nc_utils_local.h \
nc_grid.cc nc_grid.h \
3d_moments.cc 3d_moments.h \
2d_moments.cc 2d_moments.h \
fo_node.cc fo_node.h \
Expand Down
34 changes: 8 additions & 26 deletions src/tools/other/mode_time_domain/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_mtd_OBJECTS = mtd-mtd.$(OBJEXT) mtd-mtdfiletype_to_string.$(OBJEXT) \
mtd-nc_utils_local.$(OBJEXT) mtd-nc_grid.$(OBJEXT) \
mtd-3d_moments.$(OBJEXT) mtd-2d_moments.$(OBJEXT) \
mtd-fo_node.$(OBJEXT) mtd-fo_node_array.$(OBJEXT) \
mtd-fo_graph.$(OBJEXT) mtd-mtd_config_info.$(OBJEXT) \
mtd-mtd_file_base.$(OBJEXT) mtd-mtd_file_float.$(OBJEXT) \
mtd-mtd_file_int.$(OBJEXT) mtd-mtd_read_data.$(OBJEXT) \
mtd-3d_att.$(OBJEXT) mtd-3d_att_single_array.$(OBJEXT) \
mtd-nc_utils_local.$(OBJEXT) mtd-3d_moments.$(OBJEXT) \
mtd-2d_moments.$(OBJEXT) mtd-fo_node.$(OBJEXT) \
mtd-fo_node_array.$(OBJEXT) mtd-fo_graph.$(OBJEXT) \
mtd-mtd_config_info.$(OBJEXT) mtd-mtd_file_base.$(OBJEXT) \
mtd-mtd_file_float.$(OBJEXT) mtd-mtd_file_int.$(OBJEXT) \
mtd-mtd_read_data.$(OBJEXT) mtd-3d_att.$(OBJEXT) \
mtd-3d_att_single_array.$(OBJEXT) \
mtd-3d_att_pair_array.$(OBJEXT) mtd-2d_att.$(OBJEXT) \
mtd-2d_att_array.$(OBJEXT) mtd-3d_conv.$(OBJEXT) \
mtd-mtd_txt_output.$(OBJEXT) mtd-mtd_nc_output.$(OBJEXT) \
Expand Down Expand Up @@ -151,7 +151,7 @@ am__depfiles_remade = ./$(DEPDIR)/mtd-2d_att.Po \
./$(DEPDIR)/mtd-mtd_read_data.Po \
./$(DEPDIR)/mtd-mtd_txt_output.Po \
./$(DEPDIR)/mtd-mtdfiletype_to_string.Po \
./$(DEPDIR)/mtd-nc_grid.Po ./$(DEPDIR)/mtd-nc_utils_local.Po
./$(DEPDIR)/mtd-nc_utils_local.Po
am__mv = mv -f
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
Expand Down Expand Up @@ -357,7 +357,6 @@ MAINTAINERCLEANFILES = Makefile.in
mtd_SOURCES = mtd.cc \
mtdfiletype_to_string.cc mtdfiletype_to_string.h \
nc_utils_local.cc nc_utils_local.h \
nc_grid.cc nc_grid.h \
3d_moments.cc 3d_moments.h \
2d_moments.cc 2d_moments.h \
fo_node.cc fo_node.h \
Expand Down Expand Up @@ -525,7 +524,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-mtd_read_data.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-mtd_txt_output.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-mtdfiletype_to_string.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-nc_grid.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-nc_utils_local.Po@am__quote@ # am--include-marker

$(am__depfiles_remade):
Expand Down Expand Up @@ -590,20 +588,6 @@ mtd-nc_utils_local.obj: nc_utils_local.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mtd-nc_utils_local.obj `if test -f 'nc_utils_local.cc'; then $(CYGPATH_W) 'nc_utils_local.cc'; else $(CYGPATH_W) '$(srcdir)/nc_utils_local.cc'; fi`

mtd-nc_grid.o: nc_grid.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mtd-nc_grid.o -MD -MP -MF $(DEPDIR)/mtd-nc_grid.Tpo -c -o mtd-nc_grid.o `test -f 'nc_grid.cc' || echo '$(srcdir)/'`nc_grid.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtd-nc_grid.Tpo $(DEPDIR)/mtd-nc_grid.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nc_grid.cc' object='mtd-nc_grid.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mtd-nc_grid.o `test -f 'nc_grid.cc' || echo '$(srcdir)/'`nc_grid.cc

mtd-nc_grid.obj: nc_grid.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mtd-nc_grid.obj -MD -MP -MF $(DEPDIR)/mtd-nc_grid.Tpo -c -o mtd-nc_grid.obj `if test -f 'nc_grid.cc'; then $(CYGPATH_W) 'nc_grid.cc'; else $(CYGPATH_W) '$(srcdir)/nc_grid.cc'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtd-nc_grid.Tpo $(DEPDIR)/mtd-nc_grid.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nc_grid.cc' object='mtd-nc_grid.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mtd-nc_grid.obj `if test -f 'nc_grid.cc'; then $(CYGPATH_W) 'nc_grid.cc'; else $(CYGPATH_W) '$(srcdir)/nc_grid.cc'; fi`

mtd-3d_moments.o: 3d_moments.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mtd-3d_moments.o -MD -MP -MF $(DEPDIR)/mtd-3d_moments.Tpo -c -o mtd-3d_moments.o `test -f '3d_moments.cc' || echo '$(srcdir)/'`3d_moments.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtd-3d_moments.Tpo $(DEPDIR)/mtd-3d_moments.Po
Expand Down Expand Up @@ -1048,7 +1032,6 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/mtd-mtd_read_data.Po
-rm -f ./$(DEPDIR)/mtd-mtd_txt_output.Po
-rm -f ./$(DEPDIR)/mtd-mtdfiletype_to_string.Po
-rm -f ./$(DEPDIR)/mtd-nc_grid.Po
-rm -f ./$(DEPDIR)/mtd-nc_utils_local.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
Expand Down Expand Up @@ -1118,7 +1101,6 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/mtd-mtd_read_data.Po
-rm -f ./$(DEPDIR)/mtd-mtd_txt_output.Po
-rm -f ./$(DEPDIR)/mtd-mtdfiletype_to_string.Po
-rm -f ./$(DEPDIR)/mtd-nc_grid.Po
-rm -f ./$(DEPDIR)/mtd-nc_utils_local.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
Expand Down
1 change: 1 addition & 0 deletions src/tools/other/mode_time_domain/mtd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// 004 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main
// 005 08-01-22 Albo MET #1971 Differing time steps
// 006 10-03-22 Prestopnik MET #2227 Remove using namespace std from header files
// 007 09-25-24 Halley Gotway MET #2979 Fix for all supported projections
//
////////////////////////////////////////////////////////////////////////

Expand Down
14 changes: 8 additions & 6 deletions src/tools/other/mode_time_domain/mtd_file_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ using namespace netCDF;
#include "mtd_file.h"
#include "mtd_partition.h"
#include "mtd_nc_defs.h"
#include "nc_grid.h"
#include "nc_utils_local.h"
#include "mtdfiletype_to_string.h"
#include "get_met_grid.h"
#include "write_netcdf.h"

#include "vx_math.h"

Expand Down Expand Up @@ -433,7 +434,7 @@ Nt = GET_NC_SIZE(dim);

G = new Grid;

read_nc_grid(f, *G);
read_netcdf_grid(&f, *G);

// timestamp info

Expand Down Expand Up @@ -480,15 +481,16 @@ void MtdFileBase::write(NcFile & f) const
char junk[256];
ConcatString s;

// Nx, Ny, Nt
// Add the time dimension

add_dim(&f, nx_dim_name, Nx);
add_dim(&f, ny_dim_name, Ny);
add_dim(&f, nt_dim_name, Nt);

// Grid

write_nc_grid(f, *G);
NcDim ny_dim;
NcDim nx_dim;

write_netcdf_proj(&f, *G, ny_dim, nx_dim);

// timestamp info

Expand Down
12 changes: 4 additions & 8 deletions src/tools/other/mode_time_domain/mtd_nc_output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ const bool have_pairs = (fcst_obj.n_objects() != 0)
&& ( obs_obj.n_objects() != 0);

//
// dimensions
// add time dimension
//

nx_dim = add_dim(&out, nx_dim_name, fcst_raw.nx());
ny_dim = add_dim(&out, ny_dim_name, fcst_raw.ny());
nt_dim = add_dim(&out, nt_dim_name, fcst_raw.nt());

//
Expand All @@ -82,7 +80,7 @@ nt_dim = add_dim(&out, nt_dim_name, fcst_raw.nt());
write_netcdf_global(&out, output_filename, "MTD",
config.model.c_str(), config.obtype.c_str(), config.desc.c_str());

write_nc_grid(out, fcst_raw.grid());
write_netcdf_proj(&out, fcst_raw.grid(), ny_dim, nx_dim);

//
// variables
Expand Down Expand Up @@ -150,11 +148,9 @@ if ( IS_INVALID_NC(out) ) {
}

//
// dimensions
// add time dimension
//

nx_dim = add_dim(&out, nx_dim_name, raw.nx());
ny_dim = add_dim(&out, ny_dim_name, raw.ny());
nt_dim = add_dim(&out, nt_dim_name, raw.nt());

//
Expand All @@ -164,7 +160,7 @@ nt_dim = add_dim(&out, nt_dim_name, raw.nt());
write_netcdf_global(&out, output_filename, "MTD",
config.model.c_str(), config.obtype.c_str(), config.desc.c_str());

write_nc_grid(out, raw.grid());
write_netcdf_proj(&out, raw.grid(), ny_dim, nx_dim);

//
// variables
Expand Down
1 change: 0 additions & 1 deletion src/tools/other/mode_time_domain/mtd_nc_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


#include "mtd_nc_defs.h"
#include "nc_grid.h"
#include "nc_utils_local.h"

#include "mtd_file_float.h"
Expand Down
Loading

0 comments on commit c97ff92

Please sign in to comment.