c - Program to convert one KML polygon to a GMT-ready file c - suitable for using in a "psxy" command, which effectively c - makes it a customized boundary/shoreline. implicit real*8(a-h,o-z) character*200 fin,fout character*50000 card real*8 xf,yf,zf write(6,101) 101 format('Input KML file name? : ',$) read(5,'(a)')fin open(1,file=fin,status='old',form='formatted') write(6,102) 102 format('Input GMT file name? : ',$) read(5,'(a)')fout open(10,file=fout,status='new',form='formatted') n = 0 1 read(1,'(a)',end=99)card n = n + 1 do 2 i=1,50000 if(card(i:i).eq.'>')goto 1 if(card(i:i+12).eq.'')then read(1,'(a)')card goto 98 endif 2 continue goto 1 99 continue write(6,*) ' Error' stop c - Read record n+1 98 continue c write(6,*) ' Here are the coords: ' c write(6,'(a)')card c - Find first non-space: do 3 i=1,50000 if(card(i:i).ne.' ')then nf = i m = 0 goto 4 endif 3 continue c - Find all subsequent spaces, and as I do, c - read the x,y,z values. If I find a space c - and it is followed by a 2nd space, c - then get out of here. 4 continue do 5 i=nf,50000 if(card(i:i).eq.' ')then if(card(i+1:i+1).eq.' ')goto 96 read(card(nf:i-1),*)xlon,xlat,xh if(xlon.lt.0)xlon = xlon + 360.d0 m = m + 1 if(m.eq.1)then xf = xlon yf = xlat zf = xh endif nf=i+1 c write(6,104) xlon,xlat,xh write(10,104) xlon,xlat goto 4 endif 5 continue 104 format(f20.10,1x,f20.10,1x,f20.10) c 96 write(6,104)xf,yf,zf 96 write(10,104)xf,yf m = m + 1 write(6,*) ' Done. # pts, including repeat first/last=',m end