What is Fortran: Definition and 872 Discussions

Fortran (; formerly FORTRAN, derived from Formula Translation) is a general-purpose, compiled imperative programming language that is especially suited to numeric computation and scientific computing.
Originally developed by IBM in the 1950s for scientific and engineering applications, FORTRAN came to subsequently dominate scientific computing. It has been in use for over six decades in computationally intensive areas such as numerical weather prediction, finite element analysis, computational fluid dynamics, geophysics, computational physics, crystallography and computational chemistry. It is a popular language for high-performance computing and is used for programs that benchmark and rank the world's fastest supercomputers.Fortran has had multiple versions, each adding extensions while largely retaining compatibility with prior versions. Successive versions have added support for structured programming
and processing of character-based data (FORTRAN 77), array programming, modular programming and generic programming (Fortran 90), high performance Fortran (Fortran 95), object-oriented programming (Fortran 2003), concurrent programming (Fortran 2008), and native parallel computing capabilities (Coarray Fortran 2008/2018).
Fortran's design was the basis for many other programming languages. Among the better-known is BASIC, which is based on FORTRAN II with a number of syntax cleanups, notably better logical structures, and other changes to work more easily in an interactive environment.As of June 2021, Fortran was ranked 17th in the TIOBE index, a measure of the popularity of programming languages, climbing 17 positions from its ranking of 34th in January 2020.

