PROGRAM opentiff

 INTEGER*1, DIMENSION(:,:), ALLOCATABLE :: TiffDataB, Out   
 INTEGER                                :: istat, i, j, nx, ny
 REAL, DIMENSION(:,:), ALLOCATABLE      :: dummy, TiffDataA, Temp
 nx = 5900
 ny = 4200

 ALLOCATE(TiffDataB(nx,ny), dummy(nx,ny), TiffDataA(nx,ny), Temp(nx,ny), Out(nx, ny))
 
!!OPEN BINARY MODE - 1BYTE 
! OPEN(UNIT = 20, FILE = 'amazon_biomass_final.gra', ACCESS = 'DIRECT', &
!      RECL = nx*ny, STATUS = 'old')
! READ(20, REC = 1) TiffDataB	
! CLOSE(20)

 !!CONVERT TO REAL
 !Temp = TiffDataB
 
 !!SAVE IN VFM MODE
 !open (2,file='amazon_biomass_final.vfm')
 !call vforec(2,Temp,ny*nx,24,dummy,'LIN')
 !close(2) 
 
 !!OPEN VFM MODE
 open(unit=22,file='amazon_biomass_final.vfm', form='formatted',status='old')
 call vfirec(22,TiffDataA,nx*ny,'LIN')
 
 !!CONVERT TO INTEGER
 Out = ANINT(TiffDataA)
 
END PROGRAM opentiff
