⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statein.cc

📁 大型并行量子化学软件;支持密度泛函(DFT)。可以进行各种量子化学计算。支持CHARMM并行计算。非常具有应用价值。
💻 CC
📖 第 1 页 / 共 2 页
字号:
//// statein.cc//// Copyright (C) 1998 Limit Point Systems, Inc.//// Author: Curtis Janssen <cljanss@limitpt.com>// Maintainer: LPS//// This file is part of the SC Toolkit.//// The SC Toolkit is free software; you can redistribute it and/or modify// it under the terms of the GNU Library General Public License as published by// the Free Software Foundation; either version 2, or (at your option)// any later version.//// The SC Toolkit is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU Library General Public License for more details.//// You should have received a copy of the GNU Library General Public License// along with the SC Toolkit; see the file COPYING.LIB.  If not, write to// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.//// The U.S. Government is granted a limited license as per AL 91-7.//#ifdef __GNUC__#pragma implementation#endif#include <ctype.h>#include <util/misc/formio.h>#include <util/state/translate.h>#include <util/state/statein.h>using namespace std;using namespace sc;#define DEBUG 0static ClassDesc StateIn_cd(    typeid(StateIn),"StateIn",1,"public DescribedClass");StateIn::StateIn(const StateIn&){  ExEnv::errn() << "StateIn: private copy ctor called???" << endl;  abort();}voidStateIn::operator=(const StateIn&){  ExEnv::errn() << "StateIn: private assignment called???" << endl;  abort();}StateIn::StateIn() :  have_cd_(0),  translate_(new TranslateDataIn(this, new TranslateDataBigEndian)),  expected_object_num_(0),  nextclassid_(0),  node_to_node_(0){  key_[0] = '\0';  keylength_ = 0;}StateIn::~StateIn(){  delete translate_;}intStateIn::push_key(const char *keyword){  if (!keyword || override_.null()) return keylength_;  int length = strlen(keyword);  if (keylength_ + length + 1 >= KeyVal::MaxKeywordLength) {      ExEnv::errn() << "StateIn: KeyVal::MaxKeywordLength exceeded" << endl;      abort();    }  int old_keylength = keylength_;  if (keylength_) key_[keylength_++] = ':';  char *tmp = &key_[keylength_];  for (int i=0; i<length; i++) tmp[i] = keyword[i];  keylength_ += length;  key_[keylength_] = '\0';  return old_keylength;}intStateIn::tell(){  return 0;}voidStateIn::seek(int loc){}intStateIn::seekable(){  return 0;}intStateIn::use_directory(){  return 0;}intStateIn::get_array_char(char*p,int size){  return translate_->get(p,size);}intStateIn::get_array_uint(unsigned int*p,int size){  return translate_->get(p,size);}intStateIn::get_array_int(int*p,int size){  return translate_->get(p,size);}intStateIn::get_array_float(float*p,int size){  return translate_->get(p,size);}intStateIn::get_array_double(double*p,int size){  return translate_->get(p,size);}intStateIn::get(char&r, const char *keyword){  int n = get_array_char(&r,1);  if (keyword && override().nonnull()) {      int p = push_key(keyword);      char roverride = override()->charvalue(key());      if (override()->error() == KeyVal::OK) {          ExEnv::out0() << indent << "overriding \"" << key()                       << "\": " << r << " -> " << roverride << endl;          r = roverride;        }      pop_key(p);    }  return n;}intStateIn::get(unsigned int&r, const char *keyword){  int n = get_array_uint(&r,1);  if (keyword && override().nonnull()) {      int p = push_key(keyword);      int roverride = override()->intvalue(key());      if (override()->error() == KeyVal::OK) {          ExEnv::out0() << indent << "overriding \"" << key()                       << "\": " << r << " -> " << roverride << endl;          r = roverride;        }      pop_key(p);    }  return n;}intStateIn::get(int&r, const char *keyword){  int n = get_array_int(&r,1);  if (keyword && override().nonnull()) {      int p = push_key(keyword);      int roverride = override()->intvalue(key());      if (override()->error() == KeyVal::OK) {          ExEnv::out0() << indent << "overriding \"" << key()                       << "\": " << r << " -> " << roverride << endl;          r = roverride;        }      pop_key(p);    }  return n;}intStateIn::get(float&r, const char *keyword){  int n = get_array_float(&r,1);  if (keyword && override().nonnull()) {      int p = push_key(keyword);      float roverride = override()->floatvalue(key());      if (override()->error() == KeyVal::OK) {          ExEnv::out0() << indent << "overriding \"" << key()                       << "\": " << r << " -> " << roverride << endl;          r = roverride;        }      pop_key(p);    }  return n;}intStateIn::get(double&r, const char *keyword){  int n = get_array_double(&r,1);  if (keyword && override().nonnull()) {      int p = push_key(keyword);      double roverride = override()->doublevalue(key());      if (override()->error() == KeyVal::OK) {          ExEnv::out0() << indent << "overriding \"" << key()                       << "\": " << r << " -> " << roverride << endl;          r = roverride;        }      pop_key(p);    }  return n;}intStateIn::get_array_void(void*p,int s){  ExEnv::errn() << "StateIn::get_array_void(void*p,int s) "       << "is a derived class responsiblility" << endl       << "  exact type is \"" << class_name() << "\"" << endl;  abort();  return -1;}voidStateIn::get_directory(){  int i, length;  // read the type information#if DEBUG  ExEnv::outn() << "Directory length location = " << tell() << endl;#endif  get(length);#if DEBUG  ExEnv::outn() << "Directory length = " << length << endl;  ExEnv::outn() << "Directory entries location = " << tell() << endl;#endif  for (i=0; i<length; i++) {      char *name;      int version, classid;      getstring(name);      get(version);      get(classid);#if DEBUG      ExEnv::outn() << "GET CLASS:"                   << " NAME = " << name                   << " VERSION = " << version                   << " ID = " << classid << endl;#endif      ClassDesc* tmp = ClassDesc::name_to_class_desc(name);      classidmap_[tmp] = classid;      StateClassData classdat(version,tmp,name);      classdatamap_[classid] = classdat;    }  // read the object information  get(length);  for (i=0; i<length; i++) {      int n;      get(n);      StateInData num;      get(num.type);      get(num.offset);      get(num.size);#if DEBUG      ExEnv::outn() << "GET OBJECT:"                   << " NUM=" << setw(2) << n                   << " OFF=" << setw(5) << num.offset                   << " SZ=" << setw(4) << num.size                   << " ID=" << setw(2) << num.type                   << " (" << classdatamap_[num.type].name << ")"                   << endl;#endif      ps_[n] = num;      classdatamap_[num.type].ninstance++;    }}voidStateIn::find_and_get_directory(){  if (directory_location() && seekable()) {      int original_loc = tell();      seek(directory_location());#if DEBUG      ExEnv::outn() << "Getting directory from " << tell() << endl;#endif      get_directory();      seek(original_loc);    }}intStateIn::getstring(char*&s){  int r=0;  int size;#if DEBUG  ExEnv::outn() << "String length location = " << tell() << endl;#endif  r += get(size);#if DEBUG  ExEnv::outn() << "String length = " << size << endl;#endif  if (size) {#if DEBUG      ExEnv::outn() << "String location = " << tell() << endl;#endif      s = new char[size];      r += get_array_char(s,size-1);      s[size-1] = '\0';    }  else {      s = 0;    }  return r;}intStateIn::get(std::string&s){  char *cstr;  int r = getstring(cstr);  if (cstr) s = cstr;  else s = "";  delete[] cstr;  return r;}intStateIn::get(char*&s){  int r=0;  int size;  r += get(size);  if (size) {      s = new char[size];      r += get_array_char(s,size);    }  else {      s = 0;    }  return r;}intStateIn::get(unsigned int*&s){  int r=0;  int size;  r += get(size);  if (size) {      s = new unsigned int[size];      r += get_array_uint(s,size);    }  else {      s = 0;    }  return r;}int

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -