diff --git a/src/USER-NETCDF/dump_netcdf.cpp b/src/USER-NETCDF/dump_netcdf.cpp
index af9f94a728f8b61f43e08480f7b80dc33353d54d..fa222f54c13f708b5572d33c61d4582d08581834 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 890029371e53fea15213fbc5178c50602e0eaad5..7b1103bb71ea3734f1fb38847301cde9c44b59d1 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
         }
       }
     }