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.
Hello!
I am trying to write a code in Fortran to process the following data and write it into another file:
# energy (in eV), F(E) (in particles per m^2 per s per ster)
1.81E+17 8.3443E-28
2.26E+17 2.75658E-28
...
So far, I got the code to read...
Guys, I need you help. Next week I'm starting a project that requires some knowledge of FORTRAN. My programming skills are pretty rusty, I was wondering if you knew a good beginner's guide to FORTRAN.
Most of the examples here are given from the following book,
Michael Kupferschmid, "Classical Fortran: Programming for Engineering and Scientific Applications", Taylor & Francis Group, 2009
The generalized form of READ command is as follows,
READ (unit, format) list
where, the value of...
Hello all, I'm new to this forum, but not to Physics, I'm completing my master degree. :)
I'm currently running a simulation using Minuit from CERN. I recently changed the computer I'm working on, the new computer has Ubuntu 10.10 installed (I was working on my director's Mac before). All my...
Homework Statement
I have an assignment to write a program for calculating the sine (and various other functions) using the method of truncated infinite series using DO statements. The DO statement is supposed to run until the difference between the current and last iterations are less than...
I have strange situation where a code that generaly seems to work fine at times gives a error message.
Basicly I run simulations on a lattice model, and have experience no problems for small system, but when I go to larger systems (meaning that the simulation takes aprox. 15 min) I sometimes...
Due to research changes I have to switch from C++ to Fortran development. In the past I have used Microsoft development tools since they are free for students, but afaik they do not have similar software for Fortran, and the Intel software is a little too expensive for me to afford.
Which...
Hi
I'm having some trouble with understanding the whole concept of the common block in Fortran 77.
Here is an example:
common /hmat/ a,b,c,d
It means that all the variables a,b,c,d are all contained in hmat. But does hmat need to be defined previously for the above example to make...
There are some caveat in fortran 77 while calling functions inside subroutines?
I have some weird errors while calling a function inside a subroutine, e.g. Segmentation Fault while using/writing the argument of the function (but not sooner, I can still do an "Hallo World"!) or starting a do...
Hello
Could anyone help me rewrite following C code to Fortran code? It generates coords for sc silver atoms.
#include <stdio.h>
#include <math.h>
int main(void) {
int
i, j, k,
n = 0;
double
A = 4.08,
L_X = 20.0,
L_Y = 20.0,
L_Z = 15.0;
int
iMax = ceil(L_X/A)...
Hello all,
I have some data stored in character*1 array(value,value) apparently the code is in f77, i got the original reading code for the data as a text...
I am working in f90, and to the extend of my knowledge (not much in fortran) I can not declare such 2D array as character...
Hello,
I'm making now a simple program (in Fortran 77) to find the roots of the quadratic function. When the discriminant is negative, imaginary numbers are to be used and the solution of the function is a complex number.
I'd like to define a complex variable so that:
complex x...
I have been trying to merge some python with fortran, to build a nice interface but still be fast. I spent the last two days learning how to use f2py, buy everything would be so much easier if I could call a Python function from Fortran instead of doing the other way around.
Anyone know how...
I've heard that there's some movement towards newer languages like Python. But is there some resistance to this movement? Is there a similar problem with physics departments?
Do astronomers prefer their grad students to be fluent with FORTRAN or with Python? I know one professor who doesn't...
I know there are tons of them out there, but I am looking for a recommendation on one. I know absolutely nothing about Fortran and very little about programming in general. I do know that I will be inheriting a bunch of code that was written in a g90 environment (if that is even the correct...
Hi there,
I've been puzzling over the following code (which works in serial). It produces radically different answers if the (blank) WRITE(*,*) is included or not. Any help greatly appreciated!
eps = 0.0
!$omp parallel do default(none) private(i, j, current_angle, current_energy) &...
I have made and compiled a programme,but the calculations are not good,because it has somehow problems with findfiff2d.o file(calulates travel-times on nodes).May be the problem is that findiff2d calls 6 other subroutines.So main=>findiff2d=>expand,sort,pass,stensilcs2d,fnod e,fside.So how to...
Can someone suggest a way to easily compile fortran 77 code so it will run on a Windows machine. For my research I need to use a computer code that was written by former students at my school several years ago in fortran. I have very little experience with this sort of thing but I really only...
The following question pertains to programming, but I have posted it here because I want the views of mathematicians (also of physicists and engineers), not those of computer scientists (which i already know) and I do not know how many of the former category care to look into programming...
Hey guys,
I am wondering if anyone could help me with a simple problem.
I want to remove key parameters from the "type declaration/parameter" portion of my code and into an external input file for easy access. The problem is, many of my variables (such as arrays) can't be defined until...
I have a program written in Fortran IV and tryed to run it with fortran77(g77). Nevertheless
it could be not problem in fortran IV it make some errors in fortran77. I am not programmer but trying to learn some. Here is the errors that compiler fortran77 is wrote:
found.f: In program...
Hi,
I have been struggling with the Fortran IO for a while. Here is the question, any comments will be much appreciated.
I output some double precision numbers with the format:
write (file_id,'(6(ES17.10E3,2X))'), a,b,c,d,e,f ! say the filename is 'data.dat'
It works fine.
But...
Hi everybody.
I am learning Fortran on my own, and I started doing simple examples like factorials, iterations, and stuff like that.
The problem comes in recursion, I'm trying to run this simple factorial program using recursion, but the outcome is completely wrong.
I asked to an expert in...
Dear all:
For a standard linear system, y(n*1)=A(n*n)x(n*1)
If y is exact and A is well-conditioned, it is easy to calculate x.
However, if y has some disturbances or some errors, at the same time, A matrix is ill-conditioned. It is difficult to accurately obtain vector x...
I am trying to input a txt file into my fortran program. My txt file is a 9x2 table of integers, all I want is to display the values in the same format in my program. I tried using,
program name
implicit none
integer :: input(9,2), I, J
open (unit=20, file="values.txt")
DO I =...
Hi guys,
I just wrote a simple code for delta function and print it out. Here it is.
program main
implicit none
integer i
real*8 del
real*8,parameter:: ep=1D-2
real*8,parameter:: pi=3.1415926
do i=-10,10,1
write(*,*)...
I'm trying to contruct a program that will generate a different random number between 1-10. I am not sure how to make it only 1-10.
PROGRAM guess
USE const
IMPLICIT NONE
INTEGER::i
REAL(kind=dp)::x
call random_number(x)
WRITE(*,*) 'x=',x
END DO
END PROGRAM...
Hello,
I think i heard somewhere that a multidimensional array in fortran 90 may be stored non-contiguously in memory. Is this true? Even if it the size was known at compile time?
If your answer is it depends on a compiler, what about ifort and gfortran?
Hello all,
I am new to programming and fortran, I have Intel Fortran 9.1 and using this via Microsoft Visual Studio 2005. To start with I have found a simple exmaple from the a Intel Fortran 90 book. I seem to be able to run a debug, but can't seem to create an executable? Its my first time...
Hi,
I'm trying to compile a code (.f95, compiling using gfortran) in which I'm using a 'do' loop to set the values in a complex array; the following little piece is giving me trouble:
double precision, dimension(n) :: x
complex, dimension(n) :: y
do i=1, n
x(i) = ...
end do
do...
Hi,
I heard that fortran is quite a useful language for some scientific computations, so I looked it up to see what is looks like and I was surprised that the syntax is very similar to Pascal. I know that syntax doesn't mean anything, but it seems to me that when languages have a similar syntax...
Hi all,
do i = 1, 79
open(2,file=afiln(i),status='old')
do k = 1,11
read(2,'(51a)')astr1
enddo
do j=12,2000
read(2,22,end=23,err=23)iyr,imn,id,ih,imt,flx
write(7,*)i,j
obstim =...
I am a student who is currently enrolled in a computer science class, and the program we are using is Fortran 95. I was wondering how I could get this program/compiler onto my own computer? I have almost no experience with programming and Fortran so I really want toget this on my own system...
hi
i have over flow error in FORTRAN for a program that do some function and summation on matrix elements , then multiply them and at last find its determinant, the dimension is SET by input
when it is more than 7 i have this error
what should i do?
Hello all,
Although I am currently working on implementing FORTRAN on my Mac, I would also like to find a compiler that works well with Windows 7 32-bit. I initially had Win7 64-bit installed on my computer, but when I went to use my (really old) DIGITAL Visual Fortran install disk, it said it...
If so, how did you install it? I have been looking at http://gcc.gnu.org/wiki/GFortran" and apparently you have to be a rocket scientist to install the compiler. I'm a little desperate here. I really know nothing about compilers. Most compilers I have dealt with simply require me to run a...
Dear all,
I am using f90 and trying to pass only one column/row of an array into a subroutine. So I want something like...
call test(x(1,:),...)
If "test" defines the first entry as a vector, will this work?
Natski
Hello there. I've doing a program that I do not know how many files will be needed, because it'll depend on user's choice. So, how to name them?
I tought that a command like, where n is a user-input number
Do While (i .LE. n)
Open (Unit=i, File=i'.dat')
i=i+1
EndDo
Would be enough, but I...
I have a short code that calculates the running median for three columns of data in an input file and writes the running medians out to three columns of data in an output file. I use Numerical Recipe subroutines and functions to compute the running median. If I include a WRITE(*,*) directly...
Hello.
I'd like to create an array containing characters (basically a word stored as a 1xn array). I have no idea how to do this, however. I thought that the most obvious way to do it (yes, it would've been highly impractical for long words) was to write
character, dimension(3) :: A...
Hi,
I require specific formatting for a quantum chemistry calculation. But for some reason I can't seem to write using formatting. I have checked tutorials, but to no avail. Here is my toy program:
program test_format
implicit none
real :: m
write(*,*) 'Enter a number'
read(*,*)...
27 Jul 10 2:35
Hello,
I have an error when I try to execute my python program which uses a fortran subroutine (which call date_and_time function) :
"undefined symbol: G77_date_and_time_0"
Do you know how can I fix this issue?
Thank you very much!
The instructions are to calculate the odds of winning if you are dealt King and 9 of clubs, what are the odds of winning? I am finding myself spending more time trying to figure out texas hold em (never played before) than writing the program. So far I found a list on wiki that breaks down the...
I've made a program that uses more than 72 characters per line. When I try to compile it on gfortran, using -ffixed-line-length-n, it returns several errors, all of them derived from a line truncated at the very beggining. How can I compile it or untruncate the line?
The code is as follows...
I am trying to write this program, it runs fine but I can't get the imaginary numbers to print correctly. I have been trying this for a few hours now and can't figure it out. Here is the code, I am running Force 2.0. Thanks in advance for the help.
Program Quad
Implicit None...
I am using one progran,have problem with char function.
rfile(3:4)=char(id1+48)//char(id2+48)
write(6,*)rfile
open(28, file=rfile, form='unformatted', status='old')
I have entered write line.This is what I get:
fd01.picks
open: No such file or directory
apparent state: unit...
Hi all,
When I use Present(x) to check for the presence of an optional variable, I am getting TRUE even when the subroutine call clearly does NOT contain the optional variable. See here the call to test_present(a,b):
program options
implicit none
real*8 a,b
real*8 c
a =...
I was just wondering if anyone can recommend any free Fortran compilers for OSX on Mac? I am going to be starting some work that requires the use of Fortran and though I have a Windows machine, I would like to use my Mac since it is faster.
I have Googled around, but I am really not sure...