[Users] Calling a function in Thorn A from Thorn B

Roland Haas rhaas at illinois.edu
Sun May 6 11:20:37 CDT 2018


Hello Chris,

as Erik said this is pretty much the (only) way to do it.

Unfortunately this way is also not officially unsupported (ie it is
not documented) so can stop working in the future. It will also only
work for functions using C binding (not Fortran binding).

What *sometimes* works is to put the function in thorn A you want to
call in a schedule.ccl group and schedule that *group* in schedule.ccl
of thorn B (it needs to be a group since, at least in theory,
CCTK_ARGUMENTS could differ from thorn to thorn). This only works in
some circumstances though since you have to mix schedule.ccl and C code
to achieve the desired result so can become quite unwieldy if there are
multiple such functions or if you need to call them in many places.

Yours,
Roland

> Yes, this is the way to do it.
> 
> -erik
> 
> On Sat, May 5, 2018 at 03:30 Chris Stevens <c.stevens at ru.ac.za> wrote:
> 
> > Hi everyone,
> >
> > I am in a situation where I want to call a function whose argument is just
> > CCTK_ARGUMENTS from another thorn. I am aware of the following:
> >
> > -- I can share functions defined between thorns through the interface.ccl
> > of the thorns, but I do not know how to specify CCTK_ARGUMENTS in the
> > interface file. I cannot seem to find the cctk_arguments.h header anywhere
> > in the Cactus directory to see what the definition of this is?
> >
> > -- I can call functions with argument CCTK_ARGUMENTS within the same thorn
> > by using CCTK_PASS_CTOC.
> >
> > As a current fix (copied from CTGamma code), I can write the function like
> >
> > void test(CCTK_POINTER_TO_CONST _cctkGH)
> > {
> >   const cGH* const cctkGH = _cctkGH;
> >   DECLARE_CCTK_ARGUMENTS;
> >   DECLARE_CCTK_PARAMETERS;
> >
> > }
> >
> > where this argument can now be passed through the interface file and seems
> > to do a similar thing to CCTK_ARGUMENTS.
> >
> > Any help to figure out the best way to do this would be much appreciated!
> >
> > Thanks,
> >
> > Chris
> > --
> > Dr Chris Stevens
> >
> > Claude Leon Postdoctoral Fellow
> >
> > Department of Mathematics
> >
> > Rhodes University
> >
> > Room 5
> >
> > Ph: +27 46 603 8932
> >
> > Web: www.chrisdoesmaths.com
> > _______________________________________________
> > Users mailing list
> > Users at einsteintoolkit.org
> > http://lists.einsteintoolkit.org/mailman/listinfo/users
> >  



-- 
My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from http://pgp.mit.edu .
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
Url : http://lists.einsteintoolkit.org/pipermail/users/attachments/20180506/b9e41262/attachment.bin 


More information about the Users mailing list