// EnsembleOut_Single::PrintInfo() void EnsembleOut_Single::PrintInfo(int expectedNframes) const { mprintf(" '%s' (Single Ensemble, %i members",Traj().Filename().base(), ensembleSize_); if (expectedNframes > 0) mprintf(", %i frames", expectedNframes); mprintf(") "); eio_->Info(); Traj().CommonInfo(); }
void EnsembleIn_Single::EnsembleInfo(int showExtended) const { mprintf("'%s' (REMD ensemble size %i) ",Traj().Filename().base(), ensembleSize_); eio_->Info(); mprintf(", Parm %s",Traj().Parm()->c_str()); if (cInfo_.HasBox()) mprintf(" (%s box)", cInfo_.TrajBox().TypeName()); if (showExtended==1) Traj().Counter().PrintFrameInfo(); if (debug_>0) mprintf(", %i atoms, Box %i",Traj().Parm()->Natom(),(int)cInfo_.HasBox()); }
// Trajin_Multi::PrintInfo() void Trajin_Multi::PrintInfo(int showExtended) const { mprintf("REMD trajectories (%u total), lowest replica '%s'", REMDtraj_.size(), Traj().Filename().base()); if (showExtended == 1) Traj().Counter().PrintFrameInfo(); mprintf("\n"); if (debug_ > 0) REMDtraj_.PrintIOinfo(); if (remdtrajidx_.empty()) mprintf("\tLooking for frames at %.2lf K\n",remdtrajtemp_); else { mprintf("\tLooking for indices ["); for (RemdIdxType::const_iterator idx = remdtrajidx_.begin(); idx != remdtrajidx_.end(); ++idx) mprintf(" %i", *idx); mprintf(" ]\n"); } }
// EnsembleOut_Single::InitEnsembleWrite() int EnsembleOut_Single::InitEnsembleWrite(std::string const& tnameIn, ArgList const& argIn, int ensembleSizeIn, TrajectoryFile::TrajFormatType writeFormatIn) { // Require a base filename if (tnameIn.empty()) { mprinterr("Internal Error: InitTrajWrite: No filename given.\n"); return 1; } // Require that ensemble size is set. ensembleSize_ = ensembleSizeIn; if (ensembleSize_ < 1) { mprinterr("Internal Error: Ensemble size has not been set.\n"); return 1; } ArgList trajout_args = argIn; // Get onlymembers range Range members_to_write = MembersToWrite(trajout_args.GetStringKey("onlymembers"), ensembleSize_); if (members_to_write.Empty()) return 1; // Process common args if (SetTraj().CommonTrajoutSetup(tnameIn, trajout_args, writeFormatIn)) return 1; if (eio_ != 0) delete eio_; // If appending, file must exist and must match the current format. // TODO Do not pass in writeformat directly to be changed. if (Traj().Append()) { if (Traj().CheckAppendFormat( Traj().Filename(), SetTraj().WriteFormat() )) SetTraj().SetAppend( false ); } // Set up for the specified format. eio_ = TrajectoryFile::AllocTrajIO( Traj().WriteFormat() ); if (eio_ == 0) return 1; // Check that the TrajectoryIO object can read/write single ensemble if (!eio_->CanProcessEnsemble()) { mprinterr("Error: Format '%s' cannot be used for ensemble single file output.\n", TrajectoryFile::FormatString(Traj().WriteFormat())); return 1; } mprintf("\tWriting '%s' as %s\n", Traj().Filename().full(), TrajectoryFile::FormatString(Traj().WriteFormat())); eio_->SetDebug( debug_ ); // Set specified title - will not set if empty eio_->SetTitle( Traj().Title() ); // Process any write arguments specific to certain formats not related // to parm file. Options related to parm file are handled in SetupTrajWrite if (eio_->processWriteArgs(trajout_args)) { mprinterr("Error: trajout %s: Could not process arguments.\n",Traj().Filename().full()); return 1; } return 0; }
int EnsembleIn_Single::BeginEnsemble() { // Open the trajectory if (eio_->openTrajin()) { mprinterr("Error: Could not open %s\n",Traj().Filename().base()); return 1; } // Initialize counter. SetTraj().Counter().Begin(); return 0; }
/** Expect lowest replica file name to be passed in. 'remdtraj' should have * already been parsed out of input arguments. */ int Trajin_Multi::SetupTrajRead(FileName const& tnameIn, ArgList& argIn, Topology *tparmIn) { // Set file name and topology pointer. if (SetTraj().SetNameAndParm(tnameIn, tparmIn)) return 1; REMDtraj_.ClearIOarray(); // Check for deprecated args if (argIn.hasKey("remdout")) { mprinterr("%s", TrajIOarray::DEPRECATED_remdout); return 1; } // Process REMD-specific arguments if (argIn.Contains("remdtrajidx")) { // Looking for specific indices ArgList indicesArg(argIn.GetStringKey("remdtrajidx"), ","); if (indicesArg.empty()) { mprinterr("Error: remdtrajidx expects comma-separated list of target indices in each\n" "Error: dimension, '<dim1 idx>,<dim2 idx>,...,<dimN idx>'. Indices start\n" "Error: from 1.\n"); return 1; } for (ArgList::const_iterator arg = indicesArg.begin(); // TODO: validInteger? arg != indicesArg.end(); ++arg) remdtrajidx_.push_back( convertToInteger( *arg ) ); targetType_ = ReplicaInfo::INDICES; } else if (argIn.Contains("remdtrajtemp")) { // Looking for target temperature remdtrajtemp_ = argIn.getKeyDouble("remdtrajtemp",0.0); targetType_ = ReplicaInfo::TEMP; } // Set up replica file names. if (REMDtraj_.SetupReplicaFilenames( tnameIn, argIn )) return 1; // Set up TrajectoryIO classes for all file names. if (REMDtraj_.SetupIOarray(argIn, SetTraj().Counter(), cInfo_, Traj().Parm())) return 1; // Check that replica dimension valid for desired indices. if (targetType_ == ReplicaInfo::INDICES && cInfo_.ReplicaDimensions().Ndims() != (int)remdtrajidx_.size()) { mprinterr("Error: Replica # of dim (%i) not equal to target # dim (%zu)\n", cInfo_.ReplicaDimensions().Ndims(), remdtrajidx_.size()); return 1; } // If target type is temperature make sure there is temperature info. if (targetType_ == ReplicaInfo::TEMP && !cInfo_.HasTemp()) { mprinterr("Error: Some or all replicas are missing temperature info.\n"); return 1; } return 0; }
// EnsembleOut_Single::SetupEnsembleWrite() int EnsembleOut_Single::SetupEnsembleWrite(Topology* tparmIn, CoordinateInfo const& cInfoIn, int nFrames) { // Set up topology and coordinate info. if (SetTraj().SetupCoordInfo(tparmIn, nFrames, cInfoIn)) return 1; if (debug_ > 0) rprintf("\tSetting up single ensemble %s for WRITE, topology '%s' (%i atoms).\n", Traj().Filename().base(), tparmIn->c_str(), tparmIn->Natom()); // Set up TrajectoryIO if (eio_->setupTrajout(Traj().Filename(), Traj().Parm(), Traj().CoordInfo(), Traj().NframesToWrite(), Traj().Append())) return 1; if (debug_ > 0) Frame::PrintCoordInfo(Traj().Filename().base(), Traj().Parm()->c_str(), eio_->CoordInfo()); // First frame setup //if (!TrajIsOpen()) { //} return 0; }
// EnsembleIn_Single::SetupEnsembleRead() int EnsembleIn_Single::SetupEnsembleRead(FileName const& tnameIn, ArgList& argIn, Topology *tparmIn) { if (eio_ != 0) delete eio_; // Set file name and topology pointer. if (SetTraj().SetNameAndParm(tnameIn, tparmIn)) return 1; // Detect file format TrajectoryFile::TrajFormatType tformat; if ( (eio_ = TrajectoryFile::DetectFormat( Traj().Filename(), tformat )) == 0 ) { mprinterr("Error: Could not determine trajectory %s format.\n", Traj().Filename().full()); return 1; } eio_->SetDebug( debug_ ); mprintf("\tReading '%s' as %s\n", Traj().Filename().full(), TrajectoryFile::FormatString(tformat)); // Process ensemble args // TODO: Should be common to Ensemble? bool nosort = argIn.hasKey("nosort"); // Process format-specific read args if (eio_->processReadArgs( argIn )) return 1; // Set up the format for reading and get the number of frames. int nframes = eio_->setupTrajin(Traj().Filename(), Traj().Parm()); if (nframes == TrajectoryIO::TRAJIN_ERR) { mprinterr("Error: Could not set up %s for reading.\n", Traj().Filename().full()); return 1; } if (debug_ > 0) { if (nframes != TrajectoryIO::TRAJIN_UNK) mprintf("\t'%s' contains %i frames.\n", Traj().Filename().base(), nframes); else mprintf("\t'%s' contains an unknown number of frames.\n",Traj().Filename().base()); } // Set the start, stop, and offset args based on user input. Do some bounds // checking. if (SetTraj().Counter().CheckFrameArgs( nframes, argIn )) return 1; // Set trajectory coordinate info. cInfo_ = eio_->CoordInfo(); // NOTE: ensembleSize_ is saved here as a shortcut. Should always equal whats in cInfo_ // Determine if this trajectory actually contains an ensemble. // FIXME: Should check for < 2? ensembleSize_ = cInfo_.EnsembleSize(); if (ensembleSize_ < 1) { mprinterr("Error: Cannot process single file ensemble with '%s'\n", TrajectoryFile::FormatString(tformat)); return 1; } # ifdef MPI // Set up communicators if (Parallel::SetupComms( ensembleSize_ )) return 1; // Set ensemble member number. SetEnsembleMemberNum( EnsembleComm().Rank() ); # endif // If dimensions are present, assume search by indices, otherwise by temp. targetType_ = ReplicaInfo::NONE; if (cInfo_.ReplicaDimensions().Ndims() > 0) targetType_ = ReplicaInfo::INDICES; else if (cInfo_.HasTemp()) targetType_ = ReplicaInfo::TEMP; else if (!nosort) { mprinterr("Error: Ensemble trajectory does not have indices or temperature.\n"); return 1; } if (debug_ > 0) cInfo_.PrintCoordInfo( Traj().Filename().base(), Traj().Parm()->c_str() ); # ifdef MPI // This array will let each thread know who has what frame. frameidx_.resize( ensembleSize_ ); // TODO: Get rid of, should do all in TrajIO class. # endif // Get a list of all temperatures/indices. TemperatureMap_.ClearMap(); IndicesMap_.ClearMap(); if (targetType_ == ReplicaInfo::TEMP || targetType_ == ReplicaInfo::INDICES ) { # ifdef MPI FrameArray f_ensemble(1); # else FrameArray f_ensemble( ensembleSize_ ); # endif f_ensemble.SetupFrames( Traj().Parm()->Atoms(), cInfo_ ); if ( eio_->openTrajin() ) return 1; if ( eio_->readArray( Traj().Counter().Start(), f_ensemble ) ) return 1; eio_->closeTraj(); if (targetType_ == ReplicaInfo::TEMP) { std::vector<double> allTemps( ensembleSize_, -1.0 ); # ifdef MPI // Consolidate temperatures if (GatherTemperatures(f_ensemble[0].tAddress(), allTemps, EnsembleComm())) return 1; # else for (int en = 0; en != ensembleSize_; ++en) allTemps[en] = f_ensemble[en].Temperature(); # endif if (SetTemperatureMap( allTemps )) return 1; } else if (targetType_ == ReplicaInfo::INDICES) { std::vector<RemdIdxType> allIndices( ensembleSize_ ); # ifdef MPI // Consolidate replica indices if (GatherIndices(f_ensemble[0].iAddress(), allIndices, cInfo_.ReplicaDimensions().Ndims(), EnsembleComm())) return 1; # else for (int en = 0; en != ensembleSize_; ++en) allIndices[en] = f_ensemble[en].RemdIndices(); # endif if (SetIndicesMap( allIndices)) return 1; } } return 0; }