Skip to content

Commit

Permalink
Merge pull request #455 from toxa81/develop
Browse files Browse the repository at this point in the history
[api] fix for intent in/out
  • Loading branch information
toxa81 authored Jan 6, 2020
2 parents dd7f774 + e239eb9 commit 47a4181
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 97 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.2
6.4.3
2 changes: 1 addition & 1 deletion doc/doxygen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "SIRIUS"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "6.4.2"
PROJECT_NUMBER = "6.4.3"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion python_module/pybind11
Submodule pybind11 updated 97 files
+3 −5 .appveyor.yml
+1 −1 .gitmodules
+71 −164 .travis.yml
+0 −2 CONTRIBUTING.md
+1 −2 README.md
+1 −1 docs/advanced/cast/chrono.rst
+5 −5 docs/advanced/cast/eigen.rst
+0 −2 docs/advanced/cast/overview.rst
+1 −1 docs/advanced/cast/stl.rst
+6 −50 docs/advanced/classes.rst
+1 −3 docs/advanced/exceptions.rst
+0 −9 docs/advanced/functions.rst
+0 −20 docs/advanced/pycpp/numpy.rst
+1 −1 docs/basics.rst
+5 −216 docs/changelog.rst
+0 −11 docs/classes.rst
+1 −17 docs/compiling.rst
+2 −2 docs/conf.py
+4 −69 docs/faq.rst
+1 −0 docs/intro.rst
+0 −15 docs/reference.rst
+4 −0 docs/release.rst
+3 −7 include/pybind11/attr.h
+12 −18 include/pybind11/buffer_info.h
+28 −81 include/pybind11/cast.h
+5 −27 include/pybind11/chrono.h
+1 −18 include/pybind11/detail/class.h
+16 −25 include/pybind11/detail/common.h
+44 −116 include/pybind11/detail/internals.h
+0 −2 include/pybind11/detail/typeid.h
+1 −9 include/pybind11/embed.h
+5 −23 include/pybind11/functional.h
+8 −17 include/pybind11/iostream.h
+14 −49 include/pybind11/numpy.h
+117 −308 include/pybind11/pybind11.h
+10 −159 include/pybind11/pytypes.h
+7 −17 include/pybind11/stl.h
+26 −76 include/pybind11/stl_bind.h
+22 −6 pybind11/__init__.py
+2 −1 pybind11/__main__.py
+1 −1 pybind11/_version.py
+1 −3 setup.cfg
+27 −41 setup.py
+2 −24 tests/CMakeLists.txt
+15 −18 tests/conftest.py
+1 −1 tests/constructor_stats.h
+0 −73 tests/cross_module_gil_utils.cpp
+0 −1 tests/pytest.ini
+0 −26 tests/test_async.cpp
+0 −23 tests/test_async.py
+1 −27 tests/test_buffers.cpp
+0 −31 tests/test_buffers.py
+2 −27 tests/test_builtin_casters.cpp
+0 −47 tests/test_builtin_casters.py
+0 −19 tests/test_callbacks.cpp
+0 −29 tests/test_callbacks.py
+0 −8 tests/test_chrono.cpp
+0 −75 tests/test_chrono.py
+0 −26 tests/test_class.cpp
+0 −13 tests/test_class.py
+3 −3 tests/test_copy_move.py
+3 −3 tests/test_eigen.py
+1 −17 tests/test_enum.cpp
+14 −70 tests/test_enum.py
+1 −30 tests/test_exceptions.cpp
+1 −7 tests/test_exceptions.py
+0 −52 tests/test_gil_scoped.cpp
+0 −85 tests/test_gil_scoped.py
+0 −11 tests/test_iostream.py
+1 −3 tests/test_kwargs_and_defaults.cpp
+2 −2 tests/test_local_bindings.py
+6 −12 tests/test_methods_and_attributes.cpp
+8 −8 tests/test_methods_and_attributes.py
+0 −92 tests/test_numpy_array.cpp
+0 −37 tests/test_numpy_array.py
+0 −8 tests/test_numpy_dtypes.cpp
+0 −25 tests/test_operator_overloading.cpp
+7 −9 tests/test_operator_overloading.py
+0 −6 tests/test_pickling.py
+0 −38 tests/test_pytypes.cpp
+3 −26 tests/test_pytypes.py
+0 −19 tests/test_sequences_and_iterators.cpp
+0 −13 tests/test_sequences_and_iterators.py
+1 −29 tests/test_smart_ptr.cpp
+1 −23 tests/test_smart_ptr.py
+0 −28 tests/test_stl.cpp
+0 −31 tests/test_stl.py
+0 −22 tests/test_stl_binders.cpp
+0 −68 tests/test_stl_binders.py
+0 −22 tests/test_union.cpp
+0 −8 tests/test_union.py
+1 −28 tests/test_virtual_functions.cpp
+0 −6 tests/test_virtual_functions.py
+4 −11 tools/FindPythonLibsNew.cmake
+26 −101 tools/mkdoc.py
+1 −5 tools/pybind11Config.cmake.in
+7 −32 tools/pybind11Tools.cmake
38 changes: 19 additions & 19 deletions src/generated.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2754,54 +2754,54 @@ subroutine sirius_option_get_length_aux(section,length)&
call sirius_option_get_length_aux(section,length)
end subroutine sirius_option_get_length

