| 
									
										
										
										
											2020-05-04 13:13:49 -05:00
										 |  |  | subroutine encode174_91_nocrc(message,codeword)
 | 
					
						
							|  |  |  | !
 | 
					
						
							| 
									
										
										
										
											2020-05-05 14:05:46 -05:00
										 |  |  | ! Encode a 91-bit message and return a 174-bit codeword.
 | 
					
						
							| 
									
										
										
										
											2020-05-04 13:13:49 -05:00
										 |  |  | !
 | 
					
						
							| 
									
										
										
										
											2020-05-05 14:05:46 -05:00
										 |  |  |    use, intrinsic :: iso_c_binding
 | 
					
						
							|  |  |  |    use iso_c_binding, only: c_loc,c_size_t
 | 
					
						
							|  |  |  |    use crc
 | 
					
						
							| 
									
										
										
										
											2020-05-04 13:13:49 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 14:05:46 -05:00
										 |  |  |    integer, parameter:: N=174, K=91, M=N-K
 | 
					
						
							|  |  |  |    integer*1 codeword(N)
 | 
					
						
							|  |  |  |    integer*1 gen(M,K)
 | 
					
						
							|  |  |  |    integer*1 message(K)
 | 
					
						
							|  |  |  |    integer*1 pchecks(M)
 | 
					
						
							|  |  |  |    include "ldpc_174_91_c_generator.f90"
 | 
					
						
							|  |  |  |    logical first
 | 
					
						
							|  |  |  |    data first/.true./
 | 
					
						
							|  |  |  |    save first,gen
 | 
					
						
							| 
									
										
										
										
											2020-05-04 13:13:49 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 14:05:46 -05:00
										 |  |  |    if( first ) then ! fill the generator matrix
 | 
					
						
							|  |  |  |       gen=0
 | 
					
						
							|  |  |  |       do i=1,M
 | 
					
						
							|  |  |  |          do j=1,23
 | 
					
						
							|  |  |  |             read(g(i)(j:j),"(Z1)") istr
 | 
					
						
							|  |  |  |             ibmax=4
 | 
					
						
							|  |  |  |             if(j.eq.23) ibmax=3
 | 
					
						
							|  |  |  |             do jj=1, ibmax
 | 
					
						
							|  |  |  |                icol=(j-1)*4+jj
 | 
					
						
							|  |  |  |                if( btest(istr,4-jj) ) gen(i,icol)=1
 | 
					
						
							|  |  |  |             enddo
 | 
					
						
							|  |  |  |          enddo
 | 
					
						
							|  |  |  |       enddo
 | 
					
						
							|  |  |  |       first=.false.
 | 
					
						
							|  |  |  |    endif
 | 
					
						
							| 
									
										
										
										
											2020-05-04 13:13:49 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 14:05:46 -05:00
										 |  |  |    do i=1,M
 | 
					
						
							|  |  |  |       nsum=0
 | 
					
						
							|  |  |  |       do j=1,K
 | 
					
						
							|  |  |  |          nsum=nsum+message(j)*gen(i,j)
 | 
					
						
							|  |  |  |       enddo
 | 
					
						
							|  |  |  |       pchecks(i)=mod(nsum,2)
 | 
					
						
							|  |  |  |    enddo
 | 
					
						
							| 
									
										
										
										
											2020-05-04 13:13:49 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 14:05:46 -05:00
										 |  |  |    codeword(1:K)=message
 | 
					
						
							|  |  |  |    codeword(K+1:N)=pchecks
 | 
					
						
							| 
									
										
										
										
											2020-05-04 13:13:49 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 14:05:46 -05:00
										 |  |  |    return
 | 
					
						
							| 
									
										
										
										
											2020-05-04 13:13:49 -05:00
										 |  |  | end subroutine encode174_91_nocrc
 |