Commit 6e342d2e authored by Lars Pastewka's avatar Lars Pastewka
Browse files

MAINT: bigint (int64) maps onto either long or long long, depending on...

MAINT: bigint (int64) maps onto either long or long long, depending on platform. Automatically choose the correct one.
parent f2c11727
Loading
Loading
Loading
Loading
+28 −11
Original line number Diff line number Diff line
@@ -607,6 +607,32 @@ void DumpNetCDF::closefile()

/* ---------------------------------------------------------------------- */

template <typename T>
int nc_put_var1_x(int ncid, int varid, const size_t index[], const T* tp)
{
  return nc_put_var1_double(ncid, varid, index, tp);
}

template <>
int nc_put_var1_x<int>(int ncid, int varid, const size_t index[], const int* tp)
{
  return nc_put_var1_int(ncid, varid, index, tp);
}

template <>
int nc_put_var1_x<long>(int ncid, int varid, const size_t index[],
                        const long* tp)
{
  return nc_put_var1_long(ncid, varid, index, tp);
}

template <>
int nc_put_var1_x<long long>(int ncid, int varid, const size_t index[],
                             const long long* tp)
{
  return nc_put_var1_longlong(ncid, varid, index, tp);
}

void DumpNetCDF::write()
{
  // open file
@@ -638,13 +664,8 @@ void DumpNetCDF::write()
                  th->keyword[i] );
        }
        else if (th->vtype[i] == BIGINT) {
#if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG)
          NCERRX( nc_put_var1_long(ncid, thermovar[i], start, &th->bivalue),
          NCERRX( nc_put_var1_x(ncid, thermovar[i], start, &th->bivalue),
                  th->keyword[i] );
#else
          NCERRX( nc_put_var1_int(ncid, thermovar[i], start, &th->bivalue),
                  th->keyword[i] );
#endif
        }
      }
    }
@@ -930,11 +951,7 @@ void DumpNetCDF::write_prmtop()

  fprintf(f, "%%FLAG POINTERS\n");
  fprintf(f, "%%FORMAT(10I8)\n");
#if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG)
  fprintf(f, "%8li", ntotalgr);
#else
  fprintf(f, "%8i", ntotalgr);
#endif
  fprintf(f, BIGINT_FORMAT, ntotalgr);
  for (int i = 0; i < 11; i++)
    fprintf(f, "%8i", 0);
  fprintf(f, "\n");
+29 −6
Original line number Diff line number Diff line
@@ -583,6 +583,34 @@ void DumpNetCDFMPIIO::closefile()

/* ---------------------------------------------------------------------- */

template <typename T>
int ncmpi_put_var1_x(int ncid, int varid, const MPI_Offset index[],
                     const T* tp)
{
  return ncmpi_put_var1_double(ncid, varid, index, tp);
}

template <>
int ncmpi_put_var1_x<int>(int ncid, int varid, const MPI_Offset index[],
                          const int* tp)
{
  return ncmpi_put_var1_int(ncid, varid, index, tp);
}

template <>
int ncmpi_put_var1_x<long>(int ncid, int varid, const MPI_Offset index[],
                           const long* tp)
{
  return ncmpi_put_var1_long(ncid, varid, index, tp);
}

template <>
int ncmpi_put_var1_x<long long>(int ncid, int varid, const MPI_Offset index[],
                                const long long* tp)
{
  return ncmpi_put_var1_longlong(ncid, varid, index, tp);
}

void DumpNetCDFMPIIO::write()
{
  // open file
@@ -616,13 +644,8 @@ void DumpNetCDFMPIIO::write()
                  th->keyword[i] );
        }
        else if (th->vtype[i] == BIGINT) {
#if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG)
          NCERRX( ncmpi_put_var1_long(ncid, thermovar[i], start, &th->bivalue),
                  th->keyword[i] );
#else
          NCERRX( ncmpi_put_var1_int(ncid, thermovar[i], start, &th->bivalue),
          NCERRX( ncmpi_put_var1_x(ncid, thermovar[i], start, &th->bivalue),
                  th->keyword[i] );
#endif
        }
      }
    }