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(), ComputeNonbondedSelf::doForce(), ComputeGridForce::doForce(), HomePatch::doMarginCheck(), Parameters::done_reading_files(), ComputeTclBC::doWork(), ComputeFullDirect::doWork(), Node::earlyExit(), ARestraint::EarlyExit(), GlobalMasterMisc::easy_calc(), msm::Grid< BlockDiagram >::elem(), msm::GridFixed< T, N >::elem(), msm::Array< BlockDiagram >::elem(), colvarproxy_namd::error(), ScriptTcl::eval(), PmeXPencil::fft_init(), PmeYPencil::fft_init(), PmeZPencil::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(), TholeElem::getMoleculePointers(), ExclElem::getMoleculePointers(), ImproperElem::getMoleculePointers(), GromacsPairElem::getMoleculePointers(), DihedralElem::getMoleculePointers(), CrosstermElem::getMoleculePointers(), BondElem::getMoleculePointers(), AnisoElem::getMoleculePointers(), AngleElem::getMoleculePointers(), CudaComputeNonbondedKernel::getPatchReadyQueue(), TholeElem::getTupleInfo(), AnisoElem::getTupleInfo(), GlobalMasterIMD::GlobalMasterIMD(), GlobalMasterSymmetry::GlobalMasterSymmetry(), GromacsTopFile::GromacsTopFile(), BackEnd::init(), LdbCoordinator::initialize(), GridforceLiteGrid::initialize(), GridforceFullSubGrid::initialize(), GridforceFullMainGrid::initialize(), DeviceCUDA::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(), MsmC1HermiteBlockProxyMsg::put(), MsmBlockProxyMsg::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(), HomePatch::recvCheckpointReq(), Controller::recvCheckpointReq(), ComputeMgr::recvComputeDPMEData(), ComputeMgr::recvComputeDPMEResults(), ComputeMgr::recvComputeEwaldData(), ComputeMgr::recvComputeEwaldResults(), ComputeMgr::recvComputeGlobalData(), ComputeMgr::recvComputeGlobalResults(), ComputeMsmSerialMgr::recvCoord(), ComputeFmmSerialMgr::recvCoord(), ComputeExtMgr::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().

00084 {
00085   if ( ! err_msg ) err_msg = "(unknown error)";
00086   CkPrintf("FATAL ERROR: %s\n", err_msg);
00087   fflush(stdout);
00088   char repstr[24] = "";
00089   if (CmiNumPartitions() > 1) {
00090     sprintf(repstr,"REPLICA %d ", CmiMyPartition());
00091   }
00092   CkError("%sFATAL ERROR: %s\n", repstr, err_msg);
00093 #if CHARM_VERSION < 61000
00094   CkExit();
00095 #else
00096   CkExit(1);
00097 #endif
00098 }

template<typename T >
int TestArray_write ( const char *  filename,
const char *  label,
const T *  array,
int  length 
) [inline]

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:
filename save to file name
label label for array (truncated to 120 characters)
array points to the array to save
length length of the array

Definition at line 32 of file TestArray.h.

References NAMD_die(), and TestArray_write_helper().

00037       {
00038   if ( ! std::is_arithmetic<T>::value ) {
00039     NAMD_die("Called TestArray_write with non-aritmetic type");
00040   }
00041   int isfp = std::is_floating_point<T>::value;
00042   return TestArray_write_helper(filename, label,
00043       (const void *)array, sizeof(T), length, isfp);
00044 }

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().

00017       {
00018   const char *stype = "unknown";
00019   if      (  isfp && elemsize==8 ) stype = "double";
00020   else if (  isfp && elemsize==4 ) stype = "float";
00021   else if ( !isfp && elemsize==8 ) stype = "int64";
00022   else if ( !isfp && elemsize==4 ) stype = "int32";
00023   else if ( !isfp && elemsize==2 ) stype = "int16";
00024   else if ( !isfp && elemsize==1 ) stype = "int8";
00025   printf("Writing %s array of length %d to binary file %s\n",
00026       stype, length, filename);
00027   FILE *fp = fopen(filename, "wb");
00028   if ( fp == 0 ) return -1;
00029   char padbuf[LABEL_SIZE] = { 0 };
00030   strncpy(padbuf, label, LABEL_SIZE-1);
00031   fwrite(padbuf, 1, LABEL_SIZE, fp);
00032   fwrite(&isfp, sizeof(int), 1, fp);
00033   fwrite(&elemsize, sizeof(int), 1, fp);
00034   fwrite(&length, sizeof(int), 1, fp);
00035   fwrite(array, elemsize, length, fp);
00036   fclose(fp);
00037   fflush(stdout);
00038   return 0;
00039 }


Generated on 4 Jun 2020 for NAMD by  doxygen 1.6.1