This question already has an answer here: How to alias a function name in Fortran 2 answers I was wondering if there is something similar to this in FORTRAN. Of course this example does not compile but I think you can get the idea, program test character(1):: sub sub='A'...

I am a novice in Fortran programming but I have started using code::blocks with Fortran plugin. I am trying to pass variables between my code (f03) and fftsg.f (code from http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html) to calculate fft. fftsg.f contains a subroutine called rdft (real discrete Fourier transform) that I try to use to...

I have a nested IF constructed like this: if(tt-t(ind)<=t(ind+1)-tt) then t(ind)=tt y(:,ind)=yy else if((y:,ind) == 0) then y(:,ind)=y(:,ind-1) ! If a certain sample point is skipped ! then assign previous sample value to it endif ind=ind+1 t(ind)=tt y(:,ind)=yy endif I am getting an error saying if((y:,ind) == 0) then 1...

In the Fortran code given below, I have made all numbers involving calculation of PI as double precision but the value of PI I get is just a real number with a large number of zero or 9 at the end. How do I make the program give PI in...

I'm having problems fitting LAPack subroutines, written in f77, into an f90 program. Gfortran is the compiler. I know that f77 is supposed to be a subset of f90, but for example * is not recognized by the compiler as the start of a comment. It recognizes much of the...

In Fortran one can allocate memory to a pointer, or one cannot: real(kind=jp), target :: bt(100,100) real(kind=jp), pointer :: pt(:,:) But then you can allocate memory to the pointer pt: allocate(pt(100,100)) My question is: what are the pros and cons? For all I can see, allocating memory to the pointer...

I am trying to be able to pass a multidimensional Fortran array to a C++ program, in a C++ Fortran interoperating program. I have a basic idea of how passing the arrays from Fortran to C++ works; you pass a location of the array from Fortran to C++. Then C++...

I'm trying to generate the intersect of two 1-D arrays in Fortran. The intent is to use this intersection as a mask in maxloc so that I can pull the max few elements from one array into another (behavior analogous to repeated root removal in a max heap). Currently I...

I have several input data files with the name angleFile1.dat, angleFile2.dat, angleFile3.dat and so on. (I have more than 100 files) Each file contain 45000 data of angles. I want to group these angles to get a distribution within 0 to 360 degrees. I have written a Fortran code to...

I am doing some exercises programming in Fortran90 and I have to write data to file in columns with each name of columns commented and I struggled while doing this because my data come from a do while like this do while (a<b) k = 2*a - b a =...

I imagine this is something silly I've missed but I've asked my whole class and noone can seem to work it out. Making a simple program calling in a subroutine and I'm having trouble with the do loop reading in the entries of the matrix. program Householder_Program use QR_Factorisation use...

When an exception occurs I would like to terminate abnormally my program. Right now, when an exception happens a write statement with an explanatory sentence is called, and then a stop statement is called. I am debugging the program with idb (intel debugger), when the exception happens I get the...

In my code: DO i=1,numJog,1 IF(val(i) .EQV. .TRUE.)THEN DO j=1,contVenc,1 result(j) = i END DO END IF END DO Where val is a logical array, and result is a integer array. For example, if val is: F T F T Then, i=2 and i=4. But the result array just write...

I'm currently delving into Fortran and I've come across the pure keyword specifying functions/subroutines that have no side effects. I have a book, Fortran 90/95 by S Chapman which introduces the pure keyword but strangely provides no "good coding practice" uses. I'm wondering how liberally one should use this keyword...

I have a derived type declared in a module like this: MODULE dmotifs TYPE :: PRM INTEGER, PRIVATE :: nsp=4,nrx=8,maxprx=4 REAL, PRIVATE :: cref=1e-6,tref=1 REAL, DIMENSION(nrx,maxprx) :: k REAL :: input END TYPE PRM CONTAINS SUBROUTINE unreg(y,param,r,s) TYPE(PRM), INTENT(IN) :: param REAL, DIMENSION(param%nsp), INTENT(IN) :: y INTEGER, DIMENSION(param%nsp,param%nrx), INTENT(OUT) ::...

I think my code below it's not exactly give me the same random distribution. subroutine trig_random_value() implicit none integer :: t, z, y, x real(real64) :: theta, r real(real64), parameter :: PI=4.D0*DATAN(1.D0) integer, dimension(12) :: date_time integer, dimension(12) :: seed call date_and_time(values=date_time) call random_seed seed = date_time(6) * date_time(7) +...

I have been trying to apply OpenMP on a simple summation operation inside two nested loop, but it produced incorrect result so far. I have been looking around in here and here, also in here. All suggest to use reduction clause, but it does not work for my case by...

Is there posibility to use indexing directly on a function's return value? Something like this: readStr()(2:5) where readStr() is a function which returns a character string. In many other languages it is quite possible, but what about Fortran? The syntax in my example of course does not compile. Is there...

I'm trying to write a code in fortran90 that allows me to create lets say 20 columns (f10.6) with one space between them in to the "output file". When I try to create file just with the 4 columns it works, but when I try to format a file with...

I'm doing some numerical exercises in Fortran 90. When I was trying to do a sum with alternating sign in argument I noticed that (in the manner that I did it) Fortran don't know how to do that. For example I want to do a sum over k from 1...

I am attempting to sum up all the prime numbers below 2 million. I've gone over my code for hours but I cannot find what is causing it to print out the faulty number. logical function isprime(n) result(response) implicit none integer :: i integer, intent(in) :: n integer :: upto...

