diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c50538d..4603eadc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ endif() #----------------------------------------------------------------------------- set (API_VERSION_MAJOR 4) set (API_VERSION_MINOR 4) -set (API_VERSION_PATCH 2) +set (API_VERSION_PATCH 3) set (API_VERSION "${API_VERSION_MAJOR}.${API_VERSION_MINOR}.${API_VERSION_PATCH}") set (ABI_CURRENT 1) set (ABI_REVISION 0) @@ -78,7 +78,7 @@ set (ABI_VERSION "${ABI_CURRENT}.${ABI_REVISION}.${ABI_AGE}") set (NEXUS_VERSION_MAJOR 4) set (NEXUS_VERSION_MINOR 4) -set (NEXUS_VERSION_PATCH 2) +set (NEXUS_VERSION_PATCH 3) set (NEXUS_SONAME 4) set (NAPI_VERSION "${NEXUS_VERSION_MAJOR}.${NEXUS_VERSION_MINOR}.${NEXUS_VERSION_PATCH}") set (NXLTVERSINFO "${NEXUS_VERSION_MAJOR}:${NEXUS_VERSION_MINOR}:${NEXUS_VERSION_PATCH}") @@ -254,7 +254,9 @@ add_subdirectory (test) #build the tests add_subdirectory (bindings) #build the language bindings add_subdirectory (scripts) #install pkg-config files -#on user request utility applications will be built +#------------------------------------------------------------------------------ +# on user request utility applications will be built +#------------------------------------------------------------------------------ if(ENABLE_APPS) add_subdirectory (applications) endif() @@ -262,6 +264,9 @@ endif() add_subdirectory (doc) #add_subdirectory (config) +#------------------------------------------------------------------------------ +# on user request contributed applications will be built +#------------------------------------------------------------------------------ if(ENABLE_CONTRIB) add_subdirectory (contrib) endif() @@ -290,7 +295,9 @@ if(WIN32) file(GLOB HDF4_DLLS "${HDF4_LIBRARY_DIRS}/../bin/*.dll") # for some reason HDF5_LIBRARY_DIRS is blank file(GLOB HDF5_DLLS "${HDF5_INCLUDE_DIRS}/../bin/*.dll") - file(GLOB_RECURSE MXML_DLLS "${MXML_LIBRARY_DIRS}/*.dll") + if(WITH_MXML) + file(GLOB_RECURSE MXML_DLLS "${MXML_LIBRARY_DIRS}/*.dll") + endif() install(FILES ${HDF4_DLLS} ${HDF5_DLLS} ${MXML_DLLS} DESTINATION bin COMPONENT Runtime) INSTALL(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION bin COMPONENT Runtime) endif() @@ -314,6 +321,8 @@ elseif(CYGWIN) set (CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR};CygwinSource) elseif(UNIX) set (CPACK_GENERATOR ${CPACK_GENERATOR};DEB;RPM) + set (CPACK_DEBIAN_PACKAGE_DEPENDS "libhdf5-103, libhdf5-dev") + set (CPACK_RPM_PACKAGE_REQUIRES "hdf5, hdf5-devel") endif() # Include of CPack must always be last include(CPack) diff --git a/README.rst b/README.rst index c3e8403f..0d5c9dc2 100644 --- a/README.rst +++ b/README.rst @@ -83,7 +83,7 @@ Program Description ``nxbrowse`` browse a NeXus file ``nxdir`` list the contents of a NeXus file ``nxconvert`` convert a NeXus file to whatever? -``nxtraverse`` no idea what this is good for +``nxtraverse`` list the contents of a NeXus file ``nxdump`` ``nxingest`` ``nxsummary`` @@ -109,9 +109,12 @@ To build the library and program binaries simply use .. code-block:: bash + $ mkdir build + $ cd build + $ cmake -DENABLE_APPS=ON .. # building with tools as example config option $ make -and for installation +from the source directoy. For installation run .. code-block:: bash diff --git a/README.versions b/README.versions deleted file mode 100644 index f719739c..00000000 --- a/README.versions +++ /dev/null @@ -1,4 +0,0 @@ -To increment the NeXus version you need to: -- change the argument to AC_INIT in configure.ac -- update NEXUS_VERSION in include/napi.h -- change version number printed in test output contained in test/testsuite.at diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt index 0f8d0d4e..2b5b61ab 100644 --- a/applications/CMakeLists.txt +++ b/applications/CMakeLists.txt @@ -66,15 +66,22 @@ include_directories("../include") # proceed with building the programs #----------------------------------------------------------------------------- -add_subdirectory (NXbrowse) -#add_subdirectory(c-nxvalidate) +if (HAVE_LIBREADLINE) + add_subdirectory (NXbrowse) +else() + message(WARNING "libreadline not found, not building: nxbrowse") +endif() if (ENABLE_CXX) - add_subdirectory (NXdir) - add_subdirectory (NXconvert) - add_subdirectory (NXtraverse) + add_subdirectory (NXdir) + add_subdirectory (NXconvert) +else() + message(WARNING "C++ bindings not enabled, not building: NXdri, NXconvert") endif() +#depends only in Nexus C API +add_subdirectory (NXtraverse) + if (ENABLE_FORTRAN90 AND CMAKE_Fortran_COMPILER_WORKS) add_subdirectory (NXdump) endif() @@ -83,10 +90,14 @@ endif() if(LIBXML2_FOUND) add_subdirectory (NXsummary) add_subdirectory (NXtranslate) +else() + message(WARNING "LIBXML2 library not found, not building: NXsummary, NXtranslate") endif(LIBXML2_FOUND) if (WITH_MXML) add_subdirectory (nxingest) +else() + message(WARNING "MXML not enabled, not building: nxingest") endif() #----------------------------------------------------------------------------- diff --git a/applications/NXconvert/nxconvert.cpp b/applications/NXconvert/nxconvert.cpp index 204283d8..aa5a5f0c 100644 --- a/applications/NXconvert/nxconvert.cpp +++ b/applications/NXconvert/nxconvert.cpp @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) false); ValueArg defValueArg("D", "definition", "Output definition file used for validating NeXus files. Requires a definition name.", - false, EMPTY, "defintion"); + false, EMPTY, "definition"); vector allowedXml; allowedXml.push_back("keepws"); allowedXml.push_back("table"); @@ -154,7 +154,7 @@ int main(int argc, char *argv[]) } // tell the user that everything went ok - std::cout << "Convertion successful." << std::endl; + std::cout << "Conversion successful." << std::endl; return 0; } diff --git a/applications/NXdir/nxdir.1 b/applications/NXdir/nxdir.1 index ba2e8717..dd556f83 100644 --- a/applications/NXdir/nxdir.1 +++ b/applications/NXdir/nxdir.1 @@ -23,7 +23,7 @@ nxdir \- inspect a NeXus file non interactively .RI [ options ] .SH DESCRIPTION .B nxdir -allows to retrieve the structure and/or data of a NeXus file. +allows retrieval of the structure and/or data of a NeXus file. .PP .\" TeX users may be more comfortable with the \fB\fP and .\" \fI\fP escape sequences to invode bold face and italics, diff --git a/applications/NXtranslate/docs/NXtranslate.pdf b/applications/NXtranslate/docs/NXtranslate.pdf new file mode 100644 index 00000000..9239db59 Binary files /dev/null and b/applications/NXtranslate/docs/NXtranslate.pdf differ diff --git a/applications/NXtranslate/docs/translation.docbook b/applications/NXtranslate/docs/translation.docbook index a8483861..a0f6ac81 100644 --- a/applications/NXtranslate/docs/translation.docbook +++ b/applications/NXtranslate/docs/translation.docbook @@ -546,7 +546,7 @@ columns. The &mime-type for the XML retriever is text/xml. The XML retriever is built on top of libxml2's document object model (DOM) parser. Because of this the -entire file for information to be retrived from is loaded into memory +entire file for information to be retrieved from is loaded into memory as a character arrays. The DOM API was chosen to allow for jumping around the source file without needed to parse its contents multiple times. The location string will be formatted according to the diff --git a/applications/NXtranslate/esrf_edf/edf_retriever.h b/applications/NXtranslate/esrf_edf/edf_retriever.h index 7eaae045..8b7e25a6 100644 --- a/applications/NXtranslate/esrf_edf/edf_retriever.h +++ b/applications/NXtranslate/esrf_edf/edf_retriever.h @@ -4,8 +4,8 @@ // // Project: Fable data to NeXus translation // -// Description: definition of a edf_retriever class. The retriever allows to -// read data from EDF file and store in Nexus file format. +// Description: definition of a edf_retriever class. The retriever allows +// reading data from EDF file and store in Nexus file format. // It is a plugin of NXtranslate program. // // Author(s): Jaroslaw Butanowicz diff --git a/applications/NXtranslate/sns_histogram/SNS_retriever.cpp b/applications/NXtranslate/sns_histogram/SNS_retriever.cpp index 8fad73f9..60721fe4 100644 --- a/applications/NXtranslate/sns_histogram/SNS_retriever.cpp +++ b/applications/NXtranslate/sns_histogram/SNS_retriever.cpp @@ -48,7 +48,7 @@ void SnsHistogramRetriever::getData(const string &location, tree &tr) vector decla_def; //declaration and definition parts vector LocGlobArray; //local and global array (declaration part) - vector Ope; //Operators of the defintion part + vector Ope; //Operators of the definition part int OperatorNumber; string DefinitionPart; //use to determine the operators vector GrpPriority; //Vector of priority of each group @@ -71,7 +71,7 @@ void SnsHistogramRetriever::getData(const string &location, tree &tr) DeclaDef_separator(new_location, decla_def); //Separate Declaration part from Definition part -> decla_def - //check if the defintion part has a valid format + //check if the definition part has a valid format if (decla_def[1].size() > 0 && decla_def[1].size()<7) throw runtime_error("Definition part is not valid"); @@ -86,7 +86,7 @@ void SnsHistogramRetriever::getData(const string &location, tree &tr) //Work on definition part DefinitionPart = decla_def[1]; - //Parse defintion part, separate Tag from Def + //Parse definition part, separate Tag from Def TagDef_separator(decla_def[1], Tag, Def, definition_version_with_groups); //check if we have at least one tag @@ -171,7 +171,7 @@ string SnsHistogramRetriever::toString() const * \para GrpPara (OUTPUT) is the list of operators (loop or list of * identifiers * \param record (OUTPUT) is a structure Grp_parameters that contains - * all the information of the different defintion part + * all the information of the different definition part */ void store_para_of_definition(vector Def, int HowManyDef, @@ -212,8 +212,8 @@ void store_para_of_definition(vector Def, * of the loop definition; the initial value, the final value and the increment * * \param def (INPUT) the definition part to parse - * \param i (INPUT) the index of the defintion part to parse - * \param GrpPara (OUTPUT) the Grp_parameters structre of the defintion part + * \param i (INPUT) the index of the definition part to parse + * \param GrpPara (OUTPUT) the Grp_parameters structre of the definition part */ void InitLastIncre (string & def, int i, @@ -345,7 +345,7 @@ void parse_declaration_array(vector & LocGlobArray, * \param GlobalArray (INPUT) is the list of parameters of the global * declaration part * \param GrpPara (INPUT) is a list of structures of all the parameters of the - * defintion part + * definition part */ void calculate_array (vector & GrpPriority, vector & InverseDef, @@ -524,8 +524,8 @@ int FindMaxPriority (vector & GrpPriority) * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -592,8 +592,8 @@ void MakeArray_pixelID (binary_type * MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -658,8 +658,8 @@ void MakeArray_pixelX (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -724,8 +724,8 @@ void MakeArray_pixelY (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) diff --git a/applications/NXtranslate/sns_histogram/SNS_retriever.hpp b/applications/NXtranslate/sns_histogram/SNS_retriever.hpp index 3a35a2fa..f0f099f6 100644 --- a/applications/NXtranslate/sns_histogram/SNS_retriever.hpp +++ b/applications/NXtranslate/sns_histogram/SNS_retriever.hpp @@ -53,7 +53,7 @@ struct Grp_parameters //parameters of the different definitions * \para GrpPara (OUTPUT) is the list of operators (loop or list of * identifiers * \param record (OUTPUT) is a structure Grp_parameters that contains - * all the information of the different defintion part + * all the information of the different definition part */ void store_para_of_definition(vector Def, int OperatorNumber, @@ -65,8 +65,8 @@ void store_para_of_definition(vector Def, * of the loop definition; the initial value, the final value and the increment * * \param def (INPUT) the definition part to parse - * \param i (INPUT) the index of the defintion part to parse - * \param GrpPara (OUTPUT) the Grp_parameters structre of the defintion part + * \param i (INPUT) the index of the definition part to parse + * \param GrpPara (OUTPUT) the Grp_parameters structre of the definition part */ void InitLastIncre (string & def, int i, @@ -123,7 +123,7 @@ int FindMaxPriority (vector& GrpPriority); * \param GlobalArray (INPUT) is the list of parameters of the global * declaration part * \param GrpPara (INPUT) is a list of structures of all the parameters of the - * defintion part + * definition part */ void calculate_array (vector & GrpPriority, vector & InverseDef, @@ -142,8 +142,8 @@ void calculate_array (vector & GrpPriority, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -164,8 +164,8 @@ void MakeArray_pixelID (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -186,8 +186,8 @@ void MakeArray_pixelX (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -208,8 +208,8 @@ void MakeArray_pixelY (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) diff --git a/applications/NXtranslate/sns_histogram/retriever.cpp b/applications/NXtranslate/sns_histogram/retriever.cpp index 90d6168c..a3106931 100644 --- a/applications/NXtranslate/sns_histogram/retriever.cpp +++ b/applications/NXtranslate/sns_histogram/retriever.cpp @@ -48,7 +48,7 @@ void SnsHistogramRetriever::getData(const string &location, tree &tr) vector decla_def; //declaration and definition parts vector LocGlobArray; //local and global array (declaration part) - vector Ope; //Operators of the defintion part + vector Ope; //Operators of the definition part int OperatorNumber; string DefinitionPart; //use to determine the operators vector GrpPriority; //Vector of priority of each group @@ -71,7 +71,7 @@ void SnsHistogramRetriever::getData(const string &location, tree &tr) DeclaDef_separator(new_location, decla_def); //Separate Declaration part from Definition part -> decla_def - //check if the defintion part has a valid format + //check if the definition part has a valid format if (decla_def[1].size() > 0 && decla_def[1].size()<7) throw runtime_error("Definition part is not valid"); @@ -86,7 +86,7 @@ void SnsHistogramRetriever::getData(const string &location, tree &tr) //Work on definition part DefinitionPart = decla_def[1]; - //Parse defintion part, separate Tag from Def + //Parse definition part, separate Tag from Def TagDef_separator(decla_def[1], Tag, Def, definition_version_with_groups); //check if we have at least one tag @@ -171,7 +171,7 @@ string SnsHistogramRetriever::toString() const * \para GrpPara (OUTPUT) is the list of operators (loop or list of * identifiers * \param record (OUTPUT) is a structure Grp_parameters that contains - * all the information of the different defintion part + * all the information of the different definition part */ void store_para_of_definition(vector Def, int HowManyDef, @@ -212,8 +212,8 @@ void store_para_of_definition(vector Def, * of the loop definition; the initial value, the final value and the increment * * \param def (INPUT) the definition part to parse - * \param i (INPUT) the index of the defintion part to parse - * \param GrpPara (OUTPUT) the Grp_parameters structre of the defintion part + * \param i (INPUT) the index of the definition part to parse + * \param GrpPara (OUTPUT) the Grp_parameters structre of the definition part */ void InitLastIncre (string & def, int i, @@ -345,7 +345,7 @@ void parse_declaration_array(vector & LocGlobArray, * \param GlobalArray (INPUT) is the list of parameters of the global * declaration part * \param GrpPara (INPUT) is a list of structures of all the parameters of the - * defintion part + * definition part */ void calculate_array (vector & GrpPriority, vector & InverseDef, @@ -524,8 +524,8 @@ int FindMaxPriority (vector & GrpPriority) * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -592,8 +592,8 @@ void MakeArray_pixelID (binary_type * MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -658,8 +658,8 @@ void MakeArray_pixelX (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -724,8 +724,8 @@ void MakeArray_pixelY (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) diff --git a/applications/NXtranslate/sns_histogram/retriever.hpp b/applications/NXtranslate/sns_histogram/retriever.hpp index f52eec92..9d2f7596 100644 --- a/applications/NXtranslate/sns_histogram/retriever.hpp +++ b/applications/NXtranslate/sns_histogram/retriever.hpp @@ -35,7 +35,7 @@ struct Grp_parameters //parameters of the different definitions * \para GrpPara (OUTPUT) is the list of operators (loop or list of * identifiers * \param record (OUTPUT) is a structure Grp_parameters that contains - * all the information of the different defintion part + * all the information of the different definition part */ void store_para_of_definition(vector Def, int OperatorNumber, @@ -47,8 +47,8 @@ void store_para_of_definition(vector Def, * of the loop definition; the initial value, the final value and the increment * * \param def (INPUT) the definition part to parse - * \param i (INPUT) the index of the defintion part to parse - * \param GrpPara (OUTPUT) the Grp_parameters structre of the defintion part + * \param i (INPUT) the index of the definition part to parse + * \param GrpPara (OUTPUT) the Grp_parameters structre of the definition part */ void InitLastIncre (string & def, int i, @@ -105,7 +105,7 @@ int FindMaxPriority (vector& GrpPriority); * \param GlobalArray (INPUT) is the list of parameters of the global * declaration part * \param GrpPara (INPUT) is a list of structures of all the parameters of the - * defintion part + * definition part */ void calculate_array (vector & GrpPriority, vector & InverseDef, @@ -124,8 +124,8 @@ void calculate_array (vector & GrpPriority, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -146,8 +146,8 @@ void MakeArray_pixelID (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -168,8 +168,8 @@ void MakeArray_pixelX (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) @@ -190,8 +190,8 @@ void MakeArray_pixelY (binary_type* MyGrpArray, * \param MyGrpArray (INPUT) * \param BinaryArray (INPUT) is the array that comes from the binary file * \param grp_number (INPUT) is the group index - * \param InverseDef (INPUT) allows to check if we want or not the inverse - * of the defintion + * \param InverseDef (INPUT) allows checking if we want or not the inverse + * of the definition * \param def (INPUT) is the list of definition * \param LocalArray (INPUT) ???not used??? * \param GlobalArray (INPUT) diff --git a/applications/NXtranslate/spec/SPEClib.cpp b/applications/NXtranslate/spec/SPEClib.cpp index 1f97f263..6e82201f 100644 --- a/applications/NXtranslate/spec/SPEClib.cpp +++ b/applications/NXtranslate/spec/SPEClib.cpp @@ -477,7 +477,7 @@ bool get_values(ifstream &in, int number, double results[], int scan_number){ //label position must be greater then zero // if(number == 0){ - cout<<"Uncorrect number of label\n"; + cout<<"Incorrect number of label\n"; exit(1); } // @@ -981,7 +981,7 @@ double get_motor_value(ifstream &in, int noMotor, int noValue, int scan){ // int MAX = m_label_counter(in, noMotor); if(noValue>MAX || noValue<1){ - cout<<"Uncorrect number of value\n"; + cout<<"Incorrect number of value\n"; exit(1); } // @@ -1263,7 +1263,7 @@ void get_motor_name(ifstream &in, char *motor_name, int motor_group, int motor_p exit(1); } if(motor_position>motors_number || motor_position<1){ - cout<<" Uncorrect number of label\n"; + cout<<" Incorrect number of label\n"; exit(1); } // diff --git a/applications/NXtranslate/spec/spec_retriever.h b/applications/NXtranslate/spec/spec_retriever.h index 95ee11ec..9663952d 100644 --- a/applications/NXtranslate/spec/spec_retriever.h +++ b/applications/NXtranslate/spec/spec_retriever.h @@ -4,8 +4,8 @@ // // Project: Fable data to NeXus translation // -// Description: definition of a spec_retriever class. The retriever allows to -// read data from SPEC file and store in Nexus file format. +// Description: definition of a spec_retriever class. The retriever allows +// reading data from SPEC file and store in Nexus file format. // It uses SPEClib for reading SPEC files. It is a plugin of NXtranslate // program. // diff --git a/applications/NXtranslate/text_xml/xml_retriever_dom.cpp b/applications/NXtranslate/text_xml/xml_retriever_dom.cpp index dcc56f42..dad5403a 100644 --- a/applications/NXtranslate/text_xml/xml_retriever_dom.cpp +++ b/applications/NXtranslate/text_xml/xml_retriever_dom.cpp @@ -163,8 +163,8 @@ static void my_error(void *user_data, const char* msg, ...){ va_start(args,msg); // get the position of the error - int line=getLineNumber(context); - int col =getColumnNumber(context); + int line=xmlSAX2GetLineNumber(context); + int col =xmlSAX2GetColumnNumber(context); // print out the result char str[70]; @@ -186,8 +186,8 @@ static void my_fatalError(void *user_data, const char* msg, ...){ va_start(args,msg); // get the position of the error - int line=getLineNumber(context); - int col =getColumnNumber(context); + int line=xmlSAX2GetLineNumber(context); + int col =xmlSAX2GetColumnNumber(context); // print out the result char str[70]; diff --git a/applications/NXtranslate/xml_parser.cpp b/applications/NXtranslate/xml_parser.cpp index 70500a1d..7743874e 100644 --- a/applications/NXtranslate/xml_parser.cpp +++ b/applications/NXtranslate/xml_parser.cpp @@ -296,7 +296,7 @@ static void my_startElement(void *user_data, const xmlChar *name, // confirm that maximum node depth is not exceded if(((UserData *)user_data)->mime_types.size()>MAX_NODE_DEPTH) - throw runtime_error("Exceded maximum node depth"); + throw runtime_error("Exceeded maximum node depth"); // create a new retriever if necessary RetrieverPtr retriever(NULL); @@ -463,8 +463,8 @@ static void my_error(void *user_data, const char* msg, ...){ va_start(args,msg); // get the position of the error - int line=getLineNumber(context); - int col =getColumnNumber(context); + int line=xmlSAX2GetLineNumber(context); + int col =xmlSAX2GetColumnNumber(context); // print out the result char str[70]; @@ -486,8 +486,8 @@ static void my_fatalError(void *user_data, const char* msg, ...){ va_start(args,msg); // get the position of the error - int line=getLineNumber(context); - int col =getColumnNumber(context); + int line=xmlSAX2GetLineNumber(context); + int col =xmlSAX2GetColumnNumber(context); // print out the result char str[70]; diff --git a/applications/NXtraverse/CMakeLists.txt b/applications/NXtraverse/CMakeLists.txt index bfd610b2..a0535d1d 100644 --- a/applications/NXtraverse/CMakeLists.txt +++ b/applications/NXtraverse/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories(../../bindings/cpp) add_executable (nxtraverse nxtraverse.cpp main.cpp nxtraverse.h) -target_link_libraries(nxtraverse NeXus_CPP_Shared_Library ) +target_link_libraries(nxtraverse NeXus_Shared_Library ) install (TARGETS nxtraverse DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/applications/nxingest/nxingest.txt b/applications/nxingest/nxingest.txt index 344c664c..33dbb644 100644 --- a/applications/nxingest/nxingest.txt +++ b/applications/nxingest/nxingest.txt @@ -23,11 +23,11 @@ DESCRIPTION See http://nile.dl.ac.uk/trac/isis/browser/Software/icat_xsd/icatXSD.xsd NB: This work is ongoing; the schema hasn't been released yet. - This tool use the NeXus api so any of the supported format (HDF4, HDF5 - and XML) can be read. + This tool use the NeXus api so any of the supported format (HDF4, HDF5 + and XML) can be read. - nxingest can retrive metadata from the neXus file, from the mapping file - (fix parameter). it can also retrive the actual time. + nxingest can retrieve metadata from the neXus file, from the mapping file + (fix parameter). it can also retrieve the actual time. If the metadata is a date or time, nxingest may modify it to extract only part of the data (e.g. the year) or reformat it to have consistant dates @@ -322,4 +322,4 @@ COPYRIGHT You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. \ No newline at end of file + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. diff --git a/bindings/cpp/NeXusFile.cpp b/bindings/cpp/NeXusFile.cpp index 174bd07c..c4b9768a 100644 --- a/bindings/cpp/NeXusFile.cpp +++ b/bindings/cpp/NeXusFile.cpp @@ -194,7 +194,9 @@ File::~File() { NXstatus status = NXclose(&(this->m_file_id)); this->m_file_id = NULL; if (status != NX_OK) { - throw Exception("NXclose failed", status); + stringstream msg; + msg << "NXclose failed with status: " << status << "\n"; + NXReportError(const_cast(msg.str().c_str())); } } } @@ -503,7 +505,7 @@ void File::writeCompData(const string & name, const vector & value, void File::compress(NXcompression comp) { stringstream msg; - msg << "compress(" << comp << ") is depricated - use makeCompData()"; + msg << "compress(" << comp << ") is deprecated - use makeCompData()"; throw Exception(msg.str()); } diff --git a/bindings/cpp/NeXusFile.hpp b/bindings/cpp/NeXusFile.hpp index fcb5d9f3..0b93565e 100644 --- a/bindings/cpp/NeXusFile.hpp +++ b/bindings/cpp/NeXusFile.hpp @@ -116,7 +116,7 @@ namespace NeXus { * This is a deprecated function. * \param com The compression type. */ - void compress(NXcompression comp) NEXUS_DEPRECATED_FUNCTION; + void compress(NXcompression comp) NEXUS_DEPRECATED_FUNCTION(); /** * Initialize the pending group search to start again. diff --git a/bindings/swig/asciidblib.scm b/bindings/swig/asciidblib.scm index 02d51905..11b28694 100644 --- a/bindings/swig/asciidblib.scm +++ b/bindings/swig/asciidblib.scm @@ -12,8 +12,8 @@ (define currentRow '()) ;------------------------------------------------------------------------ -; functifyFields creates functions for each field which allows to -; retrieve the field value by a (fieldName) syntax. This is useful for +; functifyFields creates functions for each field which allows +; retrieval of the field value by a (fieldName) syntax. This is useful for ; operator doing computations. The row to be accessed must be put into ; currentRow however before this can work. (define functifyFields (lambda (header) diff --git a/doc/api/NeXusIntern.html b/doc/api/NeXusIntern.html index 63d4115e..2462bb94 100644 --- a/doc/api/NeXusIntern.html +++ b/doc/api/NeXusIntern.html @@ -127,13 +127,13 @@

