编译并执行代码后无输出 [英] No output after compiling and executing the code

查看:79
本文介绍了编译并执行代码后无输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是fortran的新手,我正尝试将其作为输出执行.

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

我正在Linux上运行它,并且尝试使用此语句来编译和执行输出,但是不幸的是,我无法获得'output_file.txt'

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'

有人知道怎么了吗?

推荐答案

这是评论而不是答案,但我认为需要更好的格式.执行命令后

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

您的当前工​​作目录中应该有一个名为output的可执行文件.要执行该可执行文件,请执行命令

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

应执行您的程序并导致创建请求的输出.但是该命令只是将您的源代码(在文件hi.f90中)编译为名为ouptut的可执行文件.这是您第一次使用编译器吗?

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 ?

这篇关于编译并执行代码后无输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