Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge the new library interface #466

Merged
merged 188 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
43f094e
Add initialisation values to types and remove from the read routines
sstgfbc Feb 28, 2022
1c9cbf0
Add initialisation to old wannier_lib
sstgfbc Feb 28, 2022
5d4d73d
add BGS lib interface (work in progress)
Mar 15, 2022
474808d
Change some seedname len=50 to len=* to avoid some python runtime errors
sstgfbc Mar 16, 2022
7602d5d
Copy global initialisations from wannier_prog into lib interface type
sstgfbc Mar 16, 2022
1421144
w90stat_type is only used in comms module and confuses f90wrap so make
sstgfbc Mar 16, 2022
0c3d439
Put comm back into wrapper function in library interface
sstgfbc Mar 16, 2022
94ee858
Add library interface to kmesh_get
sstgfbc Mar 16, 2022
14dff0b
Overlap interface without disentangle needed u_matrix
sstgfbc Mar 16, 2022
536cd88
Wannierise wrapper call needs the M and U matrices
sstgfbc Mar 16, 2022
a6c07c6
Try and separate transport and plot types in library
sstgfbc Mar 28, 2022
963350f
Add a_matrix to overlap_read in library for use by disentangle
sstgfbc Mar 28, 2022
35bc313
Separate time printing from each subroutine call
sstgfbc Mar 28, 2022
67d1a42
Add subroutine for plotting to library interface
sstgfbc Mar 28, 2022
a45678c
Add u_matrix_opt to wannierise (will be generated by disentangle)
sstgfbc Mar 28, 2022
88d97bb
Add routine to write checkpoint files
sstgfbc Mar 28, 2022
eaecf37
Add library interface to transport
sstgfbc Mar 28, 2022
c76dd30
Fix missing 'use' in checkpoint
sstgfbc Mar 28, 2022
7bd2c89
add make rule for library_inteface
Mar 28, 2022
7c98756
Add f90wrap example building code to repository
sstgfbc Mar 29, 2022
08d999a
Correct name of abort code in serial build
sstgfbc Mar 29, 2022
c2b65fa
Add example python scripts to experimental f90wrap directory
sstgfbc Mar 29, 2022
82eb329
Set iprint to 0 for other MPI ranks in library
sstgfbc Mar 29, 2022
5b13a56
Correct mpi example to match current python moduel name
sstgfbc Mar 29, 2022
562a36c
Fix import in mpi-example
sstgfbc Mar 30, 2022
2addfee
Fix format specifier in utility_diagonalise
sstgfbc Apr 4, 2022
4f6b2e7
f90wrap can't handle array initialisation in types. Move kslice init
sstgfbc Apr 5, 2022
1f76f09
move read in_file to main()
Apr 6, 2022
c2c1cb4
assign a var before it is used
Apr 6, 2022
9dd1714
define disentanglement variable on non-root ranks
Apr 6, 2022
cc783c6
Add output unit to library interface
sstgfbc Apr 11, 2022
7126e72
Split read checkpoint to help with python wrapping
sstgfbc Apr 11, 2022
4999cc5
check_in_file moved to driver routine should call prterr not return
sstgfbc Apr 11, 2022
d7b6794
have_disentangled should be intent(in) in second half of read_chkpt
sstgfbc Apr 12, 2022
e44ba19
Add pw90 library interface with working python DOS example
sstgfbc Apr 12, 2022
1abec31
Add a boltzwann option to the postw90 library
sstgfbc Apr 12, 2022
e08d351
Split off v_matrix build from DOS call in pw90 library
sstgfbc Apr 13, 2022
18ec71e
Add gyrotropic option to pw90 library
sstgfbc Apr 19, 2022
5ffb992
Add pw90 library call to berry
sstgfbc Apr 19, 2022
2703352
Add kpath call to postw90 library
sstgfbc Apr 20, 2022
f951b8d
Add kslice interface to pw90 library
sstgfbc Apr 20, 2022
6d60d61
Add spin moment calculation
sstgfbc Apr 25, 2022
b80becf
Add generic intepolation routines pw90 interface
sstgfbc Apr 25, 2022
bda8717
Add W90DEV flag for compiling in error finalise call
sstgfbc Apr 27, 2022
fe558da
Need a separate wanint_setup call to run postw90 with wannier90 in py…
sstgfbc Apr 27, 2022
3782b61
Read_in_file/clean_in_file were missing from library interface reader
sstgfbc May 9, 2022
3ed31b9
Need to add m_matrix_orig allocation to overlaps in library interface to
sstgfbc May 9, 2022
f59c9a4
Update python wrapper make.inc to Intel oneapi libs
sstgfbc May 12, 2022
91b7157
Need to add separated input file read to old wannier_lib. Also a few
sstgfbc Jun 1, 2022
03e8e81
Add a subroutine to get the output unit so python doesn't have to assume
sstgfbc Jun 8, 2022
c0c02b9
This creates a 'working' disentangle to run the example13 transport calc
sstgfbc May 12, 2022
31faa5d
Restore missing patch for disentangle in previous commit
sstgfbc Jun 8, 2022
9aff60f
Including the arrays as references in the global library type would n…
sstgfbc Jun 8, 2022
f54da04
Remove matrices from checkpoint library interface
sstgfbc Jun 8, 2022
ee59b8d
Attempt to restructure library global types to match the structure of…
sstgfbc Jun 8, 2022
a52fe41
Add status variable to library interface. 0 is ok, positive is an err…
sstgfbc Jun 9, 2022
bef565c
Update python examples for modified library interface with status var…
sstgfbc Jun 16, 2022
a0bd4de
Modify pw90 library to include v_matrix in type in analogy to w90 cha…
sstgfbc Jun 16, 2022
6a1d433
first hack set_option() for scalars, readwrite.F90
Jun 28, 2022
62a82c1
tweak scalar option setting
Jun 28, 2022
ec63b43
move set_option to library_interface.F90
Jun 29, 2022
8b84667
Changes to store k point distribution in library interface and use in
sstgfbc Jul 13, 2022
269ecb1
various changes around m_matrix_loc
Jul 19, 2022
b25526b
fix subtle error handling case
Jul 21, 2022
0a62b01
revert to using counts/displs (it really is better)
Jul 21, 2022
5700a85
revise disentangle lib routine (ongoing)
Jul 21, 2022
555ba51
fixup old library
Aug 10, 2022
02aab88
reshuffle a couple of m-matrices in the library interface
Aug 10, 2022
7c8dad9
Fix library interface to wannierise and restore general k point distr…
sstgfbc Aug 11, 2022
c6d2e62
Update serial python example after retesting with current code
sstgfbc Aug 11, 2022
da8d7a0
various changes associated with allocation of m_matrix* (wip)
Aug 11, 2022
9750862
add toy code using libv2
Aug 12, 2022
d0dd0dc
Update serial python example after changes to overlap
sstgfbc Aug 15, 2022
ad184db
Initial update of MPI python example for current lib interface
sstgfbc Aug 15, 2022
c0a595d
Initial changes to overlap read to read local parts of m_matrix on node
sstgfbc Aug 15, 2022
8ca8ead
pass most tests in serial using tiny-lib2-demo (error handling absent)
Aug 12, 2022
fe54963
current state
Aug 16, 2022
1e9b417
small fixes such that toy main() passes all serial and parallel tests
Aug 16, 2022
dba4e33
hacks for non-root-error-condition test
Aug 16, 2022
e957848
cosmetic changes
Aug 16, 2022
bb4347f
move from counts/displs to more general dist_k
Sep 14, 2022
d34cff8
simplify kpoint decomposition and check error in main()
Sep 15, 2022
9fd66f7
Add fortran error unit for python
sstgfbc Sep 16, 2022
ee9a7f1
make wannier main() work in serial
Sep 20, 2022
43c67d4
make wannier_lib compile
sstgfbc Oct 3, 2022
9c14eab
Add error unit to routines in pw90_lib
sstgfbc Oct 3, 2022
1ed5e6b
Add file opening option for python interface
sstgfbc Oct 3, 2022
880fbeb
Update python examples
sstgfbc Oct 3, 2022
7a87493
Split pwost90 setup from read_checkpoint and initialise some of the v…
sstgfbc Oct 3, 2022
9d7cc54
Update python pw90 dos example
sstgfbc Oct 4, 2022
6e1b570
move some output routines from wann_main to plot_main
Oct 4, 2022
5a3de35
hack printout
Oct 6, 2022
c38e419
wip checkpoint reading
Oct 7, 2022
d279e7b
fixes checkpointing, fixes old library build, removes 'library' flag
Nov 23, 2022
18d9b71
temporary hacks concerning .eig reading
Jan 11, 2023
19dc8cc
restructure settings string, set evals differently
Jan 9, 2023
d576f7b
changes to .eig reading; groundwork for array/matrix option handling
Jan 13, 2023
418d81d
wip lib testing
Jan 17, 2023
a975554
put settings_type in types module
Jan 18, 2023
cb3cf68
move overlap_project call out from overlap_read
Jan 20, 2023
8f50a12
trap some error conditions in main()
Jan 25, 2023
b46db7d
define nnkp before writing it
Jan 25, 2023
f81bb81
correct use of output units
Jan 25, 2023
0e50f25
change handling of projections during read
Jan 31, 2023
ba01fe5
adopt more sensible dummy var names in lib; use errors consistently
Feb 1, 2023
10ba7ce
fixes various and diverse details and coding issues
Feb 1, 2023
7adc322
reorganise alloc of eigval(:,:)
Feb 6, 2023
e612f03
move setting object into library data struct
Feb 6, 2023
77b74f1
Move 'set_option' routines from readwrite to library_interface
sstgfbc Feb 7, 2023
ae4bb0e
Tidy up a few unused vars in readwrite and make wannier_lib compile
sstgfbc Feb 7, 2023
8490b74
Update postw90 to use settings_type in reader
sstgfbc Feb 7, 2023
d6947d3
Initial changes to get the draft pw90_library to compile
sstgfbc Feb 7, 2023
19023b1
fixes failure to initialise LocalSigmaS var in boltzwann
Feb 8, 2023
9a2d93c
init u_opt necessary when not disentangling
Feb 13, 2023
3786903
correctly write proj_input (not proj) to nnkp
Feb 15, 2023
7c67a0c
correct use of calc_only_a variable
Feb 15, 2023
16abdea
adds subroutine get_proj
Feb 15, 2023
9040ef6
Minor updates so the python works with disentangle
sstgfbc Feb 15, 2023
c9bb89b
replace old wannier_prog with tiny-lib2-demo
Feb 15, 2023
953c1be
let wannier_lib.F90 compile
Feb 15, 2023
957e9a6
Propagate library pointer eigval usage into postw90 and draft library
sstgfbc Feb 20, 2023
b4176e7
Modify read_eigval to use pointer in helper type
sstgfbc Feb 20, 2023
324bcce
remove a module dependency from kmesh
Feb 20, 2023
0bfa6f1
Restructure eigval reading and dis_manifold initialisation. Eigenvalues
sstgfbc Feb 28, 2023
fd3b8cb
Fix automatic deallocation of eigvals in pw90 library
sstgfbc Feb 28, 2023
5cb7621
Add subroutine for setting bohr_to_angstrom conversion from SCF code
sstgfbc Mar 23, 2023
ec1364a
Create set_parallel_comms subroutine so users do not need to 'use' our
sstgfbc Mar 30, 2023
85b65ab
fixup
Mar 31, 2023
5464a72
MPI complications for gamma_only and nk>nproc cases
Apr 24, 2023
3c05ccd
rationalise some variable names
May 9, 2023
a877713
Updates to draft pw90 library and python examples to reflect recent c…
sstgfbc May 12, 2023
2fb3c01
Updated PyMPI example after testing
sstgfbc May 12, 2023
d3d81e8
Update pw90 library to remove comms and match recent changes to w90 lib
sstgfbc May 12, 2023
f35c77a
fix argument in legacy library
May 18, 2023
0698c6e
add declarations
May 30, 2023
a4eefcc
cmdline parsing
May 30, 2023
9fb79c2
differentiate between mandatory lib args and opts
Jun 15, 2023
5c14bbe
cleaning up some comments in codebase
Jun 15, 2023
5c141af
Rework handling of .win file (in_data) and set_options (entries) data
Jun 15, 2023
6a0761c
more sane way to set options
Jun 16, 2023
e292d99
plaster together basic functionality for c interface
Jul 5, 2023
3a37828
b-vec search method must allow arbitrary k order
Jan 8, 2024
0e27671
guard some prints in write_chkpt()
Jan 10, 2024
5d2228b
add c++ header file
Jan 10, 2024
b012d44
add DL team to author list for v4
Jan 10, 2024
17684fc
remove obsolete test
Jan 10, 2024
634c75e
remove obsolete forall
Jan 10, 2024
e1dbb48
cleanup
Jan 10, 2024
a0858c7
restore guiding centres assignment
Jan 10, 2024
767a8cd
cut away some unnecessary matrices
Jan 12, 2024
3daddd6
change how to set distk
Jan 14, 2024
e127542
move setting of communicator into setopt call
Jan 14, 2024
26b4935
set seedname in one place only
Jan 14, 2024
ebd34ae
merge two library data types
Jan 14, 2024
bc2eb78
use MPI_VERSION pp macro to detect parallel use of header
Jan 16, 2024
df04d34
start patching up pw90
Jan 16, 2024
7ec7995
removes legacy library
Jan 16, 2024
3b87a26
reinstate unlucky test
Jan 16, 2024
dd77bfc
small corrections to fix some tests
Jan 16, 2024
d404b97
fix nnkp generation (standalone)
Jan 17, 2024
63fc650
comment out c_interface to avoid need for std=f2018
Jan 17, 2024
a86803d
Initial tests of serial python wrappers with changes to library
sstgfbc Jan 25, 2024
c896e16
fix k distribution
Feb 6, 2024
9746e54
correct a parallel logic error
Feb 6, 2024
49415ec
small changes/cleanup
Feb 6, 2024
e0a4a7c
remove some confusion around m_matrix names
Feb 6, 2024
865bddf
avoid polluting namespace with dp
Feb 6, 2024
6d66178
no need to make kmesh before writing nnkp_file (standalone function)
Feb 8, 2024
f35e8b3
read spinors must preceed read projections
Feb 9, 2024
e9b5f1a
fix svd_omega pllel hang
Feb 9, 2024
ca31306
Revert "comment out c_interface to avoid need for std=f2018"
Feb 11, 2024
39e462c
small changes for handling special vars
Feb 11, 2024
5e0bf8f
add some simple library uses
Feb 11, 2024
b130cc6
regress keyword check change
Feb 12, 2024
a2d6dc3
move some functions out of the library and rename lib functions
Feb 12, 2024
7105370
deactivate c_interface (f90 std)
Feb 13, 2024
8fbd3f9
small bugfix in lib
Feb 13, 2024
e913e23
remove clutter
Feb 14, 2024
7ff6d48
Revert "b-vec search method must allow arbitrary k order"
Feb 14, 2024
1bc809e
fixup
Feb 14, 2024
3ab5b5c
return gkpb
Feb 15, 2024
7737ee2
restore printout parallel/serial
Feb 15, 2024
394b23a
correct nnkp logic
Feb 15, 2024
002704b
update github workflow (remove test of obsolete lib)
Feb 15, 2024
f779f98
remove no-realloc-lhs compiler flag (alloc on assign) in github workflow
Feb 15, 2024
bf36df4
correct logic for nnkp generation
Feb 15, 2024
8e61b0e
close file with delete fails in parallel (problem: .werr left behind)
Feb 15, 2024
57d5621
correctly close stderr
Feb 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/config/make.inc.gfort
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ F90 = gfortran
#MPIF90 = mpgfortran #mpif90

