运行 gfortran 时巨大的 fort.# 文件 [英] Huge fort.# files when running gfortran

查看:32
本文介绍了运行 gfortran 时巨大的 fort.# 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 gfortran 用于应用程序并通过 Matlab mex 文件运行 Fortran.我注意到,当我在我的 Mac 上运行 Fortran 文件时,它会在当前目录中创建一个 fort.9fort.16 文件,其中 9 或 16是一些任意数字.最近,我注意到这些 fort. 文件可能有 GB 大!通常它们很小,例如几 kB.我只是想知道这些文件有什么用途?其次,我的代码中是否有一些错误导致它们如此之大?我只是觉得它们如此之大令人非常怀疑.

I am using gfortran for an application and running the Fortran through a Matlab mex file. I have noticed that in the current directory when I run the Fortran file, on my mac, it creates a fort.9 or fort.16 file, where the 9 or 16 are some arbitrary number. Recently, I have noticed that these fort. files can be GBs big! Generally they are quite small, like a few kBs. I was just wondering what purpose these files have? And second, is there some error I have in my code that is causing them to be so large? I just find it to be very suspicious that they are so large.

我正在运行来自 http://hpc.sourceforge.net 的 GNU Fortran (GCC) 5.0.0 20140824(实验性)/ 而我的 mac 版本是 OSX 10.8.5.

I am running GNU Fortran (GCC) 5.0.0 20140824 (experimental) from http://hpc.sourceforge.net/ and my version of mac is OSX 10.8.5.

推荐答案

在 Fortran 中,与大多数其他语言相反,无需先打开它就可以写入一个单元(~= 文件对象,或其他语言中的文件描述符)(将本机连接到文件).在这种情况下,gfortran 将在当前工作目录中隐式创建一个名为fort.N"的文件,其中 N 是单元号(其他编译器可能会做其他事情,但通常会做类似的事情).

In Fortran, contrary to most other languages, one can write to a unit (~=file object, or file descriptor in some other languages) without first opening it (connecting the unit to a file). In that case, gfortran will implicitly create a file in the current working directory called 'fort.N', where N is the unit number (other compilers may do something else, but generally do something similar).

因此,要回答您的问题,您需要在代码中为这些单元编写内容.如果不查看有问题的代码,我显然无法说出你为什么要这样做.

So to answer your question, in your code you're writing stuff to those units. Why you're doing that I cannot obviously say without looking at the code in question.

这篇关于运行 gfortran 时巨大的 fort.# 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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