{"id":117,"date":"2017-09-13T10:15:40","date_gmt":"2017-09-13T13:15:40","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=117"},"modified":"2017-09-13T10:15:40","modified_gmt":"2017-09-13T13:15:40","slug":"htcoef2-f","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/htcoef2-f\/","title":{"rendered":"htcoef2.f"},"content":{"rendered":"<pre>      program htcoef2\r\nc\r\nc       John Mahaffy,  Penn State University, CmpSc 201 Example\r\nc       1\/26\/96\r\nc\r\n      implicit none\r\n      real k,D,h,Re,Pr\r\n      real htc\r\n      real anum\r\nc\r\nc    Calculate an approximation for heat transfer coefficients\r\nc    in a 1 inch pipe for several different Reynolds numbers\r\nc\r\nc   h    -  heat transfer coefficient ( w\/m**2\/K)'\r\nc   k   -  conductivity ( w\/m\/K)'\r\nc   D   -  hydraulic diameter (m)\r\nc   Re  -  Reynolds number\r\nc\r\n      data k,D,Pr\/0.617,0.0254,1.0\/\r\nc\r\nc     Just to prove a point, I'm going to initialize the variable\r\nc     called anum to 100 here.  Watch what happens to the value\r\nc     of the variable with the same name in the function htc,\r\nc     the subroutine output, and here.\r\nc\r\n      anum=100.\r\nc\r\nc    Calculate and print Heat Transfer Coefficients for several\r\nc    Reynolds numbers.\r\nc\r\n      Re=10.\r\n      h=htc(Re,D,k,Pr)\r\n      call output (Re,h)\r\nc\r\nc    Notice that I can use constants as arguments to subprograms\r\nc\r\n      h=htc(100.,D,k,Pr)\r\n      call output( 100., h)\r\nc\r\nc    I can also use functions within the arguments to subprograms\r\nc\r\n      call output (1000.,htc(1000.,D,k,Pr))\r\nc\r\nc    Watch what happens if the data type of my argument in the calling\r\nc    sequence doesn't match the data type of the corresponding element\r\nc    of the subprogram's argument list.\r\nc    (I'm incorrectly using integer \"10000\" instead of 1.0e4 or 10000.0)\r\nc\r\n      h=htc(10000,D,k,Pr)\r\n      call output(10000,h)\r\nc\r\nc    Although I set the value of variables called \"anum\" within htc and\r\nc    output, the value of \"anum\" in the main program remains unchanged\r\nc    The name \"anum\" represents a different memory location in each section\r\nc    of the program.\r\nc\r\nc\r\n      print *,'     In main program      anum = ',anum\r\nc\r\n      stop\r\n      end\r\nc\r\n      function htc(Re,Hd,k,Pr)\r\nc\r\nc    Calculate a heat transfer coefficient based on the maximum of the\r\nc    Laminar and Turbulent coefficients.  The turbulent coefficient is\r\nc    obtained from a Dittus-Boelter correlation\r\nc\r\nc    Notice that the variable names within the function do not have to\r\nc    match the argument names in the calling sequence where the function\r\nc    is used.  Unless you take special measures, the Fortran compiler\r\nc    makes no connection between variable names in the main program\r\nc    and in functions or subroutines.  At this point the only way that you\r\nc    can get the main program and subprograms to agree that two variable\r\nc    names represent the same location in computer memory is by alligning\r\nc    those names in the same position in appropriate calling sequences and\r\nc    subprogram argument lists.\r\nc\r\nc\r\n      implicit none\r\n      real Re,k,Hd,Pr,htc,Nulam,Nuturb\r\n      real anum\r\nc\r\nc   htc  -  heat transfer coefficient ( w\/m**2\/K)'\r\nc   Nulam - laminar Nusselt number\r\nc   Nuturb - Turbulent Nusselt number (Dittus-Boelter correlation)\r\nc   k   -  conductivity ( w\/m\/K)'\r\nc   Hd  -  hydraulic diameter (m)\r\nc   Re  -  Reynolds number\r\nc   Pr  -  Prandl number\r\nc\r\n      data Nulam \/ 4.0\/\r\nc\r\nc     Just to prove a point, I'm going to initialize the variable\r\nc     called anum to 1 within this function.  Watch what happens to the\r\nc     value of the variable with the same name in the main program and\r\nc     the subroutine output.\r\nc\r\n      data anum\/1.0\/\r\nc\r\n      Nuturb=0.023*Re**0.8*Pr**0.4\r\n      htc=k\/Hd*max(Nulam,Nuturb)\r\nc\r\n      print *,'     In function  htc     anum = ',anum\r\nc\r\n      return\r\n      end\r\nc\r\n      subroutine output ( Re, h)\r\nc   Print results to the screen\r\nc\r\n      implicit none\r\n      real Re, h\r\n      real anum\r\nc\r\nc   Re  -  Reynolds Number\r\nc   h   -  Heat Transfer Coefficient\r\nc\r\n      print *, 'For Reynolds Number = ',Re\r\n      print *, 'Heat Transfer Coefficient is ',h,' w\/m**2\/K'\r\nc\r\nc     Just to prove a point, I'm going to set the value of a variable\r\nc     called anum to 3 within this subroutine.  Watch what happens to the\r\nc     value of the variable with the same name in the main program and\r\nc     the function htc.\r\nc\r\n      anum=3\r\n      print *,'     In Subroutine output anum = ',anum\r\nc\r\n      return\r\n      end<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>program htcoef2 c c John Mahaffy, Penn State University, CmpSc 201 Example c 1\/26\/96 c implicit none real k,D,h,Re,Pr real htc real anum c c Calculate an approximation for heat transfer coefficients c in a 1 inch pipe for several different Reynolds numbers c c h &#8211; heat transfer coefficient ( w\/m**2\/K)&#8217; c k &#8211; [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-117","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/117\/revisions"}],"predecessor-version":[{"id":118,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/117\/revisions\/118"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}