View More On Wikipedia.org
  1. P

    Fortran Errors in Fortran code for solving Laplace's equation in 3D

    hey everyone. I wrote a code in Fortran to calculate potential values or solve the Laplace equation inside a cube according to the boundary conditions mentioned in the code. this is my code: program laplace_cubic implicit none REAL*8 :: LX, LY, LZ, DELTA, MAX_ERR, ERR INTEGER :: NX, NY...
  2. Vick

    Fortran Can Fortran 77 Code Be Used to Debug Python Code for Solving ODEs Using Radau5?

    Hi, I have a piece of Fortran code but I'm not Fortran literate. I'm trying to translate it into Python. I have already made it, but I need someone who can run the Fortran code to compare the values of the variables.
  3. gjleigh10

    How to read a column of data into Fortran without arrays? (Fortran 77)

    TL;DR Summary: I am beginning research as an undergrad in Physics and have an example file I must analyze for the mean of each column. I cannot use arrays. I need to take the sum of a column of data. Hi all, I am new to fortran and programming in general, but I'm having issues with creating a...
  4. Eclair_de_XII

    Fortran Does Fortran have a built-in function to calculate the determinant?

    program main ! use ! some library that defines the function to calculate the determinant of a given matrix implicit none real,dimension(2,2)::A real::det_val A(1,1)=1 A(2,2)=1 A(2,1)=0 A(1,2)=0 ! det_val=det(A) print *,det_val ! Should print 1. end program main
  5. P

    Comp Sci Can‘t call a subroutine name in a subroutine in Fortran90

    Here is the code for example: PROGRAM main CALL B() CALL CaoB(B) contains subroutine B() IMPLICIT NONE write (*,*) 'fk' end subroutine B subroutine CaoB(fcn) implicit none INTERFACE SUBROUTINE fcn() IMPLICIT NONE END SUBROUTINE fcn END INTERFACE write...
  6. MahdiI84

    Fortran Dimension of arrays (RESHAPE) in Fortran 90

    program testmatek implicit none integer :: Nc=1000 ,k integer,parameter :: N=2 REAL :: kx ,a0=1.0 ,t0=0.25 DOUBLE PRECISION :: pi=4*ATAN(1.) COMPLEX , PARAMETER :: i=(0,1) complex :: ek1 ,ek2 complex :: MATRIX_ek(N,N) open(1,file='matek.txt') MATRIX_ek(N,N)=(0,0) DO k=-Nc,+Nc...
  7. buddhanath

    Fortran Fortran jump command for fortran 95

    Even after writing the label , it is showing that label is not defined, please help! my program reads...…... ……... 99 z = b + 2*c*(d - 0.0792079*(e + log((( sqrt(x) + 1.52569)**5.64616)/(((sqrt(x) - 1.26704)**5.93863)*((sqrt(x) - 0.258652)**50.2075)))) - 2 log(x)) zs = g + 2*i*(d - 0.0792079*(e...
  8. J

    Fortran FORTRAN 90 - Insert Matrices into Other Matrices

    Hi, I haven't made a code for it yet, however I will be making a Gauss-Seidel algroithm in Fortran 90, for solving very large matrices (actually to initiate the multi-gird method but that's irrelevant for this). As part of this, I wish to insert matrices into other matrices. in MATLAB this...
  9. Abhisheko07

    Fortran Spring Pendulum system in FORTRAN

    I have checked the program several times the program is running but the graphs I am getting is not what I was accepting soon one of the variables approaches zero I don't know why is it happening. The program I have made is below and it's in the FORTRAN language. If anyone knows Fortran can they...
  10. N

    Fortran Having trouble when reading file using Fortran 90

    implicit none!do not use an undetermined constant character(len=18)::fname character(len=22)::fname_2 character(len=19)::fname_3 character(len=7)::yyyymmd character(len=1)::dash character(len=1)::d character(len=1)::f1 character(len=1)::f2 character(len=1)::f3 character(len=1)::f4...
  11. davidfur

    Fortran Parallel DO loop with OpenMP (fortran)

    Hey guys, I've started to read some OpenMP programming and now I'm trying to parallelize small part of a fortran code. The first thing I would like to do is to parallelize the innermost DO loop. It loops through the number of particles (na) and calculates the distance between some point in 3D...
  12. Pooyannikeghbali

    Fortran Extract values from ASCII file in GIS by Fortran code

    I want to read values from the ASCII file of GIS by Fortran code. In GIS, an area has meshed. Each mesh has an individual value (e.g. velocity of water). Here is the website that shows how the ASCII file is working in GIS. https://en.wikipedia.org/wiki/Esri_grid I want to know if anybody has...
  13. IreneFerri

    Problems with Landau Wang algorithm in fortran

    I have been struggling for over a month now with a problem I cannot fix. I would really appreciate any comment or guidance. Thank you! I am considering an Ising-like model with N agents that han hold one of the following 3 states, represented by vectors: state + : vector (1 0) state 0 : vector...
  14. J

    Fortran Beginner OpenMP FORTRAN help please

    I am trying to understand OpenMP, but my experiments are not paying off. I made a simple FORTRAN program to show me parallel time results. it turns out that parallel times are greater than single thread. What am I doing wrong? results: (changing number of threads) No OpenMP seconds=...
  15. Chaitanya_90

    Fortran Help with these Fortran Compiler Errors please

    What is the reason for error while compilation
  16. P

    Fortran Are these bugs for the GNU Fortran, g++, and clang compilers?

    I tried to calculate the smallest number in my machine with gfortran, g++ and clang. I did it by looping as: a = a / 1.73 In gfortran after 1358 loops, I found that a = 4.9406564584124654E-324, and the value of a never changes from loop 1358 till the end 1500 loop. It is questionable for me...
  17. suezxc6

    Comp Sci Need help with Fortran tracing

    integer n, ar(12) ar(1) = 1 ar(2) = 2 do n=1, 10 ar(n+2) = ar(n+1) + ar(n) end do do n=0,3 print*, ar(12-3*n) end do print*, ar(ar(ar(4))-1) end
  18. suezxc6

    Comp Sci Need help with Fortran homework -- Error: Invalid form of PROGRAM statement

    program Lab5A implicit none ! This program introduces Fortran string handling capabilities character*26 upper, lower, name, cap character str*2, one*1 integer from, to, i, m lower = "abcdefghijklmnopqrstuvwxyz" upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"...
  19. jedishrfu

    Old timers reminiscing about Fortran

    <Moderator's note: This thread is a spinoff from https://www.physicsforums.com/threads/need-help-with-fortran-compiler-errors.985749/> There's a lot of Fortran dummies on PF and they know who they are! :-)
  20. suezxc6

    Need Help with Fortran compiler errors

    Summary:: so I am trying to compile this program and i keep on getting "Unterminated character constant beginning at (1)" and "invalid character in name" at the months section. what do i have to change to fix it? thanks program Lab6 implicit none character*9 month integer monthNum, pos...
  21. J

    Fortran Fortran subroutine solving for the velocity and displacement of a spring

    I have a simple Fortran code for solving velocity and displacement of spring, the code works fine when writing all together without using a subroutine. but as I am learning Fortran I tried to do it using subroutine, but I keep getting errors appreciate any help in advance. program msd implicit...
  22. U

    Fortran Fixing Fortran Runtime Error for Beginner

    Hi, I am a beginner of Fortran. Recently I try to use a fortran code for my simulation. But it always shows me the following error when execute the program: At line 18 of the file sous.f (unit =11, file = 'fluid'), fortran runtime error, End of file, Error termination. Backtrace: could not print...
  23. B

    Second programming language to get under the belt: python vs C

    Hello everybody, I am a master student in Theoretical Chemistry and I am working in the DFT realm. Both TDDFT and DFT applied to extended systems (eg. using QUANTUM ESPRESSO). Of course I work with these softwares from a end-user point of view, not as a developer. But anyway, even if some of...
  24. Purahei

    Fortran Fortran Tutorials: Learn FORTRAN Easily

    Does anyone know any FORTRAN didactic tutorial?
  25. Purahei

    Fortran Discrete Element Method in FORTRAN 90 for collisions of particles

    Does anyone know a simple implementation in FORTRAN 90 of collisions of particles?
  26. Parzeevahl

    Comp Sci Multiplication of two 2x2 matrices in Fortran

    I have tried to do this using arrays and do loops: program matrixmul implicit none real A(2, 2), B (2, 2), C (2, 2) integer i, j, k write (*, *) 'Input: First matrix' do i = 1, 2 do j = 1, 2 read (*, *) A (i, j) enddo enddo write (*, *) 'Input: Second...
  27. K

    I'm getting garbage values while reading matrices from a file

    Hi All, While trying to read a matrix from data file using fortran90 code ,I get garbage values and a backtrace error. Error termination. Backtrace: #0 0x7f4a4de3631a #1 0x7f4a4de36ec5 #2 0x7f4a4de3768d #3 0x7f4a4dfa4d42 #4 0x7f4a4dfa6ad5 #5 0x7f4a4dfa80f9 #6 0x56040bbeae57 #7...
  28. S

    Fortran Generate a circle in FORTRAN having polar coordinates

    Say "I have grid in polar coordinates (r, theta). How do I plot it in tecplot. Tecplot plots it in cartesian coordinates."
  29. K

    Fortran Runtime error while reading file in fortran90

    I'm new to fortran coding and trying to read a file called "data.dat" with data like a triangular matrix 0.1 0.1 0.2 0.1 0.2 0.3 0.1 0.2 0.3 0.4 0.1 0.2 0.3 0.4 0.5 using the code PROGRAM matrix IMPLICIT NONE REAL, DIMENSION(5,5) :: a INTEGER :: row,col,max_rows,max_cols max_rows=5...
  30. Cayo

    Fortran Help with fortran numerical precision

    Hello. I need help to understand why my code is not giving me double numerical precision. In this piece of code, I create a function that is analytically normalized, but when I calculate the numerical normalization factor, it seems to be with single precision. Here it is: program dyna...
  31. R

    Fortran Reading a specific column from .csv into fortran

    Hi, I am using fortran to read specific columns from a .csv file. the rows in each columns are different, so I wish to read columns wise with a do loop. say, I wish to read from A1 to D20 initially(4 columns of 20 rows), then later f1 to h35 (3 columns, 35 rows). how do I read particular columns...
  32. K

    Fortran How do I find an exact line from a large file in fortran90

    I'm new to prorgramming . I have been working with Fortran90 for my physics project and I have to read data from a file. I need to find a specific matrix and then print the said matrix onto a different file and diagonalize it. How do I read the matrix that follows a specific line from a file ...
  33. vjvaibhu

    Fortran Calling a subroutine in Fortran 77

    I am calling a fortran 77 subroutine in a fortran 90 code and the results i am getting are wrong as confirmed from matlab. Can anybody please let me know where is the problem? do isss=1,5 do ig=1,10 dat0=dat(:,ig,isss) do iss=1,5 if...
  34. Ottodomus

    Fortran Need to do a multitask program in Fortran 95

    Hi everyone, I am new programming in Fortran and Inhave done about three or four programs that solves different problems in trigonometry, one is the basic one it gives you hypotenuse upon two sides, the other finds the theta angle by giving hypotenuse and opposite side, other find hypotenuse by...
  35. Telemachus

    Fortran Fortran: Array Syntax Explained

    Well, I'm trying to move a bit into modern Fortran, and I am more used to Fortran77 syntax. So, for example, when I wanted to make an array whose two of its components equal another array of another dimension, I used to do something like this: do k=1,N do j=1,N do i=1,N...
  36. J

    Comp Sci Help with solving first order ODE using a simple Fortran code, please

    I am trying to solve the following first order ODE using a simple Fortran code : $$ ds/dt=k_i * \sqrt{v}$$ where both (ki) and (v) are variables depending on (h) as follows $$ k_i=\sqrt{χ/h^2}$$ $$v= \mu h$$ where (μ) and (χ) are constants. (the arbitrary values of each of them can be seen...
  37. B

    Comp Sci Dynamic Link Library, Compaq Visual Fortran 6.6 & Module

    Dear Forum Members, I need to create and use dynamic-link library (DLL) for Fortran application using Compaq Visual Fortran 6.6. The following code works just fine: ########################################### PROGRAM AMAIN1 IMPLICIT NONE REAL(8):: A,B,S A = 1D0 B = 2D0 CALL SUBRO1(A,B,S)...
  38. I

    Comp Sci Solving Fortran 77 Assignments with XYZ: Reading & Calculating Values

    Hey guys, new here and was hoping for some help. Basically I have to use Fortran 77 to complete some questions for an assignment The first thing to do is, read a bunch of numbers in a list format and then use these numbers to be entered within an equation. The values I have are listed in a 1...
  39. P

    Fortran MPI_TAG_UB for openmpi/2.1.1

    Hello, I am trying to get the parameter MPI_TAG_UB for openmpi (I am using version 2.1.1). I know I need to use the routine MPI_COMM_GET_ATTR, but I have no idea how to do that, I never used fortran in my life. Following this link...
  40. Raziel13

    Fortran Fortran complex number read

    Hello, I need to read a fortran data with complex numbers and real numbers, the first column is the real numbers, the second and third complex numbers (real, imaginary). I need to read the first 64 lines and then the next 64 lines in separate ways and save in a variable. for example read from...
  41. I

    Why doesn't SNEC work with my profile?

    Hello, I have made a python script that splits my desired star.data file from a MESA model into two distinct files that I need to use in SNEC link here: https://github.com/abostroem/SNEC My script is here : https://github.com/ilaur/SNEC-Split When I try to run SNEC with my custom profile it...
  42. S

    Fortran FORTRAN 77 IO Error: Troubleshooting with FORCE 2.0

    I have a FORTRAN code that is producing no error upon compilation but when I run it, the run aborts with following message "open: illegal unit number apparent state: unit 72 <unnamed> last format: list io lately writing direct formatted external IO This application has requested the Runtime to...
  43. Aun Muhammad

    Fortran 1D Shallow Water Wave in FORTRAN using LAX WENDROFF Method

    Hey everyone, I’m trying to simulate a 1D Shallow Water wave in FORTRAN using the Lax Wendroff Method. The case is fairly simple. I have a wave generator on one end of a water pool and a wall boundary on another. The waves start traveling towards the wall and are ‘reflected off’ the wall. The...
  44. Aun Muhammad

    Fortran Successive Over Relaxation Method in FORTRAN

    Hey everyone. I've attached a code I have written in FORTRAN implementing the SOR Method for a 2 D Laplace Equation. Subroutines have been created, grid has been created and initial and BC's applied appropriately. While computing the error of each iteration, I am unable to achieve the desired...
  45. Dr. Courtney

    Programs Best Way for a Physics Major to Learn Fortran?

    A physics major I'm mentoring has been invited to join a theory group that makes heavy use of FORTRAN in their calculations. The student already knows Python and is adept at using it including integrating diff eqs and solving various challenging 1st year physics type problems. This theory...
  46. M

    If statement for Monte Carlo integration

    Hello, I am writing a program on Fortran to calculate the integral of sin^4(x) between x = 0 and x = π/2. I believe I know how to write the correct code, but I am unsure what the if statement should be for whether or not a point is inside the desired area. Any thoughts? Thanks.
  47. S

    C/C++ How to use C++ in studying calculus

    How to use C++ in studying calculus I'm having a hard time.
  48. J

    Testing my Discrete Fourier Transform program

    Homework Statement I've written a program that calculates the discrete Fourier transform of a set of data in FORTRAN 90. To test it, I need to "generate a perfect sine wave of given period, calculate the DFT and write both data and DFT out to file. Plot the result- does it look like what you...
  49. J

    Magnetostatics experiment flowchart - How can I improve this

    Homework Statement I'm attempting to write a FORTRAN program that calcuates the magnetic field, B, at any point outside of a bar magnet. I will be using a simple first order euler scheme for numerical surface integration. Homework Equations Here is the exact method I will be using...
  50. U

    Fortran How to buy Fortran Programming Software Commersial License

    Hello,, I want to know how to buy the Fortran software,? I use Fortran programming to simulate some my work for my study. Do you have any suggestion about that??