# Options for debugging When we move to 4.9 add -fsanitize=leak
FCOPTS = -fprofile-arcs -ftest-coverage -fstrict-aliasing -fno-omit-frame-pointer -fno-realloc-lhs -fcheck=bounds,do,recursion,pointer -ffree-form -Wall -Waliasing -Wsurprising -Wline-truncation -Wno-tabs -Wno-uninitialized -Wno-unused-dummy-argument -Wno-unused -Wno-character-truncation -O1 -g -fbacktrace -std=f2008
LDOPTS = -fprofile-arcs -ftest-coverage -fstrict-aliasing -fno-omit-frame-pointer -fno-realloc-lhs -fcheck=bounds,do,recursion,pointer -ffree-form -Wall -Waliasing -Wsurprising -Wline-truncation -Wno-tabs -Wno-uninitialized -Wno-unused-dummy-argument -Wno-unused -Wno-character-truncation -O1 -g -fbacktrace -std=f2008
FCOPTS = -fprofile-arcs -ftest-coverage -fstrict-aliasing -fno-omit-frame-pointer -fcheck=bounds,do,recursion,pointer -ffree-form -Wall -Waliasing -Wsurprising -Wline-truncation -Wno-tabs -Wno-uninitialized -Wno-unused-dummy-argument -Wno-unused -Wno-character-truncation -O1 -g -fbacktrace -std=f2008 -DW90DEV
LDOPTS = -fprofile-arcs -ftest-coverage -fstrict-aliasing -fno-omit-frame-pointer -fcheck=bounds,do,recursion,pointer -ffree-form -Wall -Waliasing -Wsurprising -Wline-truncation -Wno-tabs -Wno-uninitialized -Wno-unused-dummy-argument -Wno-unused -Wno-character-truncation -O1 -g -fbacktrace -std=f2008

