From 8a804460f986da3a52116632d17b98cc77bd80ee Mon Sep 17 00:00:00 2001 From: Lars Pastewka Date: Wed, 1 Nov 2017 21:19:55 +0100 Subject: [PATCH 1/3] MAINT: Use proper data type for bigint when defining NetCDF file. --- src/USER-NETCDF/dump_netcdf.cpp | 5 +++++ src/USER-NETCDF/dump_netcdf_mpiio.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/USER-NETCDF/dump_netcdf.cpp b/src/USER-NETCDF/dump_netcdf.cpp index af9f94a728..fa222f54c1 100644 --- a/src/USER-NETCDF/dump_netcdf.cpp +++ b/src/USER-NETCDF/dump_netcdf.cpp @@ -497,8 +497,13 @@ void DumpNetCDF::openfile() &thermovar[i]), th->keyword[i] ); } else if (th->vtype[i] == BIGINT) { +#if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG) + NCERRX( nc_def_var(ncid, th->keyword[i], NC_INT64, 1, dims, + &thermovar[i]), th->keyword[i] ); +#else NCERRX( nc_def_var(ncid, th->keyword[i], NC_LONG, 1, dims, &thermovar[i]), th->keyword[i] ); +#endif } } } diff --git a/src/USER-NETCDF/dump_netcdf_mpiio.cpp b/src/USER-NETCDF/dump_netcdf_mpiio.cpp index 890029371e..7b1103bb71 100644 --- a/src/USER-NETCDF/dump_netcdf_mpiio.cpp +++ b/src/USER-NETCDF/dump_netcdf_mpiio.cpp @@ -465,8 +465,13 @@ void DumpNetCDFMPIIO::openfile() &thermovar[i]), th->keyword[i] ); } else if (th->vtype[i] == BIGINT) { +#if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG) + NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_INT64, 1, dims, + &thermovar[i]), th->keyword[i] ); +#else NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_LONG, 1, dims, &thermovar[i]), th->keyword[i] ); +#endif } } } From 7ef17efe2e3e28068246c21e9495e71a61e94ed1 Mon Sep 17 00:00:00 2001 From: Lars Pastewka Date: Wed, 1 Nov 2017 21:20:19 +0100 Subject: [PATCH 2/3] MAINT: Removed superfluous code. --- src/USER-NETCDF/dump_netcdf.cpp | 12 ------------ src/USER-NETCDF/dump_netcdf_mpiio.cpp | 13 ------------- 2 files changed, 25 deletions(-) diff --git a/src/USER-NETCDF/dump_netcdf.cpp b/src/USER-NETCDF/dump_netcdf.cpp index fa222f54c1..16cbc64525 100644 --- a/src/USER-NETCDF/dump_netcdf.cpp +++ b/src/USER-NETCDF/dump_netcdf.cpp @@ -325,18 +325,6 @@ void DumpNetCDF::openfile() // variables specified in the input file for (int i = 0; i < n_perat; i++) { - nc_type xtype; - - // Type mangling - if (vtype[perat[i].field[0]] == INT) { - xtype = NC_INT; - } else { - if (double_precision) - xtype = NC_DOUBLE; - else - xtype = NC_FLOAT; - } - NCERRX( nc_inq_varid(ncid, perat[i].name, &perat[i].var), perat[i].name ); } diff --git a/src/USER-NETCDF/dump_netcdf_mpiio.cpp b/src/USER-NETCDF/dump_netcdf_mpiio.cpp index 7b1103bb71..d0090492e4 100644 --- a/src/USER-NETCDF/dump_netcdf_mpiio.cpp +++ b/src/USER-NETCDF/dump_netcdf_mpiio.cpp @@ -321,19 +321,6 @@ void DumpNetCDFMPIIO::openfile() // variables specified in the input file for (int i = 0; i < n_perat; i++) { - nc_type xtype; - - // Type mangling - if (vtype[perat[i].field[0]] == INT) { - xtype = NC_INT; - } - else { - if (double_precision) - xtype = NC_DOUBLE; - else - xtype = NC_FLOAT; - } - NCERRX( ncmpi_inq_varid(ncid, perat[i].name, &perat[i].var), perat[i].name ); } From 91e4bcca335eb0113199058a401fb016b08e72da Mon Sep 17 00:00:00 2001 From: Lars Pastewka Date: Wed, 1 Nov 2017 21:28:14 +0100 Subject: [PATCH 3/3] BUG: openfile is called multiple times, second call stopped code with 'at keyword requires use of append yes' --- src/USER-NETCDF/dump_netcdf.cpp | 1 + src/USER-NETCDF/dump_netcdf_mpiio.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/USER-NETCDF/dump_netcdf.cpp b/src/USER-NETCDF/dump_netcdf.cpp index 16cbc64525..988a9db6c3 100644 --- a/src/USER-NETCDF/dump_netcdf.cpp +++ b/src/USER-NETCDF/dump_netcdf.cpp @@ -599,6 +599,7 @@ void DumpNetCDF::openfile() count[1] = 5; NCERR( nc_put_vara_text(ncid, cell_angular_var, index, count, "gamma") ); + append_flag = 1; framei = 1; } } diff --git a/src/USER-NETCDF/dump_netcdf_mpiio.cpp b/src/USER-NETCDF/dump_netcdf_mpiio.cpp index d0090492e4..168e46a6b7 100644 --- a/src/USER-NETCDF/dump_netcdf_mpiio.cpp +++ b/src/USER-NETCDF/dump_netcdf_mpiio.cpp @@ -575,6 +575,7 @@ void DumpNetCDFMPIIO::openfile() NCERR( ncmpi_end_indep_data(ncid) ); + append_flag = 1; framei = 1; } }