NAMD
Functions
TestArray.h File Reference
#include <type_traits>

Go to the source code of this file.

Functions

void NAMD_die (const char *)
 
int TestArray_write_helper (const char *filename, const char *label, const void *array, int elemsize, int length, int isfp)
 
template<typename T >
int TestArray_write (const char *filename, const char *label, const T *array, int length)
 

Function Documentation

void NAMD_die ( const char *  )

Definition at line 83 of file common.C.

Referenced by Controller::adaptTempInit(), ConfigList::add_element(), ComputeMsmMgr::addPotential(), after_backend_init(), Controller::algorithm(), AnisoElem::AnisoElem(), msm::PatchData::anterpolation(), msm::PatchData::anterpolationC1Hermite(), Parameters::assign_angle_index(), Parameters::assign_bond_index(), Parameters::assign_crossterm_index(), Parameters::assign_dihedral_index(), Parameters::assign_improper_index(), Parameters::assign_vdw_index(), WorkDistrib::assignNodeToPatch(), ComputeNonbondedCUDA::build_exclusions(), Molecule::build_go_arrays(), Molecule::build_go_params(), Molecule::build_go_sigmas(), Molecule::build_go_sigmas2(), Molecule::build_gridforce_params(), buildBondData(), HomePatch::buildRattleList(), ReductionMgr::buildSpanTree(), CudaTileListKernel::buildTileLists(), ParallelIOMgr::calcAtomsInEachPatch(), ComputeQMMgr::calcMOPAC(), ComputeQMMgr::calcORCA(), GlobalMasterTest::calculate(), GlobalMasterTcl::calculate(), GlobalMaster::calculate(), ComputeQMMgr::calcUSR(), GlobalMaster::check(), ComputeMsmMgr::compute(), PmeRealSpace::compute_forces(), AngleElem::computeForce(), ComputeMgr::ComputeMgr(), ComputeNonbondedCUDA::ComputeNonbondedCUDA(), ComputeTclBC::ComputeTclBC(), ConfigList::ConfigList(), NamdState::configListInit(), ConfigList::ConfigListNode::ConfigListNode(), Sequencer::correctMomentum(), Controller::correctMomentum(), WorkDistrib::createAtomLists(), cuda_errcheck(), cuda_getargs(), cuda_init_bspline_coeffs(), CudaComputeNonbonded::CudaComputeNonbonded(), cudaDie(), ComputeMsmMgr::d_stencil_1d(), Molecule::delete_qm_bonded(), ComputeGridForce::doForce(), ComputeNonbondedSelf::doForce(), HomePatch::doMarginCheck(), Parameters::done_reading_files(), ComputeFullDirect::doWork(), ComputeTclBC::doWork(), ARestraint::EarlyExit(), Node::earlyExit(), GlobalMasterMisc::easy_calc(), msm::Array< msm::PatchDiagram >::elem(), msm::GridFixed< T, N >::elem(), msm::Grid< Vtype >::elem(), colvarproxy_namd::error(), ScriptTcl::eval(), PmeZPencil::fft_init(), PmeYPencil::fft_init(), PmeXPencil::fft_init(), PmeRealSpace::fill_charges(), parm::get(), Molecule::get_atom_from_index_in_residue(), Molecule::get_atom_from_name(), Molecule::get_atomtype(), Parameters::get_dihedral_params(), Molecule::get_fep_bonded_type(), Parameters::get_improper_params(), Molecule::get_residue_size(), Parameters::get_vdw_params(), AngleElem::getMoleculePointers(), ImproperElem::getMoleculePointers(), CrosstermElem::getMoleculePointers(), DihedralElem::getMoleculePointers(), TholeElem::getMoleculePointers(), AnisoElem::getMoleculePointers(), BondElem::getMoleculePointers(), ExclElem::getMoleculePointers(), GromacsPairElem::getMoleculePointers(), CudaComputeNonbondedKernel::getPatchReadyQueue(), TholeElem::getTupleInfo(), AnisoElem::getTupleInfo(), GlobalMasterIMD::GlobalMasterIMD(), GlobalMasterSymmetry::GlobalMasterSymmetry(), GromacsTopFile::GromacsTopFile(), BackEnd::init(), DeviceCUDA::initialize(), LdbCoordinator::initialize(), GridforceFullMainGrid::initialize(), GridforceFullSubGrid::initialize(), GridforceLiteGrid::initialize(), ComputePmeMgr::initialize(), ComputeMsmMgr::initialize(), SimParameters::initialize_config_data(), msm::PatchData::interpolation(), msm::PatchData::interpolationC1Hermite(), ScriptTcl::load(), NamdState::loadStructure(), ludcmp(), main::main(), Node::mallocTest(), WorkDistrib::mapComputes(), HomePatch::minimize_rattle2(), Molecule::Molecule(), HomePatch::mollyAverage(), HomePatch::mollyMollify(), NAMD_new_handler(), NAMD_read_int(), NAMD_read_line(), NAMD_seek(), NAMD_write(), ComputeMsmMgr::ndsplitting(), CudaComputeNonbondedKernel::nonbondedForce(), Vector::operator[](), Node::outputPatchComputeMaps(), MGridforceParamsList::pack_data(), WorkDistrib::patchMapInit(), PDB::PDB(), PDBUnknown::PDBUnknown(), parm::preadln(), Molecule::prepare_qm(), ProblemParsing(), MsmBlockProxyMsg::put(), MsmC1HermiteBlockProxyMsg::put(), HomePatch::rattle1old(), HomePatch::rattle2(), Molecule::read_alch_unpert_angles(), Molecule::read_alch_unpert_bonds(), Molecule::read_alch_unpert_dihedrals(), read_binary_file(), Parameters::read_charmm_parameter_file(), Parameters::read_ener_table(), Parameters::read_energy_type(), Parameters::read_energy_type_bothcubspline(), Parameters::read_energy_type_cubspline(), Molecule::read_go_file(), Parameters::read_parameter_file(), Parameters::read_parm(), SimParameters::readExtendedSystem(), GridforceFullBaseGrid::readSubgridHierarchy(), RecBisection::RecBisection(), Molecule::receive_GoMolecule(), Parameters::receive_Parameters(), CollectionMaster::receiveDataStream(), ParallelIOMgr::recvAtomsCntPerPatch(), Controller::recvCheckpointReq(), HomePatch::recvCheckpointReq(), ComputeMgr::recvComputeDPMEData(), ComputeMgr::recvComputeDPMEResults(), ComputeMgr::recvComputeEwaldData(), ComputeMgr::recvComputeEwaldResults(), ComputeMgr::recvComputeGlobalData(), ComputeMgr::recvComputeGlobalResults(), ComputeExtMgr::recvCoord(), ComputeMsmSerialMgr::recvCoord(), ComputeFmmSerialMgr::recvCoord(), ComputeQMMgr::recvPartQM(), ComputeQMMgr::recvPntChrg(), Output::recvReplicaDcdData(), Node::reloadCharges(), Node::reloadGridforceGrid(), ReductionMgr::remoteRegister(), ReductionMgr::remoteUnregister(), ReductionSet::removeData(), Sequencer::rescaleaccelMD(), Controller::rescaleaccelMD(), CudaTileListKernel::reSortTileLists(), ScriptTcl::run(), ComputeMsm::saveResults(), SimParameters::scriptSet(), ComputeNonbondedUtil::select(), Molecule::send_GoMolecule(), Parameters::send_Parameters(), ComputeMgr::sendComputeDPMEData(), ComputeMgr::sendComputeEwaldData(), StringList::set(), msm::Array< T >::setmax(), CudaTileListKernel::setTileListVirialEnergyGBISLength(), CudaTileListKernel::setTileListVirialEnergyLength(), ComputeMsmMgr::setup_hgrid_1d(), ComputeMsmMgr::setup_periodic_blocksize(), SimParameters::setupIDWS(), PatchMap::sizeGrid(), ComputeMsmMgr::splitting(), ComputeMsmMgr::stencil_1d(), NamdCentLB::Strategy(), StringList::StringList(), ScriptTcl::tclmain(), TestArray_write(), TholeElem::TholeElem(), Node::updateGridScale(), ReductionMgr::willRequire(), and ReductionMgr::willSubmit().

