Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_DeviceBlock.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2014 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_DeviceBlock.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 02/28/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.33 $
40 //
41 // Revision Date : $Date: 2014/02/24 23:49:15 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 
49 #include <iostream>
50 
51 #include <N_DEV_DeviceBlock.h>
52 #include <N_ERH_ErrorMgr.h>
53 
54 #include <N_PDS_Comm.h>
55 
56 namespace Xyce {
57 namespace Device {
58 
59 bool hasSubcircuitInInstanceName(const InstanceBlock &instance_block)
60 {
61  return instance_block.getName().find_last_of(":") != std::string::npos;
62 }
63 
64 std::string subcircuitNameFromInstanceName(const InstanceBlock &instance_block) {
65  return hasSubcircuitInInstanceName(instance_block)
66  ? instance_block.getName().substr(0, instance_block.getName().find_last_of(":"))
67  : "";
68 }
69 
70 
71 std::string modelNameFromInstanceName(const InstanceBlock &instance_block)
72 {
73  if (!instance_block.getModelName().empty())
74  return instance_block.getModelName();
75  else
76  return hasSubcircuitInInstanceName(instance_block)
77  ? instance_block.getName().substr(instance_block.getName().find_last_of(":") + 1, std::string::npos)
78  : instance_block.getName();
79 }
80 
81 
82 //-----------------------------------------------------------------------------
83 // Function : ModelBlock::ModelBlock
84 // Purpose : constructor
85 // Special Notes :
86 // Scope : public
87 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
88 // Creation Date : 5/18/00
89 //-----------------------------------------------------------------------------
90 ModelBlock::ModelBlock(const std::string & name_, const std::string &type_, int level_)
91  : name(name_),
92  level(level_),
93  type(type_),
94  lineNumber_(0)
95 {
96 }
97 
98 //-----------------------------------------------------------------------------
99 // Function : ModelBlock::ModelBlock
100 // Purpose : copy constructor
101 // Special Notes :
102 // Scope : public
103 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
104 // Creation Date : 3/16/00
105 //-----------------------------------------------------------------------------
107  : name(right.name),
108  type(right.type),
109  level(right.level),
110  netlistFileName_(right.netlistFileName_),
111  lineNumber_(right.lineNumber_),
112  params(right.params)
113 {
114 }
115 
116 //-----------------------------------------------------------------------------
117 // Function : ModelBlock::~ModelBlock
118 // Purpose : destructor
119 // Special Notes :
120 // Scope : public
121 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
122 // Creation Date : 3/16/00
123 //-----------------------------------------------------------------------------
125 {
126 }
127 
128 //-----------------------------------------------------------------------------
129 // Function : ModelBlock::operator=
130 // Purpose : "=" operator
131 // Special Notes :
132 // Scope : public
133 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
134 // Creation Date : 3/16/00
135 //-----------------------------------------------------------------------------
137 {
138  name = right.name;
139  type = right.type;
140  level = right.level;
141 
143  lineNumber_ = right.lineNumber_;
144 
145  params = right.params;
146 
147  return *this;
148 }
149 
150 //-----------------------------------------------------------------------------
151 // Function : ModelBlock::operator==
152 // Purpose : "==" operator
153 // Special Notes :
154 // Scope : public
155 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
156 // Creation Date : 3/16/00
157 //-----------------------------------------------------------------------------
158 int ModelBlock::operator==(const ModelBlock &right) const
159 {
160  return name == right.name;
161 }
162 
163 //-----------------------------------------------------------------------------
164 // Function : ModelBlock::operator!=
165 // Purpose : "!=" operator
166 // Special Notes :
167 // Scope : public
168 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
169 // Creation Date : 3/16/00
170 //-----------------------------------------------------------------------------
171 int ModelBlock::operator!=(const ModelBlock &right) const
172 {
173  return name != right.name;
174 }
175 
176 //-----------------------------------------------------------------------------
177 // Function : ModelBlock::operator<<
178 // Purpose : "<<" operator
179 // Special Notes :
180 // Scope : public
181 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
182 // Creation Date : 4/06/00
183 //-----------------------------------------------------------------------------
184 std::ostream& operator<<(std::ostream & os, const ModelBlock & mb)
185 {
186  std::vector<Param>::const_iterator it_pL, end_pL;
187 
188  os << "Model Block" << std::endl;
189  os << "Model: " << mb.name << std::endl;
190  os << " type: " << mb.type << std::endl;
191  os << " Level: " << mb.level << std::endl;
192  os << " netlistFileName_: " << mb.netlistFileName_ << std::endl;
193  os << " lineNumber_: " << mb.lineNumber_ << std::endl;
194  os << " Tagged Params" << std::endl;
195  os << " -------------" << std::endl;
196 
197  it_pL=mb.params.begin();
198  end_pL=mb.params.end();
199  for ( ; it_pL != end_pL; ++it_pL)
200  {
201  os << it_pL->tag() << "\t" << it_pL->stringValue() << std::endl;
202  }
203 
204  os << " -------------" << std::endl;
205  os << std::endl;
206 
207  return os;
208 }
209 
210 //-----------------------------------------------------------------------------
211 // Function : ModelBlock::clear
212 // Purpose : empties out the block.
213 // Special Notes :
214 // Scope : public
215 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
216 // Creation Date : 5/01/00
217 //-----------------------------------------------------------------------------
219 {
220  name = "";
221  type = "";
222  level = 0;
223 
224  netlistFileName_ = "";
225  lineNumber_ = 0;
226 
227  params.clear();
228 
229 }
230 
231 //-----------------------------------------------------------------------------
232 // Function : ModelBlock::instance
233 // Purpose :
234 // Special Notes :
235 // Scope : public
236 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
237 // Creation Date : 6/28/01
238 //-----------------------------------------------------------------------------
239 Packable * ModelBlock::instance() const
240 {
241  return new ModelBlock();
242 }
243 
244 //-----------------------------------------------------------------------------
245 // Function : ModelBlock::packedByteCount
246 // Purpose : Counts bytes needed to pack block
247 // Special Notes :
248 // Scope : public
249 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
250 // Creation Date : 6/13/00
251 //-----------------------------------------------------------------------------
253 {
254 
255  int byteCount = 0;
256 
257  int size, length, i;
258 
259  std::vector<Param>::const_iterator it_tpL;
260 
261  //----- count name
262  length = name.length();
263  byteCount += sizeof(int);
264  byteCount += length;
265 
266  //----- count type
267  length = type.length();
268  byteCount += sizeof(int);
269  byteCount += length;
270 
271  //----- count level
272  byteCount += sizeof(int);
273 
274  //----- count params
275  size = params.size();
276  byteCount += sizeof(int);
277  it_tpL = params.begin();
278  for (i = 0; i < size; ++i, ++it_tpL)
279  {
280  byteCount += it_tpL->packedByteCount();
281  }
282 
283  //----- count netlistFileName_
284  length = netlistFileName_.length();
285  byteCount += sizeof(int);
286  byteCount += length;
287 
288  //----- count lineNumber_
289  byteCount += sizeof(int);
290 
291  return byteCount;
292 
293 }
294 
295 //-----------------------------------------------------------------------------
296 // Function : ModelBlock::pack
297 // Purpose : Packs ModelBlock into char buffer using MPI_PACK
298 // Special Notes :
299 // Scope : public
300 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
301 // Creation Date : 5/24/00
302 //-----------------------------------------------------------------------------
303 void ModelBlock::pack(char * buf, int bsize, int & pos, N_PDS_Comm * comm) const
304 {
305 
306  int size, length;
307  int i;
308  std::vector<Param>::const_iterator it_tpL;
309 #ifdef Xyce_COUNT_PACKED_BYTES
310  int predictedPos = pos+packedByteCount();
311 #endif
312 
313  //----- pack name
314  length = name.length();
315  comm->pack(&length, 1, buf, bsize, pos );
316  comm->pack( name.c_str(), length, buf, bsize, pos );
317 
318  //----- pack type
319  length = type.length();
320  comm->pack(&length, 1, buf, bsize, pos );
321  comm->pack( type.c_str(), length, buf, bsize, pos );
322 
323  //----- pack level
324  comm->pack(&level, 1, buf, bsize, pos );
325 
326  //----- pack params
327  size = params.size();
328  comm->pack(&size, 1, buf, bsize, pos );
329  it_tpL = params.begin();
330  for (i = 0; i < size; ++i, ++it_tpL)
331  {
332  it_tpL->pack( buf, bsize, pos, comm );
333  }
334 
335  //----- pack netlistFileName_
336  length = netlistFileName_.length();
337  comm->pack(&length, 1, buf, bsize, pos );
338  comm->pack( netlistFileName_.c_str(), length, buf, bsize, pos );
339 
340  //----- packlineNumber_
341  comm->pack(&lineNumber_, 1, buf, bsize, pos );
342 
343 #ifdef Xyce_DEBUG_TOPOLOGY
344  Xyce::dout() << "Packed " << pos << " bytes for ModelBlock: " <<
345  name << std::endl;
346 #endif
347 
348 #ifdef Xyce_COUNT_PACKED_BYTES
349  if (pos != predictedPos)
350  {
351  DevelFatal(*this, "ModelBlock::pack") << "Predicted pos does not match actual pos";
352  }
353 #endif
354 
355 }
356 
357 //-----------------------------------------------------------------------------
358 // Function : ModelBlock::unpack
359 // Purpose : Unpacks ModelBlock from char buffer using MPI_UNPACK
360 // Special Notes :
361 // Scope : public
362 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
363 // Creation Date : 5/24/00
364 //-----------------------------------------------------------------------------
365 void ModelBlock::unpack(char * pB, int bsize,int & pos, N_PDS_Comm * comm)
366 {
367 
368  int size, length;
369  int i;
370 
371  //----- unpack name
372  comm->unpack( pB, bsize, pos, &length, 1 );
373  name = std::string( (pB+pos), length);
374  pos += length;
375 
376  //----- unpack type
377  comm->unpack( pB, bsize, pos, &length, 1 );
378  type = std::string( (pB+pos), length);
379  pos += length;
380 
381  //----- unpack level
382  comm->unpack( pB, bsize, pos, &level, 1 );
383 
384  //----- unpack params
385  comm->unpack( pB, bsize, pos, &size, 1 );
386  params.clear();
387  Param dp;
388  for( i = 0; i < size; ++i )
389  {
390  dp.unpack( pB, bsize, pos, comm );
391  params.push_back( dp );
392  }
393 
394  //----- unpack netlistFileName_
395  comm->unpack( pB, bsize, pos, &length, 1 );
396  netlistFileName_ = std::string( (pB+pos), length);
397  pos += length;
398 
399  //----- unpack lineNumber_
400  comm->unpack( pB, bsize, pos, &lineNumber_, 1 );
401 
402 #ifdef Xyce_DEBUG_TOPOLOGY
403  Xyce::dout() << "Unpacked " << pos << " bytes for ModelBlock: " <<
404  name << std::endl;
405 #endif
406 
407 }
408 
409 //-----------------------------------------------------------------------------
410 // Function : InstanceBlock::InstanceBlock
411 // Purpose : constructor
412 // Special Notes :
413 // Scope : public
414 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
415 // Creation Date : 5/18/00
416 //-----------------------------------------------------------------------------
417 InstanceBlock::InstanceBlock (const std::string &name)
418  : name_(name),
419  modelName_(),
420  iNumNodes(0),
421  numIntVars(0),
422  numExtVars(0),
423  numStateVars(0),
424  modelFlag(0),
425  sourceFlag(0),
426  bsourceFlag(0),
427  offFlag(0),
428  off(0),
429  lineNumber_(0)
430 {
431 }
432 
433 //-----------------------------------------------------------------------------
434 // Function : InstanceBlock::InstanceBlock
435 // Purpose : copy constructor
436 // Special Notes :
437 // Scope : public
438 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
439 // Creation Date : 3/16/00
440 //-----------------------------------------------------------------------------
442  : name_ (right.name_),
443  modelName_(right.modelName_),
444  iNumNodes (right.iNumNodes),
445  numIntVars(right.numIntVars),
446  numExtVars(right.numExtVars),
447  numStateVars(right.numStateVars),
448  modelFlag (right.modelFlag),
449  sourceFlag(right.sourceFlag),
450  bsourceFlag(right.bsourceFlag),
451  offFlag (right.offFlag),
452  off (right.off),
453  netlistFileName_ (right.netlistFileName_),
454  lineNumber_ (right.lineNumber_),
455  params (right.params)
456 {
457 }
458 
459 //-----------------------------------------------------------------------------
460 // Function : InstanceBlock::~InstanceBlock
461 // Purpose : destructor
462 // Special Notes :
463 // Scope : public
464 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
465 // Creation Date : 3/16/00
466 //-----------------------------------------------------------------------------
468 {
469 }
470 
471 //-----------------------------------------------------------------------------
472 // Function : InstanceBlock::operator=
473 // Purpose : "=" operator
474 // Special Notes :
475 // Scope : public
476 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
477 // Creation Date : 3/16/00
478 //-----------------------------------------------------------------------------
480 {
481  name_ = right.name_;
482  modelName_ = right.modelName_;
483  iNumNodes = right.iNumNodes;
484  numIntVars= right.numIntVars;
485  numExtVars= right.numExtVars;
486  numStateVars= right.numStateVars;
487  modelFlag = right.modelFlag;
488  sourceFlag= right.sourceFlag;
489  bsourceFlag= right.bsourceFlag;
490  offFlag = right.offFlag;
491  off = right.off;
493  lineNumber_ = right.lineNumber_;
494  params = right.params;
495 
496  return *this;
497 }
498 
499 //-----------------------------------------------------------------------------
500 // Function : InstanceBlock::operator==
501 // Purpose : "==" operator
502 // Special Notes :
503 // Scope : public
504 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
505 // Creation Date : 3/16/00
506 //-----------------------------------------------------------------------------
508 {
509  return name_ == right.name_;
510 }
511 
512 //-----------------------------------------------------------------------------
513 // Function : InstanceBlock::operator!=
514 // Purpose : "!=" operator
515 // Special Notes :
516 // Scope : public
517 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
518 // Creation Date : 3/16/00
519 //-----------------------------------------------------------------------------
521 {
522  return name_ != right.name_;
523 }
524 
525 //-----------------------------------------------------------------------------
526 // Function : InstanceBlock::clear
527 // Purpose : empties out the block.
528 // Special Notes :
529 // Scope : public
530 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
531 // Creation Date : 5/01/00
532 //-----------------------------------------------------------------------------
534 {
535  name_ = "";
536  modelName_ = "";
537  iNumNodes = 0;
538  numIntVars = 0;
539  numExtVars = 0;
540  numStateVars = 0;
541  modelFlag = 0;
542  sourceFlag = 0;
543  bsourceFlag = 0;
544  offFlag = 0;
545  off = 0;
546  netlistFileName_ = "";
547  lineNumber_ = 0;
548 
549  params.clear();
550 }
551 
552 //-----------------------------------------------------------------------------
553 // Function : InstanceBlock::operator<<
554 // Purpose : "<<" operator
555 // Special Notes :
556 // Scope : public
557 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
558 // Creation Date : 4/06/00
559 //-----------------------------------------------------------------------------
560 std::ostream& operator<<(std::ostream & os, const InstanceBlock & ib)
561 {
562  std::vector<Param>::const_iterator it_tpL, end_tpL;
563 
564  os << "Instance Block" << std::endl;
565  os << "Name: " << ib.name_ << std::endl;
566  os << " Model: " << ib.getModelName() << std::endl;
567  os << " # Nodes: " << ib.iNumNodes << std::endl;
568  os << " # Int Vars: " << ib.numIntVars << std::endl;
569  os << " # Ext Vars: " << ib.numExtVars << std::endl;
570  os << " # State Vars: " << ib.numStateVars << std::endl;
571  os << " modelFlag: " << ib.modelFlag << std::endl;
572  os << " sourceFlag: " << ib.sourceFlag << std::endl;
573  os << " bsourceFlag: " << ib.bsourceFlag << std::endl;
574  os << " offFlag: " << ib.offFlag << std::endl;
575  os << " off: " << ib.off << std::endl;
576  os << " netlistFileName_: " << ib.netlistFileName_ << std::endl;
577  os << " lineNumber_: " << ib.lineNumber_ << std::endl;
578  os << " Tagged Params" << std::endl;
579  os << " -------------" << std::endl;
580 
581  it_tpL=ib.params.begin();
582  end_tpL=ib.params.end();
583  for ( ; it_tpL != end_tpL; ++it_tpL)
584  {
585  os << it_tpL->tag() << "\t" << it_tpL->stringValue() << std::endl;
586  }
587 
588  os << " -------------" << std::endl;
589  os << std::endl;
590 
591  return os;
592 }
593 
594 //-----------------------------------------------------------------------------
595 // Function : InstanceBlock::instance
596 // Purpose :
597 // Special Notes :
598 // Scope : public
599 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
600 // Creation Date : 6/28/01
601 //-----------------------------------------------------------------------------
602 Packable * InstanceBlock::instance() const
603 {
604  return new InstanceBlock();
605 }
606 
607 //-----------------------------------------------------------------------------
608 // Function : InstanceBlock::packedByteCount
609 // Purpose : count bytes needed to pack block
610 // Special Notes :
611 // Scope : public
612 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
613 // Creation Date : 6/13/00
614 //-----------------------------------------------------------------------------
616 {
617 
618  int byteCount = 0;
619 
620  int size, length, i;
621  std::vector<Param>::const_iterator it_tpL;
622 
623  //----- count name
624  length = getName().length();
625  byteCount += sizeof(int);
626  byteCount += length * sizeof(char);
627 
628  //----- count getModelName()
629  length = getModelName().length();
630  byteCount += sizeof(int);
631  byteCount += length * sizeof(char);
632 
633  //----- count params
634  size = params.size();
635  byteCount += sizeof(int);
636  it_tpL = params.begin();
637  for (i = 0; i < size; ++i, ++it_tpL)
638  {
639  byteCount += it_tpL->packedByteCount();
640  }
641 
642  //----- count iNumNodes
643  byteCount += sizeof(int);
644 
645  //----- count numIntVars
646  byteCount += sizeof(int);
647 
648  //----- countnumExtVars
649  byteCount += sizeof(int);
650 
651  //----- count numStateVars
652  byteCount += sizeof(int);
653 
654  //----- count modelFlag
655  byteCount += sizeof(int);
656 
657  //----- count sourceFlag
658  byteCount += sizeof(int);
659 
660  //----- count bsourceFlag
661  byteCount += sizeof(int);
662 
663  //----- count offFlag
664  byteCount += sizeof(int);
665 
666  //----- pack off
667  byteCount += sizeof(int);
668 
669  //----- count netlistFileName_
670  length = netlistFileName_.length();
671  byteCount += sizeof(int);
672  byteCount += length * sizeof(char);
673 
674  //----- count lineNumber_
675  byteCount += sizeof(int);
676 
677  return byteCount;
678 
679 }
680 
681 //-----------------------------------------------------------------------------
682 // Function : InstanceBlock::pack
683 // Purpose : Packs InstanceBlock into char buffer using MPI_PACK
684 // Special Notes :
685 // Scope : public
686 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
687 // Creation Date : 5/24/00
688 //-----------------------------------------------------------------------------
689 void InstanceBlock::pack(char * buf, int bsize, int & pos, N_PDS_Comm * comm) const
690 {
691 
692  int size, length;
693  int i;
694  std::vector<Param>::const_iterator it_tpL;
695 #ifdef Xyce_COUNT_PACKED_BYTES
696  int predictedPos = pos+packedByteCount();
697 #endif
698 
699  //----- pack name
700  length = getName().length();
701  comm->pack(&length, 1, buf, bsize, pos );
702  comm->pack( name_.c_str(), length, buf, bsize, pos );
703 
704  //----- pack getModelName()
705  length = getModelName().length();
706  comm->pack(&length, 1, buf, bsize, pos );
707  comm->pack( getModelName().c_str(), length, buf, bsize, pos );
708 
709  //----- pack params
710  size = params.size();
711  comm->pack(&size, 1, buf, bsize, pos );
712  it_tpL = params.begin();
713  for (i = 0; i < size; ++i, ++it_tpL)
714  {
715  it_tpL->pack( buf, bsize, pos, comm );
716  }
717 
718  //----- pack iNumNodes
719  comm->pack(&iNumNodes, 1, buf, bsize, pos );
720 
721  //----- pack numIntVars
722  comm->pack(&numIntVars, 1, buf, bsize, pos );
723 
724  //----- pack numExtVars
725  comm->pack(&numExtVars, 1, buf, bsize, pos );
726 
727  //----- pack numStateVars
728  comm->pack(&numStateVars, 1, buf, bsize, pos );
729 
730  //----- pack modelFlag
731  i = modelFlag;
732  comm->pack(&i, 1, buf, bsize, pos );
733 
734  //----- pack sourceFlag
735  i = sourceFlag;
736  comm->pack(&i, 1, buf, bsize, pos );
737 
738  //----- pack bsourceFlag
739  i = bsourceFlag;
740  comm->pack(&i, 1, buf, bsize, pos );
741 
742  //----- pack offFlag
743  i = offFlag;
744  comm->pack(&i, 1, buf, bsize, pos );
745 
746  //----- pack off
747  i = off;
748  comm->pack(&i, 1, buf, bsize, pos );
749 
750  //----- pack name
751  length = netlistFileName_.length();
752  comm->pack(&length, 1, buf, bsize, pos );
753  comm->pack( netlistFileName_.c_str(), length, buf, bsize, pos );
754 
755  //----- pack lineNumber_
756  comm->pack(&lineNumber_, 1, buf, bsize, pos );
757 
758 #ifdef Xyce_DEBUG_TOPOLOGY
759  Xyce::dout() << "Packed " << pos << " bytes for InstanceBlock: " <<
760  getName() << std::endl;
761 #endif
762 #ifdef Xyce_COUNT_PACKED_BYTES
763  if (pos != predictedPos)
764  {
765  DevelFatal(*this, "InstanceBlock::pack") << "Predicted pos does not match actual pos";
766  }
767 #endif
768 }
769 
770 //-----------------------------------------------------------------------------
771 // Function : InstanceBlock::unpack
772 // Purpose : Unpacks InstanceBlock from char buffer using MPI_UNPACK
773 // Special Notes :
774 // Scope : public
775 // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences
776 // Creation Date : 5/24/00
777 //-----------------------------------------------------------------------------
778 void InstanceBlock::unpack(char * pB, int bsize, int & pos, N_PDS_Comm * comm)
779 {
780 
781  int size, length;
782  int i;
783 
784  //----- unpack name
785  comm->unpack( pB, bsize, pos, &length, 1 );
786  name_ = std::string( (pB+pos), length);
787  pos += length;
788 
789  //----- unpack getModelName()
790  comm->unpack( pB, bsize, pos, &length, 1 );
791  modelName_ = std::string( (pB+pos), length);
792  pos += length;
793 
794  //----- unpack params
795  comm->unpack( pB, bsize, pos, &size, 1 );
796  params.clear();
797  Param dp;
798  for( i = 0; i < size; ++i )
799  {
800  dp.unpack( pB, bsize, pos, comm );
801  params.push_back( dp );
802  }
803 
804  //----- unpack iNumNodes
805  comm->unpack( pB, bsize, pos, &iNumNodes, 1 );
806 
807  //----- unpack numIntVars
808  comm->unpack( pB, bsize, pos, &numIntVars, 1 );
809 
810  //----- unpack numExtVars
811  comm->unpack( pB, bsize, pos, &numExtVars, 1 );
812 
813  //----- unpack numStateVars
814  comm->unpack( pB, bsize, pos, &numStateVars, 1 );
815 
816  //----- unpack modelFlag
817  comm->unpack( pB, bsize, pos, &i, 1 );
818  modelFlag = ( i != 0 );
819 
820  //----- unpack sourceFlag
821  comm->unpack( pB, bsize, pos, &i, 1 );
822  sourceFlag = ( i != 0 );
823 
824  //----- unpack bsourceFlag
825  comm->unpack( pB, bsize, pos, &i, 1 );
826  bsourceFlag = ( i != 0 );
827 
828  //----- unpack offFlag
829  comm->unpack( pB, bsize, pos, &i, 1 );
830  offFlag = ( i != 0 );
831 
832  //----- unpack off
833  comm->unpack( pB, bsize, pos, &i, 1 );
834  off = ( i != 0 );
835 
836  //----- unpack netlistFileName_
837  comm->unpack( pB, bsize, pos, &length, 1 );
838  netlistFileName_ = std::string( (pB+pos), length);
839  pos += length;
840 
841  //----- unpack lineNumber_
842  comm->unpack( pB, bsize, pos, &lineNumber_, 1 );
843 
844 #ifdef Xyce_DEBUG_TOPOLOGY
845  Xyce::dout() << "Unpacked " << pos << " bytes for InstanceBlock: " <<
846  getName() << std::endl;
847 #endif
848 
849 }
850 
851 } // namespace Device
852 } // namespace Xyce