Is there an equivalent Matlab dec2bin function in fortran? : I would like to find a similar function as dec2bin(d,n) in Matlab, which produces a binary representation with at least n bits, for fortran. Online I found the following code: 

https://fr.scribd.com/doc/207122116/Program-to-Do-Decimal-to-Binary-Conversion-in-Fortran

It converts decimal to binary but we don't decide the number of bits and it asks for the user to decide whether its a positive integer or a positive real number so not very handy. 

Thank you in advance for your help, I am new to fortran. 