Fortran error *** glibc detected ***

In summary: I know that this is not the best way to do this, but I'm just a beginner. So, I'm very glad that this works now! :)In summary, the code calculates the values of the first and second members of the five-point stencil equation for a given interval [a,b] and step size of 0.1. It uses pointers and loops to reset the value of x after each calculation.
  • #1
Antonija
18
0

Homework Statement



I'm doing aproximation of derivative called five-point stencil. For every value of x, in interval [a,b], in step of 0.1 i need to calculate derivative.

Homework Equations


[/B]
The equation is like this:
Code:
Five-point stencil:
(-f(x + 2h) + 8f(x + h) - 8f(x - h) + f(x - 2h))/(12*h)
---> (-first+8*sec-8*third+fourth)/12*h

I want to calculate every of theese, so first, sec, third... expression and then at the end calc
ulate derivative.

The Attempt at a Solution

Code:
variables = 'x'
x=a+2*h
do while(x<=b)
variablesvalues=x
x=x+delta
call recog_variables (func, variables)
first(i)=evaluate(variablesvalues)
print*,'to je',first(i)
i=i+1
call destroyfunc()
end do
x=a+h  !without this, program works, prints first(i), but it doesn't print sec(i).

do while(x<=b)
variablesvalues=x
x=x+delta
call recog_variables (func, variables)
sec(i)=evaluate(variablesvalues)
print*,'to je',sec(i)
i=i+1
call destroyfunc()
end do
after do while loop I need my x to reset to another value, a+h, and print it. after that I need to reset x again, to x=a-h... in order to calculate every member of equation for derivative.

But, in my case, when I try to initialize x after loop, i get this:

Code:
*** glibc detected *** ./test.exe: free(): invalid next size (fast): 0x000000000115c070 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x76a16)[0x7f6466aa0a16]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7f6466aa57bc]
./test.exe[0x407cbf]
./test.exe[0x407e73]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd)[0x7f6466a48ead]
./test.exe[0x401309]
======= Memory map: ========
00400000-00409000 r-xp 00000000 08:02 4988214                            /home/antonija/Racunalna/test.exe
00609000-0060a000 rw-p 00009000 08:02 4988214                            /home/antonija/Racunalna/test.exe
01159000-0117a000 rw-p 00000000 00:00 0                                  [heap]
7f6460000000-7f6460021000 rw-p 00000000 00:00 0
7f6460021000-7f6464000000 ---p 00000000 00:00 0
7f6466a2a000-7f6466bac000 r-xp 00000000 08:02 1573554                    /lib/x86_64-linux-gnu/libc-2.13.so
7f6466bac000-7f6466dac000 ---p 00182000 08:02 1573554                    /lib/x86_64-linux-gnu/libc-2.13.so
7f6466dac000-7f6466db0000 r--p 00182000 08:02 1573554                    /lib/x86_64-linux-gnu/libc-2.13.so
7f6466db0000-7f6466db1000 rw-p 00186000 08:02 1573554                    /lib/x86_64-linux-gnu/libc-2.13.so
7f6466db1000-7f6466db6000 rw-p 00000000 00:00 0
7f6466db6000-7f6466deb000 r-xp 00000000 08:02 4731999                    /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f6466deb000-7f6466fea000 ---p 00035000 08:02 4731999                    /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f6466fea000-7f6466feb000 rw-p 00034000 08:02 4731999                    /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f6466feb000-7f6467000000 r-xp 00000000 08:02 1572868                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6467000000-7f6467200000 ---p 00015000 08:02 1572868                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6467200000-7f6467201000 rw-p 00015000 08:02 1572868                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6467201000-7f6467282000 r-xp 00000000 08:02 1573552                    /lib/x86_64-linux-gnu/libm-2.13.so
7f6467282000-7f6467481000 ---p 00081000 08:02 1573552                    /lib/x86_64-linux-gnu/libm-2.13.so
7f6467481000-7f6467482000 r--p 00080000 08:02 1573552                    /lib/x86_64-linux-gnu/libm-2.13.so
7f6467482000-7f6467483000 rw-p 00081000 08:02 1573552                    /lib/x86_64-linux-gnu/libm-2.13.so
7f6467483000-7f6467597000 r-xp 00000000 08:02 4732002                    /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f6467597000-7f6467797000 ---p 00114000 08:02 4732002                    /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f6467797000-7f6467799000 rw-p 00114000 08:02 4732002                    /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f6467799000-7f64677b9000 r-xp 00000000 08:02 1573559                    /lib/x86_64-linux-gnu/ld-2.13.so
7f64679a0000-7f64679a4000 rw-p 00000000 00:00 0
7f64679b6000-7f64679b8000 rw-p 00000000 00:00 0
7f64679b8000-7f64679b9000 r--p 0001f000 08:02 1573559                    /lib/x86_64-linux-gnu/ld-2.13.so
7f64679b9000-7f64679ba000 rw-p 00020000 08:02 1573559                    /lib/x86_64-linux-gnu/ld-2.13.so
7f64679ba000-7f64679bb000 rw-p 00000000 00:00 0
7fff7cd1b000-7fff7cd3c000 rw-p 00000000 00:00 0                          [stack]
7fff7cd79000-7fff7cd7a000 r-xp 00000000 00:00 0                          [vdso]
blackffff600000-blackffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Program received signal SIGABRT: Process abort signal.
How can I, after my loop, initialize value again to something else in order to calculate again the values, in another loop?
 
