      dimension amap(72,36)
      character*80 name
      real*4 lon,lat

 1    print*,'enter map file name'
      read(*,'(a)')name
      open(8,file=name,status='old',iostat=iret)
      if(iret.ne.0)goto 1
      ic=ilen(name)
      write(name(ic+1:ic+4),'(a)')'.gmt'
      open(9,file=name)
      read(8,*)((amap(i,j),i=1,72),j=1,36)
      do 20 j=1,36
         lat=90.-((j-1)*5.+2.5)
         do 20 i=1,72
            lon=(i-1)*5.+2.5
            write(9,*)lon,lat,amap(i,j)
 20   continue 
      end  

      function ilen(name)
      character*(*) name

      ilen=0
 1    continue
      il=ilen+1
      if(name(il:il).eq.' ')goto 99
      ilen=ilen+1
      goto 1
 99   return
      end
      
