问题
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.
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.
回答1:
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.
来源:https://stackoverflow.com/questions/61617148/why-does-fortran-write-to-fort-x