1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-19 12:32:40 +01:00

Added some iso_c_bindings

This commit is contained in:
Anthony Scemama 2020-10-14 01:43:13 +02:00
parent be89fd6fe2
commit baf48d1987
3 changed files with 65 additions and 18 deletions

View File

@ -1,11 +1,18 @@
CC=gcc
CFLAGS=
FC=gfortran
FFLAGS=
SOURCE_FILES=$(wildcard *.org)
%.o: %.c.org
- emacs --quick --no-init-file --batch --eval "(require 'org)" --eval '(org-babel-tangle-file "$^")'
- $(CC) $(CFLAGS) -c $*.c -o $@
- rm -f $*.c $*.h
%.c %_f.f90 %.h: %.c.org
emacs --quick --no-init-file --batch --eval "(require 'org)" --eval '(org-babel-tangle-file "$^")'
%.o: %.c
$(CC) $(CFLAGS) -c $*.c -o $*.o
%.o: %.f90
$(FC) $(FFLAGS) -c $*.f90 -o $*.o

View File

@ -2,15 +2,16 @@
** Introduction
Source files are written in org-mode format, to provide useful comments and
LaTex formulas close to the code. There exists multiple possibilities to convert
org-mode files into different formats such as HTML or pdf.
Source files are written in org-mode format, to provide useful
comments and LaTex formulas close to the code. There exists multiple
possibilities to convert org-mode files into different formats such as
HTML or pdf.
The code is extracted from the org files using Emacs in the =Makefile=, and
then the produced files are compiled.
The code is extracted from the org files using Emacs in the =Makefile=,
and then the produced files are compiled.
For a better experience, editing can be done with Emacs. Note that Emacs can
behave like Vim when switched into ``Evil'' mode.
For a better experience, editing can be done with Emacs. Note that
Emacs can behave like Vim when switched into ``Evil'' mode.
** Documentation

View File

@ -1,5 +1,9 @@
# -*- mode: org -*-
This file is written in C because it is more natural to express the context in
C than in Fortran. This file also produces the Fortran binding.
#+BEGIN_SRC C :tangle qmckl_context.c
#include <stdlib.h> /* malloc */
#include "qmckl_context.h"
@ -15,7 +19,7 @@
#define QMCKL_DEFAULT_PRECISION 53
#define QMCKL_DEFAULT_RANGE 2
typedef long int qmckl_context ;
typedef long long int qmckl_context ;
#+END_SRC
@ -53,6 +57,22 @@ qmckl_context qmckl_context_create() {
}
#+END_SRC
#+BEGIN_SRC fortran :tangle qmckl_context_f.f90
integer(8) function qmckl_context_create()
use, intrinsic :: iso_c_binding
implicit none
interface
integer(c_long_long) function c_qmckl_context_create() &
bind(C, name='qmckl_context_create')
use, intrinsic :: iso_c_binding, only : c_long_long
end function
end interface
qmckl_context_create = c_qmckl_context_create()
end
#+END_SRC
#+BEGIN_SRC C :tangle qmckl_context.h
qmckl_context qmckl_context_copy(qmckl_context context);
@ -80,6 +100,25 @@ qmckl_context qmckl_context_copy(qmckl_context context) {
#+END_SRC
#+BEGIN_SRC fortran :tangle qmckl_context_f.f90
integer(8) function qmckl_context_copy(context)
use, intrinsic :: iso_c_binding
implicit none
integer(8), intent(in) :: context
interface
integer(c_long_long) function c_qmckl_context_copy(context) &
bind(C, name='qmckl_context_copy')
use, intrinsic :: iso_c_binding, only : c_long_long
integer(c_long_long), intent(in) :: context
end function
end interface
qmckl_context_copy = c_qmckl_context_copy(context)
end
#+END_SRC
* Precision
The following functions set the expected required precision and range.