The assignment should be done by gfortran not (C or C++ or other)

User Generated

nynzbhqv980

Programming

Description

Problem 1:

Write a FORTRAN 90 subroutine named compare that takes as its rst argument (named r) a row

subscript (between 1 and DIM inclusive). The second argument is an integer array with DIM rows

and NDATA columns. The third and fourth arguments are used to return two integer values as

described below. The subroutine source code is in a module in a separate le from the le containing

the main program source code. The subroutine compare calculates the sum of the values in row r.

The subroutine compare then nds the number of rows with the row sum greater than the sum for

row r, and the number of rows with sum less than or equal to the sum of row r (exclusive of row r),

returning these counts using the third and fourth arguments of compare. The main program takes

input from the keyboard to indicate the speci c row index passed to compare as its rst argument.

Elements in the matrix are generated in a column major manner as pseudo random integer values

between -10 and 10 inclusive. Do not change the starting seed from the default in the FORTRAN

90 compiler. The main program prints this matrix in a neatly formatted manner along with the

values returned by the subroutine compare. Provide test results for the user input of r=1, r=DIM,

and r=4. Use values for DIM and NDATA of 6 and 5 respectively.





problem 2:

Write a FORTRAN 90 subroutine named cc that takes as its rst argument a two dimensional

array of characters named arr with NR rows and NC columns where NR and NC are parameters.

The second argument to the subroutine is a character string of length 1 named ch. The subroutine

source code is in a module in a separate le from the le containing the main program source code.

For each row the subroutine prints (on a single line) at the screen the characters in the row up to

but not including the rst occurrence of the character in ch. If the character in ch does not occur

in a row, then all characters in the row are printed on a single line on the screen. Write a main

program that uses the subroutine cc.

Provide test results for the following data le which the main program opens and reads. (Use values

of 5 and 6 for NR and NC respectively)

231x56

s3fgtr

wxr56t

12x3xx

xf3f3e

Provide a run with user input character "3" and another run when the input character "1"




NOTES:

In addition to the above requirements, also satisfy the following:

1. Whenever you write a program that gets interactive input from the user running the program,

your program must prompt the user (with the appropriate print statement asking for the

required input) just before the related read statement.

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags