Date: Tue, 14 Jan 1997 20:10:07 GMT Server: Apache/1.1.1 Content-type: text/html Content-length: 4873 Last-modified: Thu, 14 Nov 1996 19:26:25 GMT il
11/1/96
You will write three FORTRAN Subroutines:
1 CMPXMP:This procedure accepts four real parameters and returns two real parameters:2 CMPXAD:1) R1INR1IN and I1IN are the real and imaginary components of a complex number we will call z1. R2IN and I2IN are likewise component of z2, R3out and I3OUT is the output complex number z3. CMPXMP will calculate z3=z1 * z2. This is performed as follows:
2) I1IN
3) R2IN
4) I2IN
5) R3OUT
6) I3OUT
let z1 be represented as R1+i(I1)or (R1,I1)
then z1*z2 = R1*R2-I1*I2 + i(R1*I2+R2*I1) or
( R1*R2-I1*I2, R1*I2+R2*I1 )
This subprogram also accepts 4 real and returns two real parameters. It will interpret the first two ( as did CMPXMP) parameters as the real and imaginary components of a complex number z1, and the next two as z2 and the last two as z3. The procedure will do a complex add of z1 to z2 and return their complex sum in z3. Complex add is defined as follows: let z= R+iI z1+z2 =(R1+R2) +i(I1+I2)3 CMPXMD:This will accept two real input parameters and return one real output parameter.
The first two will be the real and imaginary components of a complex number z and the last one will be the return value (a real scalar) which will contain the modulus of z. Modulus is a way of describing the "size" of a complex number. It is the distance of the point (R, I) from the the origin of the complex plane (the real, imaginary axes). It is calculated as:
let z=R+iI be a complex number
|z|=modulus(z)= sqrt(R^2 + I^2)
You should carefully document the program source, using the BREAK subroutine one Page 301 of your text as a model. Your external documentation should consist of three sets, one for each subprogram. You will have
1) a description of the subprogramYou will be responsible for writing a driver program to test the subprograms. This may be done in one program for all the subprograms or you may write separate drivers if you wish.
2) the input parameters and their types
3) the output parameters and their types
4) and a test PLAN!!
You will write three FORTRAN Functions and change one of the above Subroutines to a Function:
1)Modify CMPXMD to be a REAL function taking two parameters (R1in,I1in).2)3)Write a REAL function Rvalid(MIN,MAX, PROMPT) that prompts the user with "PROMPT" (which is a string parameter), then reads a real input, checks that it is greater than min and less than max, if so,returns the real value read, otherwise produces a helpfull error message and repeats the above steps. MIN, MAX are real parameters, PROMPT is a string.
4)Write an INTEGER fuction Ivalid(MIN,MAX, PROMPT). This function is exactly the same as 2) above,but MIN, MAX and the function are INTEGER.
Only internal documentation is required. You do need to produce a clear statement of what each function does and provide a clear description of the return value and the input parameters. You are to provide a driver program to test (I heartily recommend that you produce a test plan, not to be handed in, but to guide you to a complete test of the functions) . Please hand in as a single script file, sent as message text (^R in compose message).Write an INTEGER function ARRGTR(A,N, VALUE) where :
REAL A(*) ///an array of realsINTEGER N /// the array sizeREAL VALUE /// a real number to be used as a search argument
This function returns the index (subscript) of the first array member that is > VALUE. If there is no such element, it returns N+1. That is, ARRGTR returns the subscript I for the first A(I) > VALUE.
PROGRAM 2C Assignment--Almost finished with Fortran!
NO More parts to follow. We are doing some FUN stuff now!.