I am a fortran beginner and writing a very simple program, compiler GNU fortran. program t1 implicit none real :: a, b a=35.4 CHARACTER (LEN=*) :: str = 'This is a test program' REAL, PARAMETER :: pi = 3.14 WRITE (*,*) a WRITE (*,*) str WRITE (*,*) pi end program...

So I am doing 2 modules which are linking to the main program. The first one has all the variables defined in it and the second one is with the functions. Module1: module zmienne implicit none integer, parameter :: ngauss = 8 integer, parameter :: out_unit=1000 integer, parameter :: out_unit1=1001...

I have the code: if i < n then x = topsep(1) y = topsep(2) realvor(n,1) = x + dx realvor(n,2) = x + dy imvor(n,1) = (realvor(n,1)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2) imvor(n,2) = (realvor(n,2)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2) tf = .TRUE. else x = botsep(1) y = botsep(2) realvor(n,1) = x + dx realvor(n,2) = y -...

I am pretty new to to fortran and I don't really know why am I getting this error. integrand(i)=inte(x(i),beta,r2,r1) 1 Error: Unclassifiable statement at (1) calka11.f95:97.6: I have made all the variables into a module file and then call them using use and when I am getting those variables into...

I'm trying to write a C wrapper to call a set of functions in a Fortran module. I'm starting with something basic but I'm missing something important. I've tried appending/prepending different numbers of underscores. I've also tried linking with gcc instead of gfortran. What I show below gives the simplest...

I got troubles with this common: COMMON /REDCOM/ DPREC,NITMA,INDIC,NBERR,NCAR,KMOTLU, & REDVAR,MOCDER(2) COMMON /REDCO1/ CTEXT C type(double_st) :: DPREC INTEGER :: NITMA,INDIC,NBERR,NCAR,KMOTLU,REDVAR,MOCDER CHARACTER(72) :: CTEXT CHARACTER(4) :: CTEXT4 C EQUIVALENCE (CTEXT,CTEXT4) The double_st derived type is: type double_st sequence real(kind(0.d0)) :: x,y,z integer :: acc = -1 end type double_st Trying...

Sorry about being new to both Fortran 90 and f2py. I am using Windows 64 bit, Python 3.4 64 bit, gfortran. Numpy version is 1.9.1, and I commented the "raise NotImplementedError("Only MS compiler supported with gfortran on win64")" in the gnu.py, as instructed on this link: http://scientificcomputingco.blogspot.com.au/2013/02/f2py-on-64bit-windows-python27.html I have a...

I am working on a global optimization using brutal force. I am wondering if it is possible to complete the following task with Fortran MPI file I/O: I have three nodes, A, B, C. I want these nodes to search for the optima over six sets of parameter inputs, which...

The following data is given in a file: 1 7 5 4 11 0 1 -13 -7 I want to form a 3x3 matrix from these columns. I have tried advance=no but receive a runtime error. program form_matrix implicit none integer:: col,A(9) open(unit=12,file='q10.txt') do col=1,9 read(12,*,advance='no')(A(col)) end do 7 format(3i4)...

I installed gfortran on my Ubuntu 15.04. While compiling in Fortran, be it .f95 or .f90 type, the DO loop asks to take integer parameters only but not real values or variables. That includes the loop variable and the step expression. Why can't it take real values too? The following...

I have this Fortran code that reads two columns of data from an external file: PRINT*, ' Q1 Q2 ' DO 2 J = 1, NPTS READ(20,*) Q1(J),Q2(J) WRITE(*,98) Q1(J),Q2(J) So the file 20 is used, but it doesn't seem to like any names I use in the file, so...

I am wanting to mask a Fortran array. Here's the way I am currently doing it... where (my_array <=15.0) mask_array = 1 elsewhere mask_array = 0 end where So then I get my masked array with: masked = my_array * mask_array Is there a more concise way to do this?...

I've searched for a long time before I ask: I need to output a lot of unformatted files in Fortran to Ensight. I want to name them with geo.000000, geo.000001 ... geo.0001000. Here is how I deal with wild card: character(54) :: filename, temp character(80) :: buffer write(temp,'(i6.6)') step filename...

I have a fortran main program called solidsolver.f90, and a module called read_mesh.f90. The module contains two subroutines and is used in the main program. I can compile them manually but not with a makefile. My makefile is named makefile.makefile, and it gives me an error: make: *** No targets...

I am using Intel's ifort and GNU make to build my project on a linux machine. The lib depends on the source files a.f90, b.f90 and c.f90 in the source directory. I am invoking make via make FLAG where these FLAGS are defined in my makefile and correspond to different...

I have to calculate commissions for different interval of sales on different days and form a table "Day", "Sales", "Commissions". So far I've done this: real::a(5),b(5) character(10)::c(5)=(/Sunday,Monday,Tuesday,Wednesday,Thursday/) open(1,file='in_1.txt') open(2,file='out_1.txt') read(1,*)(a(i),i=1,5) do i=1,5 if(0.<a(i).and.a(i)<99.)then b(i)=a(i)*.02 elseif(100.<a(i).and.a(i)<299.)then b(i)=a(i)*.05 elseif(300.<a(i).and.a(i)<499.)then b(i)=a(i)*.075 else b(i)=500.*.1+(a(i)-500.)*.125 endif enddo write(2,*)' Day ','...

I'm a starter in Fortran, using it to solve mathematical models in economics. I wrote a program (below) that is crashing when running. Windows show that message of error and nothing seems to happen. I haven't got a clue of what may be wrong, I already debugged it and it...

I have a Fortran 90 project which makes extensive use of the loc function to obtain the address of arrays (part of an API for interopability with Matlab). This code compiles and works on Mac and Linux with both Intel and gfortran, and has for some time (across a couple...