4.5 Enter a PASCAL program4 Labs4.3 Run an assembly program4.4 Fortran program

4.4 Fortran program

FORTRAN is an early programming language currently used for vector processing on super computers and other scientific programming.
  1. Enter the FORTRAN program circle.for from the listings below. Start the comments and statement numbers in column 1. Start the statement in column 9, after one tab. Do not worry about minor typing errors, you will have a chance to correct them later in this lab. Please name your source code file circle.for.
    
    
    ***************************** 
    *      your name            * 
    ***************************** 
            open(unit=21,file='circle.out',status='unknown') 
            open(unit=22,file='circle.dat',status='unknown') 
            write(unit=21,fmt=2500)
    2500    format(1x,'Circles and Spheres')
            write(unit=21,fmt=3000)
    3000    format(1x,'If radius is',3x,'with density',2x, 
            1'circumference',9x,'volume',9x,'weight'/)
    100     read(unit=22,fmt=1000)rad,dens
            if(rad.eq.0) goto 9900
    1000    format(f6.2,1x,f6.2) 
            circ=rad*2.0*3.1416 
            vol=(rad**3*3.1416*4)/3.0 
            wt=vol*dens
            write(unit=21,fmt=2000)rad,dens,circ,vol,wt 
    2000    format(1x,6(f12.2,3x))
            goto 100
    9900    write(unit=21,fmt=4000) 
    4000    format(/,1x,'End Of Data') 
            stop
            end
    
  2. In a separate file called circle.dat enter that following data. Make sure that there are no blank lines and that the first digit is in column one.
    000100 000100
    000010 000500 
    000250 000050 
    000500 000001 
    001000 000050 
    001234 004321 
    010000 001000 
    000000 000000
    
  3. Compile the FORTRAN program you created in step 1 with the command:
    f77 circle.for -o circle
    
    If you get errors refer to file above and correct them with the editor.
  4. When you get an error free compile, execute the program.
    circle 
    
  5. It should create a file circle.out that has some information about circles and spheres. Type out this file with the cat command and look at it. If the file does not exist, try to determine what went wrong and correct it.
  6. Print out circle.out and turn it in.
    lpr circle.out 
    
Print the file generated in step . On it print the following:
Your-Name
Lab 4.4: FORTRAN circle program
TABER CIS135
Place the lab in the instructor hand-in box in BUS R6E, the "terminal room".
Instructor: ltaber@pima.edu ** My new Home at GeoApps in Tucson ** The Pima College Site ** The Mad Dr. G.'s home page on phred.

4.5 Enter a PASCAL program4 Labs4.3 Run an assembly program4.4 Fortran program