program convertnmr c converts Dracinsky's NMR .txt files implicit none real*8 w ,wmin,wmax,dw integer*4 i,n,iargc real*8,allocatable::s(:) character*80 s80,FIL1,FIL2 if(iargc().lt.2)then write(6,*)'Usage: convertnmr oldfile newfile' stop endif call getarg(1,FIL1) call getarg(2,FIL2) open(9,file=FIL1) i=0 1 read(9,80,end=99,err=99)s80 80 format(a80) if(s80(3:8).eq.'LEFT =')then read(s80(9:27),*)wmin read(s80(41:58),*)wmax endif if(s80(3:8).eq.'SIZE =')read(s80(9:15),*)n i=i+1 goto 1 99 close(99) write(6,*)i,' lines' write(6,*)n,' points' write(6,601)wmin,wmax 601 format(F15.8,' - ',F15.8,' ppm') allocate (s(n)) open(9,file=FIL1) 2 read(9,80,end=991,err=991)s80 if(s80(1:1).ne.'#')then read(s80,*)s(1) do 3 i=2,n 3 read(9,*)s(i) goto 991 endif goto 2 991 close(9) open(9,file=FIL2) dw=(wmax-wmin)/dble(n-1) w=wmin-dw do 4 i=1,n w=w+dw 4 write(9,900)w,s(i) 900 format(f25.7,f20.7) close(9) stop end