From 7f9cf2c44e32bd6e68e30bf491ae3f8e9a75b516 Mon Sep 17 00:00:00 2001 From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de> Date: Wed, 3 May 2017 17:35:24 +0200 Subject: [PATCH] code compiles and links successfully It also successfully gives the "wrong number of command line arguments" message. --- bfps/_base.py | 23 ++++++++++++++--------- bfps/cpp/full_code/main_code.hpp | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bfps/_base.py b/bfps/_base.py index 8f7aeaaf..14b42b60 100644 --- a/bfps/_base.py +++ b/bfps/_base.py @@ -76,21 +76,26 @@ class _base(object): function_suffix = '', template_class = '', template_prefix = '', - file_group = 'parameters'): + file_group = 'parameters', + just_declaration = False, + simname_variable = 'simname'): if type(parameters) == type(None): parameters = self.parameters key = sorted(list(parameters.keys())) src_txt = (template_prefix + 'int ' + template_class + - 'read_parameters' + function_suffix + '()\n{\n' + - 'hid_t parameter_file;\n' + - 'hid_t dset, memtype, space;\n' + - 'char fname[256];\n' + - 'hsize_t dims[1];\n' + - 'char *string_data;\n' + - 'sprintf(fname, "%s.h5", simname);\n' + - 'parameter_file = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT);\n') + 'read_parameters' + function_suffix + '()') + if just_declaration: + return src_txt + ';\n' + src_txt += ('\n{\n' + + 'hid_t parameter_file;\n' + + 'hid_t dset, memtype, space;\n' + + 'char fname[256];\n' + + 'hsize_t dims[1];\n' + + 'char *string_data;\n' + + 'sprintf(fname, "%s.h5", {0});\n'.format(simname_variable) + + 'parameter_file = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT);\n') for i in range(len(key)): src_txt += 'dset = H5Dopen(parameter_file, "/{0}/{1}", H5P_DEFAULT);\n'.format( file_group, key[i]) diff --git a/bfps/cpp/full_code/main_code.hpp b/bfps/cpp/full_code/main_code.hpp index 06a68430..cae34b69 100644 --- a/bfps/cpp/full_code/main_code.hpp +++ b/bfps/cpp/full_code/main_code.hpp @@ -56,6 +56,7 @@ int main_code( std::cerr << "Wrong number of command line arguments. Stopping." << std::endl; + MPI_Init(&argc, &argv); MPI_Finalize(); return EXIT_SUCCESS; } -- GitLab