From abadfc3e9cce4fa7d056da0221fb560a368d9772 Mon Sep 17 00:00:00 2001 From: ahbarnett Date: Wed, 3 Feb 2021 21:21:39 -0500 Subject: [PATCH] readme bullets --- README.md | 6 +++--- ccallj/README.md | 18 +++++++++--------- fcallj/README.md | 4 ++-- jcallf/README.md | 6 +++--- jcallf/demo1.f | 6 +++--- jcallf/demomp.f90 | 6 +++--- jcallf/demomp.jl | 4 ++-- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index af3c218..c84d4f9 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,11 @@ Recent Julia installed, C complier, Fortran compiler, GNU `make`. ### Testing -`cp make.inc.example make.inc` +1. `cp make.inc.example make.inc` -Edit `make.inc` for your Julia installation directory and choice of compilers +1. Edit `make.inc` for your Julia installation directory and choice of compilers -`make` +1. `make` This goes to each directory and makes/runs all examples. Total wall-clock time is around 20 seconds. diff --git a/ccallj/README.md b/ccallj/README.md index a586e82..0d5fc5b 100644 --- a/ccallj/README.md +++ b/ccallj/README.md @@ -26,21 +26,21 @@ Take a look: there is a function `foomp` (and its variants) that we want to acce Hello-world example: -`codestring` : call single line of julia code, no passing of values; straight from the manual +* `codestring` : call single line of julia code, no passing of values; straight from the manual Julia convention (style 1): -`basefunc` : pass scalar input and output to a single existing (Base) julia function; from manual -`basearr` : array I/O to existing (Base) julia func; similar to manual 30.6 -`modulearr` : array I/O to user julia func in module; from above SO post. J allocs the output array. Fails only if multithreaded -`modulearr2` : same, except Fortran-style, output array preallocated on the C side. Works multithreaded +* `basefunc` : pass scalar input and output to a single existing (Base) julia function; from manual +* `basearr` : array I/O to existing (Base) julia func; similar to manual 30.6 +* `modulearr` : array I/O to user julia func in module; from above SO post. J allocs the output array. Fails only if multithreaded +* `modulearr2` : same, except Fortran-style, output array preallocated on the C side. Works multithreaded Cfunction wrapping convention (style 2): -`cfunction1` : basic call of native jl func with scalar I/O -`cfunction2` : call user-defined jl func with scalar I/O -`cfunctionarr` : call user-defined jl func, with array input -`cfuncmodarr` : call user-defined jl func in a module, with array I/O, timing +* `cfunction1` : basic call of native jl func with scalar I/O +* `cfunction2` : call user-defined jl func with scalar I/O +* `cfunctionarr` : call user-defined jl func, with array input +* `cfuncmodarr` : call user-defined jl func in a module, with array I/O, timing ### Notes diff --git a/fcallj/README.md b/fcallj/README.md index 51190a5..52450ea 100644 --- a/fcallj/README.md +++ b/fcallj/README.md @@ -9,9 +9,9 @@ Use `make` to build and run. We skip the trivial examples and go straight to passing arrays, with multithreading, and timers in there too. They wrap `foomp2` from the julia module `ArrModF` (which is essentially the same as the one in the `../ccallj` directory). -`modulearr` : array I/O, with output array also allocated on the F side. The Fortran driver is `modulearr.f90`, and `jlfortwrapper.c` is the intermediate C layer. Recommended example. +* `modulearr` : array I/O, with output array also allocated on the F side. The Fortran driver is `modulearr.f90`, and `jlfortwrapper.c` is the intermediate C layer. Recommended example. -`modulearr_old_style1` : same goal as above, but more clunky code that uses in C the `jl_*` Julia convention interface. The intermediate layer is `cwrapper_old_style1.c`. This generalizes less well to more complex function signatures. +* `modulearr_old_style1` : same goal as above, but more clunky code that uses in C the `jl_*` Julia convention interface. The intermediate layer is `cwrapper_old_style1.c`. This generalizes less well to more complex function signatures. ### Notes diff --git a/jcallf/README.md b/jcallf/README.md index 7d1b393..5dfa867 100644 --- a/jcallf/README.md +++ b/jcallf/README.md @@ -1,14 +1,14 @@ ## Examples of julia calling Fortran. These use the `ccall` julia function. It's very easy, although care over -`Ref` or passing pointers (eg, via everything being an array) is needed. +`Ref` or passing pointers (eg, via making a length-1 array on the Julia side) is needed. Run `make` to build and run. ### Examples -`demo1` : scalar and array float I/O -`demomp` : array I/O with OpenMP +* `demo1` : scalar and array float I/O +* `demomp` : array I/O with OpenMP ### Notes diff --git a/jcallf/demo1.f b/jcallf/demo1.f index a3267c8..368a51e 100644 --- a/jcallf/demo1.f +++ b/jcallf/demo1.f @@ -1,9 +1,9 @@ -c compile into a shared object via: +c Compile into a shared object via: c gfortran demo1.f -o demo1.so -shared -fPIC -c seems like need to restart julia to take effect (reimport the .so) +c Seems like need to restart julia to take effect (reimport the .so) SUBROUTINE MULTIPLY(A,B,C) -c multiplies two floats +c multiplies two doubles real*8 A,B,C c print *,'A=',A C = A*B diff --git a/jcallf/demomp.f90 b/jcallf/demomp.f90 index 7ad1ee9..5236ec1 100644 --- a/jcallf/demomp.f90 +++ b/jcallf/demomp.f90 @@ -1,8 +1,8 @@ -! demo calling OMP routine in Fortran90. -! compile into a shared object; see makefile. +! Demo calling OMP routine in Fortran90. +! Compile into a shared object; see makefile. SUBROUTINE sumexp(a,ans,n) - ! sums the exp of real array a, length n + ! sums the exp of double array a, length n use omp_lib ! needed to access types of omp_ calls implicit none integer*8 n,i diff --git a/jcallf/demomp.jl b/jcallf/demomp.jl index 5813ac9..914c50c 100644 --- a/jcallf/demomp.jl +++ b/jcallf/demomp.jl @@ -2,8 +2,8 @@ # Also times it. Barnett 12/28/20 n=Int64(1e8) -a = 10*rand(n).-5.0 # don't forget dot! -b = [0.0] # alloc output value (ptr, since 1-size array) +a = 10*rand(n) .- 5.0 # don't forget dot! +b = [0.0] # alloc output value (ptr, since 1-size array) println("start ccall...") # here timed returns struct; we want 2nd element dummy,t = @timed ccall((:sumexp_, "demomp.so"), Cvoid, (Ref{Float64},Ref{Float64},Ref{Int64}),a,b,Ref(n))