#=======================
# System LAPACK and BLAS
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/config/make.inc.gfort+openmpi
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ COMMS = mpi
MPIF90 = mpif90

# Options for debugging When we move to 4.9 add -fsanitize=leak
FCOPTS = -fprofile-arcs -ftest-coverage -fstrict-aliasing -fno-omit-frame-pointer -fno-realloc-lhs -fcheck=bounds,do,recursion,pointer -ffree-form -Wall -Waliasing -Wsurprising -Wline-truncation -Wno-tabs -Wno-uninitialized -Wno-unused-dummy-argument -Wno-unused -Wno-character-truncation -O1 -g -fbacktrace
LDOPTS = -fprofile-arcs -ftest-coverage -fstrict-aliasing -fno-omit-frame-pointer -fno-realloc-lhs -fcheck=bounds,do,recursion,pointer -ffree-form -Wall -Waliasing -Wsurprising -Wline-truncation -Wno-tabs -Wno-uninitialized -Wno-unused-dummy-argument -Wno-unused -Wno-character-truncation -O1 -g -fbacktrace
FCOPTS = -fprofile-arcs -ftest-coverage -fstrict-aliasing -fno-omit-frame-pointer -fcheck=bounds,do,recursion,pointer -ffree-form -Wall -Waliasing -Wsurprising -Wline-truncation -Wno-tabs -Wno-uninitialized -Wno-unused-dummy-argument -Wno-unused -Wno-character-truncation -O1 -g -fbacktrace -DW90DEV
LDOPTS = -fprofile-arcs -ftest-coverage -fstrict-aliasing -fno-omit-frame-pointer -fcheck=bounds,do,recursion,pointer -ffree-form -Wall -Waliasing -Wsurprising -Wline-truncation -Wno-tabs -Wno-uninitialized -Wno-unused-dummy-argument -Wno-unused -Wno-character-truncation -O1 -g -fbacktrace

