einsteintoolkit / CactusExamples_HelloWorld.json
xinshuo's picture
Upload folder using huggingface_hub
10a2580 verified
{
"thorn_name": "CactusExamples/HelloWorld",
"url": "https://bitbucket.org/cactuscode/cactusexamples.git",
"configuration": "",
"interface": "# Interface definition for thorn HelloWorld\n# $Header$\n\nimplements: helloworld",
"param": "# Parameter definitions for thorn HelloWorld\n# $Header$\n",
"schedule": "# Schedule definitions for thorn HelloWorld\n# $Header$\n\nschedule HelloWorld at CCTK_EVOL\n{\n LANG: C\n} \"Print message to screen\"",
"src": {
"make.code.defn": "# Main make.code.defn file for thorn HelloWorld\n# $Header$\n\n# Source files in this directory\nSRCS = HelloWorld.c\n\n# Subdirectories containing source files\nSUBDIRS = \n\n",
"HelloWorld.c": "#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n\nvoid HelloWorld(CCTK_ARGUMENTS)\n{\n DECLARE_CCTK_ARGUMENTS;\n\n CCTK_INFO(\"Hello World!\");\n}\n"
},
"test": {},
"doc": {
"documentation.tex": "\\documentclass{article}\n\n% Use the Cactus ThornGuide style file\n% (Automatically used from Cactus distribution, if you have a \n% thorn without the Cactus Flesh download this from the Cactus\n% homepage at www.cactuscode.org)\n\\usepackage{../../../../doc/latex/cactus}\n\n\\begin{document}\n\n\\title{HelloWorld}\n\\author{Gabrielle Allen}\n\\date{$ $Date$ $}\n\n\\maketitle\n\n% Do not delete next line\n% START CACTUS THORNGUIDE\n\n\\begin{abstract}\nThe Hello World thorn is the simplest possible example of programming\nan application with the Cactus Framework\n\\end{abstract}\n\n\\section{Purpose}\n\nThe thorn demonstrates how to implement the typical first example of\nall programming languages with Cactus --- printing the words {\\tt\nHello World!} to the screen.\n\n\\section{Tutorial}\n\n\\subsection{Source Code}\n\nCactus allows you to write thorns using any mixture of Fortran 77,\nFortran 90, C and C++, in this case there is only one source code\nroutine in the thorn, and we have chosen to write this in C. Later we\nwill see how this routine can be {\\it scheduled} to executed when\nCactus is run.\n\nThe actual code which prints is in the file \\\\ \\\\\n\n{\\tt CactusExamples/HelloWorld/src/HelloWorld.c} \\\\ \\\\\n\nNote that this file is listed in the thorn make file \\\\ \\\\ \n\n{\\tt CactusExamples/HelloWorld/src/make.code.defn} \\\\ \\\\\n\nwhich informs Cactus to include this file when building executables.\n\n\nThe {\\tt HelloWorld.c} file contains the lines\n\n{\\tt\n\\begin{verbatim}\nC1. #include \"cctk.h\"\nC2. #include \"cctk_Arguments.h\"\nC3 \nC4. void HelloWorld(CCTK_ARGUMENTS)\nC5. {\nC6. DECLARE_CCTK_ARGUMENTS\nC7. \nC8. CCTK_INFO(\"Hello World !\");\nC9.\nC10. return;\nC11. }\n\\end{verbatim}\n}\n\nLets go through this line by line, and compare it to a standalone Hello World program written to match the lines of the Cactus routine.\n\n{\\tt\n\\begin{verbatim}\nS1. #include <stdio.h>\nS2. \nS3. \nS4. int main()\nS5. {\nS6. \nS7. \nS8. printf(\"Hello World !\\n\");\nS9. \nS10. return 0;\nS11. }\n\\end{verbatim}\n}\n\n\\begin{description}\n\n\\item{\\bf Include Files (C1/C2):} All source files which make use of Cactus infrastructure need to include {\\tt cctk.h}, this sets up the Cactus data types and prototypes Cactus functions. All scheduled functions also need to include {\\tt cctk\\_Arguments.h} which contains information about the data variables which are available to the function.\n\n\\item{\\bf Function Name (C4):} Scheduled functions are always void, and the argument contains the macro {\\tt CCTK\\_ARGUMENTS} which is expanded during compilation to contain information about the data variable available to the function. In our simple case there are actually no data variables.\n\n\\item{\\bf Arguments Declaration (C6):} This line defines any data variables \navailable to the routine, from this thorn and inherited from other thorns.\n\n\\item{\\bf Cactus Info (C8):} Finally, the line to print to screen. We could\nhave just used {\\tt printf(\"Hello World !\\\\n\")} here as in the\nstandalone function, but here we actually use a Cactus function {\\tt\nCCTK\\_INFO} which formats output to screen to include the name of the\nthorn. That isn't so useful here, but in cases where there are many\nthorns it helps for understanding the screen output. Also, for more complicated applications running in parallel, the {\\tt CCTK\\_INFO} function controls which of the processors actually writes to screen (having 1024 processors each writing {\\tt Hello World !} could look confusing!).\n\n\\end{description}\n\n\\section{Configuration Files}\n\nCactus Configuration (or {\\tt CCL}) files are the way in which the\nCactus Flesh find out information about your thorn. Cactus isn't\ninterested in all the private stuff of your thorn, but it needs to\nknow about things like variables, routines, parameters which will\ninterface with other thorns. \n\nIn the Hello World example these files are trivial, since we have no\nvariables, only one routine to schedule, and no parameters (to learn\nabout parameters you could try to add a parameter to this thorn to\nswitch off the output, or to change the number of times the message is\nprinted). The contents of our CCL files are\n\n\\begin{description}\n\n\\item{\\bf interface.ccl} \n\n{\\tt\n\\begin{verbatim}\nimplements: helloworld\n\\end{verbatim}\n}\n\nEach thorn has to give a name to what it does, here we say that we do\nis called \"helloworld\". (If you look further into the notion of\nimplementations, you will find that this mechanism allows you to\nswitch between different thorns which provide the same implementation,\nbut for our example this isn't very useful).\n\n\\item{\\bf param.ccl} \n\nThere are no parameters in the HelloWorld thorn, so this file is empty.\n\n\\item{\\bf schedule.ccl}\n\n{\\tt\n\\begin{verbatim}\nschedule HelloWorld at CCTK_EVOL\n{\n LANG: C\n} \"Print message to screen\"\n\\end{verbatim}\n}\n\nThis file instructs Cactus to run the routine called HelloWorld in our\nthorn during the evolution timebin. Additionally it tells Cactus that\nthe source codee is written in C, and provides a descipion of what the\nroutine does. \n\n\\end{description}\n\n\\section{Screen Output}\n\nHere we list the actual output from running the Hello World parameter\nfile. Note that as we develop the framework this output may look a\nlittle different by the time you see it.\n\n{\\tt \n\\begin{verbatim}\n[allen@gullveig CactusClean]$ ./exe/cactus_world arrangements/CactusExamples \\\n /HelloWorld/par/HelloWorld.par \n--------------------------------------------------------------------------------\n 10 \n 1 0101 ************************ \n 01 1010 10 The Cactus Code V4.0 \n 1010 1101 011 www.cactuscode.org \n 1001 100101 ************************ \n 00010101 \n 100011 (c) Copyright The Authors \n 0100 GNU Licensed. No Warranty \n 0101 \n\n--------------------------------------------------------------------------------\nCactus version: 4.0.b12\nCompile date: May 01 2002 (10:26:44)\nRun date: May 01 2002 (10:28:35)\nRun host: gullveig.aei.mpg.de\nExecutable: ./exe/cactus_world\nParameter file: arrangements/CactusExamples/HelloWorld/par/HelloWorld.par\n--------------------------------------------------------------------------------\nActivating thorn Cactus...Success -> active implementation Cactus\nActivation requested for \n--->HelloWorld<---\nActivating thorn HelloWorld...Success -> active implementation helloworld\n-------------------------------------------------------------------------------- \n if (recover initial data)\n Recover parameters\n endif\n\n Startup routines\n\n Parameter checking routines\n\n Initialisation\n if (NOT (recover initial data AND recovery_mode is 'strict'))\n endif\n if (recover initial data)\n endif\n if (checkpoint initial data)\n endif\n if (analysis)\n endif\n Do periodic output of grid variables\n\n do loop over timesteps\n Rotate timelevels\n iteration = iteration + 1\n t = t+dt\n HelloWorld: Print message to screen\n if (checkpoint)\n endif\n if (analysis)\n endif\n Do periodic output of grid variables\n\n do loop over timesteps\n Rotate timelevels\n iteration = iteration + 1\n t = t+dt\n HelloWorld: Print message to screen\n if (checkpoint)\n endif\n if (analysis)\n endif\n Do periodic output of grid variables\n enddo\n\n Termination routines\n\n Shutdown routines\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\nINFO (HelloWorld): Hello World !\n--------------------------------------------------------------------------------\nDone.\n\\end{verbatim}\n}\n\n% Do not delete next line\n% END CACTUS THORNGUIDE\n\n\\end{document}\n"
}
}