[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gfortran



On Monday 24 October 2005 21:32, Dominique Rousset wrote:
> Hello everyone,
>
> I've been a silent subscriber to this list for the past 3+ months, and now,
> I am coming with my question...
>
> I am benchmarking a fortran code of my own (simulation of seismic wave
> propagation)
> whose output is a direct access binary file.
> I just modified it a little from Intel fortran90 to gfortran.
> I succesfully ran it at work on a PowerPC linux, an ultrasparc linux and a
> Pentium 4 (old, fully 32 bits) linux.  The results are consistent and
> consitent (not really equal, of course) to those obtained on Intel proc
> using Intel compiler.
>
> I tested it at home on my Athlon64.  Dual boot one in 32 bits and the other
> one in 64 bits, both debian etch.
>
> I am surprised that the output fiile in 64 bits mode is larger of 808
> bytes. It's just one excess byte per record.
>
> Any clue about that ?
> Do you thing I must issue a bug report to the maintainer, to the upstream
> developer team ?
>
> Thanks
> D.
>
> PS : computation time is 15% longer in 32 bits mode, using the same
> compiler options.
> --
> Dominique Rousset
> dominique.rousset@free.fr

I had a discussion off-list regarding different-sized output files from 
FORTRAN programs; and we came to the conclusion that the header and footer 
records were each 8 bytes long on the 64-bit system as opposed to 4 bytes on 
the 32-bit system.

I came up with a Perl script as follows:

########## CUT HERE ##########
#!/usr/bin/perl -w
use strict;

(my $self = $0) =~ s|.*/||;
die "Usage: $self infile outfile\n" if (@ARGV < 2);

my $infile = shift;
my $outfile = shift;
open INFILE, "<$infile" or die "Couldn't open $infile: $!";
open OUTFILE, ">$outfile" or die "Couldn't open $outfile: $!";
my $length = (stat INFILE)[7];

if ($self =~ /32.*64/) {
# this code will run if the name contains "32" before "64" and adds
# extra zeros to the file -- converting 32-bit save files to 64-bit.
    read INFILE, $_, 4;
    print OUTFILE;
    print OUTFILE "\x00\x00\x00\x00";
    read INFILE, $_, $length - 4;
    print OUTFILE;
    print OUTFILE "\x00\x00\x00\x00";
}
else {
# this code removes bytes 4-7 and the last four bytes -- converting
# 64-bit save files to 32-bit
    read INFILE, $_, 4;
    print OUTFILE;
    read INFILE, $_, 4;
    read INFILE, $_, $length - 12;
    print OUTFILE;
};

close INFILE;
close OUTFILE;
exit 0;
########## CUT HERE ##########

Instructions: save it as /usr/local/bin/cv3264 and make a symlink,
ln -s /usr/local/bin/cv3264 /usr/local/bin/cv6432
Now it can be run by either of those two names. This is important, as the 
program changes its behaviour according to what name it is called by.

The syntax is
cv3264 filename1 filename2
{or  cv6432 filename1 filename2}
where filename1 is the input file and filename2 is the output file.  

If this program is called as "cv3264"  {or any name which has the characters 
"32" anywhere before the characters "64"}  then it will add the extra zeros 
to a file saved by the 32-bit program, so it looks like it came out of a 
64-bit program.  If it is called as "cv6432" then it will remove bytes from 
those positions in a file saved by the 64-bit program, so it will look like 
it came out of a 32-bit program.

My earlier correspondent said it worked well.  I am releasing it into the 
public domain, as I feel the code should outweigh the licence.

-- 
AJS



Reply to: