1 /* -*- c++ -*- ----------------------------------------------------------
2    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3    https://www.lammps.org/, Sandia National Laboratories
4    Steve Plimpton, sjplimp@sandia.gov
5 
6    Copyright (2003) Sandia Corporation.  Under the terms of Contract
7    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
8    certain rights in this software.  This software is distributed under
9    the GNU General Public License.
10 
11    See the README file in the top-level LAMMPS directory.
12 ------------------------------------------------------------------------- */
13 
14 /* ----------------------------------------------------------------------
15    Contributing author: Lars Pastewka (University of Freiburg)
16 ------------------------------------------------------------------------- */
17 
18 #if defined(LMP_HAS_PNETCDF)
19 
20 #ifdef DUMP_CLASS
21 // clang-format off
22 DumpStyle(netcdf/mpiio,DumpNetCDFMPIIO);
23 // clang-format on
24 #else
25 
26 #ifndef LMP_DUMP_NETCDF_MPIIO_H
27 #define LMP_DUMP_NETCDF_MPIIO_H
28 
29 #include "dump_custom.h"
30 
31 namespace LAMMPS_NS {
32 
33 const int NC_MPIIO_FIELD_NAME_MAX = 100;
34 const int DUMP_NC_MPIIO_MAX_DIMS = 100;
35 
36 class DumpNetCDFMPIIO : public DumpCustom {
37  public:
38   DumpNetCDFMPIIO(class LAMMPS *, int, char **);
39   virtual ~DumpNetCDFMPIIO();
40   virtual void write();
41 
42  private:
43   // per-atoms quantities (positions, velocities, etc.)
44   struct nc_perat_t {
45     int dims;                              // number of dimensions
46     int field[DUMP_NC_MPIIO_MAX_DIMS];     // field indices corresponding to the dim.
47     char name[NC_MPIIO_FIELD_NAME_MAX];    // field name
48     int var;                               // NetCDF variable
49   };
50 
51   typedef void (DumpNetCDFMPIIO::*funcptr_t)(void *);
52 
53   int framei;    // current frame index
54   int blocki;    // current block index
55   int ndata;     // number of data blocks to expect
56 
57   bigint ntotalgr;    // # of atoms
58 
59   int n_perat;          // # of netcdf per-atom properties
60   nc_perat_t *perat;    // per-atom properties
61 
62   int *thermovar;    // NetCDF variables for thermo output
63 
64   bool double_precision;    // write everything as double precision
65   bool thermo;              // write thermo output to netcdf file
66 
67   bigint n_buffer;          // size of buffer
68   bigint *int_buffer;       // buffer for passing data to netcdf
69   double *double_buffer;    // buffer for passing data to netcdf
70 
71   int ncid;
72 
73   int frame_dim;
74   int vector_dim[DUMP_NC_MPIIO_MAX_DIMS];
75   int atom_dim;
76   int cell_spatial_dim;
77   int cell_angular_dim;
78   int label_dim;
79 
80   int spatial_var;
81   int cell_spatial_var;
82   int cell_angular_var;
83 
84   int time_var;
85   int cell_origin_var;
86   int cell_lengths_var;
87   int cell_angles_var;
88 
89   virtual void openfile();
90   void closefile();
91   void write_time_and_cell();
92   virtual void write_data(int, double *);
93   void write_prmtop();
94 
95   virtual int modify_param(int, char **);
96 
97   void ncerr(int, const char *, int);
98 };
99 
100 }    // namespace LAMMPS_NS
101 
102 #endif
103 #endif
104 #endif /* defined(LMP_HAS_PNETCDF) */
105