#!/usr/bin/env ruby

require "getoptlong"

parser = GetoptLong.new
parser.set_options(
                   ###    global option   ###
                   ['--Num',         GetoptLong::REQUIRED_ARGUMENT],
                   ['--info',         GetoptLong::REQUIRED_ARGUMENT]
                   )
begin
  parser.each_option do |name, arg|
    eval "$OPT_#{name.sub(/^--/, '').gsub(/-/, '_')} = '#{arg}'" 
  end
    rescue
  exit(1)
end

info = $OPT_info
num =  $OPT_Num.to_i

# ¿Þ¤ÎÅý¹ç

for l in 0..num
  time = sprintf("%05d", l+1)

  outputfile  = info+"-Anim_"+time.to_s+".jpg"  
  outputfile1 = info+"_VelZ_"+time.to_s+".jpg"  
  outputfile2 = info+"_DensCloud_"+time.to_s+".jpg"  
  outputfile3 = info+"_PotTempDist_"+time.to_s+".jpg"  
  outputfile4 = info+"_Exner_"+time.to_s+".jpg"  

  convert1 = "convert -geometry 600x600 +append "+outputfile1+" "+outputfile2+" tmp1.jpg"
  system( convert1 )
  p convert1  

  convert2 = "convert -geometry 600x600 +append "+outputfile3+" "+outputfile4+" tmp2.jpg"
  system( convert2 )
  p convert2

  convert3 = "convert -append tmp1.jpg tmp2.jpg "+outputfile
  system( convert3 )
  p convert3
end
