cloudy trunk
Loading...
Searching...
No Matches
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
31 mole.species.resize( mole_global.num_total );
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}
FILE * ioQQQ
Definition cddefines.cpp:7
#define EXIT_FAILURE
Definition cddefines.h:140
#define cdEXIT(FAIL)
Definition cddefines.h:434
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:684
void zero(void)
Definition mole.cpp:36
void make_species(void)
void init(void)
Definition mole.cpp:11
t_mole_global mole_global
Definition mole.cpp:6
t_mole_local mole
Definition mole.cpp:7
t_mole_global mole_global
Definition mole.cpp:6
void mole_make_groups(void)
t_mole_local mole
Definition mole.cpp:7
void mole_make_list(void)