Program example; animation of binomial distribution

As an example of a program generating a series of consecutively numbered PostScript files is available here. It generates and displays a series of binomial distributions. The following subroutine is used by the program to name and open ps files animxyz.ps, where xyz is given by the argument frameno. It also creates a square frame, which acts as a bounding box when the -trim option is used in the format conversion. Finally, it rescales the box to be of size 100x100.
  subroutine initframe(frameno)
  implicit none

  integer :: i1,i2,i3,frameno
  character(16) :: fname

  i3=frameno/100
  i2=mod(frameno,100)/10
  i1=mod(frameno,10)
  fname='anim000.ps'
  fname(5:5)=achar(48+i3)
  fname(6:6)=achar(48+i2)
  fname(7:7)=achar(48+i1)
  open(1,file=fname,status='replace')
  write(1,*)'%!'
  write(1,*)'1 1 scale 0 0 translate 0.5 0.5 moveto'
  write(1,*)'612 0 rlineto 0 612 rlineto -612 0 rlineto 0 -612 rlineto'
  write(1,*)'closepath stroke'
  write(1,*)'6.12 6.12 scale'
   
  end subroutine initframe
The animation below is in gif-format, it was created from the ps files using convert as discussed above.