00001
00002
00003 #include "cddefines.h"
00004 #include "mole.h"
00005
00006 t_mole_global mole_global;
00007 t_mole_local mole;
00008
00009
00010
00011 void t_mole_global::init(void)
00012 {
00013 static bool lgmole_Init_called=false;
00014
00015 DEBUG_ENTRY( "Mole::init()" );
00016
00017
00018
00019
00020 if( lgmole_Init_called )
00021 {
00022 return;
00023 }
00024
00025
00026 lgmole_Init_called = true;
00027
00028 make_species();
00029 mole_make_list();
00030 mole_make_groups();
00031 mole.species.resize( mole_global.num_total );
00032
00033 return;
00034 }
00035
00036 void t_mole_global::zero(void)
00037 {
00038 static bool lgFirstCall = true;
00039 static long int num_total_MALLOC=-1;
00040
00041 DEBUG_ENTRY("t_mole_global::zero()");
00042
00043 if( lgFirstCall )
00044 {
00045 lgFirstCall = false;
00046 num_total_MALLOC = mole_global.num_total;
00047 }
00048 else if( mole_global.num_total>num_total_MALLOC )
00049 {
00050
00051
00052 fprintf(ioQQQ,"DISASTER - the number of species in the CO network has increased. This is not allowed.\n");
00053 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");
00054 fprintf(ioQQQ,"Sorry.\n");
00055 cdEXIT(EXIT_FAILURE);
00056 }
00057
00058 for( long i=0; i<mole_global.num_total; ++i )
00059 {
00060 mole.species[i].zero();
00061 }
00062 }