#!/usr/bin/perl -w
# jkob 14/01/03

# This script modifies source files so that the program can be run on
# a 64-bit processor. The following changes are introduced:
# integer*4           --> integer*8
# implicit integer*4  --> implicit integer*8
# real*8              --> real*16
# implicit real*8     --> implicit real*16

# It may happen that routine ttime will need an individual treatment.

open (ALLFILES, "ls *.f *.c *.raw *.inc|");

@allfiles=<ALLFILES>;
$allfiles_nb=@allfiles-1;

for ($i=0; $i<=$allfiles_nb; $i++) {
    open(FILE,"cat $allfiles[$i] |") || die "cannot open ", $allfiles[$i];
    @file=<FILE>;
    $file_nb=@file-1;
    close(FILE);
    open(FILE,">$allfiles[$i]") || die "cannot open ", $allfiles[$i];
    for ($j=0; $j<=$file_nb; $j++) {
	$t=$file[$j];
	if ( $t =~  /      integer\*4/) {
	     $t =~ s/      integer\*4/      integer*8/;
	};

	if ( $t =~  /implicit integer\*4/) {
	     $t =~ s/implicit integer\*4/implicit integer\*8/;
	};

	if ( $t =~  /      real\*8/) {
	     $t =~ s/      real\*8/      real*16/;
	};

	if ( $t =~  /implicit real\*8/) {
	     $t =~ s/implicit real\*8/implicit real\*16/;
	};

	print (FILE $t);
    };
    close(FILE);
};

#


