Backtrace For This Error Fortran
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta emacs backtrace on error Discuss the workings and policies of this site About Us Learn gfortran backtrace more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack gfortran backtrace line numbers Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, fortran segmentation fault invalid memory reference helping each other. Join them; it only takes a minute: Sign up Fortran 90 - “Segmentation fault - invalid memory reference” with scalable 3D array up vote 4 down vote favorite I have compiled a fortran 90 program with gfortran which builds a scalable 3D array in a way I want. Upon running, I get the following
Fortran Segmentation Fault (core Dumped)
error: Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x10542ee42 #1 0x10542f60e #2 0x7fff8d7895a9 #3 0x10542575e #4 0x105425975 #5 0x105425d0e Segmentation fault: 11 I believe this is a memory issue with the large 3D array, as it works if I decrease the dimensions, but is there anyway to get around this? Here is my code: PROGRAM phantomtest IMPLICIT NONE INTEGER, PARAMETER:: columns=34, rows=34, diags=((4*columns)-6), m=(4*columns)-6+(2*columns) REAL, ALLOCATABLE, DIMENSION(:,:,:)::phantom INTEGER :: i, j, k CHARACTER (LEN=3) :: nstring, nullstring='' ALLOCATE(phantom(columns,rows,m)) phantom=0 CALL Phantom_Making(phantom,columns,rows,diags,m) WRITE(nstring,FMT="(I3)"), columns PRINT*, nullstring DO k=1,m DO i=1,columns WRITE(*,FMT="("//nstring//"I2)") phantom(i,:,k) END DO PRINT *, nullstring END DO END PROGRAM phantomtest !--------------------------- SUBROUTINE Phantom_Making(phantom,columns,rows,diags,m) IMPLICIT NONE INTEGER, INTENT(IN):: columns, rows, diags, m REAL, DIMENSION(columns,rows,m), INTENT(INOUT) :: phantom INTEGER :: i, j, k, l !Vertical and horizontal rays DO i=1,rows phantom(:,i,i) = 1 phantom(i,:,i+(columns)+(diags/2)) = 1 END DO !Diagonal rays phantom(1,2,1+columns) = 1 phantom(2,1,1+columns) = 1 phantom(1,columns-1,1+columns+(diags/2)+rows) = 1 phantom(2,columns,1+columns+(diags/2)+rows) = 1 j = columns-1 DO k=2+columns, (diags/2)+columns phantom(2:columns,:,k) = phantom(1:(columns-1),:,k-1) IF (((k+1)-columns).LE.co
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack
Gfortran Fcheck
Overflow the company Business Learn more about hiring developers or posting ads with us segmentation fault in fortran 90 Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a segmentation fault 11 fortran community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Segmentation fault core dumped in Fortran 90 up vote -2 down vote favorite I have a http://stackoverflow.com/questions/23130045/fortran-90-segmentation-fault-invalid-memory-reference-with-scalable-3d-ar problem with a code that I wrote, I try to explain what my program should be do. It reads data from a file (.dat), in particular values of hours, wind velocity, temperature and increments of potential temperature. Then it should elaborate these data in the subroutine PBL_6 which call subroutines LOG_FIT and LIN_FIT that linearize a semi-log function y = a*ln(x) + b where y is wind velocity or potential temperature, http://stackoverflow.com/questions/26561990/segmentation-fault-core-dumped-in-fortran-90 and x is the height of measurement. I define different arrays in the code, one for the heights (I know all the values of this array), one for the wind speed (i have 6 measurements of wind speed (u), each for every height), one for the temperature (T or tk in the code) and one for the increments (dt). The algorithm is a simple iteration, starting from the initial condition (in PBL_6 not in the loop do) it should be return me the values of u*,T* and L, then I make a loop with these values in the equations to find new u*,T* and L. The loop will stops when it reaches the convergence for L (condition at the end of the loop). I think my program is correct and it compiles, but at runtime U receive: Segmentation Fault Core dumped program profile implicit none character(len=12) filein,fileout real, dimension(6) :: u real, dimension(6) :: z=(/0.5,1.,2.,4.,8.,16./) real, dimension(2) :: dt,tp real, parameter :: k = 0.4 real, parameter :: z0 = 0.0012 real :: tk,ustarp, tstarp, tetai, Lp integer :: ih integer :: row, i write(*,'(2x,''File input .......''/)') read(*,'(a12)') filein write(*,'(2x,''File output........''/)') read(*,'(a12)') fileout open(unit=90,File=fileout) open(unit=50,File=filein) write(90,130) do row = 1,24 read(50,*) ih,(u(i),i=1,6),tk,(dt(i),i=1,2) tk = tk+273.15 dt(2) = dt(2)+dt(1) tp(1) = dt
is relevant) then a backtrace is printed when fortran segmentation fault a serious run-time error occurs. To disable the backtracing, set the variable to ‘n’, ‘N’, ‘0’. Default is to print a backtrace unless the -fno-backtrace compile option was used.