- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had a problem unusual and if someone could help me I will appreciate
I create an object with avalue and I use a get function to recover the value inside a main program with a do while loop. Things like
Do while (t
procedure
t = t + getdt(object)
enddo
In the first step no problems. The value recoverd was correct. In the second one, the value return by getdt function is NaN. In debug procedure, inside the get function, the value is set-up correct in all step. Including, the function is also used more than one time in procedure module without problems.
Did anyone get some like this?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are getting different behavior between the debug version and the release version of the program?
When this has happened to me it is usually because of either:
1) There is a variable that is not being initialized and it happens to have a different value between the debug and release versions.
2) There is a memory leak and the debug and release versions configure memory differently so the problem is only showing up on the release side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are many possible causes of behavior such as you describe. In addition to what jarvuslunt wrote, you may be corrupting the floating point stack by calling a function as a subroutine, or the other way around. This may happen elsewhere in the program. The /fp-stack-check option can help locate this.
Can you create a small but complete example demonstrating the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no difference between debug and release mode. I get the same results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The main code is extremely simple. I reproduced it below:
program main
use class_celula
type(ccelula) celula1, celula0 ! Created a celula object
type(cduto) duto !create a duto objected. Here is the getdt function
real t /0./, tfim /10./
real tir /3./, tfr /4./
call inicializa(celula0, celula1, duto) ! put arguments into objects
call cX(celula0, celula1, duto) !calcula o primeiro x para ser salvo em t=0
do while(t
call salvadados(celula0, celula1, duto, t) !save the object parameters into a file
call matriz(celula0, celula1, duto) ! made a matrix with object parameters and solve the matrix
&nb sp; call dimensao(celula0, celula1, duto) ! take the results from matrix to actualize the object parameters
t = t + getdt(duto) !increse the time, only for do while control
end do
call salvadados(celula0, celula1, duto, t)
!fecha arquivo
close(3)
end program
The object class cduto is reproduced below:
module class_duto
type cduto
private
real :: L, D, dt
end type
interface new
module procedure InicializaDuto
end interface new
contains
subroutine InicializaDuto(oduto, aL, aD, adt)
type(cduto) :: oduto
real :: aL, aD, adt
oduto%L = aL
oduto%D = aD
&n bsp; oduto%dt = adt
end subroutine
!metodos Set e Get
subroutine setL(oduto, a)
type(cduto) :: oduto
real :: a
oduto%L = a
end subroutine
subroutine setD(oduto, a)
type(cduto) :: oduto
real :: a
oduto%D = a
end subroutine
subroutine setdt(oduto, a)
type(cduto) :: oduto
real :: a
oduto%dt = a
end subroutine
real function getL(oduto)
type(cduto) :: oduto
getL = oduto%L
end function
real function getD(oduto)
type(cduto) :: oduto
; getD = oduto%D
end function
real function getdt(oduto)
type(cduto) :: oduto
getdt = oduto%dt
end function
end module
I hope this information will be helpful to find what is happen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page