aboutsummaryrefslogtreecommitdiff
path: root/src/WriteInfo.c
blob: 4c22f9eaad5e15b827c0d869607e63762115f85a (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
/*@@
   @routine    WriteInfo
   @date       June 31 1999
   @author     Gabrielle Allen, Paul Walker
   @desc 
   Dumps the Info data.
   @enddesc 
   @calls    
   @calledby   
   @history
   @hauthor Thomas Radke @hdate 17 Mar 1999
   @hdesc included "cctk_Comm.h" to overload CCTK_MyProc() properly
   @hendhistory
@@*/

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

#include "cctk.h"

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

CCTK_FILEVERSION(CactusBase_IOBasic_WriteInfo_c)

int IOBasic_WriteInfo (cGH *GH, 
                       CCTK_REAL *val, 
                       int index, 
                       const char *operator, 
                       const char *alias)
{
  int ierr;
  int reduce_handle;
  int retval = 0;

  /* first, check if variable has storage assigned */
  if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index))) 
  {
    char *fullname;

    fullname = CCTK_FullName (index);
    CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
                "IOBasic_WriteInfo: No info output for '%s' (no storage)", 
                fullname);
    free (fullname);
    return -3;
  }

  reduce_handle = CCTK_ReductionHandle(operator);

  if (reduce_handle > -1)
  {
    ierr = CCTK_Reduce(GH, 0, reduce_handle, 1, CCTK_VARIABLE_REAL, val,
                       1, index);
    if (ierr < 0)
    {
      CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
                 "IOBasic_WriteInfo: Internal error in reduction '%s'", 
                 operator);
      retval = -2;
    }
  }
  else
  {
    CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
               "IOBasic_WriteInfo: Reduction operator '%s' not found", 
               operator);
    retval = -1;
  }

  return retval;
}