program count_grid c c================================================= c c read the country-code, and c count the number of the grid c c country and country-code are from the table c================================================= c.......................................... c country_code.asc c country_code c c country_code.list c.......................................... c character*5 ncols,nrows c character*9 xllcorner,yllcorner c character*8 cellsize c character*12 nodata character*28 country(199) c parameter( infile = 11, iofile = 12, nc = 720, nr= 360 ) parameter(infile2 = 13) integer data(2000,4000),count(200),code(200),region(200) c open(infile, file= 'country_code.asc', status='old') c c ------ read from country_code.asc file ------ c
c read(infile,*) ncols,nc c read(infile,*) nrows,nr c read(infile,*) xllcorner,x0 c read(infile,*) yllcorner,y0 c read(infile,*) cellsize,s read(infile,*) nodata,znodata c do j=1,nr read(infile,100) (data(i,j),i=1,nc) end do 100 format(720i4) c c ------ read from country-code-table file ------ open(infile2,file='country_code', status='old') read(infile2,*) do n =1, 198 read(infile2,200) code(n), country(n), region(n) end do 200 format(i4,a28,i8) close(infile2) c c ------ count grid ------ do n=1,198 count(n) =0 end do do n=1,198 do j =1 ,nr do i = 1, nc if(data(i,j) .eq. code(n)) then count(n) = count(n) +1 end if end do end do end do c close(infile) c 931 SOUTH_AMERICA c open(iofile, file='country_code.list', status='new') do n =1, 198 write(iofile,300) code(n),country(n),region(n),count(n) end do 300 format(i4,a28,i8,i8) close(iofile) end