Fortran

Guide To Learn

Fortran Faqs

How do I issue a command to the operating system within a Fortran program?

A. The Fortran 2008 standard provides the execute_command_line intrinsic procedure to make system calls. Prior versions have no standard way to make system calls, but many compilers have an extension named “system” or something similar. Please consult the documentation of your compiler. In Fortran 2003, one can call C code, and it is possible to call the […]

How can I convert a string to an integer and other types? What about the reverse?

A: Use an “internal read” or “internal write”. In effect, you use a character variable as the file name and read or write the I/O list. You write things like to convert a string to another type and to convert to a string from another type, as demonstrated by the following program: This answer is […]

What does the open statement look like using this technique? OPEN(UNIT = __, FILE = ???, STATUS=’NEW’)?

A: Gfortran does not accept this block Gives, ERROR, file tag must be of type CHARACTER Can someone else help with this? A: See the answer above. Basically the way you have written the variable file_name is incorrect. Assuming that ITN has been declared as an integer and given a value.

How do I create numbered file names such as out_01.txt, out_02.txt etc.?

A: Use an “internal write” to create the file names, for example A: A neater way to do this would be: This way the formatting is clear and you are writing the correct string to the variable. I assume you wanted an integer as the number. ‘I’ format statement requires an Integer length, or zero […]

Should I learn Fortran? Is it obsolete?

Fortran is not obsolete and it will not be any time soon. Fortran is a general purpose programming language and is suitable for many applications. However, it excells at numerical computation and high performance computing. It is fast, portable and it has seamless handling of arrays. Because of this, there are many high-quality Fortran libraries […]

Scroll to top