forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Value of argument (DHYD) not being passed.

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Jim



Joined: 21 Jul 2006
Posts: 24
Location: USA

PostPosted: Mon May 23, 2022 5:15 pm    Post subject: Value of argument (DHYD) not being passed. Reply with quote

The value of argument (DHYD) is not being passed from SUBROUTINE to a FUNCTION. I verified the value exists in the SUBROUTINE but when I print out the value in the FUNCTION it is 0.0 instead of 0.177013. Output from PLATO DEBUG:

S E T V A R I A B L E S AT TIME = 0.000 DAYS
FLOWING OPTION = TWO-PHASE STEAM PRODUCTION
STEAM QUALITY = 0.160
INLET TEMPERATURE = 460. F
FLOW RATE = 580. GAL/MIN
TIME TO CHANGE DATA = 1.000 DAYS
510.928 1.124066E-04
2.337134E+06 -59358.3 0.00000 0.177013 2
2.337134E+06 -59358.3 0.00000 0.00000 2

FIRST STATEMENT IS WRITE IN SUBROUTINE AND SECOND WRITE IS WRITE IN FUNCTION.

SUBROUTINE (PORTION OF CODE RESPONSIBLE - SEE FRAC)
C BUBBLE FLOW
C
20 RE=D2*DHYD*V2/SLVIS(T1)
C
C DEBUG
WRITE(6,*)RE,WN,SN,DHYD,2
C
FRAC=FR2P(RE,WN,SN,DYHD,2)
RL=RLORK(V1,V2)
DPFR=.5*FRAC/DHYD*D2*(V2/RL)**2*DZ
DPGR=GG*(RL*(D2-D1)+D1)*DZ
IFRG=2

FUNCTION FR2P(RE,WN,SN,DHYD,IK)
C
C DEBUG
WRITE(6,*)RE,WN,SN,DHYD,IK
C
C DARCY FRICTION FACTOR FOR TWO PHASE FLOW
C
C IK = 1 COMMERCIAL STEEL
RR=.0000457/DHYD
C
C IK = 2 GALVANIZED IRON
IF(IK.EQ.2)RR=.000152/DHYD
C
C IK = 3 DUNN AND ROS MIST FLOW E/D
IF(IK.NE.3)GO TO 1
IF(WN.GT.0.005)RR=174.8*SN*WN**0.302
IF(WN.LE.0.005)RR=34.*SN
IF(RR.GT.0.5)RR=0.5
IF(RR.LT.1.E-3)RR=1.E-3
C
1 CONTINUE
A=.026*RR**.225+0.133*RR
B=22.*RR**0.44
C=-1.62*RR**0.134
FRIC=A+B*RE**C
FR2P=4.*FRIC
FRICL=64./RE
IF(FRICL.GT.FR2P)FR2P=FRICL
RETURN
END
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1743

PostPosted: Tue May 24, 2022 1:23 am    Post subject: Reply with quote

Jim, as is often the case when we can see only snippets of code, there is nothing that I can see that could have caused the discrepancy. Please make the entire code available (preferably, zip up the sources, upload to a cloud service, and post a link to the file with public access enabled).

P.S. I just noticed that WN, which is reported to have the value -59358.3, is compared to 0.005 and one of two relations is selected depending on the comparison. Something fishy here, no?

The explanation for DHYD "switching" to zero across the subroutine call: you misspelled the fourth actual argument to FR2P as DYHD instead of DHYD. If you are not protected against making such errors, use IMPLICIT NONE in your subprograms. Doing so will get the compiler to catch such errors.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1743

PostPosted: Wed May 25, 2022 9:50 am    Post subject: Reply with quote

Here is a cleaned-up and reformatted version of Jim's program in a form fit to present to the compiler. I have retained the bug in the reference to the function fr2p.

Code:
program jhydr
   implicit none
   real re, wn, sn, dhyd, frac
   integer ik
 
   re = 2.337134e+06
   wn = -59358.3
   sn = 0.00000
   dhyd = 0.177013
   ik = 2

   frac=fr2p(re,wn,sn,dyhd,ik) ! bug on this line
   print *,frac

contains

   real function fr2p(re,wn,sn,dhyd,ik)
   implicit none
   integer ik
   real re,wn,sn,dhyd,rr,a,b,c,fric,fricl

   write(*,*)re,wn,sn,dhyd,ik
   select case(ik)
      case(1)
! ik = 1 commercial steel
          rr=.0000457/dhyd
      case(2)
! ik = 2 galvanized iron
         rr=.000152/dhyd
      case(3)
! ik = 3 dunn and ros mist flow e/d
         if(wn.gt.0.005)then
            rr=174.8*sn*wn**0.302
         else
            rr=34.*sn
         endif
         rr = max(min(rr,0.5),1e-3)
   end select
   a=.026*rr**.225+0.133*rr
   b=22.*rr**0.44
   c=-1.62*rr**0.134
   fric=a+b*re**c
   fr2p=max(4.*fric,64./re)
   return
end function
end program
Back to top
View user's profile Send private message
Jim



Joined: 21 Jul 2006
Posts: 24
Location: USA

PostPosted: Wed May 25, 2022 6:54 pm    Post subject: Error solved! Recommendation for cloud service to upload? Reply with quote

Hi mecej4,

Thank you for catching that typo! I looked and looked for the error and it was right in front of me! Embarassed

Would you make a suggestion for a cloud service to upload to per your comment below?

"Please make the entire code available (preferably, zip up the sources, upload to a cloud service, and post a link to the file with public access enabled)."
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1743

PostPosted: Thu May 26, 2022 12:20 am    Post subject: Reply with quote

Jim, many of the popular free email providers such as Google, Microsoft, Yahoo, etc., provide some cloud storage as a perk. For short programs such as yours, services such as https://paste.ofcode.org/87ieDtWUeWNqqbTRNEn8VH can also be used. That particular site holds posts for just one week, so it is suitable for exchange codes and mark-ups that are not needed to be stored "permanently".
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group