summaryrefslogtreecommitdiff
path: root/src/main/ConfigData.c
blob: 36112afe0b788664ba05b9df06c14bec682e51ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
 /*@@
   @file      ConfigData.c
   @date      Fri Jan 15 13:27:50 1999
   @author    Tom Goodale
   @desc 
   Miscellaneous routines to deal with configuration data
   @enddesc 
   @version $Header$
 @@*/

#include <stdio.h>
#include <stdlib.h>

#include "cctk_Flesh.h"

static char *rcsid = "$Header$";

CCTK_FILEVERSION(main_ConfigData_c)

/********************************************************************
 *********************     Local Data Types   ***********************
 ********************************************************************/

/********************************************************************
 ********************* Local Routine Prototypes *********************
 ********************************************************************/

/********************************************************************
 ********************* Other Routine Prototypes *********************
 ********************************************************************/

/********************************************************************
 *********************     Local Data   *****************************
 ********************************************************************/

/********************************************************************
 *********************     External Routines   **********************
 ********************************************************************/

 /*@@
   @routine    CCTKi_AddGH
   @date       Fri Jan 15 13:43:11 1999
   @author     Tom Goodale
   @desc 
   Adds a GH to the config_data structure at a particular convergence level.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 
   @var     config
   @vdesc   Flesh config data
   @vtype   tFleshConfig
   @vio     in
   @vcomment 
 
   @endvar 
   @var     convergence_level
   @vdesc   The convergence level
   @vtype   int
   @vio     in
   @vcomment 
 
   @endvar 
   @var     GH
   @vdesc   the cctk GH
   @vtype   cGH *
   @vio     in
   @vcomment 
 
   @endvar 

   @returntype int
   @returndesc 
   0 - success
   1 - memory failure
   2 - duplicate convergence level
   @endreturndesc
@@*/
int CCTKi_AddGH(tFleshConfig *config, int convergence_level, cGH *GH)
{
  int retval;

  cGH **temp;

  int i;

  retval = 0;

  if(config->nGHs == 0 || convergence_level > config->nGHs-1)
  {
    temp = (cGH **)realloc(config->GH, (convergence_level+1)*sizeof(cGH *));

    if(temp)
    {
      config->GH = temp;
      for(i=config->nGHs; i<convergence_level+1;i++)
      {
        config->GH[i] = NULL;
      }
      config->nGHs=convergence_level+1;
    }
    else
    {
      retval = 1;
    }
  }

  if(!retval && !config->GH[convergence_level])
  {
    config->GH[convergence_level] = GH;
  }
  else
  {
    fprintf(stderr, "Tried to store two GHs at the same convergence level !\n");
    retval = 2;
  }

  return retval;
}

/********************************************************************
 *********************     Local Routines   *************************
 ********************************************************************/