Physics news on Phys.org
  • #2
Okay, I've forgotten most everything I knew about Fortran, but I'll make a tentative guess ...

The glibc message may not be an error message itself, it might be a helpful/useless diagnostic confirming it has linked to that library.

Have you reinitialised counter 'i' to 0 before plunging into that second block of code? (If indeed you need to.)

You never assign a value to 'b' or delta, yet you use them. Is this only part of your code?
 
  • #3
NascentOxygen said:
Okay, I've forgotten most everything I knew about Fortran, but I'll make a tentative guess ...

The glibc message may not be an error message itself, it might be a helpful/useless diagnostic confirming it has linked to that library.

Have you reinitialised counter 'i' to 0 before plunging into that second block of code? (If indeed you need to.)

You never assign a value to 'b' or delta, yet you use them. Is this only part of your code?
Thank you very much, I had been struggling with this a 3 days non-stop...I reinitialized counter i, to 1. it's initialized at one at the beggining. That's not the whole code, it's just a part of it. Well, I think i solve it now because there is no more errors! :) Just, I used pointers. It was not working without them. I'll put the part of code fixed so I can maybe help someone who might have a problems as I had...
Code:
integer::i=1
real, target::meta1,meta2
real,pointer::x

meta1=a+2*h

x=>meta1
do while(x<=b)
variablesvalues(1)=x
x=x+delta
call recog_variables (func, variables)
prva(i)=evaluate(variablesvalues)
print*,'First values are',prva(i)
call destroyfunc()
i=i+1

end dox=>meta2
meta2=a+h
i=1
do while(x<=b)
variablesvalues(1)=x
x=x+delta
call recog_variables (func, variables)
druga(i)=evaluate(variablesvalues)
print*,'second values are',druga(i)
call destroyfunc()
i=i+1
end do
 

What does the "Fortran error *** glibc detected ***" mean?

The "Fortran error *** glibc detected ***" is an error message that indicates a problem with the GNU C Library (glibc) while running a Fortran program. It usually means that there is a memory error or a problem with the program's dynamic memory allocation.

Why am I getting this error?

There are several potential reasons for this error, including a bug in the program, incorrect usage of memory allocation functions, or a problem with the system's memory. It is important to carefully debug the program and check for any memory-related issues to resolve this error.

How can I fix this error?

To fix this error, you can try debugging the program and checking for any memory-related issues. You can also try updating the glibc library or rebuilding the program with different compiler options. If the error persists, it may be necessary to seek assistance from a more experienced programmer or a technical support team.

Is this a common error in Fortran programming?

This error can occur in Fortran programming, but it is not considered a common error. It usually indicates a problem with the program's memory management, which can be avoided by following good coding practices and thoroughly testing the program before running it.

How can I prevent this error from happening in the future?

To prevent this error from occurring in the future, it is important to follow good coding practices and regularly test the program for any memory-related issues. Additionally, staying updated with the latest versions of the glibc library and the Fortran compiler can help prevent this error from happening.

Similar threads

  • Programming and Computer Science
Replies
16
Views
5K
Replies
2
Views
6K
Replies
2
Views
5K
  • Programming and Computer Science
Replies
1
Views
2K
Back
Top