More work on calling ldpc encoder/decoder from fortran.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6492 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Steven Franke 2016-02-24 01:50:57 +00:00
parent a0514e051b
commit 08bf465a47
4 changed files with 40 additions and 15 deletions

View File

@ -384,8 +384,19 @@ void iterprp
}
}
void ldpc_decode_ ( mod2sparse *H, double *lratio, char *dblk, char *pchk, double *bprb )
void ldpc_decode_ ( double *lratio, char *dblk, char *pchk, double *bprb )
{
int n;
int i, n;
n = prprp_decode ( H, lratio, dblk, pchk, bprb );
printf("in ldpc_decode n=%d\n");
printf("dblk: ");
for( i=0; i<128; i++) {
printf("%d",dblk[i]);
}
printf("\n");
printf("pchk: ");
for( i=0; i<46; i++) {
printf("%d",pchk[i]);
}
printf("\n");
}

View File

@ -155,9 +155,18 @@ void mixed_encode
// Wrapper for calling sparse_encode from fortran
void ldpc_encode_(
char msg[72],
char msg[82],
char cdw[128]
){
int i;
printf("msg: ");
for (i=0; i<82; i++) {
printf("%d", msg[i]); }
printf("\n");
sparse_encode(msg,cdw);
printf("cdw: ");
for (i=0; i<128; i++) {
printf("%d", cdw[i]); }
printf("\n");
}

View File

@ -16,4 +16,3 @@
void sparse_encode (char *, char *);
void dense_encode (char *, char *, mod2dense *, mod2dense *);
void mixed_encode (char *, char *, mod2dense *, mod2dense *);
void ldpc_encode_ (char *, char *);

View File

@ -2,22 +2,28 @@ program msksim
use, intrinsic :: iso_c_binding
parameter (N=128, M=46, K=82)
character(1) message(1:K)
character(1) codeword(1:N)
character(1) decoded(1:N)
real lratio(N), bitprobs(N)
character(1) pchk
parameter (N=128, M=46, K=82) ! M and N are global variables on the C side.
integer(1) message(1:K)
integer(1) codeword(1:N)
integer(1) decoded(1:N)
integer(1) pchk(1:M)
real*8 lratio(N), bitprobs(N)
write(*,*) "calling init_ldpc"
call init_ldpc()
message(1:K)=char(0)
write(*,*) "message: ",message
message(1:K)=0
message(10)=1
write(*,*) "calling ldpc_encode"
call ldpc_encode(message,codeword)
write(*,*) "codeword: ",codeword
write(*,*) "calling ldpc_decode"
do i=1,N
lratio(i)=exp(2.0*(codeword(i)-0.5))
enddo
lratio(10)=10.0
bitprobs(1:N)=0.0 ! shouldn't need this
call ldpc_decode(lratio, decoded, pchk, bitprobs)
write(*,*) decoded
do i=1,N
write(*,*) i,bitprobs(i), lratio(i)
enddo
end program msksim