gfortran

passing pointer arguments in fortran

懵懂的女人 提交于 2019-12-02 01:00:57
I am wondering what is the proper way to write the following code? PROGRAM foo INTEGER :: x REAL(KIND=8), TARGET, DIMENSION(0: 10) :: array REAL(KIND=8), POINTER, DIMENSION(:) :: ptr ptr => array CALL bar(ptr) END PROGRAM foo SUBROUTINE bar (ptr) REAL(KIND=8), POINTER, DIMENSION(:) :: ptr INTEGER x DO x =0, 10 ptr(x) = 2 // seg faults ENDDO END SUBROUTINE bar It works if I declare ptr in bar as REAL(KIND=8), DIMENSION(0:10) . But in general I might not know the size of the passed-in array, so is there a way to declare ptr to be a pointer to some array? I am compiling this with gfortran If a

How to determine what gfortran is vectorizing

别等时光非礼了梦想. 提交于 2019-12-02 00:57:03
问题 I am trying to write a massively parallel monte carlo code part of which will be exported to a xeon phi coprocessor. To ensure that I am using the coprocessor efficiently, I would like to see which parts of my code the compiler, currently gfortran, is able to vectorize. I understand I can do this using the ifort commane -vec-report. However, I won't have access to the coprocessor for about a month, and therefore am stuck with gfortran for the time being. However, I would like to start

Floating point exception when reading real values from an input file

ε祈祈猫儿з 提交于 2019-12-02 00:02:00
I try to read a float value from an input file in Fortran . To do so I use this code : ... INTEGER :: nf REAL :: re OPEN(newunit=nf, file='toto.txt') READ(unit=nf, fmt=*) re ... with toto.txt a text file containing my real value : 10.1001 ! this value is supposed to be read by the Fortran program If I compile and execute like this, everything works well. But I get some trouble when I compile and execute with fpe option. I have a error at the readding line that looks like: Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation Backtrace for this error #0

How to choose the best configuration of 2D array A(i,j)

旧街凉风 提交于 2019-12-01 23:09:58
问题 Hopefully you could me explaining this thing. I'm working with Fortran and actually writing my code on CFD topic, and below (just for sake of simplicity and just for example) are short explanations of my case: I should use one 2D array A(i,j) and one 1D array B(i) I have to do 2 times looping, which is the first looping should be 50,000 times and the second one is 5 times (can't be changed). The point number 2 above should be looped 10,000 times. I write the codes with 2 versions (I called

How to choose the best configuration of 2D array A(i,j)

血红的双手。 提交于 2019-12-01 22:27:51
Hopefully you could me explaining this thing. I'm working with Fortran and actually writing my code on CFD topic, and below (just for sake of simplicity and just for example) are short explanations of my case: I should use one 2D array A(i,j) and one 1D array B(i) I have to do 2 times looping, which is the first looping should be 50,000 times and the second one is 5 times (can't be changed). The point number 2 above should be looped 10,000 times. I write the codes with 2 versions (I called them Prog_A and Prog_B). The first one is as shown below: PROGRAM PROG_A REAL*8, DIMENSION(50000,5):: A

Catch integer exceptions in Fortran

徘徊边缘 提交于 2019-12-01 22:03:28
Is there a way to catch integer exceptions with gfortran or ifort like there is for catching floating point exceptions? Consider this simple program to calculate the factorial: program factorial use, intrinsic :: iso_fortran_env implicit none integer(8) :: fac real(REAL64) :: facR integer,parameter :: maxOrder = 30 integer :: i fac = 1 ; facR = 1.e0_REAL64 do i=2,maxOrder fac=fac*i ; facR=facR*real(i,REAL64) write(*,*) i, fac, facR enddo ! i end program At some point there will be an overflow - for integer(8) as shown here, it will occur at around 21. But without the calculation using floats

Strict fortran77 compiler? (or gfortran compiler flag)

你。 提交于 2019-12-01 22:01:03
问题 Is there any way to get gfortran to reject the f95 additions to Fortran 77? If not, is there another f77-only compiler available for unix systems? I've tried using the -std=legacy flag but that only seems to remove depreciation warnings from f77 programs; the f95 enhancements still work fine. 回答1: You can set fixed format with gfortran -ffixed-form -ffixed-line-length-none [sourcefiles] And this can actually make a difference (I have a program here where this changes the output!). I’m pretty

How to determine what gfortran is vectorizing

本小妞迷上赌 提交于 2019-12-01 21:30:00
I am trying to write a massively parallel monte carlo code part of which will be exported to a xeon phi coprocessor. To ensure that I am using the coprocessor efficiently, I would like to see which parts of my code the compiler, currently gfortran, is able to vectorize. I understand I can do this using the ifort commane -vec-report. However, I won't have access to the coprocessor for about a month, and therefore am stuck with gfortran for the time being. However, I would like to start optimizing now if possible. Unfortanately, I cannot seem to find the command line flag for gfortran that tells

Strict fortran77 compiler? (or gfortran compiler flag)

走远了吗. 提交于 2019-12-01 20:03:24
Is there any way to get gfortran to reject the f95 additions to Fortran 77? If not, is there another f77-only compiler available for unix systems? I've tried using the -std=legacy flag but that only seems to remove depreciation warnings from f77 programs; the f95 enhancements still work fine. You can set fixed format with gfortran -ffixed-form -ffixed-line-length-none [sourcefiles] And this can actually make a difference (I have a program here where this changes the output!). I’m pretty sure that there are options, which disable at least most of the f95 features. 来源: https://stackoverflow.com

What's wrong with my random number generator in Fortran 95 please?

∥☆過路亽.° 提交于 2019-12-01 18:27:01
This a randon number generator module that I use to compile along with my main program (not listed here) When I try to compile my random number generator module to see if it works, I get the following message: at line 61: call random_seed( put = seed) Error: size of 'put' argument of 'random_seed' intrinsic too small <4/12> What does it mean? How can I fix it? module random_angle contains 0 integer Function random_integer (N) ! return a random integer between 1 and N integer, intent(in) :: N real*8 :: x call random_number(x) random_integer = floor(real(N)*x)+1 end function random_integer Real