!> @brief return the name and a type of an option from its index
!> @param [in] section name of the section
!> @param [out] elem_ index of the option
!> @param [out] key_name name of the option
!> @param [out] type type of the option (real, integer, boolean, string)
subroutine sirius_option_get_name_and_type(section,elem_,key_name,type)
!> @brief Return the name and a type of an option from its index.
!> @param [in] section Name of the section.
!> @param [in] elem Index of the option.
!> @param [out] key_name Name of the option.
!> @param [out] type Type of the option (real, integer, boolean, string).
subroutine sirius_option_get_name_and_type(section,elem,key_name,type)
implicit none
character(C_CHAR), dimension(*), intent(in) :: section
integer(C_INT), intent(out) :: elem_
integer(C_INT), intent(in) :: elem
character(C_CHAR), dimension(*), intent(out) :: key_name
integer(C_INT), intent(out) :: type
interface
subroutine sirius_option_get_name_and_type_aux(section,elem_,key_name,type)&
subroutine sirius_option_get_name_and_type_aux(section,elem,key_name,type)&
&bind(C, name="sirius_option_get_name_and_type")
use, intrinsic :: ISO_C_BINDING
character(C_CHAR), dimension(*), intent(in) :: section
integer(C_INT), intent(out) :: elem_
integer(C_INT), intent(in) :: elem
character(C_CHAR), dimension(*), intent(out) :: key_name
integer(C_INT), intent(out) :: type
end subroutine
end interface

call sirius_option_get_name_and_type_aux(section,elem_,key_name,type)
call sirius_option_get_name_and_type_aux(section,elem,key_name,type)
end subroutine sirius_option_get_name_and_type

!> @brief return the description and usage of a given option
!> @param [in] section name of the section
!> @param [in] name name of the option
!> @param [out] desc_ description of the option
!> @param [out] usage_ how to use the option
subroutine sirius_option_get_description_usage(section,name,desc_,usage_)
!> @param [out] desc description of the option
!> @param [out] usage how to use the option
subroutine sirius_option_get_description_usage(section,name,desc,usage)
implicit none
character(C_CHAR), dimension(*), intent(in) :: section
character(C_CHAR), dimension(*), intent(in) :: name
character(C_CHAR), dimension(*), intent(out) :: desc_
character(C_CHAR), dimension(*), intent(out) :: usage_
character(C_CHAR), dimension(*), intent(out) :: desc
character(C_CHAR), dimension(*), intent(out) :: usage
interface
subroutine sirius_option_get_description_usage_aux(section,name,desc_,usage_)&
subroutine sirius_option_get_description_usage_aux(section,name,desc,usage)&
&bind(C, name="sirius_option_get_description_usage")
use, intrinsic :: ISO_C_BINDING
character(C_CHAR), dimension(*), intent(in) :: section
character(C_CHAR), dimension(*), intent(in) :: name
character(C_CHAR), dimension(*), intent(out) :: desc_
character(C_CHAR), dimension(*), intent(out) :: usage_
character(C_CHAR), dimension(*), intent(out) :: desc
character(C_CHAR), dimension(*), intent(out) :: usage
end subroutine
end interface

call sirius_option_get_description_usage_aux(section,name,desc_,usage_)
call sirius_option_get_description_usage_aux(section,name,desc,usage)
end subroutine sirius_option_get_description_usage

!> @brief return the default value of the option
Expand Down
22 changes: 16 additions & 6 deletions src/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* \brief Contains input parameters structures.
*
* \todo Some of the parameters belong to SCF ground state mini-app. Mini-app should parse this values itself.
* \todo parse atomic coordinates and magnetic field separtely, not as 6D vector.
*/

