aboutsummaryrefslogtreecommitdiff
path: root/src/WriteInfo.c
blob: ca06ae9dfdc3b58aa99c1f8d9db29dd6af1d272e (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
/*@@
   @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"
#include "CactusBase/IOUtil/src/ioGH.h"

CCTK_REAL IOBasic_WriteInfo (cGH *GH, int index, const char *operator, const char *alias)
{
  int reduce_handle;
  CCTK_REAL 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,
                "No info output for '%s' (no storage)", fullname);
    free (fullname);
    return (0);
  }

  reduce_handle = CCTK_ReductionHandle(operator);

  if (reduce_handle > -1)
  {
    CCTK_Reduce(GH,0,reduce_handle,1,CCTK_VARIABLE_REAL,&retval,1,index);
  }
  else
  {
    CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
               "Reduction operator '%s' doesn't exist or failed internally", operator);
    retval = -27;
  }

  return retval;
}