Unable to execute Fortran77 program after successful compilation - fortran

I have a Fortran program and have command to compile it. It compiles but after that even I am unable to execute it. Any help or detailed explanation would be highly appreciated. A part of the program which I am facing problem with is mentioned below.
READ 20, ITEXT
OPEN(14, STATUS='UNKNOWN')
OPEN(3, STATUS='UNKNOWN') ! DIPAK
OPEN(9, STATUS='UNKNOWN',FILE=ITEXT) ! EFG 1
OPEN(10,STATUS='UNKNOWN',FILE='/usr/local/bin/EBTABLE.DAT',FORM='UNFORMATTED') ! DIPAK
OPEN(11,STATUS='UNKNOWN',FILE='/usr/local/bin/TL03_99.DAT', FORM='UNFORMATTED') ! DIPAK
OPEN(12,STATUS='UNKNOWN', FORM='UNFORMATTED',
1ACCESS='DIRECT',RECL=8192)
OPEN(13,STATUS='UNKNOWN', FORM='UNFORMATTED',
1ACCESS='DIRECT',RECL=8192)
The files EBTABLE.DAT and TL03_99.DAT are copied at the mentioned locations.
The command used for compiling it is given as:
fort77 -a -f -g -h -w8 ../cascade.f -o cascade
After this how should I execute, suppose my input file is named cascade.inp

Related

GDB list shows nothing

A program compiled with arm-linux-gnueabi-gcc -g3 main.c .
$ gdb a.out
$ l
$ main.c: No such file or directory.
It is unable to display program lines with line number. let me know If i am missing something ?
However I am able to run program , with run command even backtrace I am able to get.
My issue is same as gdb can not load source file?
but , GDB version 7.8.
GDB needs source code to be present on same machine as in where binary been run.
mine was cross compilation , I was running program on different host . That's why I had that issue.

Can't run an executable file in matlab with system(), but it works in command line

I need to run a C++ executable file which uses the OPencv library using the system command in Matlab. I already compile all the code with make and it was successful. When I run the program in command line it works as shown below.
lib/sift/bin/siftfeat -x -o tampered1.txt tampered1.jpg
Finding SIFT features...
Found 2596 features.
The problem is when I run it with matlab. The following error happens:
>>system('lib/sift/bin/siftfeat -x -o tampered1.txt tampered1.jpg')
Finding SIFT features...
Error: unable to load image from tampered1.jpg
lib/sift/bin/siftfeat -x -o tampered1.txt tampered1.jpg: Aborted
The error happens in lib/sift/src/siftfeat.c in the following piece of code:
fprintf( stderr, "Finding SIFT features...\n" );
img = cvLoadImage( img_file_name, 1 );
if( ! img )
fatal_error( "unable to load image from %s", img_file_name );
Why does this happen? I mean, if the code runs in command line, why it doesn't run with system Matlab command? doesn't matlab recognize the cvLoadImage function? I am using Matlab R2014a and OPencv-2.4.9. This code was copied from another PC and I just recompiled it. In the original PC in which the code was copied the system command works.
You are running the system()-cmd in the wrong folder.
While you call your binary with an absolute path, the path to your images are relative.
Therefore, the images need to be in the folder, where matlab executes your system()-cmd.
You can simply check this by executing:
>> system('pwd')
"Folder/where/matlab/exec/your/cmd"
If the output corresponds to your image location, everything should be fine, otherwise you have to give your program the absolute path like this:
>> system('lib/sift/bin/siftfeat -x -o Folder/to/your/txt/tampered1.txt Folder/to/your/image/tampered1.jpg')
I tried it, and found that using sudo will work.

`Fortran runtime error: End of file` in Amber12

