// Traj_AmberNetcdf::openTrajin() int Traj_AmberNetcdf::openTrajin() { // If already open, return if (Ncid()!=-1) return 0; if ( NC_openRead( filename_.Full() ) != 0 ) { mprinterr("Error: Opening Netcdf file %s for reading.\n", filename_.base()); return 1; } return 0; }
// Traj_AmberRestartNC::openTrajin() int Traj_AmberRestartNC::openTrajin() { // If already open, return if (Ncid()!=-1) return 0; if ( NC_openRead( filename_.Full() ) != 0 ) { mprinterr("Error: Opening Netcdf restart file %s for reading.\n", filename_.base()); return 1; } if (debug_>1) NetcdfDebug(); return 0; }
// Traj_NcEnsemble::openTrajin() int Traj_NcEnsemble::openTrajin() { // If already open, return if (Ncid()!=-1) return 0; # if HAS_PNETCDF int err = ncmpi_open(MPI_COMM_WORLD, filename_.full(), NC_NOWRITE, MPI_INFO_NULL, &ncid_); //err += ncmpi_begin_indep_data( ncid_ ); // Disable independent data mode # else int err = NC_openRead( filename_.Full() ); # endif if ( err != 0 ) { mprinterr("Error: Opening Netcdf file %s for reading.\n", filename_.base()); return 1; } return 0; }
// Traj_NcEnsemble::setupTrajin() int Traj_NcEnsemble::setupTrajin(FileName const& fname, Topology* trajParm) { # ifdef MPI if (NoPnetcdf()) return TRAJIN_ERR; # endif readAccess_ = true; filename_ = fname; //if (openTrajin()) return TRAJIN_ERR; // Open single thread for now if (NC_openRead( filename_.Full() )) return TRAJIN_ERR; // Sanity check - Make sure this is a Netcdf ensemble trajectory if ( GetNetcdfConventions() != NC_AMBERENSEMBLE ) { mprinterr("Error: Netcdf file %s conventions do not include \"AMBERENSEMBLE\"\n", filename_.base()); return TRAJIN_ERR; } // This will warn if conventions are not 1.0 CheckConventionsVersion(); // Get title SetTitle( GetNcTitle() ); // Get Frame info if ( SetupFrameDim()!=0 ) return TRAJIN_ERR; if ( Ncframe() < 1 ) { mprinterr("Error: Netcdf file is empty.\n"); return TRAJIN_ERR; } // Get ensemble info int ensembleSize = SetupEnsembleDim(); if (ensembleSize < 1) { mprinterr("Error: Could not get ensemble dimension info.\n"); return TRAJIN_ERR; } // Setup Coordinates/Velocities if ( SetupCoordsVelo( useVelAsCoords_, useFrcAsCoords_ )!=0 ) return TRAJIN_ERR; // Check that specified number of atoms matches expected number. if (Ncatom() != trajParm->Natom()) { mprinterr("Error: Number of atoms in NetCDF file %s (%i) does not\n" "Error: match number in associated parmtop (%i)!\n", filename_.base(), Ncatom(), trajParm->Natom()); return TRAJIN_ERR; } // Setup Time - FIXME: Allowed to fail silently SetupTime(); // Box info Box nc_box; if (SetupBox(nc_box, NC_AMBERENSEMBLE) == 1) // 1 indicates an error return TRAJIN_ERR; // Replica Temperatures - FIXME: Allowed to fail silently SetupTemperature(); // Replica Dimensions ReplicaDimArray remdDim; if ( SetupMultiD(remdDim) == -1 ) return TRAJIN_ERR; // Set traj info: FIXME - no forces yet SetCoordInfo( CoordinateInfo(ensembleSize, remdDim, nc_box, HasVelocities(), HasTemperatures(), HasTimes(), false) ); if (debug_>1) NetcdfDebug(); //closeTraj(); // Close single thread for now NC_close(); // Set up local ensemble parameters # ifdef MPI ensembleStart_ = Parallel::World().Rank(); ensembleEnd_ = Parallel::World().Rank() + 1; # else ensembleStart_ = 0; ensembleEnd_ = ensembleSize; # endif // DEBUG: Print info for all ranks WriteVIDs(); // Allocate float array if (Coord_ != 0) delete[] Coord_; Coord_ = new float[ Ncatom3() ]; return Ncframe(); }