Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

NaN error

mazza
Beginner
1,224 Views

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?

0 Kudos
5 Replies
jarvusluntatintel
1,224 Views

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.

0 Kudos
Steven_L_Intel1
Employee
1,224 Views
I have generally found that when someone describes their code rather than showing it, the description does not reflect the actual code. It is not clear to me what your actual code looks like - for example, what is meant by "procedure"?

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?
0 Kudos
mazza
Beginner
1,224 Views

There is no difference between debug and release mode. I get the same results.

0 Kudos
mazza
Beginner
1,224 Views

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.

0 Kudos
Steven_L_Intel1
Employee
1,224 Views
That program is not complete. The main program uses a module not provided, and doesn't reference the module you did provide.
0 Kudos
Reply