program poly
  
  implicit none
  
  integer :: i
  real :: u
  type polynome
     integer :: degre
     real, dimension(100):: coeffs
  end type polynome
  
  type(polynome) :: P
  character(len=500) ::ch
  integer :: clen

  P =  initialize_pol(5)
  P%coeffs(6) = 5.
  
 
  call print_pol(P,ch)

 
 
contains

  function initialize_pol(n)
    integer :: n
    type(polynome) :: initialize_pol

     initialize_pol%degre = n
     initialize_pol%coeffs = 0.
   end function initialize_pol


   subroutine print_pol(P,ch)

     character(len=500) :: ch
     type(polynome) :: P
     integer :: n
     character(len=10) :: form
     n = len(ch)
     
    ! form = 'elle'
    !form = trim(form)//'rrr'
    ! print*, form
     write(form,fmt='(1i3)'),P%degre
     
     ch = trim(form)//''
    
     do i=1,P%degre+1
        write(form,'(1f5.2)'),P%coeffs(i)
       ch = trim(ch)//trim(form)//''       
     enddo
    print*, 'Le polynome est ', ch
    
   end subroutine print_pol

end program poly
