economia news e media viaggi informatica internet salute e benessere int rattenimento e spettacolo sport tempo libero istruzio ne e formazione arte cultura scienza

Il Sondaggio

Quale versione del fortran utilizzi?

Guarda i risultati

Convertitori

unfseq.f90

A cura di Giuseppe Ciaburro

Pubblicato il 24/04/2007

Il programmma è usato per convertire file sequenziali non formattati Lahey-Fujitsu nello stile Lahey.

Il file in formato fortran dovrà essere compilato e girare con il sistema Lahey LF90 language altrimenti il processo di conversione non andrà a buon termine.

!**----------------------------------------------------------------------------
!**
!**           file : unfseq.f90
!**
!**           date : December 1998
!**
!**       function : The program is used to convert Lahey-Fujitsu sequential
!**                  unformatted files to Lahey style.
!**
!**  compatibility : This Fortran file MUST be compiled and run with the Lahey
!**                  LF90 language system; compilation with LF95 will defeat
!**                  the conversion process.
!**
!**  to create/run : Type 'lf90 unfseq' at the DOS command prompt.
!**
!**    portability : This code is portable to any system running Lahey LF90.
!**
!**                       Lahey Computer Systems, Inc.
!**                                PO Box 6091
!**                         Incline Village, NV 89450
!**                            voice: 702-831-2500
!**                              fax: 702-831-8123
!**                        e-mail: support@lahey.com
!**
!**              Copyright(c) 1995 - 1998, Lahey Computer Systems, Inc.
!**
!**----------------------------------------------------------------------------
        program unfseq
        implicit none

	external iswhite, abort
	logical*1 iswhite
        integer*2 i, j
        integer len
        integer(kind=1), allocatable :: buf(:)
        character*128 dosbuf
        character*64 infile, outfile

	dosbuf = ' '
	call getcl( dosbuf )
	if (index( dosbuf, '?' ) .ne. 0)                                  &
     & stop 'Usage: sequnf [? | { []}]'

	if (dosbuf .ne. ' ') then		! if there's a command line
		infile = ' '
		outfile = ' '
		i = 1
    1		if (iswhite( dosbuf(i:i) )) then	! turf white space
			i = i+1
			goto 1
		endif
		j = 1
    2		if (.not. iswhite( dosbuf(i:i) )) then	! parse input filename
			infile(j:j) = dosbuf(i:i)
			i = i+1
			j = j+1
			goto 2
		endif
		if (dosbuf(i:) .ne. ' ') then		! if output filename was typed
			i = i+1					! seek it
    3			if (iswhite( dosbuf(i:i) )) then
				i = i+1
				goto 3
			endif
			outfile = dosbuf(i:)			! and get it
		else					! else prompt for it
                        print *, 'Please enter LF90 output-filename: '
			read(5,*) outfile
		endif
	else					! else prompt for both filenames
                print *, 'Please enter LF95 input-filename: '
		read(5,*) infile
                print *, '   and the LF90 output-filename: '
		read(5,*) outfile
	endif

!*  now let Fortran check for existence/validity of files
        open( 11, infile, status='old', access='transparent', err=50 )
        open( 12, outfile, status='new', form='unformatted', err=60 )


   20   read (11, end=80) len                               ! get record length
        allocate (buf(len))
        read (11) buf
        write(12) buf                                       ! write rec. length ind.
        deallocate (buf)
        read(11) len                                        ! read past trailing rec. length ind.
        goto 20

   50	call abort( 'input file does not exist' )

   60	call abort( 'output file already exists' )

   80   stop 'Conversion complete'

	end

!*****		Return TRUE if character is blank or tab (white space)
      logical*1 function iswhite( arg )
      character arg
      integer tab
      parameter (TAB=9)

	if (arg .eq. ' ' .or. arg .eq. char(TAB)) then
		iswhite = .TRUE.
	else
		iswhite = .FALSE.
	endif
	return
	end

!*****		Scram routine
	subroutine abort( msg )
	character msg*(*)
        print *, 'Error: ', msg
	call exit( 4 )
	end

I link correlati all'argomento

Vuoi essere aggiornato sulle novità della guida?

Feed RSS XML vostro feed RSS