C************************************************************************* C scanfile.f C scan a FTNMR/DANS file using Fortran read C C Written by: Ed Sternin, Brock U., Physics C Completed: VI.92 C Revisions: C********************************************************** declarations * integer*4 IN(50000) /50000*0/ real*4 in_r(50000) equivalence (in_r,IN) !same data can be real or integer integer*4 icom(32) character*128 ccom equivalence (icom,ccom) ! comments field character*80 fname character*7 type(2)/'real ','complex'/, 1 domain(2)/'fid ','ft '/, 1 axis(4)/'none ','pts ','Hz ','ppm '/ integer I,J,Nargs,ios character*80 fname C************************************************************************* C...File names ? Nargs=iargc() ! # of arguments on the command line if (Nargs .ge. 1) then if (Nargs .gt. 1) then write(6,'(A)') ' scanfile: ignoring extra arguments!' endif call getarg(1,fname) goto 101 end if 10 WRITE(6,FMT='(A,$)') ' File to scan: ' READ(5,FMT='(A)',END=901) fname 101 OPEN(UNIT=1,FILE=fname,STATUS='OLD',FORM='UNFORMATTED', 1 IOSTAT=IOS,ERR=200) C DO WHILE (.TRUE.) !infinite loop READ(1, END=900) I, (IN(J), J=1, ABS(2*I)) !read a record write(6,*)' Record length: ',I C...if I is negative, then this is a parameter block. The fixed part of the C record should consist of 16 integers followed by 16 reals. IF (I .LT. 0) THEN write(6,*) ' Header size: ',ABS(2*I),' 4-byte words' write(6,*) ' No of points: ',IN(1) write(6,*) ' Data type: ',type(IN(2)+1) write(6,*) ' Data domain: ',domain(IN(3)+1) write(6,*) ' Axis type: ',axis(IN(4)+1) write(6,*) ' SW (Hz): ',in_r(17) if(IN(12).NE.0) THEN ! have a comments field DO J=1,IN(12) ICOM(J)=IN(IN(11) - 1 + J) END DO write(6,*)' Comments (may not translate correctly!):' write(6,'(X,A80)') ccom else write(6,*) ' Comments: none' end if C...DANS quirk: it uses the 20th field to store an integer! if(IN(16).eq.'DANS') then write(6,*) ' DANS FT stadd:',IN(20) end if ELSE ! it is a data record, dump the first 32 fields write(6,'(A,I4,A)') ' ------------data[',I,']----------------' DO j=1,32,2 write(6,'(2G16.5)') in_r(J),in_r(J+1) ENDDO write(6,'(A,I4,A)') ' --------------etc------------------' END IF ENDDO !go read the next record C************************************************************************ 900 CONTINUE close(1) 901 stop ' Done.' C**************************************************************** errors * 200 if(IOS.eq.29) then write(6,'(A,A)') ' File not found: ',fname else WRITE(6,209) IOS,fname endif goto 10 209 FORMAT (' Input file opening error #',I8,' on: ',A) END