00001
00010 #ifndef __DEBUG_TOOLS_H_
00011 #define __DEBUG_TOOLS_H_
00012
00013 #ifdef _MPI
00014 #include <mpi.h>
00015 #endif
00016
00017 #include <stdio.h>
00018
00019
00020 int error_messager (const char *filenum, const int line, const char *errormessage);
00021
00023 struct AutoFile
00024 {
00026 FILE *fp_;
00027
00028 AutoFile(FILE *fp = 0) : fp_(fp) {}
00029
00030 ~AutoFile()
00031 {
00032 if (fp_)
00033 fclose(fp_);
00034 }
00035
00036 FILE *operator()() const
00037 {
00038 return fp_;
00039 }
00040 };
00041
00042 bool file_exists(const char *file_name);
00043
00048 int write_vector_to_file(FILE *fp, double *vector, size_t n, int offset);
00049
00050 int write_vector_to_file(const char *file_name, double *vector, size_t n, int offset);
00051
00056 int read_vector_from_file(FILE *fp, double *vector, size_t n, int offset);
00057
00058 int read_vector_from_file(const char *file_name, double *vector, size_t n, int offset);
00059
00060
00061
00062
00063 int write_vector_to_file (const char *file_name, double *vector, const int n);
00064
00065
00066
00067 int write_int_vector_to_file (const char *file_name, int* vector, const int n);
00068 #ifdef _MPI
00069 int mpi_write_int_vector_to_file (const char *file_name, int* vector, const int n, MPI_Comm comm);
00070 int mpi_write_vector_to_file (const char *file_name, double* vector, const int n, MPI_Comm comm);
00071 #endif
00072
00073
00074 int read_vector_from_file (const char *file_name, double* vector, const int n);
00075
00076 int write_int_vector_to_file (const char *file_name, int* vector, const int n);
00077 #endif //__DEBUG_TOOLS_H_
00078