#=======================
# System LAPACK and BLAS
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ TESTDIR=$(pwd)/test-suite/
echo $TESTDIR
cd "$TESTDIR"

echo "****************************************"
echo "* RUNNING SERIAL TEST FOR LIBRARY MODE *"
echo "****************************************"
cd library-mode-test
# Create the binary for testing
make
# remove the output file from old runs, if there
rm -f results.dat
# Run it - if it crashes it should give a non-zero error
./test_library_serial.x
# Check the output values
./compare_results.py

## Going back to the test dir
cd "$TESTDIR"

# Default: serial, no mpirun. Run these in any case
echo "************************"
echo "* RUNNING SERIAL TESTS *"
Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ The Wannier90 Developer Group includes:
* Arash A. Mostofi (Imperial College London, GB)
* Jonathan R. Yates (University of Oxford, GB)

In addition to the Wannier90 Developer Group, the other authors of Wannier90 v.4.x are:

* Jerome Jackson (STFC Daresbury Laboratory, UK): CCP9 code restructuring and parallel library design
* Leon Petit (STFC Daresbury Laboratory, UK): CCP9 code restructuring and parallel library design
* Barry G. Searle (STFC Daresbury Laboratory, UK): CCP9 code restructuring and parallel library design, python interface

In addition to the Wannier90 Developer Group, the other authors of Wannier90 v.3.x are:

