ugly but working
This commit is contained in:
parent
86553a65b5
commit
f8d5e66a5c
|
@ -0,0 +1,2 @@
|
|||
call_the_c
|
||||
*.o
|
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# 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 $@
|
||||
|
||||
# ----------------------------------------------------------
|
|
@ -0,0 +1,12 @@
|
|||
# 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.
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
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
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
/* --------------------------------------------------------------- */
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* SOUNDFILES
|
||||
* ----------
|
||||
*
|
||||
* Interface pour libsndfile
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
/* --------------------------------------------------------------- */
|
Loading…
Reference in New Issue