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
you should have an executable called
outputin your current working directory. To execute that executable execute the commandwhich 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
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 calledouptut. Is this the first time you’ve used a compiler ?