diff --git a/lib/ldpc/Makefile b/lib/ldpc/Makefile index 13c372303..5f539ee84 100755 --- a/lib/ldpc/Makefile +++ b/lib/ldpc/Makefile @@ -70,7 +70,6 @@ progs: modules $(LINK) verify.o mod2sparse.o mod2dense.o mod2convert.o check.o \ rcode.o alloc.o intio.o blockio.o open.o -lm -o verify - # MAKE THE TEST PROGRAMS. First makes the modules used. tests: modules diff --git a/lib/ldpc/Makefile.msk_osx b/lib/ldpc/Makefile.msk_osx new file mode 100644 index 000000000..265871ec6 --- /dev/null +++ b/lib/ldpc/Makefile.msk_osx @@ -0,0 +1,39 @@ +# Compilers +CC = gcc +CXX = g++ +FC = gfortran +AR = ar cr +RANLIB = ranlib +MKDIR = mkdir -p +CP = cp +RM = rm -f + +FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion +CFLAGS = -O2 -I. + +# Default rules +%.o: %.c + ${CC} ${CFLAGS} -c $< +%.o: %.f + ${FC} ${FFLAGS} -c $< +%.o: %.F + ${FC} ${FFLAGS} -c $< +%.o: %.f90 + ${FC} ${FFLAGS} -c $< +%.o: %.F90 + ${FC} ${FFLAGS} -c $< + +all: msksim + +OBJS = msksim.o alloc.o rcode.o channel.o dec.o enc.o \ + intio.o blockio.o check.o open.o mod2dense.o \ + mod2sparse.o mod2convert.o distrib.o rand.o + +msksim: $(OBJS) + $(FC) -o msksim $(OBJS) + +rand.o: + $(CC) -DRAND_FILE=\"`pwd`/randfile\" rand.c + +clean: + $(RM) *.o msksim diff --git a/lib/ldpc/dec.c b/lib/ldpc/dec.c index fa4f8f939..63c2bebcd 100755 --- a/lib/ldpc/dec.c +++ b/lib/ldpc/dec.c @@ -383,3 +383,9 @@ void iterprp } } } + +void ldpc_decode_ ( mod2sparse *H, double *lratio, char *dblk, char *pchk, double *bprb ) +{ + int n; + n = prprp_decode ( H, lratio, dblk, pchk, bprb ); +} diff --git a/lib/ldpc/enc.c b/lib/ldpc/enc.c index 0ff1520a7..df04d5a83 100755 --- a/lib/ldpc/enc.c +++ b/lib/ldpc/enc.c @@ -152,3 +152,12 @@ void mixed_encode { cblk[cols[j]] = mod2dense_get(v,j,0); } } + +// Wrapper for calling sparse_encode from fortran +void ldpc_encode_( +char msg[72], +char cdw[128] +){ + sparse_encode(msg,cdw); +} + diff --git a/lib/ldpc/enc.h b/lib/ldpc/enc.h index c36e92927..083b5f52f 100755 --- a/lib/ldpc/enc.h +++ b/lib/ldpc/enc.h @@ -16,3 +16,4 @@ void sparse_encode (char *, char *); void dense_encode (char *, char *, mod2dense *, mod2dense *); void mixed_encode (char *, char *, mod2dense *, mod2dense *); +void ldpc_encode_ (char *, char *); diff --git a/lib/ldpc/rcode.c b/lib/ldpc/rcode.c index 3ccf20c51..15b091f45 100755 --- a/lib/ldpc/rcode.c +++ b/lib/ldpc/rcode.c @@ -198,3 +198,20 @@ garbled: fprintf(stderr,"Garbled generator matrix in file %s\n",gen_file); exit(1); } + +// Fortran interface routine +void init_ldpc_ ( ) +{ + char *pchk_file,*gen_file; + pchk_file="./jtmode_codes/ldpc-128-82-sf11.pchk"; + gen_file="./jtmode_codes/ldpc-128-82-sf11.gen"; + + printf("pchk_file %s\n",pchk_file); + printf("gen_file %s\n",gen_file); + + read_pchk( pchk_file ); + read_gen( gen_file, 0, 0 ); + + printf("N %d M %d\n",N,M); +} +