Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

main.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <math.h>
00005 #include <mpi.h>
00006 
00007 #include "allvars.h"
00008 #include "proto.h"
00009 
00010 
00022 int main(int argc, char **argv)
00023 {
00024   double t0, t1;
00025 
00026   MPI_Init(&argc, &argv);
00027   MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask);
00028   MPI_Comm_size(MPI_COMM_WORLD, &NTask);
00029 
00030   if(NTask <= 1)
00031     {
00032       if(ThisTask == 0)
00033         printf
00034           ("Note: This is a massively parallel code, but you are running with 1 processor only.\nCompared to an equivalent serial code, there is some unnecessary overhead.\n");
00035     }
00036 
00037   for(PTask = 0; NTask > (1 << PTask); PTask++);
00038 
00039   if(argc < 2)
00040     {
00041       if(ThisTask == 0)
00042         {
00043           printf("Parameters are missing.\n");
00044           printf("Call with <ParameterFile> [<RestartFlag>]\n");
00045         }
00046       endrun(0);
00047     }
00048 
00049   strcpy(ParameterFile, argv[1]);
00050 
00051   if(argc >= 3)
00052     RestartFlag = atoi(argv[2]);
00053   else
00054     RestartFlag = 0;
00055 
00056   All.CPU_TreeConstruction = All.CPU_TreeWalk = All.CPU_Gravity = All.CPU_Potential = All.CPU_Domain =
00057     All.CPU_Snapshot = All.CPU_Total = All.CPU_CommSum = All.CPU_Imbalance = All.CPU_Hydro =
00058     All.CPU_HydCompWalk = All.CPU_HydCommSumm = All.CPU_HydImbalance =
00059     All.CPU_EnsureNgb = All.CPU_Predict = All.CPU_TimeLine = All.CPU_PM = All.CPU_Peano = 0;
00060 
00061   CPUThisRun = 0;
00062 
00063   t0 = second();
00064 
00065   begrun();                     /* set-up run  */
00066 
00067   t1 = second();
00068   CPUThisRun += timediff(t0, t1);
00069   All.CPU_Total += timediff(t0, t1);
00070 
00071   run();                        /* main simulation loop */
00072 
00073   MPI_Finalize();               /* clean up & finalize MPI */
00074 
00075   return 0;
00076 }
00077 
00078 
00079 
00080 
00081 /* ----------------------------------------------------------------------
00082    The rest of this file contains documentation for compiling and
00083    running the code, in a format appropriate for 'doxygen'.
00084    ----------------------------------------------------------------------
00085  */
00086 

Generated on Sun May 22 17:33:29 2005 for GADGET-2 by  doxygen 1.3.9.1