Skip to content

Commit 0effe61

Browse files
author
Roberto Di Remigio
committed
Fix Fortran bindings
1 parent 27abea9 commit 0effe61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+388
-371
lines changed

CHANGELOG.md

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,65 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- Signatures for strings in Fortran90 bindings. They have now the proper
8+
C interoperable type `character(kind=c_char, len=1) :: label(lbl_size)`.
9+
For the host this means that surface function labels will have to be declared
10+
as character arrays, for example: `character :: label(7) = (/'T', 'o', 't', 'M', 'E', 'P', char(0)/)`
11+
12+
### Changed
13+
14+
- More informative error messages for runtime crashes caused by access to
15+
surface functions.
16+
- The signatures for the interface functions now accept and/or return `int` (`c_int`)
17+
instead of `size_t` (`c_size_t`). This simplifies interfacing with Fortran hosts.
18+
519
## [v1.1.1] (2016-03-10)
620

721
### Added
822

9-
- A runtime check to ensure that all atoms have a nonzero radius.
10-
API kills program execution if this is the case.
23+
- A runtime check to ensure that all atoms have a nonzero radius. API kills
24+
program execution if this is the case.
1125
- An API function to retrieve the areas/weights of the cavity finite elements.
12-
The values in the returned array are in Bohr^2. Addresses a feature request from @shofener (Issue #13)
13-
- The standalone executable `run_pcm` is now tested within the unit tests suite.
14-
The tests cover the cases where the cavity is given implicitly, explicitly or by substitution of
15-
radii on chosen atoms.
26+
The values in the returned array are in Bohr^2. Addresses a feature request
27+
from @shofener (Issue #13)
28+
- The standalone executable `run_pcm` is now tested within the unit tests
29+
suite. The tests cover the cases where the cavity is given implicitly,
30+
explicitly or by substitution of radii on chosen atoms.
1631

1732
### Changed
1833

19-
- Boundary integral operators classes learnt to accept a scaling factor for the diagonal
20-
elements of the approximate collocation matrices. The change is reflected in the
21-
Green's funtion classes and in the input parsing. Addresses a feature request from @shofener (Issue #16)
22-
- GePolCavity learnt to print also the list of spheres used to generate
23-
the cavity.
34+
- Boundary integral operators classes learnt to accept a scaling factor for the
35+
diagonal elements of the approximate collocation matrices. The change is
36+
reflected in the Green's funtion classes and in the input parsing. Addresses
37+
a feature request from @shofener (Issue #16)
38+
- GePolCavity learnt to print also the list of spheres used to generate the
39+
cavity.
2440
- Different internal handling of conversion factors from Bohr to Angstrom.
2541
- CMake minimum required version is 2.8.10
26-
- Atom, Solvent and Sphere are now PODs. The radii and solvent lists are free functions.
27-
- `PCMSOLVER_ERROR` kills program execution when an error arises but does
28-
not use C++ exceptions.
29-
- `include`-s are now specified on a per-directory basis (see programmers' manual
30-
for a more detailed explanation)
31-
- Default types for template paramters `DerivativeTraits`, `IntegratorPolicy` and `ProfilePolicy`
32-
are now given for the Green's functions classes. This reduced the verbosity in instatiating
33-
these objects significantly.
42+
- Atom, Solvent and Sphere are now PODs. The radii and solvent lists are free
43+
functions.
44+
- `PCMSOLVER_ERROR` kills program execution when an error arises but does not
45+
use C++ exceptions.
46+
- `include`-s are now specified on a per-directory basis (see programmers'
47+
manual for a more detailed explanation)
48+
- Default types for template paramters `DerivativeTraits`, `IntegratorPolicy`
49+
and `ProfilePolicy` are now given for the Green's functions classes. This
50+
reduced the verbosity in instatiating these objects significantly.
3451

3552
### Known Issues
3653

3754
- The new printer in GePolCavity might not work properly when an explicit list
38-
of spheres is provided in the input.
39-
- On Ubuntu 12.10, 32 bit the Intel compiler version 2013.1 produces a faulty library.
40-
It is possibly a bug in the implementation of `iso_c_binding`, see Issue #25
55+
of spheres is provided in the input.
56+
- On Ubuntu 12.10, 32 bit the Intel compiler version 2013.1 produces a faulty
57+
library. It is possibly a bug in the implementation of `iso_c_binding`, see
58+
Issue #25
4159

4260
### Removed
4361

44-
- SurfaceFunction as a class is no longer available. We keep track of surface functions
45-
at the interface level _via_ a label-vector map.
62+
- SurfaceFunction as a class is no longer available. We keep track of surface
63+
functions at the interface level _via_ a label-vector map.
4664

4765
## [v1.1.0] (2016-02-07)
4866

api/pcmsolver.F90

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ end subroutine pcmsolver_print
114114
function pcmsolver_get_cavity_size(context) result(nr_points) bind(C)
115115
import
116116
type(c_ptr), value :: context
117-
integer(c_size_t) :: nr_points
117+
integer(c_int) :: nr_points
118118
end function pcmsolver_get_cavity_size
119119
end interface pcmsolver_get_cavity_size
120120

121121
interface pcmsolver_get_irreducible_cavity_size
122122
function pcmsolver_get_irreducible_cavity_size(context) result(nr_points_irr) bind(C)
123123
import
124124
type(c_ptr), value :: context
125-
integer(c_size_t) :: nr_points_irr
125+
integer(c_int) :: nr_points_irr
126126
end function pcmsolver_get_irreducible_cavity_size
127127
end interface pcmsolver_get_irreducible_cavity_size
128128

@@ -155,7 +155,7 @@ end subroutine pcmsolver_get_areas
155155
subroutine pcmsolver_compute_asc(context, mep_name, asc_name, irrep) bind(C)
156156
import
157157
type(c_ptr), value :: context
158-
character(c_char), intent(in) :: mep_name, asc_name
158+
character(kind=c_char, len=1), intent(in) :: mep_name(*), asc_name(*)
159159
integer(c_int), value, intent(in) :: irrep
160160
end subroutine pcmsolver_compute_asc
161161
end interface pcmsolver_compute_asc
@@ -164,7 +164,7 @@ end subroutine pcmsolver_compute_asc
164164
subroutine pcmsolver_compute_response_asc(context, mep_name, asc_name, irrep) bind(C)
165165
import
166166
type(c_ptr), value :: context
167-
character(c_char), intent(in) :: mep_name, asc_name
167+
character(kind=c_char, len=1), intent(in) :: mep_name(*), asc_name(*)
168168
integer(c_int), value, intent(in) :: irrep
169169
end subroutine pcmsolver_compute_response_asc
170170
end interface pcmsolver_compute_response_asc
@@ -173,7 +173,7 @@ end subroutine pcmsolver_compute_response_asc
173173
function pcmsolver_compute_polarization_energy(context, mep_name, asc_name) result(energy) bind(C)
174174
import
175175
type(c_ptr), value :: context
176-
character(c_char), intent(in) :: mep_name, asc_name
176+
character(kind=c_char, len=1), intent(in) :: mep_name(*), asc_name(*)
177177
real(c_double) :: energy
178178
end function pcmsolver_compute_polarization_energy
179179
end interface pcmsolver_compute_polarization_energy
@@ -182,19 +182,19 @@ end function pcmsolver_compute_polarization_energy
182182
subroutine pcmsolver_get_surface_function(context, f_size, values, name) bind(C)
183183
import
184184
type(c_ptr), value :: context
185-
integer(c_size_t), value, intent(in) :: f_size
185+
integer(c_int), value, intent(in) :: f_size
186186
real(c_double), intent(inout) :: values(*)
187-
character(c_char), intent(in) :: name
187+
character(kind=c_char, len=1), intent(in) :: name(*)
188188
end subroutine pcmsolver_get_surface_function
189189
end interface pcmsolver_get_surface_function
190190

191191
interface pcmsolver_set_surface_function
192192
subroutine pcmsolver_set_surface_function(context, f_size, values, name) bind(C)
193193
import
194194
type(c_ptr), value :: context
195-
integer(c_size_t), value, intent(in) :: f_size
195+
integer(c_int), value, intent(in) :: f_size
196196
real(c_double), intent(in) :: values(*)
197-
character(c_char), intent(in) :: name
197+
character(kind=c_char, len=1), intent(in) :: name(*)
198198
end subroutine pcmsolver_set_surface_function
199199
end interface pcmsolver_set_surface_function
200200

@@ -209,15 +209,15 @@ end subroutine pcmsolver_save_surface_functions
209209
subroutine pcmsolver_save_surface_function(context, name) bind(C)
210210
import
211211
type(c_ptr), value :: context
212-
character(c_char), intent(in) :: name
212+
character(kind=c_char, len=1), intent(in) :: name
213213
end subroutine pcmsolver_save_surface_function
214214
end interface pcmsolver_save_surface_function
215215

216216
interface pcmsolver_load_surface_function
217217
subroutine pcmsolver_load_surface_function(context, name) bind(C)
218218
import
219219
type(c_ptr), value :: context
220-
character(c_char), intent(in) :: name
220+
character(kind=c_char, len=1), intent(in) :: name
221221
end subroutine pcmsolver_load_surface_function
222222
end interface pcmsolver_load_surface_function
223223

api/pcmsolver.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ typedef enum
9595
* \param[in] message_length length of the passed message
9696
* This function **must** be defined by the host program
9797
*/
98-
void host_writer(const char * message, size_t message_length);
98+
void host_writer(const char * message, int message_length);
9999

100100
/*! \brief Creates a new PCM context object
101101
* \param[in] input_reading input processing strategy
@@ -138,13 +138,13 @@ PCMSOLVER_API void pcmsolver_print(pcmsolver_context_t * context);
138138
* \param[in, out] context the PCM context object
139139
* \return the size of the cavity
140140
*/
141-
PCMSOLVER_API size_t pcmsolver_get_cavity_size(pcmsolver_context_t * context);
141+
PCMSOLVER_API int pcmsolver_get_cavity_size(pcmsolver_context_t * context);
142142

143143
/*! \brief Getter for the number of irreducible finite elements composing the molecular cavity
144144
* \param[in, out] context the PCM context object
145145
* \return the number of irreducible finite elements
146146
*/
147-
PCMSOLVER_API size_t pcmsolver_get_irreducible_cavity_size(pcmsolver_context_t * context);
147+
PCMSOLVER_API int pcmsolver_get_irreducible_cavity_size(pcmsolver_context_t * context);
148148

149149
/*! \brief Getter for the centers of the finite elements composing the molecular cavity
150150
* \param[in, out] context the PCM context object
@@ -211,7 +211,7 @@ PCMSOLVER_API double pcmsolver_compute_polarization_energy(pcmsolver_context_t *
211211
* \param[in] name label of the surface function
212212
*/
213213
PCMSOLVER_API void pcmsolver_get_surface_function(pcmsolver_context_t * context,
214-
size_t size,
214+
int size,
215215
double values[],
216216
const char * name);
217217

@@ -222,7 +222,7 @@ PCMSOLVER_API void pcmsolver_get_surface_function(pcmsolver_context_t * context,
222222
* \param[in] name label of the surface function
223223
*/
224224
PCMSOLVER_API void pcmsolver_set_surface_function(pcmsolver_context_t * context,
225-
size_t size,
225+
int size,
226226
double values[],
227227
const char * name);
228228

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if(NOT DEFINED ENV{CFLAGS})
22
if(CMAKE_C_COMPILER_ID MATCHES Clang)
33
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DRESTRICT=restrict -DFUNDERSCORE=1 -Qunused-arguments -fcolor-diagnostics")
4-
set(CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG -g3 -Wall -Wextra -Winit-self -Wuninitialized -Wmissing-declarations -Wwrite-strings ")
4+
set(CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG -g3 -Wall -Wextra -Winit-self -Wuninitialized -Wmissing-declarations -Wwrite-strings -Wno-sign-compare")
55
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
66
endif()
77
endif()

cmake/custom/compilers/Clang.CXX.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if(NOT DEFINED ENV{CXXFLAGS})
88
endif()
99

1010
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAG} -Qunused-arguments -fcolor-diagnostics")
11-
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -DDEBUG -Wall -Wextra -Winit-self -Woverloaded-virtual -Wuninitialized -Wmissing-declarations -Wwrite-strings -Weffc++ -Wdocumentation")
11+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -DDEBUG -Wall -Wextra -Winit-self -Woverloaded-virtual -Wuninitialized -Wmissing-declarations -Wwrite-strings -Weffc++ -Wdocumentation -Wno-sign-compare")
1212
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -Wno-unused")
1313
endif()
1414
endif()

cmake/custom/compilers/GNU.C.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if(NOT DEFINED ENV{CFLAGS})
22
if(CMAKE_C_COMPILER_ID MATCHES GNU)
33
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DRESTRICT=restrict -DFUNDERSCORE=1 -fPIC")
4-
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -DDEBUG -Wall -Wextra -Winit-self -Wuninitialized -Wmissing-declarations -Wwrite-strings ")
4+
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -DDEBUG -Wall -Wextra -Winit-self -Wuninitialized -Wmissing-declarations -Wwrite-strings -Wno-sign-compare")
55
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
66
endif()
77
endif()

cmake/custom/compilers/GNU.CXX.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if(NOT DEFINED ENV{CXXFLAGS})
1414
endif()
1515

1616
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAG} ${EXDIAG_CXX_FLAGS}")
17-
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DDEBUG -Wall -Wextra -Winit-self -Woverloaded-virtual -Wuninitialized -Wmissing-declarations -Wwrite-strings")
17+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DDEBUG -Wall -Wextra -Winit-self -Woverloaded-virtual -Wuninitialized -Wmissing-declarations -Wwrite-strings -Wno-sign-compare")
1818
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -Wno-unused")
1919
endif()
2020
endif()

cmake/custom/compilers/Intel.C.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if(NOT DEFINED ENV{CFLAGS})
22
if(CMAKE_C_COMPILER_ID MATCHES Intel)
33
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -restrict -DRESTRICT=restrict -std=c99 -fPIC")
4-
set(CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG -g -w3 -Wall -Wuninitialized")
4+
set(CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG -g -w3 -Wall -Wuninitialized -Wno-sign-compare")
55
set(CMAKE_C_FLAGS_RELEASE "-O3 -ip -DNDEBUG")
66
# FIXME Not sure this is really needed
77
set(CMAKE_C_LINK_FLAGS "-shared-intel -fPIC")

cmake/custom/compilers/Intel.CXX.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if(NOT DEFINED ENV{CXXFLAGS})
1414
endif()
1515

1616
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAG}")
17-
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -debug -DDEBUG -Wall -Wuninitialized -Wno-unknown-pragmas")
17+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -debug -DDEBUG -Wall -Wuninitialized -Wno-unknown-pragmas -Wno-sign-compare")
1818
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
1919
# FIXME not sure this is actually needed...
2020
set(CMAKE_CXX_LINK_FLAGS "-shared-intel")

include/Config.hpp.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343

4444
#include <boost/current_function.hpp>
4545

46+
// Inspired from Eigen EIGEN_DEFAULT_DENSE_INDEX_TYPE
47+
#ifndef PCMSOLVER_DEFAULT_INDEX_TYPE
48+
#define PCMSOLVER_DEFAULT_INDEX_TYPE int
49+
typedef PCMSOLVER_DEFAULT_INDEX_TYPE PCMSolverIndex;
50+
#endif
51+
4652
#include "Cxx11Workarounds.hpp"
4753
#include "ErrorHandling.hpp"
4854
#include "LoggerInterface.hpp"

0 commit comments

Comments
 (0)