84 {
85  if ( ! err_msg ) err_msg = "(unknown error)";
86  CkPrintf("FATAL ERROR: %s\n", err_msg);
87  fflush(stdout);
88  char repstr[24] = "";
89  if (CmiNumPartitions() > 1) {
90  sprintf(repstr,"REPLICA %d ", CmiMyPartition());
91  }
92  CkError("%sFATAL ERROR: %s\n", repstr, err_msg);
93 #if CHARM_VERSION < 61000
94  CkExit();
95 #else
96  CkExit(1);
97 #endif
98 }
template<typename T >
int TestArray_write ( const char *  filename,
const char *  label,
const T *  array,
int  length 
)

Write an array to file for later analysis. The array type needs to be a standard arithmetic type, as designated true by std::is_arithmetic<T>.

File format is:

  • label is padded to 116 characters including null terminator
  • nonzero 4-byte int if array is floating point
  • number of bytes per element stored as 4-byte int
  • length of the array stored as 4-byte int
  • the array data

Returns zero for success or nonzero for error.

Parameters
filenamesave to file name
labellabel for array (truncated to 120 characters)
arraypoints to the array to save
lengthlength of the array

Definition at line 32 of file TestArray.h.

References NAMD_die(), and TestArray_write_helper().

37  {
38  if ( ! std::is_arithmetic<T>::value ) {
39  NAMD_die("Called TestArray_write with non-aritmetic type");
40  }
41  int isfp = std::is_floating_point<T>::value;
42  return TestArray_write_helper(filename, label,
43  (const void *)array, sizeof(T), length, isfp);
44 }
int TestArray_write_helper(const char *filename, const char *label, const void *array, int elemsize, int length, int isfp)
Definition: TestArray.C:10
void NAMD_die(const char *err_msg)
Definition: common.C:83
int TestArray_write_helper ( const char *  filename,
const char *  label,
const void array,
int  elemsize,
int  length,
int  isfp 
)

