Hi everybody,
I have just joined this forum and I have a problem in fortran programming. I want to do a program in fortran where in the do loop it will read an input file from the first line upto a line and again it will go to the starting line of the file in the next loop and read...
Hi All,
I am very new to FORTRAN Programming. The problem is related to commandline argument. i have a executable program which take 3 command line argument as an input. one is text file and two is variable. I want to write a script were i can execute this script and save in different file and...
I am freaking out man :smile: I have this program and in it I have the variable nPT declared as Integer. Somehow, after nPT is passed to subroutine, its value changes to a very large negative integer value. I cannot make sense of it. In the subroutine pasted at the bottom, the value of N (which...
I want to interpolate a set of points (x(i),y(i)) for i=0, n; using Newton's polynomial of degree n.
I've Kincaid's book of numerical analysis. He gives an algorithm that doesn't make entirely sense to me.
He says for
i=0, n do
di <- f(xi)
end
for j=1, n do
etc.
Basically I'm stuck...
Can someone tell me why there exist 2 different ways of indicating the end of a 'Do' loop? Is one advantageous over the other? Or is one just an older way of doing it?
What do you tend to use?
If you call a subroutine from the MAIN code, is it standard to declare the variables used in the subroutine in the subroutine itself or in the main code? My gut tells me the former, but the horrendously written code before me tells me the latter.
Any thoughts?
Input a polynomial into FORTRAN?
Hello all, I took a Fortran programming class last semester and can write Fortran well. However, I never recall anyone ever asking if there would be a way to input a polynomial into the command prompt. I'm assuming there is not. It would be great though. I have...
Here's a part of my program in which I'm having an error while compiling:
open(unit=1,file="tabla.dat")
allocate (x(n),y(n),f(n))
do i=0,n
x=(2*i)/n-1
f=1/(1+25*x**2)
write(1,*)x,f
end do
do i=0,n
read(1,*)x(i), y(i)
end do
close(1)
I'm having the error with gfortran: "Fortran runtime error...
Hi all,
It is my first time to resort to the help of members of this forum :)
My question is related to programming in fortran but I am rather new with it.
So here is the question:Can I use user defined functions as arguments of a user defined functions in Fortran?
I have written a simple...
Dear Physics forum
I tried to compile fortran program using the command "g77-ffree-form program.for", while compiling it shows following error.
C:\Documents and Settings\Balaji\Desktop\Fortaran>gfortran -ffree-form program.f
or
program.for:1.64...
I have problems with my code.As a result of calculation I got rank2 l(21,1) array.Due to the THE ITERATIVE PROCESS I will get the same array in every iteration.How to allocate values and use them later.Should I create new array
like
do iter=1,n
lbig(iter,nmax,1)=l(nmax,1)?
Well the issue here is that I will have 21 numerical values written into one array,but then goes iterative procedure and get 21 values for model 2.How to write l(m0),l(m1)?I will need these arrays later for calculations.
Can you please help me I can't compile using lapack libraries and I can't find anyone who can tell me how to compile.
I have blas_LINUX.a and lapack_LINUX.a and I am trying to use ifort to compile my program but I always get the below error. Please help.
These are the libraries I have in...
I have a problem,actually I want to join two FORTRAN codes.One of them is main and the other calculates some issues(geophysics stuff).I am not sure that the second code can be represented as subroutine because it has 2000+ lines,with 10 subroutines inside itself.How to solve this?Is it possible...
Homework Statement
Write a program that reads the time, temperature, pressure, and volume measurements from a data file like :
0900015001990700
1000019602210877
1100021202790925
1234034203221015
1300038803221121
1400044803241425
1503051303201520
1604055503181665
1700061303191865...
I don't understand why I get an error when I use the goto "command" like this:
(...)
goto 11
(...)
11 end program
----------------------------------------------------------
The (...) represent the other part of my program. I tried to change the place of the 11. Because if I...
I have a 3D ising model simulation, what i am trying to do is look up each column in the array and if all the values of that column are -1 then i wish to write the i and j coordinates of that column to a file. the section of code I am having problems with is:
OPEN (10, FILE='holes.dat')...
This might be a stupid question but my TAs in my lab could not answer it so I thought I would try to ask it here. What I want to do is for the user to enter some string of characters for something such as a password and for the input not to show up on the screen or for it to be replaced by...
Hi All,
I have an interview concerning Fortran programming. Actually one section of the interview will be on Fortran programming.
First, i am trying to get differences between Fortran 77 and Fortran 90 and have the following questions. The differences are:
1) Control Structures...
Hi guys
Im quite proficient when it comes to Matlab, and am now scheduled to learn Fortran 90/95 for a PhD-project (OS: winXP/win7) and I want to ease the transition as much as possible. I have been scouring the internet to learn more about what I am faced with and one thing keeps bugging me...
Hey,
I want to solve a parabolic PDE with boundry conditions by using FINITE DIFFERENCE METHOD in fortran. (diffusion) See the attachment for the problem
The problem is that there is a droplet on a leaf and it is diffusing in the leaf
the boundry conditions are
dc/dn= 0 at the upper...
Hey,
I want to solve a parabolic PDE with boundry conditions by using FINITE DIFFERENCE METHOD in fortran. (diffusion) See the attachment for the problem
The problem is that there is a droplet on a leaf and it is diffusing in the leaf
the boundry conditions are
dc/dn= 0 at the upper...
I have several fortran code files which can be correctly compiled and run in Windows XP using gfortran. But, when I use the gfortran 4.2.1 compile these files on Mac(10.6), the code files can be compiled, but, it reports errors when I run the compiled file.
the error is related to the...
Hello,
I am am confused about how fortran code is being executed and how are the variables in the memory updated during the execution.
My code in simple terms looks like this:
give some values to a matrix psi(lx,ly) (initialization)
main loop do n=1,nend
nt=psi^3
make Fourier...
Hello,
I'm writing a really simple program in fortran which is a part of a bigger program.
It is not working at the moment, but I really don't know why.
I am calling a function called precision, but the program does not enter it ( I know it since I use write statements inside).
I compared...
Hi,
I have a rather large program written in fortran 77/90. In one of the subroutines a lot of local dynamic arrays are declared.
In order to make this program able to calculate more stuff, I need to bring these dynamic arrays back into the main program.
I have tried to define the...
program pr2
implicit none
integer:: i,j
real, dimension(21,80) :: istat
open(7,file='sens.dat',status='old',action='read')
read(7,*)((istat(i,j),i=1,21),j=1,80)
write(*,*)istat
end
Where is the problem?Input file has 1680 values.But I get...
I have a fortran program and need to compile it with LF95 (Lahey/Fujitsu fortran 95). Anyone knows where to download a demo or trial version of LF95? Or if you can upload to rapidshare or megaupload or send me a private message. That would be very helpfull.
I have an assignment to calculate the least squares fit line to a set of points, and I have to read in an arbitrary number of points from the user
So my plan was to have the user enter how many elements they have, and then create an array with that many elements. So let's say I read the...
Hi. I'm trying to make a pointer point to sections of a rank-2 array given by specific values of
it's second index. I other words: given a table I wan't a pointer to point to specific columns, making of it a "filtered" table.
The method I was trying was like
DOUBLE PRECISION...
Here is the problem.I have this array zmdsens(iper,i,1,iprd) where iper is period,i site,1 mt function and iprd conductivity.This array stores MT functions for all above mentioned.I need tot find transpose of MT function,but fortran 90 can easily do that only with 2dimensional arrays.How to...
Hi, just wanted to know which version of FORTRAN is best to learn for one studying astrophysics...and whether C++ is of any importance in computational astrophysics...Thanks
Hello everybody.I have a problem with a program I wrote in Fortran.The program is this and it is giving me the error 299 at line 4(parameter (n-100001)) saying -Statement ordering error - PARAMETER cannot appear after executable statements. What can I do to fix the problem?? :-(
program...
Any suggestion for a windows Fortran compiler? I've seen many around but it is somewhat difficult to choose when you don't know much about the subject!
If you have any suggestion for Linux feel free to add them anyway!
Leo
Hello all,
I am trying to learn fortran 90 by rewriting some simple MATLAB codes I have in fortran.
I tried to rewrite a linear, 1D finite element code for an elliptic equation and my fortran and MATLAB codes both end up assembling the same system matrixes (K and f), but the solution to...
I found the following program in a textbook and I don't understand how logical variables are used for the sorting function. I understand that variables is supposed to tell the program to keep functioning until the sorting is complete, I just don't understand the specifics. The logical variable...
I feel somewhat embarassed to ask for help concerning this. I am a C/C++ programmer, but I am currently learning Fortran 90 on the fly and in a hurry. I am going to have to read in a 32x25600 dataset into a 1-d array (I know, not especially efficicent). I decided to start with a more...
Hi all
I am currently using subroutines, and placing them at the end of the main program. However, I was wondering if it is possible to save them to a separate file, which the main program then calls?
For example, in the program below I call the subroutine 'SUB', which is located at the end of...
I have a function that seems to be ignoring the first of 3 dummy variables. These variables are arrays with integer elements, should that be important.
For example, the call in the program is something like:
A = F(b,c,d)
and this transfers control to a function F, that is similar to...
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...