I am using amber12 software used for molecular mechanical force fields for the simulation of biomolecules, I follow the installation instructions described in the next link Intallation of amber in Mac OS X the program actually works but when in try to execute a program part of the software its stops and says
Fortran runtime error: End of file
1.So this is what I do, first access the file folder that contain the files
N-terminal-2:~ javieralejandrorendoncarrillo$ cd Desktop/amber/Complex1
2.then set the path
N-terminal-2:Complex1 javieralejandrorendoncarrillo$ export AMBERHOME=/Users/javieralejandrorendoncarrillo/amber/amber12
3.and finally execute the program whit the next command line:
N-terminal-2:Complex1 javieralejandrorendoncarrillo$ $AMBERHOME/bin/sander.MPI -O -i min.in -o min_complex.out -p complex.prmtop -c complex.inpcrd -r complex_min.crd &
[2] 13377
N-terminal-2:Complex1 javieralejandrorendoncarrillo$ At line 524 of file mdread.F90 (unit = 5, file = 'min.in')
Fortran runtime error: End of file
[2]- Exit 2 $AMBERHOME/bin/sander.MPI -O -i min.in -o min_complex.out -p complex.prmtop -c complex.inpcrd -r complex_min.crd
N-terminal-2:Complex1 javieralejandrorendoncarrillo$
The file min.in is saved in file folder Complex 1 where I'm running the simulation this is the script for min.in
Initial minimisation of our complex
&cntrl
imin=1, maxcyc=3000, ncyc=2500,
cut=16, ntb=0, igb=1,
&end
How do I solve this problem? Is the syntax wrong? Does anyone know how to execute or what kind of programming language is this?
This is the version installed of gfortran I have
N-terminal-2:~ javieralejandrorendoncarrillo$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.7.2/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.7.2/configure --prefix=/opt/local --build=x86_64-apple-darwin12 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --disable-cloog-version-check --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.2_2'
Thread model: posix
gcc version 4.7.2 (MacPorts gcc47 4.7.2_2)
I had the same error message: ..file mdread.F90 (unit = 5, file = 'min_all.in')...
When investigating this, I for some reason found that changing the ntpr=5 to 6 in the min_all.in file got rid of the problem:
&cntrl
imin=1, maxcyc=200,
ntpr=6,
&end
Not being the sharpest knife in the drawer about these things, I have a hard time seeing why this solved it for me though.
The ntpr value only defines how often the trajectory coordinates should be sent to the out-file, in this case every 6 steps instead of every 5 steps.
Extended comment rather than an answer. The two common causes of the error message you are getting, that is
At line 524 of file mdread.F90 (unit = 5, file = 'min.in') Fortran runtime error: End of file
are
The file being read is not where the program is looking for it.
The program tries to read more data out of the file than the file contains.
From what you have posted it seems that (1) is unlikely, but you could check this by inserting an INQUIRE statement to check the file's existence prior to opening it. Alternatively you could make use of the STATUS='old' keyword (and value) in your file OPEN statement, if the file does not exist the program will report an error.
As for (2), you're pretty much on your own. No-one here (unless you are very very lucky) is likely to have a clue what your program expects to read from the input file, and you don't post any of the relevant code. You might care to modify the file READ statements to incorporate an END= keyword argument to smoke out the source of the error.
I presume that the suppliers of Amber12 are themselves likely to be more knowledgeable about their code than the SO community; your question would be better directed to them.
For what it's worth I think that the problem is unrelated to the compiler you are using.
The '&end' or '/' line should not be the last line in your input script. Have a new empty line after the '&end' or '\' line, whichever you are using.
This fixed the problem for me.

No output after compiling and executing the code

I'm new to fortran and i'm trying to execute this as an output.
program write2file
implicit none
! open file
open (10, file='output_file.txt', status='unknown')
! write to file
write(10, *) 'Hello World!'
! close file
close(10)
end program write2file
I'm running it on Linux and I have tried to use this statement to compile and execute the output, but unfortunately, I wasn't able to get the 'output_file.txt'
Does anyone know what's wrong?
This is a comment rather than an answer but I feel in need of better formatting. After you execute the command
ifort -o output hi.f90
you should have an executable called output in your current working directory. To execute that executable execute the command
./output
which will, if you are successful, write the output you want to wherever the current version of the program directs it.
Reading your comments makes me suspect that you think the command
ifort -o output hi.f90
ought to execute your program and cause the creation of the output requested. But that command just compiles your sources (in the file hi.f90) into the executable called ouptut. Is this the first time you've used a compiler ?

How can I solve Fortran runtime error: End of file?

I am using Codeblock 13.12. My file is not readable. and getting the runtime error
program asd
implicit none
integer :: x
open(unit = 2, file = "text.txt")
read(2,*)x
write(*,*)x
end program
and my text.txt file is :
1
I've seen many answers, but none of them worked for my code
Your program is just fine. As a matter of fact, even if the first line is not properly terminated, gfortran will take the EOF as the EOL and still work.
Your problem is you are working in the IDE CodeBlock. The IDE does not run the program in your working directory so the file text.txt is not where the program is running, hence the end of file error.
Check out this post Codeblock working directory which will guide you to solving your problem.