Commit fdb81bdf authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added a debugging routine which prints all the relevant particle information...

Added a debugging routine which prints all the relevant particle information in a grep and gnuplot friendly way.


Former-commit-id: 6b8d9dc8541bd68d6b57800f15a6bf898dc232d1
parent fa4b8832
......@@ -862,6 +862,8 @@ int main ( int argc , char *argv[] ) {
parts[k].x[2] += shift[2];
}
for(k=0; k<10; ++k)
printParticle(parts, k);
/* Dump the kernel to make sure its ok. */
// kernel_dump( 100 );
......
......@@ -31,9 +31,9 @@ AM_LDFLAGS = $(LAPACK_LIBS) $(BLAS_LIBS) $(HDF5_LDFLAGS) -version-info 0:0:0
# Build the libswiftsim library
lib_LTLIBRARIES = libswiftsim.la
libswiftsim_la_SOURCES = space.c runner.c queue.c task.c cell.c engine.c input.c timers.c
libswiftsim_la_SOURCES = space.c runner.c queue.c task.c cell.c engine.c input.c timers.c debug.c
# List required headers
include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
engine.h swift.h io.h timers.h
engine.h swift.h io.h timers.h debug.h
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include <stdio.h>
#include "part.h"
void printParticle(struct part *parts, int i)
{
printf("## Particle[%d]: id= %lld x=( %f, %f, %f) v=( %f, %f, %f) h= %f m= %f rho= %f u= %f dt= %f\n",
i,
parts[i].id,
parts[i].x[0], parts[i].x[1], parts[i].x[2],
parts[i].v[0], parts[i].v[1], parts[i].v[2],
parts[i].h,
parts[i].mass,
parts[i].rho,
parts[i].u,
parts[i].dt
);
}
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
void printParticle(struct part *parts, int i);
......@@ -36,65 +36,7 @@
#include "task.h"
#include "part.h"
#include "space.h"
/* Error macro. */
#define error(s) { fprintf( stderr , "%s:%s():%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); }
/**
* @brief The different types of data used in the GADGET IC files.
*
* (This is admittedly a poor substitute to C++ templates...)
*/
enum DATA_TYPE{INT, LONG, LONGLONG, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE};
/**
* @brief The two sorts of data present in the GADGET IC files: compulsory to start a run or optional.
*
*/
enum DATA_IMPORTANCE{COMPULSORY=1, OPTIONAL=0};
/**
* @brief Converts a C data type to the HDF5 equivalent.
*
* This function is a trivial wrapper around the HDF5 types but allows
* to change the exact storage types matching the code types in a transparent way.
*/
hid_t hdf5Type(enum DATA_TYPE type)
{
switch(type)
{
case INT: return H5T_NATIVE_INT;
case UINT: return H5T_NATIVE_UINT;
case LONG: return H5T_NATIVE_LONG;
case ULONG: return H5T_NATIVE_ULONG;
case LONGLONG: return H5T_NATIVE_LLONG;
case ULONGLONG: return H5T_NATIVE_ULLONG;
case FLOAT: return H5T_NATIVE_FLOAT;
case DOUBLE: return H5T_NATIVE_DOUBLE;
default: error("Unknown type");
}
}
/**
* @brief Returns the memory size of the data type
*/
size_t sizeOfType(enum DATA_TYPE type)
{
switch(type)
{
case INT: return sizeof(int);
case UINT: return sizeof(unsigned int);
case LONG: return sizeof(long);
case ULONG: return sizeof(unsigned long);
case LONGLONG: return sizeof(long long);
case ULONGLONG: return sizeof(unsigned long long);
case FLOAT: return sizeof(float);
case DOUBLE: return sizeof(double);
default: error("Unknown type");
}
}
#include "io_types.h"
/**
......
......@@ -34,3 +34,4 @@
#include "runner_iact.h"
#include "engine.h"
#include "io.h"
#include "debug.h"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment