summaryrefslogtreecommitdiff
path: root/src/main/FortranWrappers.c
blob: 52ab58da9d4ffa0096ef5fdb7263eaee1e8d3a93 (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
 /*@@
   @file      FortranWrappers.c
   @date      Sat Sep 18 00:42:12 1999
   @author    Tom Goodale
   @desc 
   File for dealing with fortran wrapper functions.
   @enddesc 
   @version $Header$
 @@*/

#include <stdlib.h>

#include "cctki_FortranWrappers.h"
#include "cctk_Flesh.h"

#include "StoreNamedData.h"

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

CCTK_FILEVERSION(main_FortranWrappers_c);

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

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

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

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

static pNamedData *registry = NULL;

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

 /*@@
   @routine    CCTKi_RegisterFortranWrapper
   @date       Sat Sep 18 00:51:21 1999
   @author     Tom Goodale
   @desc 
   Registers a Fortran wrapper function.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 
   @var     name
   @vdesc   name of the wrapper function
   @vtype   const char *
   @vio     in
   @vcomment 
 
   @endvar 
   @var     function
   @vdesc   Wrapper function
   @vtype   int (*)(void *, void *)
   @vio     in
   @vcomment 
 
   @endvar 

   @returntype int
   @returndesc 
   The return code of StoreNamedData
   @endreturndesc
@@*/
int CCTKi_RegisterFortranWrapper(const char *name, 
                                 int (*function)(void *, void *))
{
  int retcode;
  retcode = StoreNamedData(&registry, name, (void *)function);

  return retcode;
}

 /*@@
   @routine    CCTKi_FortranWrapper
   @date       Sat Sep 18 00:51:57 1999
   @author     Tom Goodale
   @desc 
   Gets a Fortran wrapper function. 
   (A function taking (void *,void *), and returning an int. )
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 
   @var     name
   @vdesc   Name of the wrapper
   @vtype   const char *
   @vio     in
   @vcomment 
 
   @endvar 

   @returntype int (*)(void *,void *)
   @returndesc 
   The wrapper function
   @endreturndesc
@@*/
int (*CCTKi_FortranWrapper(const char *name))(void *, void *)
{
  return (int (*)(void *,void *))GetNamedData(registry, name);
}

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