cloudy  trunk
mole.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 #include "cddefines.h"
4 #include "mole.h"
5 
8 
9 /*=================================================================*/
10 /*mole_Init called from cdInit to initialize CO routines */
12 {
13  static bool lgmole_Init_called=false;
14 
15  DEBUG_ENTRY( "Mole::init()" );
16 
17  /* prevent memory leaks */
18  /* \todo this is a temporary fix for PR14. We should improve the overall design
19  * of this code to prevent valid pointers being overwritten in a second call to mole_Init */
20  if( lgmole_Init_called )
21  {
22  return;
23  }
24 
25  /* say that we have been called */
26  lgmole_Init_called = true;
27 
28  make_species();
32 
33  return;
34 }
35 
37 {
38  static bool lgFirstCall = true;
39  static long int num_total_MALLOC=-1;
40 
41  DEBUG_ENTRY("t_mole_global::zero()");
42 
43  if( lgFirstCall )
44  {
45  lgFirstCall = false;
46  num_total_MALLOC = mole_global.num_total;
47  }
48  else if( mole_global.num_total>num_total_MALLOC )
49  {
50  /* number of species has increased since last time - this can't happen
51  * tsuite / programs / comp4 has 95 first time, 98 second time */
52  fprintf(ioQQQ,"DISASTER - the number of species in the CO network has increased. This is not allowed.\n");
53  fprintf(ioQQQ,"This could happen if an element was initially turned off or grains not included, then the element or grains was included. There are not allowed.\n");
54  fprintf(ioQQQ,"Sorry.\n");
56  }
57 
58  for( long i=0; i<mole_global.num_total; ++i )
59  {
60  mole.species[i].zero();
61  }
62  mole.elec = 0.;
63 }
ioQQQ
FILE * ioQQQ
Definition: cddefines.cpp:7
t_mole_local
Definition: mole.h:369
mole.h
t_mole_local::elec
double elec
Definition: mole.h:390
t_mole_global::zero
void zero(void)
Definition: mole.cpp:36
mole_make_groups
void mole_make_groups(void)
Definition: mole_species.cpp:1142
t_mole_global::init
void init(void)
Definition: mole.cpp:11
EXIT_FAILURE
#define EXIT_FAILURE
Definition: cddefines.h:140
mole
t_mole_local mole
Definition: mole.cpp:7
cddefines.h
t_mole_global::num_total
int num_total
Definition: mole.h:314
mole_make_list
void mole_make_list(void)
Definition: mole_species.cpp:296
cdEXIT
#define cdEXIT(FAIL)
Definition: cddefines.h:434
t_mole_local::species
valarray< class molezone > species
Definition: mole.h:398
mole_global
t_mole_global mole_global
Definition: mole.cpp:6
t_mole_global
Definition: mole.h:266
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:684
t_mole_global::make_species
void make_species(void)
Definition: mole_species.cpp:140