Definition at line 10 of file TestArray.C.

References LABEL_SIZE.

Referenced by TestArray_write().

17  {
18  const char *stype = "unknown";
19  if ( isfp && elemsize==8 ) stype = "double";
20  else if ( isfp && elemsize==4 ) stype = "float";
21  else if ( !isfp && elemsize==8 ) stype = "int64";
22  else if ( !isfp && elemsize==4 ) stype = "int32";
23  else if ( !isfp && elemsize==2 ) stype = "int16";
24  else if ( !isfp && elemsize==1 ) stype = "int8";
25  printf("Writing %s array of length %d to binary file %s\n",
26  stype, length, filename);
27  FILE *fp = fopen(filename, "wb");
28  if ( fp == 0 ) return -1;
29  char padbuf[LABEL_SIZE] = { 0 };
30  strncpy(padbuf, label, LABEL_SIZE-1);
31  fwrite(padbuf, 1, LABEL_SIZE, fp);
32  fwrite(&isfp, sizeof(int), 1, fp);
33  fwrite(&elemsize, sizeof(int), 1, fp);
34  fwrite(&length, sizeof(int), 1, fp);
35  fwrite(array, elemsize, length, fp);
36  fclose(fp);
37  fflush(stdout);
38  return 0;
39 }
static const int LABEL_SIZE
Definition: TestArray.C:8