Sample Header Ad - 728x90

Interactive Fortran Program

1 vote
1 answer
309 views
I have an old fortran executable foo.exe that requires interactive input. If I call foo.exe from Cywin I am prompted for the interactive input and the program works fine. If I call foo.exe from WSL I am prompted for interactive input and the program works fine.


I would like to run a script or send input to foo.exe such that I don't need to go through the process of entering everything interactively. In Cygwin I do the following:
foo.exe 

I attempt to do the same thing in WSL and I get the following error message:
forrtl: An attempt was made to move the file pointer before the beginning of the file. forrtl: severe (39): error during read, unit -4, file CONIN$ Image PC Routine Line Source libifcorert.dll 1003A159 Unknown Unknown Unknown

----------------- So I grabbed the original file foo.f and I attempted to recompile it using gfortran
gfortran foo.f -o new_foo.exe
I then attempt to interactively call new_foo.exe from Cygwin and I get the following:
bash: ./newfoo.exe: cannot execute binary file: Exec format error
So what used to work in Cygwin no longer does.  

I then attempt to interactively call new_foo.exe from WSL and it works fine.

I can now run a script or send input to new_foo.exe using WSL and it works fine (couldn't do that before) but I have lost the ability to do it on Cygwin. One step forward, two steps back??

-----------------



I then thought maybe I should recompiling it using 32-bit:
gfortran -m32 foo.f -o new_foo_32.exe
This 32-bit compiled program doesn't work with Cygwin or WSL giving the following error on both:
bash: ./newfoo.exe: cannot execute binary file: Exec format error
The ultimate goal is to have a single foo.exe program that runs interactively on both Cygwin & WSL (my original code does this) **AND** allows me to pipe/send input on both Cygwin & WSL (my original code only allows me to do this in Cygwin).    

Any suggestions?



==============
Cygwin Version ==============
CYGWIN_NT-10.0-WOW 2.4.1(0.293/5/3) 2016-01-24 11:24 i686 Cygwin
==============
WSL version ==============
Linux 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal ```
Asked by Matt (83 rep)
Mar 22, 2021, 04:12 PM
Last activity: Mar 22, 2021, 09:36 PM