Page 1 of 1

AME 20214, Homework 9

Posted: Mon Dec 01, 2008 5:42 pm
by goodwine
Collaborative Problem: Write a program with a subroutine called switchrows that will switch two rows in a matrix. If the matrix is called A, then switchrows(A,2,3) should switch rows two and three in the matrix. Your subroutine should work with any size matrix. If you need to have other arguments to the subroutine that give the dimensions for the matrix, that is o.k. Your main program should only have the data for the matrix, print the original matrix and then print the matrix after the subroutine is called, showing that the rows were switched. Test it on at least two matrices of with different dimensions. Your subroutine should check that the the numbers that are sent to switch the rows are valid, i.e., that neither is zero or less or greater than the number of rows.

Individual Promlem: Do the same as the collaborative problem, but switch two columns instead.

Re: AME 20214, Homework 9

Posted: Mon Dec 01, 2008 6:37 pm
by jcockerh
Professor,

I know Fortran 90 has built in functions to find the dimensions of an array. Does Fortran 77 have anything similar or are we forced to explicitly pass the array size to the subroutine?

-Casey Cockerham

Re: AME 20214, Homework 9

Posted: Mon Dec 01, 2008 8:24 pm
by goodwine
jcockerh wrote:I know Fortran 90 has built in functions to find the dimensions of an array. Does Fortran 77 have anything similar or are we forced to explicitly pass the array size to the subroutine?
To the best of my knowledge, you have to explicitly pass it to the subroutine. If you find a way to do it that's built-in, please let me know.

Re: AME 20214, Homework 9

Posted: Tue Dec 02, 2008 12:06 pm
by mbohnert
So do you want us to have the user set the size of the array and enter variables or do you just want the matrix values within the program?

Re: AME 20214, Homework 9

Posted: Tue Dec 02, 2008 12:17 pm
by goodwine
mbohnert wrote:So do you want us to have the user set the size of the array and enter variables or do you just want the matrix values within the program?
Either way is fine. You might as well do it in the program since it would be unwieldy for the user to enter the whole matrix. Just use a data statement for that.

Re: AME 20214, Homework 9

Posted: Tue Dec 02, 2008 4:47 pm
by twallac1
Tim Wallace
hw9.f - collaborative problem
hw9ind.f - individual problem

Re: AME 20214, Homework 9

Posted: Tue Dec 02, 2008 9:11 pm
by AL089
Adam Letcher
Homework 9

Re: AME 20214, Homework 9

Posted: Wed Dec 03, 2008 3:55 pm
by cmikkels
My code compiles fine but when I run it, I get a segmentation fault when it should be calling the subroutine. What does this mean and what would this problem be stemming from?

Re: AME 20214, Homework 9

Posted: Wed Dec 03, 2008 4:06 pm
by goodwine
cmikkels wrote:My code compiles fine but when I run it, I get a segmentation fault when it should be calling the subroutine. What does this mean and what would this problem be stemming from?
Lots of things can produce a segmentation fault. Some common ones are when a subscript has a value bigger than an array or when you call a subroutine with a number of variables that doesn't match.

Re: AME 20214, Homework 9

Posted: Wed Dec 03, 2008 5:41 pm
by jcorona
Julian Corona
Hmwrk 9

Re: AME 20214, Homework 9

Posted: Thu Dec 04, 2008 10:53 am
by enoel
Eras Noel III
Homework nine