Sie sind auf Seite 1von 7

In the formulas below, we use the mathematical standard computer conventions for algebraic and numeric expressions.

The characters ([ ]) represent order of calc ulations, / represents division, * represents multiplication, - subtraction, + a ddition and = is equal. It is very important to follow the order of operations a s different results can be obtained giving inaccurate results. 1. The Celsius temperature scale is still sometimes referred to as the "centigra de" scale. Centigrade means "consisting of or divided into 100 degrees;" the Cel sius scale, devised by Swedish Astronomer Andres Celsius (1701-1744) for scienti fic purposes, has 100 degrees between the freezing point of 0 degrees and boilin g point of 100 degrees of pure water at sea level air pressure, 29.92 inches of mercury. That pressure criteria is often called an atmosphere, or more commonly, standard pressure. The term Celsius was adopted in 1948 by an international con ference on weights and measures. This is the most widely used scale in the world . 2. On the Fahrenheit scale, used primarily in the United States, the freezing po int of water is 32 degrees and the boiling point is 212 degrees while measured a t standard pressure. Zero degrees Fahrenheit was the coldest temperature that th e German born scientist Gabriel Daniel Fahrenheit could create with a mixture of ice and ordinary salt. He is credited with the invention of the mercury thermom eter and introduced it and his scale in 1714 in Holland, where he lived most of his life. His thermometer was based on the original design papers by Galileo for a temperature and pressure measuring device. 3. Scientists use a third scale for unique measurements, called the absolute or Kelvin scale. This scale was invented by William Thomson, also know as Lord Kelv in, a British scientist who made important discoveries about heat in the 1800's. Scientists have determined that the coldest it can get, in theory, is minus 273 .15 degrees Celsius. This temperature has never actually been reached, though sc ientists have come close. The value, minus 273.15 degrees Celsius, is called abs olute zero. At this temperature scientists believe that molecular motion would s top. You can't get any colder than that. The Kelvin scale uses this number as ze ro. To get other temperatures in the Kelvin scale, you add 273 degrees to the Ce lsius temperature. Conversion is very straight forward, though, strangely enough , the word degree is not used with the Kelvin scale. 4. A now somewhat obsolete scale is used in specific calculations and measuremen ts. It was created by R A F de Raumur (1683-1757) a French scientist. He knew no thing of Fahrenheit's work and did not use mercury, but did produce a good worki ng thermometer. He used the freezing point of water as his zero mark, and put th e boiling point at 80 degrees. This scale was widely used in the 18th and 19th c enturies, especially in France, in scientific communities. He has a greater clai m to fame for much of the other scientific work he did. 5. W J M Rankine (1820-1872), a Scottish engineer, created his scale, which was merely the Kelvin scale using the Fahrenheit degree instead of the Celsius. It h as also had some wide use in scientific communities but is of no practical use i n other areas of measurement. Kelvin, Raumur, and Rankine The formula in mathematics are : a C = (4/5)a Raumur = [32 + (9/5)a] F b Raumur = (5/4)b C = [32 + (9/4)b] F c F = (5/9)(c - 32) C = (4/9)(c - 32) Raumur t C = (t + 273.15) K

TK K = (TK - 273.15) C = [1.80 * (TK - 273.15) + 32] F = 1.80 TK Rankine Here, The program of temperature converter using Fortran 95. ! DECLARED VARIABLES ! c = the temperature in degrees Celsius. ! f = the temperature in degrees Fahrenheit. ! k = the temperature in Kelvin. ! r = the temperature in degrees Rankine. ! re = the temperature in degrees Raumur. ! t = the input value for temperature. ! scail = the user's input menu choice. It's my homophone adaptation of "s cale," which happens to ! be a FORTRAN command. It isn't a CHARACTER variable be cause my menu is numbered. ! choice = a one character CHARACTER string for the user to input 'y', 'n' , 'Y', or 'N' when ! prompted to run the program again. REAL :: c, f, k, r, re, t INTEGER :: scail CHARACTER(1) :: choice CONTAINS ! This is basically the "library" of the module. ! What follows is a long list of functions. I used a lot, as there are a lot of possible conversions ! that can be done. Since the only thing that changes between them is the mathem atical operations, ! so I'll explain the first one. The conversion equations can be found in chemic al engineering books ! and on the internet (and probably a whole slew of other places). If this displ eases you, kindly ! go fuck yourself. REAL FUNCTION cf(t) FUNCTION because temperature can be fractional. IMPLICIT NONE me is 'cf' and the 't' is a dummy variable used in it. REAL, INTENT(IN) :: t alue comes from the program and is not ! This is a REAL ! Its na ! INTENT(IN) means the v

! to be modified or relayed to the program by the FUNCTION. cf = t*(9.0/5.0) + 32.0 equation. END FUNCTION cf FUNCTION. ! This ends the ! This is the conversion

! And now what follows is more of the same. As I said before, lots of delicious copypasta. REAL FUNCTION ck(t) IMPLICIT NONE REAL, INTENT(IN) :: t ck = t + 273.15

