Commit 41477992 authored by Elisa Rebolini's avatar Elisa Rebolini
Browse files

Merge branch 'python_api_pattern' into 'release_pythonAPI'

API 0.0.3

See merge request !32
parents ea08fa01 2c983d0c
Pipeline #13668 passed with stages
in 6 minutes and 15 seconds
...@@ -9,9 +9,7 @@ option(MINGW_HDF_TRICK "Help building with MinGW" OFF) ...@@ -9,9 +9,7 @@ option(MINGW_HDF_TRICK "Help building with MinGW" OFF)
option(USE_HDF "Build crysfml with HDF5 library" OFF) option(USE_HDF "Build crysfml with HDF5 library" OFF)
option(GUI "Build crysfml and wcrysfml library" OFF) option(GUI "Build crysfml and wcrysfml library" OFF)
option(ARCH32 "32 or 64 bit architecture" ON) option(ARCH32 "32 or 64 bit architecture" ON)
option(CRYSFML08 "Build CrysFML08" OFF)
option(HEAP_ARRAYS "Put arrays in heap instead of stack (only for Windows ifort)" OFF) option(HEAP_ARRAYS "Put arrays in heap instead of stack (only for Windows ifort)" OFF)
option(PROG_EX "Build the Program Examples" ON)
option(PYTHON_API "Build Python API" OFF) option(PYTHON_API "Build Python API" OFF)
option(QPARALLEL "qparallel option for Ifort on Windows" ON) option(QPARALLEL "qparallel option for Ifort on Windows" ON)
option(PYSETUP "Building from setup.py" OFF) option(PYSETUP "Building from setup.py" OFF)
...@@ -42,12 +40,9 @@ message(STATUS "Setting CMAKE_INSTALL_PREFIX to ${CMAKE_INSTALL_PREFIX}") ...@@ -42,12 +40,9 @@ message(STATUS "Setting CMAKE_INSTALL_PREFIX to ${CMAKE_INSTALL_PREFIX}")
if (DEFINED CRYSFML_PREFIX) if (DEFINED CRYSFML_PREFIX)
set(CRYSFML_PREFIX ${CRYSFML_PREFIX}) set(CRYSFML_PREFIX ${CRYSFML_PREFIX})
else() else()
if(CRYSFML08) set(CRYSFML_PREFIX LibC)
set(CRYSFML_PREFIX LibC08)
else()
set(CRYSFML_PREFIX LibC)
endif()
endif() endif()
set (CRYSFML_PREFIX ${CMAKE_INSTALL_PREFIX}/${CRYSFML_PREFIX}) set (CRYSFML_PREFIX ${CMAKE_INSTALL_PREFIX}/${CRYSFML_PREFIX})
message(STATUS "CrysFML installation path set to ${CRYSFML_PREFIX}") message(STATUS "CrysFML installation path set to ${CRYSFML_PREFIX}")
...@@ -84,17 +79,17 @@ message(STATUS "CrysFML installation path set to ${CRYSFML_PREFIX}") ...@@ -84,17 +79,17 @@ message(STATUS "CrysFML installation path set to ${CRYSFML_PREFIX}")
# Include and library paths for HDF5. # Include and library paths for HDF5.
# They must be set by the user. # They must be set by the user.
if(DEFINED HDF5_INCLUDE_PATH) # if(DEFINED HDF5_INCLUDE_PATH)
set(HDF5_INCLUDE_PATH ${HDF5_INCLUDE_PATH} CACHE PATH "HDF5 include path") # set(HDF5_INCLUDE_PATH ${HDF5_INCLUDE_PATH} CACHE PATH "HDF5 include path")
else() # else()
set(HDF5_INCLUDE_PATH "" CACHE PATH "HDF5 include path") # set(HDF5_INCLUDE_PATH "" CACHE PATH "HDF5 include path")
endif() # endif()
if(DEFINED HDF5_LIBRARY_PATH) # if(DEFINED HDF5_LIBRARY_PATH)
set(HDF5_LIBRARY_PATH ${HDF5_LIBRARY_PATH} CACHE PATH "HDF5 library path") # set(HDF5_LIBRARY_PATH ${HDF5_LIBRARY_PATH} CACHE PATH "HDF5 library path")
else() # else()
set(HDF5_LIBRARY_PATH "" CACHE PATH "HDF5 library path") # set(HDF5_LIBRARY_PATH "" CACHE PATH "HDF5 library path")
endif() # endif()
################################# #################################
# Project section # Project section
...@@ -126,17 +121,12 @@ endif() ...@@ -126,17 +121,12 @@ endif()
# Includes some modules and build the project. # Includes some modules and build the project.
include(add_prefix) include(add_prefix)
include(add_suffix) include(add_suffix)
if (NOT CRYSFML08)
include(set_compiler_flags) include(set_compiler_flags)
set_compiler_flags() set_compiler_flags()
# The subdirectories of the project. # The subdirectories of the project.
add_subdirectory(Src) add_subdirectory(Src)
else()
include(set_compiler_flags_08)
set_compiler_flags_08()
# The subdirectories of the project.
add_subdirectory(Src08)
endif()
# Build the program example executables and use them as functional tests # Build the program example executables and use them as functional tests
if (PROG_EX) if (PROG_EX)
......
...@@ -12,7 +12,7 @@ print("========\nCreate job_info from string") ...@@ -12,7 +12,7 @@ print("========\nCreate job_info from string")
dat = [ dat = [
'Title SrTiO3', 'Title SrTiO3',
'Npatt 1', 'Npatt 1',
'Patt_1 NEUT_2THE 1.54056 1.54056 1.00 0.0 135.0', 'Patt_1 XRAY_2THE 1.54056 1.54056 1.00 0.0 135.0',
'UVWXY 0.025 -0.00020 0.01200 0.00150 0.00465', 'UVWXY 0.025 -0.00020 0.01200 0.00150 0.00465',
'STEP 0.05 ', 'STEP 0.05 ',
'Backgd 50.000'] 'Backgd 50.000']
...@@ -22,6 +22,10 @@ job_info.print_description() ...@@ -22,6 +22,10 @@ job_info.print_description()
job_info.range_2theta = (0.0, 12.0) job_info.range_2theta = (0.0, 12.0)
job_info.pattern_type = "NEUT_2THE"
job_info.lambda_ratio = 0.5
job_info.print_description() job_info.print_description()
#help(CFML_api.JobInfo) #help(CFML_api.JobInfo)
...@@ -127,7 +127,17 @@ class JobInfo(CFML_api.FortranBindedClass): ...@@ -127,7 +127,17 @@ class JobInfo(CFML_api.FortranBindedClass):
key=0 key=0
return CFML_api.crysfml_api.IO_Formats_get_patt_typ(self.get_fortran_address(), key+1)["patt_typ"] return CFML_api.crysfml_api.IO_Formats_get_patt_typ(self.get_fortran_address(), key+1)["patt_typ"]
pattern_type = property(get_pattern_types) def set_pattern_types(self, patt, indx=None):
"""
String with the pattern type of indx in [0, num_patterns-1]
"""
if indx:
key=indx
else:
key=0
return CFML_api.crysfml_api.IO_Formats_set_patt_typ(self.get_fortran_address(), patt, key+1)
pattern_type = property(get_pattern_types, set_pattern_types)
def get_phase_names(self, indx=None): def get_phase_names(self, indx=None):
""" """
...@@ -278,7 +288,14 @@ class JobInfo(CFML_api.FortranBindedClass): ...@@ -278,7 +288,14 @@ class JobInfo(CFML_api.FortranBindedClass):
key=0 key=0
return CFML_api.crysfml_api.IO_Formats_get_ratio(self.get_fortran_address(),key+1)["ratio"] return CFML_api.crysfml_api.IO_Formats_get_ratio(self.get_fortran_address(),key+1)["ratio"]
lambda_ratio = property(get_lambda_ratio) def set_lambda_ratio(self, ratio, indx=None):
if indx:
key=indx
else:
key=0
CFML_api.crysfml_api.IO_Formats_set_ratio(self.get_fortran_address(), ratio, key+1)
lambda_ratio = property(get_lambda_ratio, set_lambda_ratio)
@property @property
def d_to_tof_1(self): def d_to_tof_1(self):
......
...@@ -1270,6 +1270,62 @@ contains ...@@ -1270,6 +1270,62 @@ contains
!--------------------- !---------------------
!Setters !Setters
!--------------------- !---------------------
function IO_Formats_set_patt_typ(self_ptr, args_ptr) result(r) bind(c)
type(c_ptr), value :: self_ptr
type(c_ptr), value :: args_ptr
type(c_ptr) :: r
type(tuple) :: args
type(dict) :: retval
integer :: num_args
integer :: ierror
type(Job_info_Type_p) :: job_p
type(object) :: val_obj, indx_obj
character(len=:), allocatable :: val
integer :: indx
r = C_NULL_PTR ! in case of an exception return C_NULL_PTR
! use unsafe_cast_from_c_ptr to cast from c_ptr to tuple
call unsafe_cast_from_c_ptr(args, args_ptr)
! Check if the arguments are OK
ierror = args%len(num_args)
! we should also check ierror, but this example does not do complete error checking for simplicity
if (num_args /= 3) then
call raise_exception(TypeError, "set_pattern_types expects exactly 3 arguments")
!self, new_value
call args%destroy
return
endif
! Doing boring stuff
call get_job_info_type_from_arg(args, job_p)
ierror = args%getitem(val_obj, 1) !get the value
ierror = cast_nonstrict(val, val_obj)
ierror = args%getitem(indx_obj, 2) !get the indx
ierror = cast_nonstrict(indx, indx_obj)
select case (val)
case ("XRAY_2THE", "XRAY_SXTAL", "XRAY_ENER","NEUT_2THE", "NEUT_SXTAL", "NEUT_TOF" )
job_p%p%patt_typ(indx) = val
case default
write(*,*) val, " is not a valid pattern type"
end select
ierror = dict_create(retval)
r = retval%get_c_ptr()
call args%destroy
call val_obj%destroy
call indx_obj%destroy
end function IO_Formats_set_patt_typ
function IO_Formats_set_range_2theta(self_ptr, args_ptr) result(r) bind(c) function IO_Formats_set_range_2theta(self_ptr, args_ptr) result(r) bind(c)
...@@ -1405,6 +1461,55 @@ contains ...@@ -1405,6 +1461,55 @@ contains
call maxb_obj%destroy call maxb_obj%destroy
end function IO_Formats_set_lambda end function IO_Formats_set_lambda
function IO_Formats_set_ratio(self_ptr, args_ptr) result(r) bind(c)
type(c_ptr), value :: self_ptr
type(c_ptr), value :: args_ptr
type(c_ptr) :: r
type(tuple) :: args
type(dict) :: retval
integer :: num_args
integer :: ierror
type(Job_info_Type_p) :: job_p
type(object) :: val_obj, indx_obj
real(kind=cp) :: val
integer :: indx
r = C_NULL_PTR ! in case of an exception return C_NULL_PTR
! use unsafe_cast_from_c_ptr to cast from c_ptr to tuple
call unsafe_cast_from_c_ptr(args, args_ptr)
! Check if the arguments are OK
ierror = args%len(num_args)
! we should also check ierror, but this example does not do complete error checking for simplicity
if (num_args /= 3) then
call raise_exception(TypeError, "set_lambda_ratio expects exactly 3 arguments")
!self, new_value, indx
call args%destroy
return
endif
! Doing boring stuff
call get_job_info_type_from_arg(args, job_p)
ierror = args%getitem(val_obj, 1) !get the value
ierror = cast_nonstrict(val, val_obj)
ierror = args%getitem(indx_obj, 2) !get the phase number
ierror = cast_nonstrict(indx, indx_obj)
job_p%p%ratio(indx) = val
ierror = dict_create(retval)
r = retval%get_c_ptr()
call args%destroy
call val_obj%destroy
call indx_obj%destroy
end function IO_Formats_set_ratio
function IO_Formats_set_U(self_ptr, args_ptr) result(r) bind(c) function IO_Formats_set_U(self_ptr, args_ptr) result(r) bind(c)
......
...@@ -136,16 +136,21 @@ contains ...@@ -136,16 +136,21 @@ contains
call get_reflection_list_from_arg(args, reflection_list_p, 2) call get_reflection_list_from_arg(args, reflection_list_p, 2)
call get_job_info_type_from_arg(args, job_p, 3) call get_job_info_type_from_arg(args, job_p, 3)
write(*,*) job_p%p%patt_typ(1)
select case (job_p%p%patt_typ(1)) select case (job_p%p%patt_typ(1))
case ("XRAY_2THE", "XRAY_SXTAL", "XRAY_ENER") case ("XRAY_2THE", "XRAY_SXTAL", "XRAY_ENER")
mode = "NUC"
call Structure_Factors(atom_list_p%p, spg_p%p, reflection_list_p%p, mode)
case("NEUT_2THE", "NEUT_SXTAL", "NEUT_TOF" )
mode = "XRA" mode = "XRA"
!write(*,*) "X-Ray calculation"
lambda = job_p%p%lambda(1)%mina lambda = job_p%p%lambda(1)%mina
call Structure_Factors(atom_list_p%p, spg_p%p, reflection_list_p%p, mode, lambda) call Structure_Factors(atom_list_p%p, spg_p%p, reflection_list_p%p, mode, lambda)
case("NEUT_2THE", "NEUT_SXTAL", "NEUT_TOF" )
mode = "NUC"
!write(*,*) "Neutron calculation"
call Structure_Factors(atom_list_p%p, spg_p%p, reflection_list_p%p, mode)
case default case default
write(*,*) 'Default calculation' write(*,*) 'Default calculation'
call Structure_Factors(atom_list_p%p, spg_p%p, reflection_list_p%p) call Structure_Factors(atom_list_p%p, spg_p%p, reflection_list_p%p)
......
...@@ -69,6 +69,7 @@ module API_init ...@@ -69,6 +69,7 @@ module API_init
IO_Formats_get_num_patterns, & IO_Formats_get_num_patterns, &
IO_Formats_get_num_cmd, & IO_Formats_get_num_cmd, &
IO_Formats_get_patt_typ, & IO_Formats_get_patt_typ, &
IO_Formats_set_patt_typ, &
IO_Formats_get_phas_nam, & IO_Formats_get_phas_nam, &
IO_Formats_get_cmd, & IO_Formats_get_cmd, &
IO_Formats_get_range_stl, & IO_Formats_get_range_stl, &
...@@ -80,6 +81,7 @@ module API_init ...@@ -80,6 +81,7 @@ module API_init
IO_Formats_get_lambda, & IO_Formats_get_lambda, &
IO_formats_set_lambda, & IO_formats_set_lambda, &
IO_Formats_get_ratio, & IO_Formats_get_ratio, &
IO_Formats_set_ratio, &
IO_Formats_get_dtt1, & IO_Formats_get_dtt1, &
IO_Formats_get_dtt2, & IO_Formats_get_dtt2, &
IO_Formats_get_U, & IO_Formats_get_U, &
...@@ -271,7 +273,7 @@ CONTAINS ...@@ -271,7 +273,7 @@ CONTAINS
!-------------------------- !--------------------------
!Total number of method in the binding !Total number of method in the binding
!-------------------------- !--------------------------
call method_table%init(208) call method_table%init(210)
...@@ -708,7 +710,7 @@ CONTAINS ...@@ -708,7 +710,7 @@ CONTAINS
!-------------------------- !--------------------------
! IO formats (35) ! IO formats (37)
!-------------------------- !--------------------------
call method_table%add_method("IO_Formats_readn_set_xtal_structure", & ! method name call method_table%add_method("IO_Formats_readn_set_xtal_structure", & ! method name
"read an input file and construct the crystal structure in terms of Cell, SpG and A", & !doc-string "read an input file and construct the crystal structure in terms of Cell, SpG and A", & !doc-string
...@@ -749,6 +751,11 @@ CONTAINS ...@@ -749,6 +751,11 @@ CONTAINS
"pat_typ getter", & !doc-string "pat_typ getter", & !doc-string
METH_VARARGS, & ! this method takes arguments but no keyword arguments METH_VARARGS, & ! this method takes arguments but no keyword arguments
c_funloc(IO_Formats_get_patt_typ)) ! address of Fortran function to add c_funloc(IO_Formats_get_patt_typ)) ! address of Fortran function to add
call method_table%add_method("IO_Formats_set_patt_typ", & ! method name
"pat_typ setter", & !doc-string
METH_VARARGS, & ! this method takes arguments but no keyword arguments
c_funloc(IO_Formats_set_patt_typ)) ! address of Fortran function to add
call method_table%add_method("IO_Formats_get_phas_nam", & ! method name call method_table%add_method("IO_Formats_get_phas_nam", & ! method name
"phas_nam getter", & !doc-string "phas_nam getter", & !doc-string
...@@ -804,6 +811,11 @@ CONTAINS ...@@ -804,6 +811,11 @@ CONTAINS
"ratio getter", & !doc-string "ratio getter", & !doc-string
METH_VARARGS, & ! this method takes arguments but no keyword arguments METH_VARARGS, & ! this method takes arguments but no keyword arguments
c_funloc(IO_Formats_get_ratio)) ! address of Fortran function to add c_funloc(IO_Formats_get_ratio)) ! address of Fortran function to add
call method_table%add_method("IO_Formats_set_ratio", & ! method name
"ratio setter", & !doc-string
METH_VARARGS, & ! this method takes arguments but no keyword arguments
c_funloc(IO_Formats_set_ratio)) ! address of Fortran function to add
call method_table%add_method("IO_Formats_get_dtt1", & ! method name call method_table%add_method("IO_Formats_get_dtt1", & ! method name
"dtt1 getter", & !doc-string "dtt1 getter", & !doc-string
......
...@@ -4,35 +4,23 @@ workspaces that can be used in the compiler environment of your choice. ...@@ -4,35 +4,23 @@ workspaces that can be used in the compiler environment of your choice.
Here are the instructions to run cmake in order to build the CrysFML library. Here are the instructions to run cmake in order to build the CrysFML library.
*** 1. download and install a recent version of cmake (>= 3.0.0 required)
1) download and install a recent version of cmake (>= 2.8.0 required) 2. check that the cmake binary directory is in the PATH altogether
***
2) check that the cmake binary directory is in the PATH altogether
with the different compilers that will be used for the build. with the different compilers that will be used for the build.
*** 3. set the environment variable CRYSFML to the directory where the README.md is
3) set the environment variable CRYSFML to the directory where the README is
located. located.
*** 4. create a directory wherever you want that will contain the files
4) create a directory wherever you want that will contain the files
generated during the build (e.g. ${CRYSFML}/build). generated during the build (e.g. ${CRYSFML}/build).
If you intend to do the build as superuser, this directory should If you intend to do the build as superuser, this directory should
give recursively the writing rights for every user. give recursively the writing rights for every user.
Now you are ready for the cmake run that will configure your build. Now you are ready for the cmake run that will configure your build.
***
5) change directory to the build directory created in step 4. 5. change directory to the build directory created in step 4.
*** 6. the CMake usage is:
6) the CMake usage is:
cmake -G generator -Dvariable=value path_to_your_source_directory cmake -G generator -Dvariable=value path_to_your_source_directory
...@@ -61,7 +49,7 @@ Here are the instructions to run cmake in order to build the CrysFML library. ...@@ -61,7 +49,7 @@ Here are the instructions to run cmake in order to build the CrysFML library.
Useful CMake variables (case sensitive): Useful CMake variables (case sensitive):
* USE_HDF: ON|OFF. * USE_HDF: ON|OFF. (Deprecated)
Default OFF Default OFF
If ON, CrysFML will be able to read NeXuS input data files. If ON, CrysFML will be able to read NeXuS input data files.
...@@ -69,7 +57,19 @@ Here are the instructions to run cmake in order to build the CrysFML library. ...@@ -69,7 +57,19 @@ Here are the instructions to run cmake in order to build the CrysFML library.
Default OFF Default OFF
If OFF, only CrysFML will be built. If OFF, only CrysFML will be built.
If ON, both CrysFML and WCrysFML libraries will be built If ON, both CrysFML and WCrysFML libraries will be built
* ARCH32: ON|OFF
Default ON
If ON 32-bits architecture is built
* HEAP_ARRAYS: ON|OFF
Default OFF
Put arrays in heap instead of stack (only for Windows ifort)
* PYTHON_API: ON|OFF
Default OFF
If ON, build the Python API
* CMAKE_Fortran_COMPILER: ifort|g95|gfortran. * CMAKE_Fortran_COMPILER: ifort|g95|gfortran.
Default ifort. Default ifort.
Sets the compiler to use for the build. Sets the compiler to use for the build.
...@@ -93,9 +93,8 @@ Here are the instructions to run cmake in order to build the CrysFML library. ...@@ -93,9 +93,8 @@ Here are the instructions to run cmake in order to build the CrysFML library.
Sets the name of the subdirectory within CMAKE_INSTALL_PREFIX where Sets the name of the subdirectory within CMAKE_INSTALL_PREFIX where
wcrysfml will be installed. wcrysfml will be installed.
***
7) the final step is now to build and install the library. The command to invoke will 7. the final step is now to build and install the library. The command to invoke will
depend on the generator used for the build. depend on the generator used for the build.
Examples: Examples:
......
...@@ -325,7 +325,7 @@ class BuildCommand(distutils.command.build.build): ...@@ -325,7 +325,7 @@ class BuildCommand(distutils.command.build.build):
setup(name="CFML", setup(name="CFML",
version="0.0.2", version="0.0.3",
author="Juan Rodriguez-Carvajal, Elisa Rebolini, Simon Ward", author="Juan Rodriguez-Carvajal, Elisa Rebolini, Simon Ward",
author_email="rebolini@ill.fr", author_email="rebolini@ill.fr",
description="The Crystallographic Fortran Modules Library (CrysFML) is a set of modules containing " description="The Crystallographic Fortran Modules Library (CrysFML) is a set of modules containing "
......
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