* Ryotaro Arita (Riken and U. Tokyo, JP): Symmetry-adapted Wannier functions
Expand Down
17 changes: 10 additions & 7 deletions src/Makefile.2
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ $(DYNLIBRARY): $(OBJS) $(OBJS) $(OBJS_LIBV1)
clean:
rm -f *.o *.mod *.MOD *.obj

library_interface.o : ../library_interface.F90 \
comms.o constants.o error_base.o io.o kmesh.o overlap.o plot.o transport.o \
types.o wannier90_readwrite.o wannier90_types.o wannierise.o
$(COMPILER) $(POSTOPTS) $(FCOPTS) -c ../library_interface.F90

c_interface.o : ../c_interface.F90 \
library_interface.o comms.o constants.o error_base.o io.o kmesh.o overlap.o plot.o transport.o \
types.o wannier90_readwrite.o wannier90_types.o wannierise.o
$(COMPILER) $(POSTOPTS) $(FCOPTS) -c ../c_interface.F90

constants.o: ../constants.F90
$(COMPILER) $(POSTOPTS) $(FCOPTS) -c ../constants.F90

Expand Down Expand Up @@ -189,12 +199,5 @@ postw90_types.o: $(POSTDIR)postw90_types.F90 comms.o types.o utility.o constants
postw90_readwrite.o: $(POSTDIR)postw90_readwrite.F90 comms.o postw90_types.o types.o utility.o constants.o io.o error.o
$(COMPILER) $(POSTOPTS) $(FCOPTS) -c $(POSTDIR)postw90_readwrite.F90

