Sample Header Ad - 728x90

How to debug binary file from legacy FORTRAN? Help

0 votes
1 answer
179 views
I'm working with an older proprietary FORTRAN legacy code from specific corporation (so can't post much source code), I'm having an issue with the file interactions. My compiler bash shell Install is calling make newspaper which calls a series of other functions via the makefile bash shell to create newspaper. However, when newspaper is then called within Install with an input file to compare to an output file newspaper then returns not found. I've tried opening the file newspaper to look at it for the error. I've tried converting newspaper into text, simply yielding a text file filled with numbers. I need to read the file as "code" to figure out whats going wrong and causing not found to crop up. For Clarification: - newspaper is a binary file as when doing less newspaper in the terminal my Linux operator said its a binary file - the calling of newspaper inside Install has the following format newspaper f1.test this is followed by diff xfile1R.out f1.test > f1.dif - gfortran is the compiler being used in Ubuntu, the c drive is a mounted drive - little endian should be the binary format used according to this site I'm a noob when it comes to Linux and FORTRAN, I may just be making a rookie mistake, would really appreciate any advice, im not sure if this is a Linux or FORTRAN issue.
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/Documents/NEWSPAPER/Newspaper/Newspaper$ sh ./Install.sh
cat makefile.sh >makefile
chmod a+x makefile
make: 'newspaper' is up to date.
./Install.sh: 10: newspaper: not found
./Install.sh: 12: newspaper: not found
./Install.sh: 14: newspaper: not found
./Install.sh: 16: newspaper: not found
./Install.sh: 18: newspaper: not found
./Install.sh: 20: newspaper: not found
 84 -rwxrwxrwx 1 roman roman  83071 Feb 17 16:08 f1.dif
152 -rwxrwxrwx 1 roman roman 153543 Feb 17 16:08 f2.dif
108 -rwxrwxrwx 1 roman roman 109718 Feb 17 16:08 f3.dif
232 -rwxrwxrwx 1 roman roman 236209 Feb 17 16:08 f4.dif
164 -rwxrwxrwx 1 roman roman 166612 Feb 17 16:08 f5.dif
 48 -rwxrwxrwx 1 roman roman  48898 Feb 17 16:08 f6.dif
./Install.sh: 31: Syntax error: newline unexpected
Edit 1: tried file newspaper to check PATH
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/Documents/NEWSPAPER/Newspaper/Newspaper$ file newspaper
newspaper: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=8ac6de30da50639d7e3ea55a09416b049a5291c0, for GNU/Linux 3.2.0, not stripped
Edit 2: Make file fix?
#
# Makefile for newspaper
#

OBJF = \
	sfun1.o \
	sfun2.o \
	sfun3.o \
	sfun4.o \
	sfun5.o \
	sfun6.o \
	sfun7.o 


FLAGS = -O2 -static -std=legacy
COMP  = gfortran

newspaper: $(OBJF)
	$(COMP) $(FLAGS) -o newspaper $(OBJF)

.f.o:
	$(COMP) $(FLAGS) -c $ f1.test
diff xfile1R.out f1.test > f1.dif
./newspaper  f2.test
diff xfile2R.out f2.test > f2.dif
./newspaper  f3.test
diff xfile3R.out f3.test > f3.dif
./newspaper  f4.test
diff xfile4R.out f4.test > f4.dif
./newspaper  f5.test
diff xfile5R.out f5.test > f5.dif
./newspaper  f6.test
diff xfile6.out f6.test > f6.dif

ls -als *.dif

# User input for directory to put executable
if ( $1 == '' ) then
   echo " "
   echo -n "Enter directory for executable file: "
   set Edir = $<
else
   set Edir = $1
endif

if ( $Edir != '' ) then
   mv newspaper $Edir
endif
Edit 4: More Syntax error, same error
./Install.sh: 30: Syntax error: newline unexpected
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/Documents/NEWSPAPER/Newspaper/Newspaper$ ./
-bash: ./: Is a directory
roman@DESKTOP-QKJTF3S:
Edit 5: csh check
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/Documents/NEWSPAPER/Newspaper/Newspaper$ sudo apt-get install csh
Reading package lists... Done
Building dependency tree
Reading state information... Done
csh is already the newest version (20110502-5).
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.
Edit 6: It worked!! Courtesy to @steeldriver for guiding myself the noob
164 -rwxrwxrwx 1 roman roman 164829 Feb 17 21:36 f1.dif
304 -rwxrwxrwx 1 roman roman 307257 Feb 17 21:36 f2.dif
216 -rwxrwxrwx 1 roman roman 217791 Feb 17 21:36 f3.dif
460 -rwxrwxrwx 1 roman roman 468651 Feb 17 21:36 f4.dif
324 -rwxrwxrwx 1 roman roman 331213 Feb 17 21:36 f5.dif
 96 -rwxrwxrwx 1 roman roman  96955 Feb 17 21:36 f6.dif

Enter directory for executable file: ./Outputs
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/
Asked by The Immortal (31 rep)
Feb 17, 2022, 11:24 PM
Last activity: Feb 18, 2022, 05:12 AM