Fortran code to write data in NUTS format

Contributed by Todd Alam

     
c
c nuts_sub
c
c fortran subroutine to produce data files in the CDFF format for NUTS
c presently limited to 16K real and 16K imaginary points
c
c Todd Alam 2/97 Sandia National Labs
c

        subroutine nuts_sub(sf,sw,npts,rdata,idata)
        integer ihdr(256)
        real    fhdr(256)
        equivalence(ihdr,fhdr)
        real rdata(16384),idata(16384)
        character*13 fileout

        write(*,'(a)') ' NUTS_DATA '
        write(*,'(a,$)') ' Enter Output File Name: ==>'
        read(*,'(a)') fileout
c
c general header information - see NUTS manual for specific detail entries
c 
c Note: array indice = word number+1
c
c  
       ihdr(1)=67305985
       ihdr(2)=256
       ihdr(3)=1
       ihdr(4)=0
       ihdr(5)=1
       ihdr(6)=32
       ihdr(7)=200
       ihdr(8)=0

       fhdr(19)=sw
       fhdr(20)=sf
       fhdr(113)=sw
       fhdr(114)=sf
c
c frame 1 parameters
c
       ihdr(97)=npts
       ihdr(98)=1
       ihdr(99)=0
       ihdr(100)=1     
c
c  Write Header
c
1      open(unit=20,file=fileout,status='new',form='unformatted',
     * access='direct', recl=4, err=101)
       do 10 i=1,256
        write(20,rec=i) ihdr(i)
10     continue
       write(*,*) 'Header Written'
c
c  Write data set - real-imaginary complex set
c
       k=1 
       write(20,rec=259) npts
       do 20 i=1,npts
        j=k+259
        jj=k+260
        write(20,rec=j) rdata(i)
        write(20,rec=jj) idata(i)
        k=k+2
20    continue

      stop

101   write(*,*) 'Error opening output file ! ' 
      write(*,'(a,$)') ' Enter New Output File Name: ==>'
      read(*,'(a)') fileout
      goto 1
 
      stop 
      end



Description of NUTS file format

NUTS Help main page

Last updated 11/3/97