wannier_lib.o: ./constants.o ./io.o ./utility.o ./types.o \
./hamiltonian.o ./kmesh.o ./overlap.o ./disentangle.o \
./wannierise.o ./plot.o ./transport.o ./wannier90_types.o \
./wannier90_readwrite.o ../wannier_lib.F90
$(COMPILER) $(POSTOPTS) $(FCOPTS) -c ../wannier_lib.F90


.PHONY: wannier libs post clean mpi_test w90spn2spn

5 changes: 1 addition & 4 deletions src/Makefile.header
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
OBJS = constants.o io.o utility.o types.o hamiltonian.o overlap.o kmesh.o disentangle.o \
ws_distance.o wannierise.o plot.o transport.o sitesym.o comms.o wannier90_types.o \
wannier90_readwrite.o readwrite.o error.o error_base.o

OBJS_LIBV1 = wannier_lib.o
wannier90_readwrite.o readwrite.o error.o error_base.o library_interface.o #c_interface.o

OBJS_POST = ws_distance.o types.o kmesh.o io.o comms.o utility.o get_oper.o constants.o \
postw90_common.o wan_ham.o spin.o dos.o berry.o gyrotropic.o kpath.o kslice.o \
boltzwann.o geninterp.o postw90_types.o postw90_readwrite.o readwrite.o \
error.o error_base.o

LIBRARY = ../../libwannier.a
LIBRARYV2 = ../../libwan2.a

## Dynamic library section
Expand Down
249 changes: 249 additions & 0 deletions src/c_interface.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@

module w90_library_c

!Fortran 2018: Assumed-length character dummy argument ‘keyword’ at (1) of procedure ‘cset_option_int’ with BIND(C) attribute
use iso_c_binding
use w90_library
implicit none
public
contains
type(c_ptr) function w90_create() bind(c)
! return a c-pointer to a instance of the wannier90 library data structure
type(lib_common_type), pointer :: common_data
allocate (common_data)
w90_create = c_loc(common_data)
end function

subroutine w90_delete(common_cptr) bind(c)
! deallocates/clears a c-pointer to a instance of the wannier90 library data structure
implicit none
type(c_ptr), value :: common_cptr
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
deallocate (common_fptr)
common_cptr = C_NULL_PTR
end subroutine w90_delete

subroutine cdisentangle(common_cptr, ierr) bind(c)
implicit none
type(c_ptr), value :: common_cptr
type(lib_common_type), pointer :: common_fptr
integer(kind=c_int) :: istdout, istderr, ierr
call w90_get_fortran_stderr(istderr)
call w90_get_fortran_stdout(istdout)
call c_f_pointer(common_cptr, common_fptr)
call w90_disentangle(common_fptr, istdout, istderr, ierr)
end subroutine cdisentangle