#ifndef __INPUT_HPP__
Expand All @@ -47,25 +48,25 @@ namespace sirius {
[a3_x, a3_y, a3_z]
],
"lattice_vectors_scale" : scale,
"lattice_vectors_scale" : (float) scale,
"atom_types" : [label_A, label_B, ...],
"atom_types" : ["label_A", "label_B", ...],
"atom_files" : {
label_A : file_A,
label_B : file_B,
"label_A" : "file_A",
"label_B" : "file_B",
...
},
"atom_coordinate_units" : units,
"atoms" : {
label_A: [
"label_A": [
coordinates_A_1,
coordinates_A_2,
...
],
label_B : [
"label_B" : [
coordinates_B_1,
coordinates_B_2,
...
Expand Down Expand Up @@ -187,6 +188,15 @@ struct Unit_cell_input
};

/// Parse mixer input section.
/** The following part of the input file is parsed:
\code{.json}
"mixer" : {
"beta" : (float) beta,
"beta0" : beta0,
"linear_mix_rms_tol" :
}
\endcode
*/
struct Mixer_input
{
/// Mixing paramter.
Expand Down
147 changes: 78 additions & 69 deletions src/sirius_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2625,118 +2625,127 @@ void sirius_update_atomic_potential(void* const* handler__)
}


/* @fortran begin function void sirius_option_get_length return the number of options in a given section
@fortran argument in required string section name of the seciton
@fortran argument out required int length number of options contained in the section
/* @fortran begin function void sirius_option_get_length return the number of options in a given section
@fortran argument in required string section name of the seciton
@fortran argument out required int length number of options contained in the section
@fortran end */

void sirius_option_get_length(char *section, int *length)
void sirius_option_get_length(char const* section__, int *length__)
{
const json &parser = sirius::get_options_dictionary();
// ugly as hell but fortran is a piece of ....
for ( char *p = section; *p; p++) *p = tolower(*p);
auto const& parser = sirius::get_options_dictionary();

auto section = std::string(section__);
std::transform(section.begin(), section.end(), section.begin(), ::tolower);

*length = parser[section].size();
*length__ = parser[section].size();
}

/* @fortran begin function void sirius_option_get_name_and_type return the name and a type of an option from its index
@fortran argument in required string section name of the section
@fortran argument out required int elem_ index of the option
@fortran argument out required string key_name name of the option
@fortran argument out required int type type of the option (real, integer, boolean, string)
/* @fortran begin function void sirius_option_get_name_and_type Return the name and a type of an option from its index.
@fortran argument in required string section Name of the section.
@fortran argument in required int elem Index of the option.
@fortran argument out required string key_name Name of the option.
@fortran argument out required int type Type of the option (real, integer, boolean, string).
@fortran end */

void sirius_option_get_name_and_type(char *section, int *elem_, char *key_name, int *type)
void sirius_option_get_name_and_type(char const* section__, int const* elem__, char* key_name__, int* type__)
{
const json &dict = sirius::get_options_dictionary();

// ugly as hell but fortran is a piece of ....
for ( char *p = section; *p; p++) *p = tolower(*p);
auto section = std::string(section__);
std::transform(section.begin(), section.end(), section.begin(), ::tolower);

int elem = 0;
*type = -1;
for (auto& el : dict[section].items())
{
if (elem == *elem_) {
*type__ = -1;
for (auto& el : dict[section].items()) {
if (elem == *elem__) {
if (!dict[section][el.key()].count("default_value")) {
std::cout << "key : " << el.key() << "\n the default_value key is missing" << std::endl;
exit(0);
}
if (dict[section][el.key()]["default_value"].is_array()) {
*type = 10;
if (dict[section][el.key()]["default_value"][0].is_number_integer())
*type += 1;
if (dict[section][el.key()]["default_value"][0].is_number_float())
*type += 2;
if (dict[section][el.key()]["default_value"][0].is_boolean())
*type += 3;
if (dict[section][el.key()]["default_value"][0].is_string())
*type += 4;
*type__ = 10;
if (dict[section][el.key()]["default_value"][0].is_number_integer()) {
*type__ += 1;
}
if (dict[section][el.key()]["default_value"][0].is_number_float()) {
*type__ += 2;
}
if (dict[section][el.key()]["default_value"][0].is_boolean()) {
*type__ += 3;
}
if (dict[section][el.key()]["default_value"][0].is_string()) {
*type__ += 4;
}
} else {
if (dict[section][el.key()]["default_value"].is_number_integer())
*type = 1;
if (dict[section][el.key()]["default_value"].is_number_float())
*type = 2;
if (dict[section][el.key()]["default_value"].is_boolean())
*type = 3;
if (dict[section][el.key()]["default_value"].is_string())
*type = 4;
if (dict[section][el.key()]["default_value"].is_number_integer()) {
*type__ = 1;
}
if (dict[section][el.key()]["default_value"].is_number_float()) {
*type__ = 2;
}
if (dict[section][el.key()]["default_value"].is_boolean()) {
*type__ = 3;
}
if (dict[section][el.key()]["default_value"].is_string()) {
*type__ = 4;
}
}
std::memcpy(key_name, el.key().c_str(), el.key().size());
std::memcpy(key_name__, el.key().c_str(), el.key().size());
}
elem++;
}
}

/* @fortran begin function void sirius_option_get_description_usage return the description and usage of a given option
@fortran argument in required string section name of the section
@fortran argument in required string name name of the option
@fortran argument out required string desc_ description of the option
@fortran argument out required string usage_ how to use the option
/* @fortran begin function void sirius_option_get_description_usage return the description and usage of a given option
@fortran argument in required string section name of the section
@fortran argument in required string name name of the option
@fortran argument out required string desc description of the option
@fortran argument out required string usage how to use the option
@fortran end */

void sirius_option_get_description_usage(char * section, char * name, char *desc_, char *usage_)
void sirius_option_get_description_usage(char const* section__, char const* name__, char* desc__, char* usage__)
{
const json &parser = sirius::get_options_dictionary();

// ugly as hell but fortran is a piece of ....
for ( char *p = section; *p; p++) *p = tolower(*p);
// ugly as hell but fortran is a piece of ....
// for ( char *p = name; *p; p++) *p = tolower(*p);
auto section = std::string(section__);
std::transform(section.begin(), section.end(), section.begin(), ::tolower);

auto name = std::string(name__);

if (parser[section][name].count("description")) {
std::string description = parser[section][name].value("description", "");
std::copy(description.begin(), description.end(), desc_);
auto description = parser[section][name].value("description", "");
std::copy(description.begin(), description.end(), desc__);
}
if (parser[section][name].count("usage")) {
std::string usage = parser[section][name].value("usage","");
std::copy(usage.begin(), usage.end(), usage_);
auto usage = parser[section][name].value("usage", "");
std::copy(usage.begin(), usage.end(), usage__);
}
}

/* @fortran begin function void sirius_option_get_int return the default value of the option
@fortran argument in required string section name of the section of interest
@fortran argument in required string name name of the element
@fortran argument out required int default_value table containing the default values (if vector)
@fortran argument out required int length length of the table containing the default values
/* @fortran begin function void sirius_option_get_int return the default value of the option
@fortran argument in required string section name of the section of interest
@fortran argument in required string name name of the element
@fortran argument out required int default_value table containing the default values (if vector)
@fortran argument out required int length length of the table containing the default values
@fortran end */

void sirius_option_get_int(char * section, char * name, int *default_value, int *length)
void sirius_option_get_int(char const* section__, char const* name__, int *default_value__, int *length__)
{
const json &parser = sirius::get_options_dictionary();
auto const &parser = sirius::get_options_dictionary();

// ugly as hell but fortran is a piece of ....
for ( char *p = section; *p; p++) *p = tolower(*p);
// ugly as hell but fortran is a piece of ....
// for ( char *p = name; *p; p++) *p = tolower(*p);
if (!parser[section][name].count("default_value"))
std::cout << "default value is mossing" << std::endl;
auto section = std::string(section__);
std::transform(section.begin(), section.end(), section.begin(), ::tolower);

auto name = std::string(name__);

if (!parser[section][name].count("default_value")) {
std::cout << "default value is missing" << std::endl;
}
if (parser[section][name]["default_value"].is_array()) {
std::vector<int> v = parser[section][name]["default_value"].get<std::vector<int>>();
*length = v.size();
memcpy(default_value, &v[0], v.size() * sizeof(int));
*length__ = v.size();
std::memcpy(default_value__, &v[0], v.size() * sizeof(int));
} else {
*default_value = parser[section][name].value("default_value", -1);
*default_value__ = parser[section][name].value("default_value", -1);
}
}

Expand Down

0 comments on commit 47a4181

Please sign in to comment.