Index: param.ccl =================================================================== RCS file: /cactusdevcvs/Cactus/src/param.ccl,v retrieving revision 1.32 diff -u -r1.32 param.ccl --- param.ccl 29 Aug 2006 16:21:31 -0000 1.32 +++ param.ccl 28 Sep 2007 10:41:58 -0000 @@ -25,6 +25,14 @@ 0: :: "Any whole number" } 0 +KEYWORD process_termination "How to terminate the Cactus processes" STEERABLE=always +{ + "regular" :: "Call exit (after MPI_Finalize, if appropriate)" + "quick" :: "Call kill (0, SIGKILL)" + "exit" :: "Call exit (without calling MPI_Finalize)" + "abort" :: "call abort (without calling MPI_Finalize)" +} "regular" + BOOLEAN allow_mixeddim_gfs "Allow use of GFs from different dimensions" { } "no" Index: main/ShutdownCactus.c =================================================================== RCS file: /cactusdevcvs/Cactus/src/main/ShutdownCactus.c,v retrieving revision 1.14 diff -u -r1.14 ShutdownCactus.c --- main/ShutdownCactus.c 12 Nov 2002 11:22:28 -0000 1.14 +++ main/ShutdownCactus.c 28 Sep 2007 10:42:02 -0000 @@ -11,15 +11,49 @@ #include #include -#include "cctk_Flesh.h" -#include "cctk_Misc.h" +#include "cctk.h" #include "cctk_Parameters.h" #include "cctk_Schedule.h" +#ifdef HAVE_SIGNAL_H +#include +#include +#endif + +#ifdef CCTK_MPI +#include +#endif + static const char *rcsid = "$Header: /cactusdevcvs/Cactus/src/main/ShutdownCactus.c,v 1.14 2002/11/12 11:22:28 goodale Exp $"; CCTK_FILEVERSION(main_ShutdownCactus_c); +#ifdef CCTK_MPI +extern char MPI_Active; +#endif + +#ifdef CCTK_MPI +#define CACTUS_MPI_ERROR(xf) \ + do \ + { \ + int errcode; \ + \ + \ + if((errcode = xf) != MPI_SUCCESS) \ + { \ + char mpi_error_string[MPI_MAX_ERROR_STRING+1]; \ + int resultlen; \ + \ + \ + MPI_Error_string(errcode, mpi_error_string, &resultlen); \ + fprintf(stderr, "MPI Call %s returned error code %d (%s)\n", \ + #xf, errcode, mpi_error_string); \ + fprintf(stderr, "At line %d of file %s\n", \ + __LINE__, __FILE__); \ + } \ + } while (0) +#endif + /*@@ @routine CCTKi_ShutdownCactus @date Mon Sep 28 14:50:50 1998 @@ -53,5 +87,42 @@ CCTK_SchedulePrintTimes (NULL); } + printf("--------------------------------------------------------------------------------\n"); + printf("Done.\n"); + fflush(stdout); + + /* Terminate this process differently, if so desired */ + if (CCTK_EQUALS (process_termination, "regular")) + { + /* do nothing */ + } + else if (CCTK_EQUALS (process_termination, "quick")) + { +#ifdef HAVE_SIGNAL_H + kill (0, SIGKILL); +#else + CCTK_WARN (0, "This system does not support the kill system call. You cannot set the parameter \"Cactus::process_termination\" to \"quick\""); +#endif + } + else if (CCTK_EQUALS (process_termination, "exit")) + { + exit (0); + } + else if (CCTK_EQUALS (process_termination, "abort")) + { + abort (); + } + else + { + CCTK_WARN (0, "Internal error -- unknown value for parameter \"Cactus::process_termination\""); + } + +#ifdef CCTK_MPI + if(MPI_Active) + { + CACTUS_MPI_ERROR(MPI_Finalize()); + } +#endif + return 0; }