g77 program for converting unformatted files
Bud Davis
bdavis9659@sbcglobal.net
Sat Jul 22 17:57:00 GMT 2006
hello all,
in case anyone is interested, below is a g77 program
that will convert a g77 unformatted file to one that
is readable by gfortran.
there has been a lot of e-mail traffic about these
issues; here is a code snippet that might ease the
problems for some users. i know how easy it is to say
"just write a little program to do it" and also how
difficult actually realizing a piece of code can be.
many fortran users are engineers and scientists who
want to solve equations, not play with bytes.
the code is not pretty and has only been tested on a
handful of examples, but it should be enough to get
someone started. changing the code to go in the other
direction should be very straightforward.
provided 'as is, where is' with no warranty of any
kind !!
--bud davis
! this g77 program converts g77 style 4 byte record
marker files into
! 8 byte record marker files for gfortran.
implicit none
integer*4 recm4
character*1 recm4_char(4)
equivalence (recm4,recm4_char)
integer*8 recm8
character*1 recm8_char(8)
equivalence (recm8,recm8_char)
character*1 c
integer status_in,status_out,i,j
data status_in / 0 /
data status_out / 0 /
! unit 7 is the IN FILE
! unit 8 is the OUT FILE
open(7,file='fort.7',form='unformatted')
open(8,file='outfile',form='unformatted')
do while (status_in.ge.0)
! read in the starting marker
recm4 = 0
DO J = 1,4
CALL FGETC(7,recm4_char(J),status_in)
IF (status_in.eq.-1) goto 100
END DO
recm8 = recm4
DO J = 1, 8
CALL FPUTC(8,recm8_char(J),status_out)
END DO
DO I = 1,RECM4
CALL FGETC(7,C,status_in)
CALL FPUTC(8,C,status_out)
END DO
DO J = 1,4
CALL FGETC(7,recm4_char(J),status_in)
END DO
DO J = 1, 8
CALL FPUTC(8,recm8_char(J),status_out)
END DO
end do
! EOF detected
100 continue
end
More information about the Fortran
mailing list