Skip to content

Commit

Permalink
readme bullets
Browse files Browse the repository at this point in the history
  • Loading branch information
ahbarnett committed Feb 4, 2021
1 parent d2de993 commit abadfc3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
18 changes: 9 additions & 9 deletions ccallj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions fcallj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions jcallf/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 3 additions & 3 deletions jcallf/demo1.f
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions jcallf/demomp.f90
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions jcallf/demomp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit abadfc3

Please sign in to comment.