NeXus Programmers Reference

 	void NXIReportError(void *pData, char *errorText);
A NeXus-API user now can replace the default error reporting function through an own implementation with the -function NXMSetError. NXMSetError also allows to pass in a pointer to a user defined data structure which is +function NXMSetError. NXMSetError also allows one to pass in a pointer to a user defined data structure which is passed as pData to the error reporting function.

NeXus File Drivers

NeXus HDF File Drivers

The NeXus file drivers for the HDF file formats HDF-4 and HDF-5 share common features. I recall that NeXus uses a hierarchy in order to organize information storage. But both HDF-API's are not tree based -but use an interface which allows to open and close groups and datasets. This is sensible as HDF is designed +but use an interface which allows one to open and close groups and datasets. This is sensible as HDF is designed to support very large data sets which may not necessarily fit into a computers memory in one go. But this also implies that the current position in the hierarchy of a given NeXus file has to be maintained by the NeXus-API. Such information is maintained in a stack which is pushed an popped while moving through the hierarchy. This diff --git a/doc/api/NeXusIntern.radi b/doc/api/NeXusIntern.radi index d9d90240..0f8cb830 100755 --- a/doc/api/NeXusIntern.radi +++ b/doc/api/NeXusIntern.radi @@ -137,7 +137,7 @@ the signature: void NXIReportError(void *pData, char *errorText); }}} A NeXus-API user now can replace the default error reporting function through an own implementation with the -function NXMSetError. NXMSetError also allows to pass in a pointer to a user defined data structure which is +function NXMSetError. NXMSetError also allows one to pass in a pointer to a user defined data structure which is passed as pData to the error reporting function. = NeXus File Drivers = @@ -145,7 +145,7 @@ passed as pData to the error reporting function. == NeXus HDF File Drivers == The NeXus file drivers for the HDF file formats HDF-4 and HDF-5 share common features. I recall that NeXus uses a hierarchy in order to organize information storage. But both HDF-API's are not tree based -but use an interface which allows to open and close groups and datasets. This is sensible as HDF is designed +but use an interface which allows one to open and close groups and datasets. This is sensible as HDF is designed to support very large data sets which may not necessarily fit into a computers memory in one go. But this also implies that the current position in the hierarchy of a given NeXus file has to be maintained by the NeXus-API. Such information is maintained in a stack which is pushed an popped while moving through the hierarchy. This diff --git a/doc/api/NeXusIntern.tex b/doc/api/NeXusIntern.tex index 827b5765..a1daca0a 100644 --- a/doc/api/NeXusIntern.tex +++ b/doc/api/NeXusIntern.tex @@ -149,7 +149,7 @@ \section{The Top Level NeXus API } void NXIReportError(void *pData, char *errorText); \end{verbatim} A NeXus-API user now can replace the default error reporting function through an own implementation with the -function NXMSetError. NXMSetError also allows to pass in a pointer to a user defined data structure which is +function NXMSetError. NXMSetError also allows one to pass in a pointer to a user defined data structure which is passed as pData to the error reporting function. @@ -157,7 +157,7 @@ \section{NeXus File Drivers } \subsection{NeXus HDF File Drivers } The NeXus file drivers for the HDF file formats HDF-4 and HDF-5 share common features. I recall that NeXus uses a hierarchy in order to organize information storage. But both HDF-API's are not tree based -but use an interface which allows to open and close groups and datasets. This is sensible as HDF is designed +but use an interface which allows one to open and close groups and datasets. This is sensible as HDF is designed to support very large data sets which may not necessarily fit into a computers memory in one go. But this also implies that the current position in the hierarchy of a given NeXus file has to be maintained by the NeXus-API. Such information is maintained in a stack which is pushed an popped while moving through the hierarchy. This diff --git a/doc/api/napi.tex b/doc/api/napi.tex index 74d08343..7266ed0d 100644 --- a/doc/api/napi.tex +++ b/doc/api/napi.tex @@ -1167,7 +1167,7 @@ \subsubsection{NXgetnextentry} \end{flushleft} \subsubsection{NXgetnextattr} NXgetnextattr works very much like NXgetnextentry except, that it works on -SDS attributes and not on Vgroup entries. This function allows to scan the +SDS attributes and not on Vgroup entries. This function allows one to scan the names of attributes available. iLength will be filled with the length of the attributes data in byte. iType will be filled with the HDF type of the attribute. Be warned: this routine returns global attributes when no SDS is @@ -1407,7 +1407,7 @@ \subsubsection{NX error handling} because stdout is supported only in a very strange way. Think about operating system like MS-Windows, MAC-OS (going to die anyway) or other windowing systems. In order to cater for this there is an inofficial support -function which allows to set both a pointer to a datastructure and a new +function which allows one to set both a pointer to a datastructure and a new function for error reporting. This is called NXMSetError. \begin{flushleft} \small diff --git a/include/napi.h.in b/include/napi.h.in index 29725231..76f5e206 100644 --- a/include/napi.h.in +++ b/include/napi.h.in @@ -259,9 +259,9 @@ typedef struct { */ #if (defined(__GNUC__) || defined(__clang__)) -#define NEXUS_DEPRECATED_FUNCTION __attribute__((deprecated)) +#define NEXUS_DEPRECATED_FUNCTION(msg) __attribute__((deprecated(msg))) #else -#define NEXUS_DEPRECATED_FUNCTION +#define NEXUS_DEPRECATED_FUNCTION(msg) #endif #ifdef __cplusplus @@ -435,7 +435,7 @@ extern NXstatus NXcompmakedata64 (NXhandle handle, CONSTCHAR* label, int dataty * \li NX_COMP_HUF Huffmann encoding (only HDF-4) * \ingroup c_readwrite */ -extern NXstatus NXcompress (NXhandle handle, int compr_type) NEXUS_DEPRECATED_FUNCTION; +extern NXstatus NXcompress (NXhandle handle, int compr_type) NEXUS_DEPRECATED_FUNCTION(); /** * Open access to a dataset. After this call it is possible to write and read data or @@ -632,7 +632,7 @@ extern NXstatus NXgetslab64(NXhandle handle, void* data, const int64_t start[] * \return NX_OK on success, NX_ERROR in the case of an error, NX_EOD when there are no more items. * \ingroup c_readwrite */ -extern NXstatus NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType) NEXUS_DEPRECATED_FUNCTION; +extern NXstatus NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType) NEXUS_DEPRECATED_FUNCTION("Use NXgetnextattra instead"); /** * Read an attribute containing a single string or numerical value. @@ -878,7 +878,7 @@ extern NXstatus NXgetrawinfo64(NXhandle handle, int* rank, int64_t dimension[] /** \typedef void (*ErrFunc)(void *data, char *text) * All NeXus error reporting happens through this special function, the - * ErrFunc. The NeXus-API allows to replace this error reporting function + * ErrFunc. The NeXus-API allows this error reporting function to be replaced * through a user defined implementation. The default error function prints to stderr. User * defined ones may pop up dialog boxes or whatever. * \param data A pointer to some user defined data structure diff --git a/src/napi4.c b/src/napi4.c index 9e03123f..63dbfa92 100644 --- a/src/napi4.c +++ b/src/napi4.c @@ -452,36 +452,47 @@ static int findNapiClass(pNexusFile pFile, int groupRef, NXname nxclass) * need to create global attributes file_name file_time NeXus_version * at some point for new files */ - if (am != NXACC_READ) { - if (SDsetattr(pNew->iSID, "NeXus_version", DFNT_CHAR8, strlen(NEXUS_VERSION), NEXUS_VERSION) < 0) { - NXReportError( "ERROR: HDF failed to store NeXus_version attribute "); - return NX_ERROR; - } - Hgetlibversion(&lmajor, &lminor, &lrelease, HDF_VERSION); - if (SDsetattr(pNew->iSID, "HDF_version", DFNT_CHAR8, strlen(HDF_VERSION), HDF_VERSION) < 0) { - NXReportError( "ERROR: HDF failed to store HDF_version attribute "); - return NX_ERROR; - } - } - - time_puffer = NXIformatNeXusTime(); if (am == NXACC_CREATE || am == NXACC_CREATE4) { - if (SDsetattr(pNew->iSID, "file_name", DFNT_CHAR8, strlen(filename), (char*)filename) < 0) { - NXReportError( "ERROR: HDF failed to store file_name attribute "); - return NX_ERROR; - } - if(time_puffer != NULL){ - if (SDsetattr(pNew->iSID, "file_time", DFNT_CHAR8, - strlen(time_puffer), time_puffer) < 0) { - NXReportError( - "ERROR: HDF failed to store file_time attribute "); - free(time_puffer); - return NX_ERROR; - } - } - } - if (time_puffer != NULL) { - free(time_puffer); + /* set the NeXus_version attribute*/ + if (SDsetattr(pNew->iSID, "NeXus_version", DFNT_CHAR8, + strlen(NEXUS_VERSION), NEXUS_VERSION) < 0) + { + NXReportError( "ERROR: HDF failed to store NeXus_version attribute "); + return NX_ERROR; + } + + /* set the HDF4 version attribute */ + Hgetlibversion(&lmajor, &lminor, &lrelease, HDF_VERSION); + if (SDsetattr(pNew->iSID, "HDF_version", DFNT_CHAR8, strlen(HDF_VERSION),HDF_VERSION) < 0) + { + NXReportError( "ERROR: HDF failed to store HDF_version attribute "); + return NX_ERROR; + } + + /* set the filename attribute */ + if (SDsetattr(pNew->iSID, "file_name", DFNT_CHAR8, strlen(filename), (char*)filename) < 0) + { + NXReportError( "ERROR: HDF failed to store file_name attribute "); + return NX_ERROR; + } + + /* set the file_time attribute */ + time_puffer = NXIformatNeXusTime(); + if(time_puffer != NULL){ + if (SDsetattr(pNew->iSID, "file_time", DFNT_CHAR8,strlen(time_puffer),time_puffer) < 0) + { + NXReportError("ERROR: HDF failed to store file_time attribute "); + free(time_puffer); + return NX_ERROR; + } + free(time_puffer); + } + + if (SDsetattr(pNew->iSID,"NX_class",DFNT_CHAR8,7,"NXroot")<0) + { + NXReportError("ERROR: HDF failed to store NX_class attribute "); + return NX_ERROR; + } } /* diff --git a/src/napi5.c b/src/napi5.c index fd4a1322..f7d43b31 100644 --- a/src/napi5.c +++ b/src/napi5.c @@ -233,28 +233,127 @@ NXstatus NX5reopen(NXhandle pOrigHandle, NXhandle * pNewHandle) return NX_OK; } + +/*--------------------------------------------------------------------- + * private functions used in NX5open + */ + +pNexusFile5 create_file_struct() +{ + pNexusFile5 pNew = (pNexusFile5) malloc(sizeof(NexusFile5)); + if (!pNew) { + NXReportError + ("ERROR: not enough memory to create file structure"); + } + else{ + memset(pNew, 0, sizeof(NexusFile5)); + } + + return pNew; +} + +hid_t create_file_access_plist(CONSTCHAR *filename) +{ + char pBuffer[512]; + hid_t fapl = -1; + + /* create file access property list - required in all cases*/ + if((fapl = H5Pcreate(H5P_FILE_ACCESS))<0){ + sprintf(pBuffer,"Error: failed to create file access property " + "list for file %s",filename); + NXReportError(pBuffer); + return fapl; + } + + /* set file close policy - need this in all cases*/ + if(H5Pset_fclose_degree(fapl, H5F_CLOSE_STRONG)<0){ + sprintf(pBuffer,"Error: cannot set close policy for file " + "%s",filename); + NXReportError(pBuffer); + return fapl; + } + + return fapl; +} + + +herr_t set_file_cache(hid_t fapl,CONSTCHAR *filename) +{ + char pBuffer[512]; + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + herr_t error = -1; + + error = H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, + &rdcc_nbytes,&rdcc_w0); + + if(error < 0){ + sprintf(pBuffer,"Error: cannot obtain HDF5 cache size" + " for file %s",filename); + NXReportError(pBuffer); + return error; + } + + rdcc_nbytes = (size_t) nx_cacheSize; + error = H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes,rdcc_w0); + if(error < 0){ + sprintf(pBuffer,"Error: cannot set cache size " + "for file %s",filename); + NXReportError(pBuffer); + return error; + } + return error; +} + +herr_t set_str_attribute(hid_t parent_id,CONSTCHAR *name,CONSTCHAR *buffer) +{ + char pBuffer[512]; + hid_t attr_id; + hid_t space_id = H5Screate(H5S_SCALAR); + hid_t type_id = H5Tcopy(H5T_C_S1); + + H5Tset_size(type_id, strlen(buffer)); + + attr_id = H5Acreate(parent_id,name,type_id,space_id,H5P_DEFAULT, + H5P_DEFAULT); + if (attr_id < 0) { + sprintf(pBuffer,"ERROR: failed to create %s attribute",name); + NXReportError(pBuffer); + return -1; + } + + if(H5Awrite(attr_id,type_id,buffer) < 0) { + sprintf(pBuffer,"ERROR: failed writting %s attribute"); + NXReportError(pBuffer); + return -1; + } + + H5Tclose(type_id); + H5Sclose(space_id); + H5Aclose(attr_id); + + return 0; +} + NXstatus NX5open(CONSTCHAR * filename, NXaccess am, NXhandle * pHandle) { - hid_t attr1, aid1, aid2, iVID; + hid_t root_id; pNexusFile5 pNew = NULL; char pBuffer[512]; char *time_buffer = NULL; char version_nr[10]; unsigned int vers_major, vers_minor, vers_release, am1; hid_t fapl = -1; - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - unsigned hdf5_majnum, hdf5_minnum, hdf5_relnum; *pHandle = NULL; - if (H5get_libversion(&hdf5_majnum, &hdf5_minnum, &hdf5_relnum) < 0) { + if (H5get_libversion(&vers_major, &vers_minor, &vers_release) < 0) { NXReportError("ERROR: cannot determine HDF5 library version"); return NX_ERROR; } - if (hdf5_majnum == 1 && hdf5_minnum < 8) { + if (vers_major == 1 && vers_minor < 8) { NXReportError("ERROR: HDF5 library 1.8.0 or higher required"); return NX_ERROR; } @@ -263,54 +362,26 @@ NXstatus NX5open(CONSTCHAR * filename, NXaccess am, NXhandle * pHandle) am = (NXaccess) (am & NXACCMASK_REMOVEFLAGS); /* turn off the automatic HDF error handling */ - H5Eset_auto(H5E_DEFAULT, NULL, NULL); + H5Eset_auto(H5E_DEFAULT, NULL, NULL); #ifdef USE_FTIME struct timeb timeb_struct; #endif - pNew = (pNexusFile5) malloc(sizeof(NexusFile5)); - if (!pNew) { - NXReportError - ("ERROR: not enough memory to create file structure"); - return NX_ERROR; - } - memset(pNew, 0, sizeof(NexusFile5)); - - /* create file access property list - required in all cases*/ - if((fapl = H5Pcreate(H5P_FILE_ACCESS))<0){ - sprintf(pBuffer,"Error: failed to create file access property " - "list for file %s",filename); - NXReportError(pBuffer); - free(pNew); - return NX_ERROR; - } - - /* set file close policy - need this in all cases*/ - if(H5Pset_fclose_degree(fapl, H5F_CLOSE_STRONG)<0){ - sprintf(pBuffer,"Error: cannot set close policy for file " - "%s",filename); - NXReportError(pBuffer); + /* create the new file structure */ + if(!(pNew = create_file_struct())) return NX_ERROR; + + /* create the file access property list*/ + if((fapl = create_file_access_plist(filename))<0) + { free(pNew); return NX_ERROR; } /* start HDF5 interface */ if (am == NXACC_CREATE5) { - if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, - &rdcc_w0) < 0){ - sprintf(pBuffer,"Error: cannot obtain HDF5 cache size" - " for file %s",filename); - NXReportError(pBuffer); - free(pNew); - return NX_ERROR; - } - - rdcc_nbytes = (size_t) nx_cacheSize; - if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, - rdcc_w0) < 0){ - sprintf(pBuffer,"Error: cannot set cache size " - "for file %s",filename); - NXReportError(pBuffer); + + /* set the cache size for the file */ + if(set_file_cache(fapl,filename)<0) { free(pNew); return NX_ERROR; } @@ -327,7 +398,7 @@ NXstatus NX5open(CONSTCHAR * filename, NXaccess am, NXhandle * pHandle) if (fapl != -1) H5Pclose(fapl); /*close file access property list*/ if (pNew->iFID <= 0) { - sprintf(pBuffer, "ERROR: cannot open file: %s", filename); + snprintf(pBuffer,sizeof(pBuffer)-1, "ERROR: cannot open file: %s", filename); NXReportError(pBuffer); free(pNew); return NX_ERROR; @@ -337,108 +408,55 @@ NXstatus NX5open(CONSTCHAR * filename, NXaccess am, NXhandle * pHandle) * need to create global attributes file_name file_time NeXus_version * at some point for new files */ - if (am1 != H5F_ACC_RDONLY) { - iVID = H5Gopen(pNew->iFID, "/", H5P_DEFAULT); - aid2 = H5Screate(H5S_SCALAR); - aid1 = H5Tcopy(H5T_C_S1); - H5Tset_size(aid1, strlen(NEXUS_VERSION)); - if (am1 == H5F_ACC_RDWR) { - H5Adelete(iVID, "NeXus_version"); - } - attr1 = - H5Acreate(iVID, "NeXus_version", aid1, aid2, H5P_DEFAULT, - H5P_DEFAULT); - if (attr1 < 0) { - NXReportError - ("ERROR: failed to store NeXus_version attribute "); - return NX_ERROR; - } - if (H5Awrite(attr1, aid1, NEXUS_VERSION) < 0) { - NXReportError - ("ERROR: failed to store NeXus_version attribute "); - return NX_ERROR; - } - /* Close attribute dataspace */ - H5Tclose(aid1); - H5Sclose(aid2); - /* Close attribute */ - H5Aclose(attr1); - H5Gclose(iVID); - } - if (am1 == H5F_ACC_TRUNC) { - iVID = H5Gopen(pNew->iFID, "/", H5P_DEFAULT); - aid2 = H5Screate(H5S_SCALAR); - aid1 = H5Tcopy(H5T_C_S1); - H5Tset_size(aid1, strlen(filename)); - attr1 = - H5Acreate(iVID, "file_name", aid1, aid2, H5P_DEFAULT, - H5P_DEFAULT); - if (attr1 < 0) { - NXReportError - ("ERROR: failed to store file_name attribute "); - return NX_ERROR; - } - if (H5Awrite(attr1, aid1, (char *)filename) < 0) { - NXReportError - ("ERROR: failed to store file_name attribute "); - return NX_ERROR; - } - H5Tclose(aid1); - H5Sclose(aid2); - H5Aclose(attr1); - /* ------- library version ------ */ - H5get_libversion(&vers_major, &vers_minor, &vers_release); - sprintf(version_nr, "%d.%d.%d", vers_major, vers_minor, - vers_release); - aid2 = H5Screate(H5S_SCALAR); - aid1 = H5Tcopy(H5T_C_S1); - H5Tset_size(aid1, strlen(version_nr)); - attr1 = - H5Acreate(iVID, "HDF5_Version", aid1, aid2, H5P_DEFAULT, - H5P_DEFAULT); - if (attr1 < 0) { - NXReportError - ("ERROR: failed to store file_name attribute "); - return NX_ERROR; - } - if (H5Awrite(attr1, aid1, (char *)version_nr) < 0) { - NXReportError - ("ERROR: failed to store file_name attribute "); - return NX_ERROR; - } - H5Tclose(aid1); - H5Sclose(aid2); - H5Aclose(attr1); - /*----------- file time */ - time_buffer = NXIformatNeXusTime(); - if (time_buffer != NULL) { - aid2 = H5Screate(H5S_SCALAR); - aid1 = H5Tcopy(H5T_C_S1); - H5Tset_size(aid1, strlen(time_buffer)); - attr1 = - H5Acreate(iVID, "file_time", aid1, aid2, - H5P_DEFAULT, H5P_DEFAULT); - if (attr1 < 0) { - NXReportError - ("ERROR: failed to store file_time attribute "); - free(time_buffer); - return NX_ERROR; - } - if (H5Awrite(attr1, aid1, time_buffer) < 0) { - NXReportError - ("ERROR: failed to store file_time attribute "); - free(time_buffer); - return NX_ERROR; - } - /* Close attribute dataspace */ - H5Tclose(aid1); - H5Sclose(aid2); - /* Close attribute */ - H5Aclose(attr1); - free(time_buffer); - } - H5Gclose(iVID); - } + + if(am == NXACC_CREATE5) + { + root_id = H5Gopen(pNew->iFID,"/",H5P_DEFAULT); + if(set_str_attribute(root_id,"NeXus_version",NEXUS_VERSION)<0) { + H5Gclose(root_id); + H5Fclose(pNew->iFID); + free(pNew); + return NX_ERROR; + } + + if(set_str_attribute(root_id,"file_name",filename)<0) { + H5Gclose(root_id); + H5Fclose(pNew->iFID); + free(pNew); + return NX_ERROR; + } + + sprintf(version_nr,"%d.%d.%d",vers_major,vers_minor,vers_release); + if(set_str_attribute(root_id,"HDF5_Version",version_nr)<0) { + H5Gclose(root_id); + H5Fclose(pNew->iFID); + free(pNew); + return NX_ERROR; + } + + time_buffer = NXIformatNeXusTime(); + if (time_buffer != NULL){ + if(set_str_attribute(root_id,"file_time",time_buffer)<0) { + H5Gclose(root_id); + H5Fclose(pNew->iFID); + free(pNew); + free(time_buffer); + return NX_ERROR; + } + free(time_buffer); + } + + /*finally we set the NXroot NX_class attribute*/ + if(set_str_attribute(root_id,"NX_class","NXroot")<0) { + H5Gclose(root_id); + H5Fclose(pNew->iFID); + free(pNew); + return NX_ERROR; + } + + H5Gclose(root_id); + } + /* Set HDFgroup access mode */ if (am1 == H5F_ACC_RDONLY) { strcpy(pNew->iAccess, "r"); @@ -1067,7 +1085,7 @@ static hid_t getAttVID(pNexusFile5 pFile) } /*---------------------------------------------------------------*/ -static void killAttVID(pNexusFile5 pFile, int vid) +static void killAttVID(pNexusFile5 pFile, hid_t vid) { if (pFile->iCurrentG == 0 && pFile->iCurrentD == 0) { H5Gclose(vid); @@ -1082,7 +1100,6 @@ NXstatus NX5putattr(NXhandle fid, CONSTCHAR * name, const void *data, pNexusFile5 pFile; hid_t attr1, aid1, aid2; hid_t type; - hid_t attr_id; herr_t iRet; hid_t vid, attRet; @@ -1520,7 +1537,7 @@ static int countObjectsInGroup(hid_t loc_id) status = H5Gget_info(loc_id, &numobj); if (status < 0) { NXReportError - ("Internal error, failed to retrive no of objects"); + ("Internal error, failed to retrieve no of objects"); return 0; } @@ -2173,7 +2190,7 @@ NXstatus NX5getattr(NXhandle fid, const char *name, NXstatus NX5getattrinfo(NXhandle fid, int *iN) { pNexusFile5 pFile; - hid_t idx; + int idx; hid_t vid; H5O_info_t oinfo; @@ -2184,7 +2201,7 @@ NXstatus NX5getattrinfo(NXhandle fid, int *iN) vid = getAttVID(pFile); H5Oget_info(vid, &oinfo); - idx = (hid_t) oinfo.num_attrs; + idx = oinfo.num_attrs; if (idx > 0) { if (pFile->iCurrentG > 0 && pFile->iCurrentD == 0) { *iN = idx - 1; @@ -2492,6 +2509,8 @@ NXstatus NX5getnextattra(NXhandle handle, NXname pName, int *rank, int dim[], i /* skip NXclass attribute which is internal */ + free(iname); + iname = NULL; killAttVID(pFile, vid); return NX5getnextattra(handle, pName, rank, dim, iType); } diff --git a/src/nxxml.c b/src/nxxml.c index 230c6044..95318d98 100644 --- a/src/nxxml.c +++ b/src/nxxml.c @@ -182,6 +182,7 @@ NXstatus NXXopen(CONSTCHAR *filename, NXaccess am, current = mxmlNewElement(xmlHandle->root,"NXroot"); mxmlElementSetAttr(current,"NeXus_version",NEXUS_VERSION); mxmlElementSetAttr(current,"XML_version","mxml"); + mxmlElementSetAttr(current,"NX_class","NXroot"); mxmlElementSetAttr(current,"file_name",filename); mxmlElementSetAttr(current,"xmlns", NEXUS_SCHEMA_NAMESPACE); mxmlElementSetAttr(current,"xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); diff --git a/test/testsuite.at b/test/testsuite.at index 1de55ff6..d14f6a60 100644 --- a/test/testsuite.at +++ b/test/testsuite.at @@ -2222,55 +2222,55 @@ AT_BANNER([[Testing the NeXus File Converter.]]) AT_SETUP([Checking nxconvert HDF5 -> HDF5 ]) AT_CHECK([$HAVE_HDF5 && nxconvert --hdf 5 NXtest.h5 a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.h5 to HDF5 NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP AT_SETUP([Checking nxconvert HDF5 -> HDF4 ]) AT_CHECK([skip_test && $HAVE_HDF5 && $HAVE_HDF4 && nxconvert --hdf 4 NXtest.h5 a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.h5 to HDF4 NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP AT_SETUP([Checking nxconvert HDF5 -> XML ]) AT_CHECK([$HAVE_HDF5 && $HAVE_XML && nxconvert -x NXtest.h5 a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.h5 to XML NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP AT_SETUP([Checking nxconvert HDF4 -> HDF5 ]) AT_CHECK([$HAVE_HDF4 && $HAVE_HDF5 && nxconvert --hdf 5 NXtest.hdf a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.hdf to HDF5 NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP AT_SETUP([Checking nxconvert HDF4 -> HDF4 ]) AT_CHECK([skip_test && $HAVE_HDF4 && nxconvert --hdf 4 NXtest.hdf a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.hdf to HDF4 NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP AT_SETUP([Checking nxconvert HDF4 -> XML ]) AT_CHECK([$HAVE_HDF4 && $HAVE_XML && nxconvert -x NXtest.hdf a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.hdf to XML NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP AT_SETUP([Checking nxconvert XML -> HDF5 ]) AT_CHECK([$HAVE_XML && $HAVE_HDF5 && nxconvert --hdf 5 NXtest.xml a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.xml to HDF5 NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP AT_SETUP([Checking nxconvert XML -> HDF4 ]) AT_CHECK([skip_test && $HAVE_XML && $HAVE_HDF4 && nxconvert --hdf 4 NXtest.xml a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.xml to HDF4 NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP AT_SETUP([Checking nxconvert XML -> XML ]) AT_CHECK([$HAVE_XML && nxconvert -x NXtest.xml a.a | sed -e 's/\r$//' ],[], [[Converting NXtest.xml to XML NeXus file a.a -Convertion successful. +Conversion successful. ]]) AT_CLEANUP