Basic Fortran Project

Fortran Project

This is our last project of the semester. You have freedom to code anyway you like, but make sure to meet the minimum project requirements.  Any changes, notes, or additions to this specification will be made here or on the class site and you will be notified via email of such.

studentRecords.dat (available on site)

This project will use a posted file named studentRecords.dat.  This file has the following format:

For example, here are the first few lines from the file:

Julia       Tubs                       28978    ECON    3.8636613            116

Lois        Foley                      14420     ENGL     1.9225476            58

James   Smith                       10413     ENGL     1.3883250            42

Patrick  MaGuirk                    3995       EECS      0.5326414            1

To read in or write all the attributes from a single line you will have to remember that no more than 132 characters can be on one line of code.  So you will to use the & to continue the writing to the next line.

Example READ to an array of students:

OPEN(FILE="studentRecords.dat", UNIT=1, STATUS="OLD")

TYPE(STUDENT), DIMENSION(50) :: students

DO i=1, SIZE(students), 1

READ (1,*) students(i)%firstName, students(i)%lastName, &

students(i)%stuID, students(i)%dept, & students(i)%gpa, &

      students(i)%credits

END DO

Example PRINT:

DO i=1, SIZE(students), 1

PRINT *, students(i)%firstName, students(i)%lastName, &

students(i)%stuID, students(i)%dept, & students(i)%gpa, &

      students(i)%credits

END DO

Please note the above examples are reading and print a single line from/to a single variable of TYPE(STUDENT). In the driver you will need to modify this for an array.

studentModule.f90

MInimum requirements:

Name the module studentMod

Create a new type called STUDENT with the following attributes

  1. CHARACTER(10)  named firstName
  2. CHARACTER(10)  named lastName
  3. INTEGER named stuID
  4. CHARACTER(4) named dept
  5. REAL named gpa
  6. INTEGER name credits

Required Subroutines

1    sortByLastName( students )

a)      students is the array of students and will be INTENT(INOUT)

b)      students is sorted by the last name in ascending order

2   sortByGPA( students )

a)      students is the array of students and will be INTENT(INOUT)

b)      students is sorted by the GPA in descending order

3  sortByCredits( students  )

a)      students is the array of students and will be INTENT(INOUT)

b)      students is sorted by the credits in descending order

Studentdriver.f90

Minimum Requirements:

You are free to declare as many variables as you want and set things up to your liking, but the driver must:

1   Write all students in alphabetical order by their last names to a file named "alphetize.dat"

2   Write the top 10 students (the 10 largest gpa's) to a file named "topTen.dat"

3   Print all student names to the screen in alphabetical order.

4   Prompt the user for a minimum number of credits and write all students who have more credits the number specified by the user to a file named "creditChoice.dat"

5   Prompt the user for a letter and write all students whose first name starts with that letter to a file name "letterChoice.dat"

6   Prompt the user for a student id then print all the information you have for the student with that student id to the screen

7   Print the student lowest  gpa to the screen

8   Print the student highest gpa to the screen

9   Print the average gpa (across all students) to the screen

10  Print the average number of credits (across all students) to the screen

11  Print the department name with the most students

Important notes:

1    When I say "print the student" or "write the student" I require you to print/write all the information regarding that student (first name, last name, dept, id, gpa, credits)

2   When you write or print preserve the original order from studentRecords.dat

3   

CircleType.f90

Name the module circleType

You may use your point module from project 3.

Create a new type called CIRCLE with the following attributes

1             TYPE(POINT) named center

2             REAL named radius

Required Functions

1 distBetweenCircles(c1, c2)

a c1 and c2 are circles

b returns the distance between the centers of c1 and c2

2 intersect( c1, c2)

a c1 and c2 are circles

b returns true if the distance between the centers of c1 and c2 is less than the sum of their radii (modified 2012.12.05)

3 area( c )

a c is a circle

b returns the area of the circle, c

i recall Area of a circle is pi * radius2

ii use 3.14159 as an approximation for pi

Required Subroutines

1 storeCircles( array, fileNum, fileName, fileStatus)

a array is an array of type CIRCLE of an unknown DIMENSION and is INTENT(INOUT)

b fileNum is and INTEGER representing the UNIT of the file holding the circle information

c fileName is CHARACTER of unknown length

d fileStatus is CHARACTER of unknown length

e This subroutine will open the file given

f Reads in as many circles as SIZE( array ) will allow

g We'll discuss this function later and in class

2 printIntersections( circles )

a circles is an array of circles

b prints the indexes of any circles that intersect

c sample output as seen from the circleAnalyzer.f90

3 printAreas( circles )

a circles is an array of circles

b prints the area of all circles to the screen

c sample output as seen from the circleAnalyzer.f90

CircleAnalyzer.f90

Use the circleType module to perform the following:

1 Obtain a number from the user indicating how many circles to retrieve from the file (max of 50)

a if the user gives a number under 1, then force their number to 1

b if the user gives a number over 50, then force their number to be 50

2 Print a list of all intersecting circles

3 Print a list of all circle areas

   Related Questions in Managerial Accounting

©TutorsGlobe All rights reserved 2022-2023.