summaryrefslogtreecommitdiff
path: root/src/main/ProcessParameterDatabase.c
blob: 207377694ac702c5b73bf338df6fc18ba8c6cefd (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
 /*@@
   @file      ProcessParameterDatabase.c
   @date      Thu Sep 24 10:34:46 1998
   @author    Tom Goodale
   @desc 
   Routines to determine the parameters and store them.
   @enddesc 
   @version $Header$
 @@*/

#include <stdio.h>
#include <string.h>

#include "cctk_Flesh.h"
#include "cctk_Parameter.h"

#include "cctki_Parameter.h"
#include "ParameterData.h"

static const char *rcsid = "$Header$";

CCTK_FILEVERSION(main_ProcessParameterDatabase_c)

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

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

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

int ParseFile(FILE *ifp, 
              int (*set_function)(const char *, const char *),tFleshConfig *ConfigData);

void CCTKi_SetParameterSetMask(int mask);

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

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

 /*@@
   @routine    CCTKi_ProcessParameterDatabase
   @date       Thu Sep 24 10:37:07 1998
   @author     Tom Goodale
   @desc 
   
   @enddesc 
   @calls     CCTKi_SetParameterSetMask ParseFile
   @calledby   
   @history 
 
   @endhistory 
   @var     ConfigData
   @vdesc   Flesh configuration data
   @vtype   tFleshConfig
   @vio     inout
   @vcomment 
 
   @endvar 

   @returntype int
   @returndesc
   0  - success
   1  - unable to open parameter file
   @endreturndesc
@@*/
int CCTKi_ProcessParameterDatabase(tFleshConfig *ConfigData)
{
  int retval;
  FILE *parameter_file;

  CCTKi_SetParameterSetMask(PARAMETER_RECOVERY_PRE);

  if(!strcmp(ConfigData->parameter_file_name,"-"))
  {
    parameter_file = stdin;
  }
  else
  {
    parameter_file = fopen(ConfigData->parameter_file_name, "r");
  }

  if(parameter_file)
  {
    ParseFile(parameter_file, CCTKi_SetParameter, ConfigData);

    if(strcmp(ConfigData->parameter_file_name,"-"))
    {
      fclose(parameter_file);
    }
    retval = 0;
  }
  else
  {
    fprintf(stderr, "Unable to open parameter file '%s'\n", 
                    ConfigData->parameter_file_name);
    retval = 1;
  }
      
  return retval;
}

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