Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

problem in debug version

rainerjordan
Beginner
1,036 Views
Stumbled across a problem with debug version

Please see code snippet:

subroutine jiroush(bereich, pPa, ksizus, msd, d, l, h,
1 hein, haus, rauh, ksirohr, pdyn,
1 pstat, paus, xein, xaus, roe, roa, rom, w )

implicit none

integer bereich !Eintritts- und Austrittsbereich = 1,
!Rohrbereich = 2 ,Blendenbereich = 3
c Eingabegabewerte
double precision ksizus, msd, d, l, h, rauh, pPa,
+ pi1, hein, haus
c lokale Werte
double precision vd, vw, pi, zweiphas, schlupf, schlupf1,
+ x, spezVol_H2O, pBar, palt, pMPaaus,
+ zeta, R1, ts, siedet, pMPa, tsaus,
+ enth_h2o, hdam, hwas, vwaus !,logargument
character cdummy*1
c Ausgabewerte
double precision w, pdyn, pstat, roa, rom, xein, xaus, ksirohr,
+ paus, roe

c Alle Groessen in SI-Einheiten
c de,da,g in kg/s
c l,h,d in m
c w,w0 in m/s
c p, pdyn,pstat in Pa
pMPa = pPa * 1d-6
pBar = pPa * 1d-5
ts = siedet(pMPa)
c write(*,*) 'jirous 32 ts', ts, ' pMPa ', pMPa

vd = spezVol_H2O(ts, pMPa, 1)
vw = spezVol_H2O(ts, pMPa, 2)
hwas = enth_H2O(ts, pMPa, 2)
hdam = enth_H2O(ts, pMPa, 1)
xein = (hein - hwas)/(hdam - hwas)
xaus = (haus - hwas)/(hdam - hwas)

c write(*,*) 'vw', vw,' vd',vd,' hwas', hwas,' hdam',hdam
c write(*,*) 'hein ',hein,' haus ',haus,'xein',xein,' xaus',xaus
if(xaus .gt. 1d0) xaus = 1d0

pi = vd/vw
pi1 = pi - 1d0

schlupf = 10.d0**(0.031636d0+(0.07773d0+.051306d0*dlog10(pi))*
1 dlog10(pi))
schlupf1 = pi-schlupf


c write(*,*)'jiroush pi,vd,vw',pi,vd,vw


c write (*,*)ksiein,ksiaus,ksirohr,w0,w,d,l,h,xein,xaus,
c 1 rauh,pdyn,pstat,k,roa,rom,p
c read (*,*)abc
if(bereich .eq. 0) then
c Bestimmung der Dichte am Eintritt oder Austritt
if(h.lt.0.0d0)then
roe = 1.d0/(vw *(xein*pi1+1.d0))
else
roe = (schlupf-xein*(schlupf-1.d0))/
+ (vw*(schlupf+xein*schlupf1))
endif
c write(*,*)'ende jiroush bereich 0'
return
else if(bereich.eq.1.or.bereich.eq.3)then
c Berechnung des dynamischen Druckverlustes fr Eintritts- und Austrittsbereich
!oder Blende enthlt auch den Beschleunigungsdruckverlust
write(*,*) 'jirous 72 ts', ts, ' pMPa ', pMPa
write(*,*) 'vw', vw,' vd',vd,' hwas', hwas,' hdam',hdam
write(*,*) 'hein ',hein,' haus ',haus,'xein',xein,' xaus',xaus
write(*,*)'jiroush pi,vd,vw',pi,vd,vw
paus = pPa
vwaus = vw
do
palt = paus
x = (xein + xaus) /2d0
roe =1d3
write(*,*)'pi1',pi1,' h',h, 'schlupf',schlupf,'s1',schlupf1
write(*,*)'xein ',xein,' xaus',xaus,' x',x, 'roe ',roe
write(*,*)'homogen roe',1.d0/(vw *(xein*pi1+1.d0))
if(h.lt.0.0d0)then
rom = 1.d0/(vw *(x*pi1+1.d0))
roe = 1.d0/(vw *(xein*pi1+1.d0))
roa = 1.d0/(vwaus *(xaus*pi1+1.d0))
else
rom = (schlupf-x*(schlupf-1.d0))/
+ (vw*(schlupf+x*schlupf1))
roe = (schlupf-xein*(schlupf-1.d0))/
+ (vw*(schlupf+xein*schlupf1))
c write(*,*)'in else clause homogen roe',1.d0/(vw *(xein*pi1+1.d0))
write(*,*) 'in else clause roe ', roe
roa = (schlupf-xaus*(schlupf-1.d0))/
+ (vwaus*(schlupf+xaus*schlupf1))
endif
w = msd / rom
write(*,*)'msd ', msd,' ksizus ',ksizus, ' roe ', roe,
+ ' roa', roa
if(ksizus .gt. 2d0) read(*,'(a1)') cdummy
pdyn = ((ksizus/2.d0-2.d0)/roe + !ksizus = ksiein oder ksiaus oder ksiblende
+ (ksizus/2.d0+2.d0)/roa) / 2.d0 * msd * msd
paus = pPa - pdyn
pMPaaus = paus/1.d6
tsaus = siedet(pMPaaus)
write(*,*) 'jirous 93 tsaus', tsaus, ' pMPaaus ', pMPaaus,
+ ' ppa ', ppa, ' pdyn', pdyn
vwaus = spezVol_H2O(tsaus, pMPaaus, 2)
hwas = enth_H2O(tsaus, pMPaaus, 2)
hdam = enth_H2O(tsaus, pMPaaus, 1)
xaus = (haus - hwas) / (hdam - hwas)
if(dabs((paus-palt)/pPa) .lt. 1d-5) exit
enddo
c write(*,*)'ende jiroush bereich 1'
return
else !bereich 2 Rohrbereich
and some code following

