Merge branch 'develop' into always-exceptions
This commit is contained in:
@ -207,7 +207,7 @@ END SUBROUTINE f_lammps_scatter_atoms_subset_mask
|
||||
|
||||
SUBROUTINE f_lammps_setup_gather_topology() BIND(C)
|
||||
USE LIBLAMMPS
|
||||
USE keepstuff, ONLY : lmp, cont_input, more_input, pair_input
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
|
||||
CALL lmp%command('include ${input_dir}/in.fourmol')
|
||||
@ -232,7 +232,7 @@ FUNCTION f_lammps_test_gather_bonds_small() BIND(C) RESULT(count)
|
||||
nbonds = nbonds_small
|
||||
ELSE
|
||||
nbonds_big = lmp%extract_global('nbonds')
|
||||
nbonds = nbonds_big
|
||||
nbonds = INT(nbonds_big)
|
||||
END IF
|
||||
|
||||
CALL lmp%gather_bonds(bonds)
|
||||
@ -280,7 +280,7 @@ FUNCTION f_lammps_test_gather_bonds_big() BIND(C) RESULT(count)
|
||||
INTEGER(c_int64_t), POINTER :: nbonds_big
|
||||
|
||||
nbonds_big = lmp%extract_global('nbonds')
|
||||
nbonds = nbonds_big
|
||||
nbonds = INT(nbonds_big)
|
||||
CALL lmp%gather_bonds(bonds)
|
||||
bonds_array(1:3,1:SIZE(bonds)/3) => bonds
|
||||
count = 0
|
||||
@ -332,7 +332,7 @@ FUNCTION f_lammps_test_gather_angles_small() BIND(C) RESULT(count)
|
||||
nangles = nangles_small
|
||||
ELSE
|
||||
nangles_big = lmp%extract_global('nangles')
|
||||
nangles = nangles_big
|
||||
nangles = INT(nangles_big)
|
||||
END IF
|
||||
|
||||
CALL lmp%gather_angles(angles)
|
||||
@ -380,7 +380,7 @@ FUNCTION f_lammps_test_gather_angles_big() BIND(C) RESULT(count)
|
||||
INTEGER(c_int64_t), POINTER :: nangles_big
|
||||
|
||||
nangles_big = lmp%extract_global('nangles')
|
||||
nangles = nangles_big
|
||||
nangles = INT(nangles_big)
|
||||
CALL lmp%gather_angles(angles)
|
||||
angles_array(1:4,1:SIZE(angles)/4) => angles
|
||||
count = 0
|
||||
@ -432,7 +432,7 @@ FUNCTION f_lammps_test_gather_dihedrals_small() BIND(C) RESULT(count)
|
||||
ndihedrals = ndihedrals_small
|
||||
ELSE
|
||||
ndihedrals_big = lmp%extract_global('ndihedrals')
|
||||
ndihedrals = ndihedrals_big
|
||||
ndihedrals = INT(ndihedrals_big)
|
||||
END IF
|
||||
|
||||
CALL lmp%gather_dihedrals(dihedrals)
|
||||
@ -478,7 +478,7 @@ FUNCTION f_lammps_test_gather_dihedrals_big() BIND(C) RESULT(count)
|
||||
INTEGER(c_int64_t), POINTER :: ndihedrals_big
|
||||
|
||||
ndihedrals_big = lmp%extract_global('ndihedrals')
|
||||
ndihedrals = ndihedrals_big
|
||||
ndihedrals = INT(ndihedrals_big)
|
||||
CALL lmp%gather_dihedrals(dihedrals)
|
||||
dihedrals_array(1:5,1:SIZE(dihedrals)/5) => dihedrals
|
||||
count = 0
|
||||
@ -528,7 +528,7 @@ FUNCTION f_lammps_test_gather_impropers_small() BIND(C) RESULT(count)
|
||||
nimpropers = nimpropers_small
|
||||
ELSE
|
||||
nimpropers_big = lmp%extract_global('nimpropers')
|
||||
nimpropers = nimpropers_big
|
||||
nimpropers = INT(nimpropers_big)
|
||||
END IF
|
||||
|
||||
CALL lmp%gather_impropers(impropers)
|
||||
@ -566,7 +566,7 @@ FUNCTION f_lammps_test_gather_impropers_big() BIND(C) RESULT(count)
|
||||
INTEGER(c_int64_t), POINTER :: nimpropers_big
|
||||
|
||||
nimpropers_big = lmp%extract_global('nimpropers')
|
||||
nimpropers = nimpropers_big
|
||||
nimpropers = INT(nimpropers_big)
|
||||
CALL lmp%gather_impropers(impropers)
|
||||
impropers_array(1:5,1:SIZE(impropers)/5) => impropers
|
||||
count = 0
|
||||
|
||||
@ -152,3 +152,111 @@ FUNCTION f_lammps_get_thermo_zhi() BIND(C)
|
||||
|
||||
f_lammps_get_thermo_zhi = lmp%get_thermo('zhi')
|
||||
END FUNCTION f_lammps_get_thermo_zhi
|
||||
|
||||
SUBROUTINE f_lammps_last_thermo_setup() BIND(C)
|
||||
USE liblammps
|
||||
USE keepstuff, ONLY : lmp, big_input, cont_input, pair_input
|
||||
IMPLICIT NONE
|
||||
|
||||
CALL lmp%commands_list(big_input)
|
||||
CALL lmp%commands_list(cont_input)
|
||||
CALL lmp%commands_list(pair_input)
|
||||
CALL lmp%command('thermo 10')
|
||||
CALL lmp%command('run 15 post no')
|
||||
END SUBROUTINE f_lammps_last_thermo_setup
|
||||
|
||||
FUNCTION f_lammps_last_thermo_step() BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY: c_int, c_int64_t
|
||||
USE liblammps
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int) :: f_lammps_last_thermo_step
|
||||
INTEGER :: size_bigint
|
||||
INTEGER(c_int), POINTER :: ival
|
||||
INTEGER(c_int64_t), POINTER :: bval
|
||||
|
||||
size_bigint = lmp%extract_setting('bigint')
|
||||
IF (size_bigint == 4) THEN
|
||||
ival = lmp%last_thermo('step',1)
|
||||
f_lammps_last_thermo_step = INT(ival)
|
||||
ELSE
|
||||
bval = lmp%last_thermo('step',1)
|
||||
f_lammps_last_thermo_step = INT(bval)
|
||||
END IF
|
||||
END FUNCTION f_lammps_last_thermo_step
|
||||
|
||||
FUNCTION f_lammps_last_thermo_num() BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY: c_int
|
||||
USE liblammps
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int) :: f_lammps_last_thermo_num
|
||||
INTEGER(c_int), POINTER :: ival
|
||||
|
||||
ival = lmp%last_thermo('num',1)
|
||||
f_lammps_last_thermo_num = ival
|
||||
END FUNCTION f_lammps_last_thermo_num
|
||||
|
||||
FUNCTION f_lammps_last_thermo_type(idx) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY: c_int
|
||||
USE liblammps
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int), VALUE :: idx
|
||||
INTEGER(c_int) :: f_lammps_last_thermo_type
|
||||
INTEGER(c_int), POINTER :: ival
|
||||
|
||||
ival = lmp%last_thermo('type',idx)
|
||||
f_lammps_last_thermo_type = ival
|
||||
END FUNCTION f_lammps_last_thermo_type
|
||||
|
||||
FUNCTION f_lammps_last_thermo_string(idx) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY: c_int, c_ptr, c_null_ptr
|
||||
USE liblammps
|
||||
USE keepstuff, ONLY : lmp, f2c_string
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int), VALUE :: idx
|
||||
TYPE(c_ptr) :: f_lammps_last_thermo_string
|
||||
CHARACTER(LEN=12) :: buffer
|
||||
|
||||
buffer = lmp%last_thermo('keyword',idx)
|
||||
IF (LEN_TRIM(buffer) > 0) THEN
|
||||
f_lammps_last_thermo_string = f2c_string(buffer)
|
||||
ELSE
|
||||
f_lammps_last_thermo_string = c_null_ptr
|
||||
END IF
|
||||
END FUNCTION f_lammps_last_thermo_string
|
||||
|
||||
FUNCTION f_lammps_last_thermo_int(idx) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY: c_int, c_int64_t
|
||||
USE liblammps
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int), VALUE :: idx
|
||||
INTEGER(c_int), POINTER :: ival
|
||||
INTEGER(c_int64_t), POINTER :: bval
|
||||
INTEGER(c_int) :: f_lammps_last_thermo_int
|
||||
INTEGER :: size_bigint
|
||||
|
||||
size_bigint = lmp%extract_setting('bigint')
|
||||
IF (size_bigint == 4) THEN
|
||||
ival = lmp%last_thermo('data',idx)
|
||||
f_lammps_last_thermo_int = INT(ival)
|
||||
ELSE
|
||||
bval = lmp%last_thermo('data',idx)
|
||||
f_lammps_last_thermo_int = INT(bval)
|
||||
END IF
|
||||
END FUNCTION f_lammps_last_thermo_int
|
||||
|
||||
FUNCTION f_lammps_last_thermo_double(idx) BIND(C)
|
||||
USE, INTRINSIC :: ISO_C_BINDING, ONLY: c_int, c_double
|
||||
USE liblammps
|
||||
USE keepstuff, ONLY : lmp
|
||||
IMPLICIT NONE
|
||||
INTEGER(c_int), VALUE :: idx
|
||||
REAL(c_double), POINTER :: dval
|
||||
REAL(c_double) :: f_lammps_last_thermo_double
|
||||
|
||||
dval = lmp%last_thermo('data',idx)
|
||||
f_lammps_last_thermo_double = dval
|
||||
END FUNCTION f_lammps_last_thermo_double
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// unit tests for getting thermodynamic output from a LAMMPS instance through the Fortran wrapper
|
||||
|
||||
#include "lammps.h"
|
||||
#include "lmptype.h"
|
||||
#include <mpi.h>
|
||||
#include <string>
|
||||
|
||||
@ -23,8 +24,18 @@ double f_lammps_get_thermo_ylo();
|
||||
double f_lammps_get_thermo_yhi();
|
||||
double f_lammps_get_thermo_zlo();
|
||||
double f_lammps_get_thermo_zhi();
|
||||
|
||||
void f_lammps_last_thermo_setup();
|
||||
int f_lammps_last_thermo_step();
|
||||
int f_lammps_last_thermo_num();
|
||||
int f_lammps_last_thermo_type(int);
|
||||
const char *f_lammps_last_thermo_string(int);
|
||||
int f_lammps_last_thermo_int(int);
|
||||
double f_lammps_last_thermo_double(int);
|
||||
}
|
||||
|
||||
using LAMMPS_NS::multitype;
|
||||
|
||||
class LAMMPS_thermo : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS_NS::LAMMPS *lmp;
|
||||
@ -65,3 +76,33 @@ TEST_F(LAMMPS_thermo, get_thermo)
|
||||
EXPECT_DOUBLE_EQ(f_lammps_get_thermo_zlo(), 0.0);
|
||||
EXPECT_DOUBLE_EQ(f_lammps_get_thermo_zhi(), 4.0);
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_thermo, last_thermo)
|
||||
{
|
||||
EXPECT_EQ(f_lammps_last_thermo_step(), -1);
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(1), multitype::LAMMPS_NONE);
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(2), multitype::LAMMPS_NONE);
|
||||
f_lammps_last_thermo_setup();
|
||||
EXPECT_EQ(f_lammps_last_thermo_step(), 15);
|
||||
EXPECT_EQ(f_lammps_last_thermo_num(), 6);
|
||||
EXPECT_STREQ(f_lammps_last_thermo_string(1), "Step");
|
||||
EXPECT_STREQ(f_lammps_last_thermo_string(2), "Temp");
|
||||
EXPECT_STREQ(f_lammps_last_thermo_string(3), "E_pair");
|
||||
EXPECT_STREQ(f_lammps_last_thermo_string(6), "Press");
|
||||
#if defined(LAMMPS_SMALLSMALL)
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(1), multitype::LAMMPS_INT);
|
||||
#else
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(1), multitype::LAMMPS_INT64);
|
||||
#endif
|
||||
EXPECT_EQ(f_lammps_last_thermo_int(1), 15);
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(2), multitype::LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(3), multitype::LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(4), multitype::LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(5), multitype::LAMMPS_DOUBLE);
|
||||
EXPECT_EQ(f_lammps_last_thermo_type(6), multitype::LAMMPS_DOUBLE);
|
||||
EXPECT_DOUBLE_EQ(f_lammps_last_thermo_double(2), 0.0);
|
||||
EXPECT_DOUBLE_EQ(f_lammps_last_thermo_double(3), -0.13713425198078993);
|
||||
EXPECT_DOUBLE_EQ(f_lammps_last_thermo_double(4), 0.0);
|
||||
EXPECT_DOUBLE_EQ(f_lammps_last_thermo_double(5), -0.13713425198078993);
|
||||
EXPECT_DOUBLE_EQ(f_lammps_last_thermo_double(6), -0.022421073321023492);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user