END FUNCTION ck REAL FUNCTION cr(t) IMPLICIT NONE REAL, INTENT(IN) :: t cr = (t + 273.15)*(9.0/5.0) END FUNCTION cr REAL FUNCTION cre(t) IMPLICIT NONE REAL, INTENT(IN) :: t cre = t*(4.0/5.0) END FUNCTION cre REAL FUNCTION fc(t) IMPLICIT NONE REAL, INTENT(IN) :: t fc = (t - 32.0)*(5.0/9.0) END FUNCTION fc REAL FUNCTION fk(t) IMPLICIT NONE REAL, INTENT(IN) :: t fk = (t + 459.67)*(5.0/9.0) END FUNCTION fk REAL FUNCTION fr(t) IMPLICIT NONE REAL, INTENT(IN) :: t fr = t + 459.67 END FUNCTION fr REAL FUNCTION fre(t) IMPLICIT NONE REAL, INTENT(IN) :: t fre = (t - 32.0)*(4.0/9.0) END FUNCTION fre REAL FUNCTION kc(t) IMPLICIT NONE

REAL, INTENT(IN) :: t kc = t - 273.15 END FUNCTION kc REAL FUNCTION kf(t) IMPLICIT NONE REAL, INTENT(IN) :: t kf = t*(9.0/5.0) - 459.67 END FUNCTION kf REAL FUNCTION kr(t) IMPLICIT NONE REAL, INTENT(IN) :: t kr = t*(9.0/5.0) END FUNCTION kr REAL FUNCTION kre(t) IMPLICIT NONE REAL, INTENT(IN) :: t kre = (t - 273.15)*(4.0/5.0) END FUNCTION kre REAL FUNCTION rc(t) IMPLICIT NONE REAL, INTENT(IN) :: t rc = (t - 491.67)*(5.0/9.0) END FUNCTION rc REAL FUNCTION rf(t) IMPLICIT NONE REAL, INTENT(IN) :: t rf = t - 459.67 END FUNCTION rf REAL FUNCTION rk(t) IMPLICIT NONE REAL, INTENT(IN) :: t rk = t*(5.0/9.0) END FUNCTION rk

REAL FUNCTION rre(t) IMPLICIT NONE REAL, INTENT(IN) :: t rre = (t - 491.67)*(4.0/9.0) END FUNCTION rre REAL FUNCTION remc(t) IMPLICIT NONE REAL, INTENT(IN) :: t remc = t*(5.0/4.0) END FUNCTION remc REAL FUNCTION ref(t) IMPLICIT NONE REAL, INTENT(IN) :: t ref = t*(9.0/4.0) + 32.0 END FUNCTION ref REAL FUNCTION rek(t) IMPLICIT NONE REAL, INTENT(IN) :: t rek = t*(5.0/4.0) + 273.15 END FUNCTION rek REAL FUNCTION rer(t) IMPLICIT NONE REAL, INTENT(IN) :: t rer = t*(9.0/4.0) + 491.67 END FUNCTION rer ! So now all of the functions are covered, now it's time for the subroutines. SUBROUTINE menu(scail, t) OUTINE named 'menu' that uses the variables IMPLICIT NONE ! 'scail' and 't'. INTEGER, INTENT(OUT) :: scail e variables will be written to by REAL, INTENT(OUT) :: t r or the program. 101 FORMAT(/A) are the FORMATs used by the 'menu' SUBROUTINE. 110 FORMAT(A/) ! This is a SUBR

! INTENT(OUT) means thes ! either the use ! These

111 FORMAT(A) 1010 FORMAT(/A/) ! What follows is the erotic text-based menu that the user sees. Notice the ADVA NCE for user input. WRITE(*,101) "Please select your current temperature scale:" WRITE(*,*) "1. Celsius" WRITE(*,*) "2. Fahrenheit" WRITE(*,*) "3. Kelvin" WRITE(*,*) "4. Rankine" WRITE(*,*) "5. Raumur" WRITE(*,101,ADVANCE="NO") "Enter the number of your selection he re: " READ(*,*) scail ! This IF checks to make sure 'scail' is a valid choice. The reason I put this i n is not because I ! think I can do a better job than the CASE construct, but because if an invalid selection is made, ! the program doesn't notice until after it asks the user for a temperature. IF (scail < 1 .OR. scail > 5) THEN WRITE(*,1010) " ### ERROR: Invalid selection. Prog ram ending. ###" STOP END IF ! Now the user is asked for his or her temperature. Notice the use of the ADVANC E formatter. WRITE(*,101,ADVANCE="NO") "Enter the current temperature: " READ(*,*) t ! And that's all for this SUBROUTINE. END SUBROUTINE menu SUBROUTINE endgame(c, f, k, r, re, choice) ed 'endgame' and uses the IMPLICIT NONE ! variables 'c', 'f', 'k', 'r', 're', and 'choice'. REAL, INTENT(IN) :: c, f, k, r, re are the values to be returned to the user. CHARACTER(1), INTENT(OUT) :: choice s a string to be input by the user 101 FORMAT(/A) ! Once again, these are the FORMATs used by the 110 FORMAT(A/) ! SUBROUTINE. 111 FORMAT(A) 1010 FORMAT(/A/) ! This is the sensually organized output seen by the user. WRITE(*,101) "The current temperature is:" WRITE(*,*) c, "Celsius" WRITE(*,*) f, "Fahrenheit" WRITE(*,*) k, "Kelvin" WRITE(*,*) r, "Rankine" WRITE(*,*) re, "Raumur" ! This is when the user is prompted to run the program again. Notice the ADVANCE ! This SUBROUTINE is nam

! These ! This i

formatter. WRITE(*,1010,ADVANCE="NO") "Do you want to run this program agai n? (y/n) " READ(*,*) choice ! That's all for this SUBROUTINE as well. END SUBROUTINE endgame ! And now for the big finish: END MODULE tempmod NB: ! : means a comment, so it's a declaration of explain what it is.

Das könnte Ihnen auch gefallen