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.
small FORTRAN code for combinations. BUG!
PROGRAM test
implicit double precision(a-h,o-z)
INTEGER :: r=2,n=4,k=1
INTEGER,allocatable :: comb(:) !array to hold a set of combinations
allocate(comb(r))
comb(1)=1
CALL iterate(1,n-r+1,1)
CONTAINS...
Welcome all,
I have a following code:
program aaaa
implicit none
double precision, dimension(:), allocatable :: inp,outp
integer ::n,i
read(*,*) n
allocate(inp(n),outp(n))
write(*,*) allocated(inp), allocated(outp)
write(*,*) inp(1)
inp=cshift(outp,-size(outp)/2)...
Hello all, I am developing a new analytical solution for a problem in flow in porous media, and I need to write it in Fortran.
This solution contains the modified Bessel function of the first kind, I_n(x).
The order n is a real number, and it can be both negative and positive.
The argument x...
Dear Fellow Members,
I am presently trying to write a Fortran 95 program to
separate acids from a list of chemicals in a text file and
then write them to a second text file. The program first
matches the word "acid" and is then supposed to check if
the word preceding the word...
Hi all,
I'm writing a program in FORTRAN to calculate neutron flux in a reactor, but when I try to get a numerical output it simply says NaN. Anyone know what this means or how to fix it? Code is below, and this is happening on the flux2(N) output on the last write statement. Thanks...
Hi everyone
I am completely new to the Fortran. I have to make a program in fortran 90 to either add or multiply the matrix on user demand and ask user to enter the file name inorder to read the desired matrices.
I came up with the the following code which does not read the program and...
Hi!
I've never done any programming in fortran and got stuck trying to test run a program.
Note that I am not learning how to program in fortran, this is for an astrophysics course.
Basically what I need is an instruction how to run a fortran code if I have some .f files and .o files as well...
there is a program in written in fortran 90 and a program written in c, the first program is able to modify .xyz (mol files) and the C program can read those,
so is it possible to make an interprocess communication between these 2 program to let one update instantly if i change anything in the...
Hi everybody,
I have 3 columns of data (3 different variables) and 400 rows. How would I set up a matrix/array sort of thing to read each row individually and store it in my fortran program to calculate equations at each step?
What I have basically tried and can't get to work, I think it...
Hey guys I am trying to understand a code for a Fortran 77 subroutine which calculates spherical harmonics using the CERN library RASLGF for legendre functions. The code looks like this
subroutine harmonics(max,theta,phi,Yr,Yi)
implicit none
integer max,k,nn,n,grens...
Hi all
I'm using Fortran code written by someone else, and a lot of the files have #ifndef statements in them. For example:
#ifndef global
REAL array(2500)
#endif
I've tried searching online, but can't find anything useful that actually explains what this bit of code does...
I'm having some difficulty figuring out exactly what the issue is here. The compiler tells me that I'm lacking types for certain function variables, but when I define them in the module it tells me they are defined in multiple locations, and still won't compile. what can I do to absolve this...
Hello. I am a physics student working on research project which involves Fortran 95 code. I am very new to Fortran but I do have an intermediate knowledge of Java. The task I am attempting seems like it should be very simple but there are many subtleties to learning a new language that are...
Alright, I have a situation where I need to create a user defined function (I've done that) next I need to write a subroutine that uses the bisection method to find the zeros of said function (I've also done that) but I can't figure out how to call on the user defined function to evaluate at...
Homework Statement
Write a Towers of Hanoi program in Fortran 90 using a subroutine.
Homework Equations
The Attempt at a Solution
hello all
Ive been trying to write a simple Towers of Hanoi problem in FORTRAN 90 dealing with recursion.
Ive got my program to compile but it...
Alright, I cannot seem to get this subroutine to return the correct sums for the trapezoidal rule... Where do I need to fix?
SUBROUTINE atrap(i)
USE space_data
IMPLICIT NONE
INTEGER :: i, j
REAL :: f_b1, f_b2, f_x1, f_x2, trap_area
REAL :: delta_x
trap_area = 0
f_b1 = lower
f_b2...
I am working in FORTRAN
I need to avoid writing to the same file at the same time while working in a parallel environment.
I have a program (that I have not written and cannot edit) that calls a subroutine (that I have written and can edit). The subroutine is called over and over again by...
Homework Statement
This is assignment is on FORTRAN 90:
In an assignment i have, i am to enter a date in the format DDMMYYYY, and its suppose to compute and display the day of the week that date falls on (based on a given algorithm). I was able to code a program that would give me the right...
Well I am taking a Numerical Analysis course, and I just bought a MacBook Pro. My problem is that I just barely can handle Mac's software, I need to install fortran and I don't have any idea of how to do it, also I need a program similar to Origin on windows for my mac, for the data analysis...
Hi all,
Greetings.
This could be a basic question, and if it is, pardon me for my ignorance as I am a newbie to FORTRAN. I am trying to modify a FORTRAN code where I have added a subroutine (say SUB1) to calculate a variable, say (QX). What I did is to call this subroutine in another one...
Alright, so I've updated it once more... The only thing I need to do is figure out how to convert the functions x_data, y_data and choi_1 that store all 3 of the inputs I need for the main program and other functions.
program calculator
IMPLICIT NONE
REAL :: addition, subtraction...
Homework Statement
The purpose of this program is to calculate the approximate roots of the Sine function on given intervals. The intervals are input by the user, and then the do loop continues until the condition (m becomes very close to 0 or equals 0) is met.
The Attempt at a Solution...
Homework Statement
I'm trying to convert data that's entered as a real number into integer data to be used in a do loop. The problem is that it keeps telling me that the numbers I've just converted are not scalar integers...
The Attempt at a Solution
program interest
IMPLICIT NONE...
Hi everybody,
I am currently enrolled in a course in university based on scientific programming in fortran 77. The issue that I have is that I cannot find a decent IDE for fortran. I have tried multiple other IDE's such as eclipse, netbeans (both requiring additional add-ons) and other stand...
Hello guys. I want to save the numbers between 0 and 1 with 0.01 increasement to a dat file. I wrote a code for this using Fortran however, after a point I get 0.314999 instead of 0.315000. Can you help me to solve my problem?
<code>
REAL, DIMENSION(:), ALLOCATABLE :: Y
REAL STEP, JEND...
This is my problem:
I would like to read data (saved in a text file) from a file. My data is written in a matrix format (1,000,000 rows x 3 columns).
I want to read a data from a particular line, say row number 90,000.
Since the number of rows is large, it will be very expensive if I have to...
I am very much confused and frustrated at this point and would just like to understand what I'm doing wrong... This program is supposed to calculate a truncated value of sine using it's series expansion beginning at i = 1. At values under 20 degrees it compares almost exactly with the intrinsic...
Hi
I have an array going from 0 to n (where n has been previously defined) but I want the array to be in steps of 5 rather than increasing each value by 1
eg 0,5,10,15,20,25...n
how can I do this?
Thanks
Hi all
I am trying to run an executable compiled from some Fortran files (not my own), which look like they are written in Fortran 77. One of these includes some dynamic space arrays, where the number of elements depends on an integer value passed to the subroutine, e.g.
subroutine...
Can some1 kindly help me understand the following code, I am trying to translate the following code in VBA:
Thanks in advance
FFLC = FLC ...i understand this part
ANGLE=PI/6 !Suppose 30 Degrees ...i understand this part
Do 21800 I=i,5 ...Don't understand this
FLC=FFLC-COS(ANGLE)*NDIA...
I would like to input a word in the fortran command line rather than a number. For example, if I wanted to exit a program with the word 'exit' how would that be done?
Thanks for the help :D
-Glenn
I am making the switch to OSX from Linux and am unable to find any solid reference to the best way to get gfortran onto my mac without using MacPorts?
What (other?) compilers are people using on OSX? I will have xcode installed as I typically develop in C and am looking to target the new Mac...
Hello, I am having trouble figuring out how to use Control Characters in Fortran. My professor skipped over that chapter back in my Computational Tools 1 course and I am trying to figure out how to use them. I am currently compiling my programs in the GNU Fortran compiler if that helps any. I...
Hello,
I am wondering if there is a way to update a number without printing a bunch of stuff in the CMD window. For example this is what I don't want (below). I don't want a long list of totals..
Total = 1
Total = 2
Total = 3
Total = 4
This is what I do want.
Total = # <=== I...
Hi, I am new in fortran.
I have this code in fortran 90, I get segmentation fault when I run my program, can you help me please, I am desperate!
SUBROUTINE COUNTX(NX,ncov)
IMPLICIT NONE
INTEGER, INTENT(IN)::ncov
INTEGER,DIMENSION(ncov),INTENT(INOUT)::NX(:)
INTEGER...
Is it possible to increase the size of an already allocated array in FORTRAN, without reallocation?
e.g. if in start A(3)=[4, 5, 6] and now I want something like A(4)=[4, 5, 6, 7].
Currently I am using a temporary array to do this
allocate(A(3))
A=(/4, 5, 6/)
allocate(temp(3))
temp=A...
It takes a lot of time for my Fortran program to do I/O jobs. Is there any way to do I/O jobs while at the same time it is doing computing jobs? To do I/O jobs and computing jobs at the same time would save a lot of time.
Thanks.
I have a program I am trying to understand. According to the function definition(vdot), the function acccepts arrays as inputs. But the function is called with a scalar input and it works just fine. Shouldnt it throw an error ?
w and v are arrays of different sizes. ms is a scalar constant...
Hi!
Im trying to do some rather easy QM-calculations in Fortran.
To do that i need a routine that calculates the generalized Laguerre polynomials.
I just did the simplest implementation of the equation:
L^l_n(x)=\sum_{k=0}^n\frac{(n+l)!(-x^2)^k}{(n-k)!k!}
I implemented this in the...
I need to create an empty array but the length of the array is determined by the start and end numbers entered by the user
for example if the range of numbers the user was interested in was 4-10 inclusive then i want the array to be of length 7
How to I go about doing this?
Other...
Hi,
Below is a fortran program to calculate the roots of an equation by Newton's method.
I compile the program with the free compiler g95:
g95 -c Newton.f95 then g95 Newton.f95 -o Newton.exe
When I run the program Newton.exe I get the error can't assign value INTENT(IN)::x to...
Hi everyone
I've been doing maths for quite a while now, but have never done any programming until recently. What I'm finding difficult is how you go from an initial value/boundary value problem on a bit of paper to a piece of code that will approximate the equation. I've done a bit of book...
Hi I am trying to write the following into a file using visual studio 2005:
REAL :: X =5
open(1, file = 'File.txt')
write(1,*) X, X, X, X, X, X, X
END
Is there a way I can have the output on just one line?
I need it to be from the variable X instead of just changing it to '5'
The...
Hi, I tried compiling my program in Fortran using the following commands:
nagfor -g90 -C=all -C=undefined -g -gline -nan -u -mtrace=all test09b.f90 cell_functions.o -o test09b
I ended up getting this error message:
[Allocated item 15285 (size 17) = Z'FFFFFFFFB744A790']
Runtime Error...
Hey, I'm trying to write my very first Fortran program. I'm a physics student and I don't know a lot about computer science and since I'm new to Fortran I'm still having problems with finding answers to my questions on my own. So..please bear with me.
I'm doing heavy numerical calculations...
I'm having problems compiling files with interfaces in Fortran. My compiler is NAG Fortran Compiler Release 5.2. I get this error:
-------------------------------------
Error: subroutines.f90, line 2: USE TEST_MOD in program-unit MY_SUB imports
symbol MY_SUB
detected at...
Hi,
How could I make a variable name with a variable in it in fortran?
For example I want to use a loop to assign values to a11, a12, a13, a14, a15 and a21, a22, a23
I DO NOT WANT TO USE ARRAY FOR THIS
Real X1,x2,x3,x4,x5
Do I=1,5
Xi(i=1 to5)=i
Enddo
( How should I get...
Hello all,
I wanted to know if there was a way to read in numerical data on the same command line on which you execute a file.
I know you can do that for i/o files like:
test.exe < file1.in > file2.out
But I wanted to know if there's some similar notation that can be used for floating...