subroutine cwannierise(common_cptr, ierr) bind(c)
implicit none
type(c_ptr), value :: common_cptr
type(lib_common_type), pointer :: common_fptr
integer(kind=c_int) :: istdout, istderr, ierr
call w90_get_fortran_stderr(istderr)
call w90_get_fortran_stdout(istdout)
call c_f_pointer(common_cptr, common_fptr)
call w90_wannierise(common_fptr, istdout, istderr, ierr)
end subroutine cwannierise

subroutine cinput_setopt(common_cptr, seedname, ierr, comm) bind(c)
! specify parameters through the library interface
#ifdef MPI08
use mpi_f08
#endif
implicit none
type(c_ptr), value :: common_cptr
character(*, kind=c_char) :: seedname
type(lib_common_type), pointer :: common_fptr
integer(kind=c_int) :: istderr, istdout, ierr
#ifdef MPI08
type(mpi_comm), value :: comm
#else
integer(kind=c_int), value :: comm
#endif
call w90_get_fortran_stderr(istderr)
call w90_get_fortran_stdout(istdout)
call c_f_pointer(common_cptr, common_fptr)
call w90_input_setopt(common_fptr, seedname, comm, istdout, istderr, ierr)
end subroutine cinput_setopt

subroutine cinput_reader(common_cptr, ierr) bind(c)
! read (optional) parameters from .win file
implicit none
type(c_ptr), value :: common_cptr
type(lib_common_type), pointer :: common_fptr
integer(kind=c_int) :: istderr, istdout, ierr
call w90_get_fortran_stderr(istderr)
call w90_get_fortran_stdout(istdout)
call c_f_pointer(common_cptr, common_fptr)
call w90_input_reader(common_fptr, istdout, istderr, ierr)
end subroutine cinput_reader

subroutine cset_eigval(common_cptr, eigval_cptr) bind(c)
! copy a pointer to eigenvalue data
implicit none
type(c_ptr), value :: common_cptr, eigval_cptr
real(8), pointer :: eigval_fptr(:, :)
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(eigval_cptr, eigval_fptr, [common_fptr%num_bands, common_fptr%num_kpts])
call w90_set_eigval(common_fptr, eigval_fptr)
end subroutine cset_eigval

subroutine cset_m_local(common_cptr, m_cptr) bind(c)
! copy a pointer to m-matrix data
implicit none
type(c_ptr), value :: common_cptr, m_cptr
complex(8), pointer :: m_fptr(:, :, :, :)
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(m_cptr, m_fptr, [common_fptr%num_bands, common_fptr%num_bands, &
common_fptr%kmesh_info%nntot, common_fptr%num_kpts])
call w90_set_m_local(common_fptr, m_fptr)
end subroutine cset_m_local

subroutine cset_u_matrix(common_cptr, a_cptr) bind(c)
! copy pointer to u-matrix
implicit none
type(c_ptr), value :: common_cptr, a_cptr
complex(8), pointer :: a_fptr(:, :, :)
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(a_cptr, a_fptr, [common_fptr%num_wann, common_fptr%num_wann, &
common_fptr%num_kpts]) ! these are reversed wrt c
call w90_set_u_matrix(common_fptr, a_fptr)
end subroutine cset_u_matrix

subroutine cset_u_opt(common_cptr, a_cptr) bind(c)
! copy pointer to u-matrix (also used for initial projections)
implicit none
type(c_ptr), value :: common_cptr, a_cptr
complex(kind=8), pointer :: a_fptr(:, :, :)
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(a_cptr, a_fptr, [common_fptr%num_bands, common_fptr%num_wann, &
common_fptr%num_kpts]) ! these are reversed wrt c
call w90_set_u_opt(common_fptr, a_fptr)
end subroutine cset_u_opt

subroutine cget_nn(common_cptr, n) bind(c)
! return the number of adjacent k-points in finite difference scheme
implicit none
type(c_ptr), value :: common_cptr, n
type(lib_common_type), pointer :: common_fptr
integer(kind=c_int), pointer :: ndat
integer(kind=c_int) :: istderr, istdout, ierr
call w90_get_fortran_stderr(istderr)
call w90_get_fortran_stdout(istdout)
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(n, ndat)
call w90_get_nn(common_fptr, ndat, istdout, istderr, ierr)
end subroutine cget_nn