------------------
yes I know it's Fortran 77 but I do not know better
------------------

this funtion works well several hundred times but then produces crach

before crash it gives:
jirous 72 ts 152.408820704794 pMPa 0.507645249041383
vw 1.093201625184451E-003 vd 0.369482632136270 hwas
642.661148450612 hdam 2748.78329628054
hein 670.501208031550 haus 670.501208031550 xein
1.321863483066403E-002 xaus 1.321863483066403E-002
jiroush pi,vd,vw 337.982146773637 0.369482632136270
1.093201625184451E-003
pi1 336.982146773637 h 0.000000000000000E+000 schlupf
3.60018121114453 s1 334.381965562492
xein 1.321863483066403E-002 xaus 1.321863483066403E-002 x
1.321863483066403E-002 roe 1000.00000000000
homogen roe 167.706250247628
in else clause roe 406.695938404221
msd 1235.82263370958 ksizus 35.1243152660860 roe
3.03868939178162 roa 3.03868939178162

my problem is variable roe
I set it to 1000.
enter if branch
because h is 0 it goes to else branch
it gives roe = 406...
after leaving end if
roe is 3.03

subsequent usage of roe being too small causes crash

cross checked with release version and it gives:

jirous 72 ts 152.408820704794 pMPa 0.507645249041383
vw 1.093201625184451E-003 vd 0.369482632136270 hwas
642.661148450612 hdam 2748.78329628054
hein 670.501208031550 haus 670.501208031550 xein
1.321863483066403E-002 xaus 1.321863483066403E-002
jiroush pi,vd,vw 337.982146773637 0.369482632136270
1.093201625184451E-003
pi1 336.982146773637 h 0.000000000000000E+000 schlupf
3.60018121114453 s1 334.381965562492
xein 1.321863483066403E-002 xaus 1.321863483066403E-002 x
1.321863483066403E-002 roe 1000.00000000000
homogen roe 167.706250247628
in else clause roe 406.695938404222
msd 1235.82263370958 ksizus 35.1243152660860 roe
406.695938404222 roa 406.695938404222

In release version the value is correct

What can I do to have a reliable program version in debug mode?
0 Kudos
4 Replies
mecej4
Honored Contributor III
1,036 Views
Please edit your post to make it more readable. Select the code part, cut, click the Insert Code button (the yellow slanted pencil/pen icon), choose "Fortran fixed format" and paste from your Fortran source.

Please, also, specify values for the input arguments to the subroutine which will enable the code to be run. Tell us what input values to give when READ statements are executed. State which version of the compiler you used, and which compiler options were in effect.

Without that information, the number of possible combinations are too many for anyone to get interested.
0 Kudos
rainerjordan
Beginner
1,036 Views
Thank you for the hints.

I looked up and found that ONE dummy variable was the receiving variable for almost all of the "returning" parameters (some calling levels up). So I assume that all the variables in question were pointing to the same address.

Changed to appropiate number of "receiving" dummy variables and now it's working.

Problem solved.


By the way: In former compiler versions a depply nested error could be traced easily. If a value was out of range (checked by if ....) the next stament was f.i. sqrt(-1.). The calculation crashed due to sqrt error and gave a traceback with all the calling functions.

This does not work with the actual version with default settings. The program (debug version) keeps running. Only some values are NAN and program execution goes on.

What switch I have to set to force the "former" behaviour?

Best regards

Rainer
0 Kudos
jansson
Beginner
1,036 Views
Try Setting:
Fortran -> Floating Point -> Floting Point Exception Handling
To:
Underflow gives 0.0; Abort on other IEEE exceptions (/fpe:0)

Regards
/Magnus
0 Kudos
rainerjordan
Beginner
1,036 Views
Thank you for the hint.

I tried this before but with no result.

After your hint i fiddled around with all the other settings for floating points and now i get it working in the expected way.

Thanks
0 Kudos
Reply