next up previous contents
Next: Error Handling, Warnings and Up: Completing a Thorn Previous: Commenting Source Code   Contents


Providing Runtime Information

To write from thorns to standard output (i.e. the screen) at runtime, use the macro CCTK_INFO or the function CCTK_VInfo().

For example, from the Fortran thorn MyThorn,

  call CCTK_INFO("Starting Tricky Calculation")
will write the line:
  INFO (MyThorn): Starting Tricky Calculation

For a multiprocessor run, only runtime information from processor zero will be printed to screen by default. The standard output of other processors will usually be discarded unless the ``-r'' command line option is used (Section A3.1).

Note that the routine CCTK_VInfo() can only be called from C, because Fortran doesn't know about variable argument lists. So, including variables in the info message using CCTK_INFO is currently more tricky, since you need to build the string to be output.

For example, in C you would just write

  int myint;

  CCTK_VInfo(CCTK_THORNSTRING, "The integer is %d", myint);

But in Fortran you have to do the following

  integer       myint
  character*200 message

  write (message, '("The integer is ",i4)') myint
  call CCTK_INFO (message)

In Fortran 90, you can also do

  integer        myint
  character(200) message

  write (message, '("The integer is ",i4)') myint
  call CCTK_INFO (message)

Note that

  • CCTK_INFO is just a macro which expands to a call to the internal function CCTK_Info() and automatically includes the thorn name in function call.

  • CCTK_INFO should be used rather than print statements, since it will give consistent behaviour on multiprocessors, and also provides a mechanism for switching the output to screen on and off, even on a thorn-by-thorn basis. (Although this is not yet implemented).


next up previous contents
Next: Error Handling, Warnings and Up: Completing a Thorn Previous: Commenting Source Code   Contents