subroutine cget_nnkp(common_cptr, nnkp) bind(c)
! return the indexing of adjacent k-points in finite difference scheme
implicit none
type(c_ptr), value :: common_cptr, nnkp
type(lib_common_type), pointer :: common_fptr
integer(kind=c_int), pointer :: nfptr(:, :)
integer(kind=c_int) :: istderr, istdout, ierr
call w90_get_fortran_stderr(istderr)
call w90_get_fortran_stdout(istdout)
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(nnkp, nfptr, [common_fptr%num_kpts, common_fptr%kmesh_info%nntot])
call w90_get_nnkp(common_fptr, nfptr, istdout, istderr, ierr)
end subroutine cget_nnkp

subroutine cget_spreads(common_cptr, spreads) bind(c)
! returns the spreads of calulated mlwfs
implicit none
type(c_ptr), value :: common_cptr, spreads
type(lib_common_type), pointer :: common_fptr
real(kind=8), pointer :: fspreads(:)
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(spreads, fspreads, [common_fptr%num_wann])
call w90_get_spreads(common_fptr, fspreads)
end subroutine cget_spreads

subroutine cget_centres(common_cptr, centres) bind(c)
! returns the centres of calulated mlwfs
implicit none
type(c_ptr), value :: common_cptr, centres
type(lib_common_type), pointer :: common_fptr
real(kind=8), pointer :: fcentres(:, :)
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(centres, fcentres, [3, common_fptr%num_wann])
call w90_get_centres(common_fptr, fcentres)
end subroutine cget_centres

subroutine cset_option_int(common_cptr, keyword, ival) bind(c)
implicit none
type(c_ptr), value :: common_cptr
character(*, kind=c_char) :: keyword
integer(kind=c_int), value :: ival
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
call w90_set_option(common_fptr, keyword, ival)
end subroutine cset_option_int

subroutine cset_option_int3(common_cptr, keyword, ival) bind(c)
implicit none
type(c_ptr), value :: common_cptr
type(c_ptr) :: ival
integer(kind=c_int), pointer :: m_fptr(:)
character(*, kind=c_char) :: keyword
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(ival, m_fptr, [3])
call w90_set_option(common_fptr, keyword, m_fptr)
end subroutine cset_option_int3

subroutine cset_option_intx(common_cptr, keyword, ival, ict) bind(c)
implicit none
type(c_ptr), value :: common_cptr
type(c_ptr), value :: ival
character(*, kind=c_char) :: keyword
integer(kind=c_int), value :: ict
integer(kind=c_int), pointer :: m_fptr(:)
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
call c_f_pointer(ival, m_fptr, [ict])
call w90_set_option(common_fptr, keyword, m_fptr)
end subroutine cset_option_intx

subroutine cset_option_float(common_cptr, keyword, ival) bind(c)
implicit none
type(c_ptr), value :: common_cptr
character(*, kind=c_char) :: keyword
real(kind=c_double), value :: ival
type(lib_common_type), pointer :: common_fptr
call c_f_pointer(common_cptr, common_fptr)
call w90_set_option(common_fptr, keyword, ival)
end subroutine cset_option_float

subroutine cset_option_float33(common_cptr, keyword, ival) bind(c)
implicit none
type(c_ptr), value :: common_cptr
character(*, kind=c_char) :: keyword
type(c_ptr) :: ival
type(lib_common_type), pointer :: common_fptr
real(kind=8), pointer :: m_fptr(:, :)
call c_f_pointer(ival, m_fptr, [3, 3])
call c_f_pointer(common_cptr, common_fptr)
call w90_set_option(common_fptr, keyword, m_fptr)
end subroutine cset_option_float33

subroutine cset_option_floatxy(common_cptr, keyword, ival, x, y) bind(c)
implicit none
type(c_ptr), value :: common_cptr
character(*, kind=c_char) :: keyword
type(c_ptr), value :: ival
integer(kind=c_int), value :: x, y
type(lib_common_type), pointer :: common_fptr
real(kind=8), pointer :: m_fptr(:, :)
call c_f_pointer(ival, m_fptr, [y, x]) ! these are reversed wrt c
call c_f_pointer(common_cptr, common_fptr)
call w90_set_option(common_fptr, keyword, m_fptr)
end subroutine cset_option_floatxy

end module w90_library_c
Loading
Loading