       program binariza 
       real mask(241,161),slp(241,161),ps(241,161),topo(241,161)
       real uvel(241,161,37),vvel(241,161,37),zgeo(241,161,37),umes(241,161,37),temp(241,161,37)
       real tmps1(241,161),tmps2(241,161),umrs1(241,161),umrs2(241,161) 
       real tmps3(241,161),tmps4(241,161),umrs3(241,161),umrs4(241,161)
       real last(241,161,12)
       real var(37),vari(37),mrsat
       integer z,nz,nx,ny,it,k,i,j
       
        z=37
 	var(1)=1000
	var(2)=975
	var(3)=950
	var(4)=925
	var(5)=900
	var(6)=875
	var(7)=850
	var(8)=825
	var(9)=800 
	var(10)=775
	var(11)=750
	var(12)=700 
        var(13)=650
	var(14)=600
        var(15)=550 
        var(16)=500 
        var(17)=440 
        var(18)=400 
        var(19)=350 
        var(20)=300 
        var(21)=250
	var(22)=225
	var(23)=200
	var(24)=175
        var(25)=150
	var(26)=125
	var(27)=100
	var(28)=70
	var(29)=50
	var(30)=30
	var(31)=20
	var(32)=10
        var(33)=7
	var(34)=5
	var(35)=3
	var(36)=2
	var(37)=1
	
	
                	
       OPEN(unit=11,file='entrada',form='unformatted',access='direct',status='old',recl=241*161*4)
       
       OPEN(unit=8,file='saida',access='sequential',form='unformatted',status='unknown')
    
       do 20 i=1,z,1
       j=i
       read(11,rec=j) uvel(:,:,i) 
   20  continue 

       do 30 i=1,z,1
       j=i+z
       read(11,rec=j) vvel(:,:,i) 
   30  continue        
       
       do 40 i=1,z,1
       j=i+z+z
       read(11,rec=j) zgeo(:,:,i) 
   40  continue 
 
       do 50 i=1,z,1
       j=i+z+z+z
       read(11,rec=j) umes(:,:,i) 
   50  continue
   
       do 60 i=1,z,1
       j=i+z+z+z+z
       read(11,rec=j) temp(:,:,i) 
   60  continue   
   
       read(11,rec=z+z+z+z+z+1) mask(:,:)
       read(11,rec=z+z+z+z+z+2) slp(:,:)
       read(11,rec=z+z+z+z+z+3) ps(:,:)
       read(11,rec=z+z+z+z+z+4) topo(:,:)
       read(11,rec=z+z+z+z+z+5) tmps1(:,:)
       read(11,rec=z+z+z+z+z+6) umrs1(:,:)
       read(11,rec=z+z+z+z+z+7) tmps2(:,:)
       read(11,rec=z+z+z+z+z+8) umrs2(:,:)
       read(11,rec=z+z+z+z+z+9) tmps3(:,:)
       read(11,rec=z+z+z+z++z10) umrs3(:,:)
       read(11,rec=z+z+z+z++z11) tmps4(:,:)
       read(11,rec=z+z+z+z++z12) umrs4(:,:)
       
      
       mask=-99999.00
       last(:,:,1)= mask(:,:)     
       last(:,:,2)= slp(:,:)
       last(:,:,3)= ps(:,:)     
       last(:,:,4)= topo(:,:)
       last(:,:,5)= tmps1(:,:)
       last(:,:,6)= umrs1(:,:)
       last(:,:,7)= tmps2(:,:)
       last(:,:,8)= umrs2(:,:)
       last(:,:,9)= tmps3(:,:)
       last(:,:,10)= umrs3(:,:)
       last(:,:,11)= tmps4(:,:)
       last(:,:,12)= umrs4(:,:)
  
       write(8) z
       
       write(8) uvel
       
       write(8) vvel
       
       write(8) zgeo
       
       write(8) umes
       
       write(8) temp
       
       write(8) var
       
       write(8) last
       
       end

