Question

In: Computer Science

Write a fortran 90 program that sets up a 4x4 2D real array A and associate...

Write a fortran 90 program that sets up a 4x4 2D real array A and associate a single value pointer AP with element (2,1) of that array. Set all elements in A equal to 0. and print the value of AP to the screen. Next set all elements in A equal to 1.23 and print the value AP to the screen.

Solutions

Expert Solution

Program Description

The program uses the statement

real, dimension(4,4)::A

To declare a two dimensional array (4X4) named A

real,pointer::AP

AP is a real pointer variable

AP=A(2,1)

As mentioned in the problem AP has been made associated with a single value A(2,1).

using do loop set the array elements to 0.

print the AP value. In this program write method has been used to do some format to print as AP=value.

Again use do loop to set the values in the array as 1.23.

Again print AP vlaue.

program ends

Code

program hello
real, dimension(4,4)::A ! Two Dimensional Array
real, pointer::AP ! Pointer
AP=A(2,1) ! Associating the pointer to the single value A(2,1)
!Loop to assign the array values as 0
do i=1,4
do j=1,4
A(i,j)=0
end do
end do
write (*,"(A,F7.2)"), "AP=",AP ! Printing AP
!Loop to assign the array values as 1.23

do i=1,4
do j=1,4
A(i,j)=1.23
end do
end do
write (*,"(A,F7.2)"), "AP=",AP ! Printing AP
end program hello

Output

AP= 0.00

AP= 0.00

Screenshot

Output

The Compiler used is online compiler.


Related Solutions

Write a java program of a multiplication table of binary numbers using a 2D array of...
Write a java program of a multiplication table of binary numbers using a 2D array of integers.
Given a 2D array a, sum up ALL the edges of the array. Ex. int a[...
Given a 2D array a, sum up ALL the edges of the array. Ex. int a[ ][ ] = { {1, 2, 3, 4},                        {5, 6, 7, 8},                        {9, 10, 11, 12} }; OUTPUT: Sum of the edges = 65
1. (50 pts) Write a C program that generates a 2D array-of-double and finds the indexes...
1. (50 pts) Write a C program that generates a 2D array-of-double and finds the indexes of the largest value stored in the 2D array. Specific requirements: (1) Your main function defines the 2D array a. You will need to prompt the user to specify the size of the 2D array b. You will need to prompt the user to put in numbers to initialize the array (2) Write a function to display the array that is visualized as rows...
Write a program (fortran 90) that calls a subroutine to approximate the derivative of y=sin(x)+2x^2 using...
Write a program (fortran 90) that calls a subroutine to approximate the derivative of y=sin(x)+2x^2 using a one-sided difference approach fx = (fi-fi-1)/deltaX and a centered difference approach fx = (fi+1-fi-1)/deltaX. The value of the function f and its derivative fx should be evaluated at x=3.75. Your code should print both values tot he screen when it runs.
write a c++ program. Define a class ‘Matrix’ which contain 2D int array ‘m’ of size...
write a c++ program. Define a class ‘Matrix’ which contain 2D int array ‘m’ of size 3x3 as private member.        There should be two public methods within the class definition namely: void setMatrixValue(int i, int j); that should set m[i][j] with user defined values int getMatrixValue(int i, int j); that should return m[i][j] Make a global function named ‘CrossProduct(Matrix m1, Matrix m2)’ that should compute the marix multiplication
Write a program in c++ to do the following: 2. Create an array to hold up...
Write a program in c++ to do the following: 2. Create an array to hold up to 20 integers. 3. Create a data file or download attached text file (twenty_numbers.txt) that contains UP TO 20 integers. 4. Request the input and output file names from the user. Open the files being sure to check the file state. 5. Request from the user HOW MANY numbers to read from the data file, up to twenty. Request the number until the user...
Write a Fortran program that is able to read in the data file. The file has...
Write a Fortran program that is able to read in the data file. The file has lines with the structure: 19990122 88888 30.5 Where: i) the first is an 8 digit code with the date: yyyymmdd (yyyy is the year, mm is the month, and dd is the day) ii) the second is the five digit odometer reading of a car iii) the third is the amount of fuel put into the car on that date to fill the tank...
Write a FORTRAN program to simulate the daily activity at a gas station. Assuming that one...
Write a FORTRAN program to simulate the daily activity at a gas station. Assuming that one customer is served every six minutes, what is the average waiting time per customer?
write a function declaration for a 2d array where each row size is 8 and the...
write a function declaration for a 2d array where each row size is 8 and the function does not return anything.
Write a function declaration for a function that sums each row of a 2D array, where...
Write a function declaration for a function that sums each row of a 2D array, where each row size is 10. The function does not return a result. IN C Program.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT