user1204868
user1204868

Reputation: 606

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?

Upvotes: 1

Views: 2221

Answers (1)

High Performance Mark
High Performance Mark

Reputation: 78316

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 ?

Upvotes: 2

Related Questions