Compare commits
No commits in common. "f8d5e66a5cdd60f065e007e0efed735437c409a6" and "86b1e9e01102c35c59c24faf4811e44bd23b7ee4" have entirely different histories.
f8d5e66a5c
...
86b1e9e011
2
Call_the_C/.gitignore
vendored
2
Call_the_C/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
call_the_c
|
|
||||||
*.o
|
|
@ -1,20 +0,0 @@
|
|||||||
#
|
|
||||||
# Fortran calls to a C function
|
|
||||||
#
|
|
||||||
|
|
||||||
all: call_the_c
|
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
|
|
||||||
first-try.o: first-try.c Makefile
|
|
||||||
gcc -Wall -g -c $<
|
|
||||||
|
|
||||||
soundfiles.o: soundfiles.c Makefile
|
|
||||||
gcc -Wall -g -c $<
|
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
|
|
||||||
call_the_c: call_the_c.f90 Makefile first-try.o
|
|
||||||
gfortran -Wall -g $< first-try.o -o $@
|
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
|
@ -1,12 +0,0 @@
|
|||||||
# Calling a C function
|
|
||||||
|
|
||||||
WARNING : THIS IS A WIP !
|
|
||||||
|
|
||||||
## Unix utilities
|
|
||||||
|
|
||||||
getpid, sleep, ...
|
|
||||||
|
|
||||||
## libsndfile
|
|
||||||
|
|
||||||
Bibliothèque de fonctions pour lire et écrire les fichiers sonores.
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
program call_the_c
|
|
||||||
implicit none
|
|
||||||
|
|
||||||
integer :: foo
|
|
||||||
integer, external :: give_me_my_pid
|
|
||||||
|
|
||||||
print *, "XXX we are calling a C func"
|
|
||||||
call first_try ()
|
|
||||||
foo = give_me_my_pid()
|
|
||||||
print *, "process id = ", foo
|
|
||||||
print *, "XXX are we alive ?"
|
|
||||||
|
|
||||||
end program
|
|
||||||
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* first try of a C func called from Fortran
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------- */
|
|
||||||
void first_try_(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr, " pid=%u file='%s' func='%s' \n",
|
|
||||||
(long)getpid(), __FILE__, __func__);
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------- */
|
|
||||||
long give_me_my_pid_ (void)
|
|
||||||
{
|
|
||||||
pid_t my_pid;
|
|
||||||
|
|
||||||
my_pid = (long)getpid();
|
|
||||||
fprintf(stderr, " %s -> %d\n", __func__, my_pid);
|
|
||||||
|
|
||||||
return my_pid;
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------- */
|
|
@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
* SOUNDFILES
|
|
||||||
* ----------
|
|
||||||
*
|
|
||||||
* Interface pour libsndfile
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------- */
|
|
||||||
/* --------------------------------------------------------------- */
|
|
@ -1,48 +0,0 @@
|
|||||||
|
|
||||||
module centermag
|
|
||||||
implicit none
|
|
||||||
!-----------------------------------------------------------------------
|
|
||||||
! definition of structures
|
|
||||||
!-
|
|
||||||
type t_centermag
|
|
||||||
integer :: wscr, hscr ! "physycal" screen size
|
|
||||||
real :: mag = 1.0 ! magnitude factor
|
|
||||||
real :: cx, cy ! the center
|
|
||||||
|
|
||||||
integer :: flag = 0
|
|
||||||
end type
|
|
||||||
!-------------------------------------------------------------------
|
|
||||||
contains
|
|
||||||
!-------------------------------------------------------------------
|
|
||||||
subroutine print_centermag (cm)
|
|
||||||
type(t_centermag), intent(in) :: cm
|
|
||||||
|
|
||||||
print *, "Screen ", cm%wscr, cm%hscr
|
|
||||||
print *, "MagFactor ", cm%mag
|
|
||||||
print *, "Center ", cm%cx, cm%cy
|
|
||||||
|
|
||||||
end subroutine
|
|
||||||
!-------------------------------------------------------------------
|
|
||||||
subroutine centermag_scr2real (sx, sy, rx, ry)
|
|
||||||
integer, intent(in) :: sx, sy
|
|
||||||
real, intent(out) :: rx, ry
|
|
||||||
|
|
||||||
print *, 'from scr :', sx, sy
|
|
||||||
|
|
||||||
rx = 999.999
|
|
||||||
ry = 666.666
|
|
||||||
|
|
||||||
end subroutine
|
|
||||||
!-------------------------------------------------------------------
|
|
||||||
subroutine centermag_real2scr (rx, ry, sx, sy)
|
|
||||||
real, intent(in) :: rx, ry
|
|
||||||
integer, intent(out) :: sx, sy
|
|
||||||
|
|
||||||
print *, 'from real :', rx, ry
|
|
||||||
|
|
||||||
sx = -1
|
|
||||||
sy = -1
|
|
||||||
|
|
||||||
end subroutine
|
|
||||||
!-------------------------------------------------------------------
|
|
||||||
end module
|
|
@ -1,33 +0,0 @@
|
|||||||
module mathstuff2
|
|
||||||
|
|
||||||
! XXX This module was a copy of mathstuff.f90 fromthe BloubWorld
|
|
||||||
! XXX will be moved in an other place some day...
|
|
||||||
|
|
||||||
implicit none
|
|
||||||
contains
|
|
||||||
|
|
||||||
! ----------------------------------------------------------------
|
|
||||||
! really quick'n'dirty hack
|
|
||||||
! not really tested yet...
|
|
||||||
|
|
||||||
subroutine init_random_seed()
|
|
||||||
|
|
||||||
integer, dimension(3) :: tarray
|
|
||||||
integer :: t3, foo
|
|
||||||
real :: dummy
|
|
||||||
call itime(tarray)
|
|
||||||
t3 = 3600*tarray(1) + 60*tarray(2) + tarray(3)
|
|
||||||
! write(0, '(A,3I3,A,I6)') "sranding: ", tarray, " --> ", t3
|
|
||||||
call srand(t3)
|
|
||||||
|
|
||||||
! after initializing the random generator engine,
|
|
||||||
! you MUST use it for initializing the initializer
|
|
||||||
do foo=1, tarray(1)+5
|
|
||||||
dummy = rand()
|
|
||||||
enddo
|
|
||||||
|
|
||||||
end subroutine
|
|
||||||
|
|
||||||
! ----------------------------------------------------------------
|
|
||||||
end module mathstuff2
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user