AEROSPAC ENG PROBLM
AEROSPAC ENG PROBLM AER E 160
Popular in Course
Popular in Aerospace Engineering
This 5 page Class Notes was uploaded by Noel Koelpin on Sunday September 27, 2015. The Class Notes belongs to AER E 160 at Iowa State University taught by Dana Haugli in Fall. Since its upload, it has received 42 views. For similar materials see /class/214529/aer-e-160-iowa-state-university in Aerospace Engineering at Iowa State University.
Reviews for AEROSPAC ENG PROBLM
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/27/15
Counter or Indexed DO Loops The essential structure of a counter also called an quotindexedquot DO loop is DO ltindexgt ltstartgt ltendgt ltincrement or step sizegt ltInsert executable statements here on one line after the othergt END DO The quantities ltindexgt ltstartgt ltendgt and ltincrement or stepgt MUST be oftype INTEGER either kind4 or kind8 The ltincrement or step sizegt is optional 7 if left Off FORTRAN will assume a step size of 1 For example DO i 1 n 1 isthe same as DOiln Example 1 This example would write out the even values of i from 2 to 10 0 Example 2 Add up all the even numbers from 2 to 10 Assume that i and sum are both integers DO 1 2 10 2 sum sum i END DO WRITE sum The output in this case the value of sum would be 30 Example 3 Compute the product of all the even numbers from 2 to 10 Assume that i is an integer but product is real To avoid mixed mode use the REAL intrinsic function product l DOi2 102 product productREALi WRITE product The output in this case the value of product would be 3840 Example 4 Compute and write to the screen the first 101 positions x along an x aXis given real values for dx and x0 dx 0160 X0 lel DO 1 0 100 1 X X0 REALidX WRITE i x END DO Questions why is the REAL intrinsic function necessary Does running the loop from 0 to 100 in increments of 1 add up to 101 positions List Directed InputOutput Listdirect inputoutput means reading from the keyboard and writing to the screen without attempting to control the format of the output such as the number of decimals the location on the screen etc Instead FORTRAN reads and writes in lists using its own default format A listdirected read has the form READ ltlist variables separated by commasgt The first asterisk means read from the keyboard and the second asterisk means read in list directed form When the READ statement is executed it waits for the user to type data on the keyboard followed by the ltentergt key then assigns the data sequentially to each variable in the READ statement Each READ statement starts on a new line and reads from lefttoright ie as the data appears on the screen when the user types it in A READ statement is usually preceded by a WRITE statement so that the user is told what to type in Without a preceding WRITE statement the program will show only the cursor on the screen as it waits for input The user typically will not recognize the ashing cursor as a request for input A listdirected WRITE statement has the form WRITE lt TeXt in quotes calculations amp variables separated by commasgt The first asterisk means write to the screen and the second asterisk means write in listdirected form Each WRITE statement starts on a new line and writes out strings and variables from left toright on the screen A WRITE statement with nothing following such as WRITE will display a blank line Calculations may also be performed on the WRITE line as shown in the following example Example 1 This example computes and displays the area of a right triangle All the variables are type REAL WRITE This program computes the area of a right triangle WRITE Please enter the base and height of the triangle READ base height area baseheight2 WRITE The area is area Note the last line in this example could be replaced directly with a calculation such as WRITE The area is baseheight2 eliminating the need for the variable area With base 4 and height 5 the output from this code is This program computes the area of a right triangle Please enter the base and height of the triangle 4 The area is 1000000 Note that the user entered 4 and 5 on the same line FORTRAN will also accept inputs on separate lines This program computes the area of a right triangle Please enter the base and height of the triangle 4 5 The area is 1000000 within a given READ statement but each new READ statement will start on a new line Example 2 This example asks the user for x0 and dx then computes and displays in table form the rst 11 values of x along an xaXis PROGRAM axis IMPLICIT NONE INTEGER i REAL X0 dX X WRITE This program displays the first 11 coordinates along WRITE the X aXis WRITE Please enter the starting value of X and the increment READ x0 dX WRITE i X This line creates a table heading DOi 0 100 1 X X0 REALidX WRITE i X This line creates the table one row at a time END DO STOP END PROGRAM aXis The output from this program is This program displays the first 11 coordinates along the X aXis Please enter the starting value of X and the increment dx 1 X 0000000E00 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000 9000000 l000000 komxlmU39IbWNHOIh OOOOOOOOO H O List Dir Page 1
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'