Fortran Programming|Computer Science

Fortran Programming|Computer Science

Due: Specified on the Moodle assignment page. ​Late submissions will automatically be marked as late and NOT GRADED​. Please make sure you submit your assignment far in advance of the stated deadline, so that you avoid losing credit due to bad networks, etc. It is recommended that you start early and if you have questions, ask them in the course Moodle Discussion forum. If you wait until the last minute to ask questions, it’s very likely that nobody will answer you in time. It is also recommended that you turn in something, even if it’s not complete. Even if you weren’t able to complete the assignment, taking the time to explain what you tried and what problems you faced will likely prevent you from getting a zero. Grading​: Grading is somewhat subjective in this assignment, on a scale of 0 to 10, roughly equivalent to a standard grading scale where 10 would be an A+ (Excellent), 9 would be a B+/A- (Good), 8 would be a C+/B- (Fair), etc. In this particular assignment, if you do all that is asked of you, you should receive a 10. If you neglect, or poorly explain 2 or more minor items, you should receive a 9, and so on. This assignment consists of several goals

● To provide you with experience running and modifying a Fortran program ● To provide you with experience running and modifying a parallel MPI program

Because few, if any, of you have experience with Fortran or MPI, and because it’s so close to the end of the semester, I have written a well-documented functional MPI program to solve the heat diffusion equation, with one “gap” that you will need to fill in so that it produces correct results. Once you have a program that produces correct results, you will introduce and analyze three simple “simulated problems” to force you into gaining further insight in the parallel program. The deliverable that you should plan on submitting is a PDF-format formal report on the activities described below. I have ​highlighted in red​ the components that you should place in your report.

Problem 7.1: Verify that you understand, can compile and can run the serial program and test case that I give you You may want to refer to class lecture notes for parallel programming to familiarize yourself with how to compile and run. I have made a tar file available to you at http://www.borealscicomp.com/Academic/HU/CISC600/Assign07/Assign07.tgz When you untar it you’ll find two directories – FDMSerial and FDMMPI. FDMSerial is code that I have previously shared with you, which solves the time-dependent heat diffusion problem using explicit finite difference methods. I have given it to you as a courtesy to help you see a full solution without the complexity of parallel programming constructs, and as a way to verify that your parallel solutions for different scenarios is correct. You should verify that you can compile and run it. Use the ​gfortran​ compiler, and the ​-DDEBUG flag if you want to see timestepping output. Assuming you name the executable ​fdmserial​, you can run it with the given test file $ ./fdmserial < test1.dat . . . t: 9.80 | uold: 0.00 14.28 28.57 42.85 57.14 71.43 85.71 100.00 t: 9.90 | uold: 0.00 14.28 28.57 42.85 57.14 71.43 85.71 100.00 t: 10.00 | uold: 0.00 14.28 28.57 42.85 57.14 71.43 85.71 100.00 You should read the file and make sure you understand what’s going on. It doesn’t make sense to start on the next problem until you feel comfortable with this one. I recommend that you play around with the input parameter file, ​test1.dat,​ and make sure that the output you get matches your expectations. Please do not provide output for this step in your report. I don’t need to see it, and it just adds noise. This step is simply recommended to prepare you for the next steps.

http://www.borealscicomp.com/Academic/HU/CISC600/Assign07/Assign07.tgz
Problem 7.2: Verify that you understand, can compile and can run the parallel program and test case that I give you Again, I recommend you browse through the lectures notes on parallel computing before proceeding. In directory ​FDMMPI​, I have provided you with source code and a simple test file that will produce incorrect results when executed. Use the ​mpif90​ compiler (it’s actually a wrapper around the ​gfortran​ compiler) with the ​-DDEBUG​ flag to produce the executable, then you can run it as follows $ mpirun -np 2 ./fdmmpi < test1.dat PE: 1 of 2 tasks PE: 0 of 2 tasks PE: 0 NumNodes: 8 k: 1.00 c: 2.00 rho: 5.00 length: 1.0 tn: *** deltat: 0.10 initval: 0.0 leftbc: 0.0 rightbc: 100.0 PE: 0 mynumnodes: 4 h: 0.1 r: .49E+00 PE: 0 Allocated nodes for uold and unew: 4 plus left and right ghost nodes PE: 1 NumNodes: 8 k: 1.00 c: 2.00 rho: 5.00 length: 1.0 tn: *** deltat: 0.10 initval: 0.0 leftbc: 0.0 rightbc: 100.0 . . . Global — t: 9.90 umaster: 0.00 0.00 0.00 0.00 25.00 50.00 75.00 100.00 PE: 0 sent 0.0000000000000000 to PE: 1 PE: 1 recvd 0.0000000000000000 from PE: 0 PE: 0 t: 10.00 uold: 0.00 0.00 0.00 0.00 0.00 0.00 PE: 1 t: 10.00 uold: 0.00 25.00 50.00 75.00 100.00 0.00 PE: 0 t: 10.00 unew: 0.00 0.00 0.00 0.00 0.00 0.00 PE: 1 t: 10.00 unew: 0.00 25.00 50.00 75.00 100.00 0.00 Global — t: 10.00 umaster: 0.00 0.00 0.00 0.00 25.00 50.00 75.00 100.00 Master: Walltime: 0.0 seconds There is a huge amount of output to help with development and debugging, but you can filter it for the lines with ​Global ​in them as follows $ mpirun -np 2 ./fdmmpi < test1.dat | grep Global Global — t: 0.00 umaster: 0.00 0.00 0.00 0.00 0.00 0.00 49.00 100.00 Global — t: 0.10 umaster: 0.00 0.00 0.00 0.00 0.00 24.01 49.98 100.00 Global — t: 0.20 umaster: 0.00 0.00 0.00 0.00 11.76 24.97 61.76 100.00 . . .

Global — t: 9.90 umaster: 0.00 0.00 0.00 0.00 25.00 50.00 75.00 100.00 Global — t: 10.00 umaster: 0.00 0.00 0.00 0.00 25.00 50.00 75.00 100.00 You should notice that something looks wrong in the results, and if you look in your source code you’ll find what you need to do to fix this problem. For further insight, you might check out the results from running this on 4 tasks. I recommend that while you’re doing this development work, you simplify the process by using only four total nodes, and just four or five timesteps until you get it working correctly. With a smaller problem size there is less to confuse you, and this should be enough for you to understand whether your development is working or not. Once you have it working correctly, test it on a variety of cases, but show me the output, in a single window, for your running the case with ​8 nodes and 4 tasks, for t = 0 to 1 second with timestep sizes of 0.1​. Your output should look something like this

Please be sure that you make the window wide enough so that it displays neatly and not “wrapped.” Please be sure that your name is in the command line prompt. THIS AND THE SOURCE CODE YOU ADDED IS THE ONLY OUTPUT THAT YOU NEED TO SHOW ME FOR THIS PROBLEM. Please don’t dump in anything else unless it’s needed to explain problems you are having.

What you need to paste into your document is

● The lines of code that you added to make the program produce correct results. Please do not paste in the entire program. Please format this neatly, using a monospaced font (Courier is often a good one) that makes it very easy to read. I’m not asking this so much for my own viewing pleasure (though it helps), but because I think you need to be taking the time to present your work well for others.

● A screenshot, like I’ve shown you above, showing successful execution and correct results.

Problem 7.3: Introduce a couple of simulated programming errors, predict what will happen, observe what happens, and explain in detail why it happened In this section, I want to introduce you to very subtle errors in parallel programming that can make your life miserable. First, you should set up your test file so that it runs on 8 nodes. Use timestepping of 0 to 1 second in timestep sizes of 0.1. Verify that you can run your program with this setup, ​using 4 tasks​, and that the output is correct. Simulated Stupid Error #1 Then, you should introduce a simulated programming error. In the section of code where you are sending tasks’ rightmost values to their right neighbour, replace the IF (MyRank < NumTasks-1) THEN with IF (MyRank < NumTasks) THEN

● Before you compile and run this, explain what you expect to happen. Take a while to think about this.

● Run the code and explain what happened, and why it happened ● Fix your code so that it runs correctly again.

Simulated Stupid Error #2 For the second simulated problem, you should go down to the corresponding receive, where tasks are receiving values from their left neighbour, replacing IF (MyRank > 0) THEN with IF (MyRank > 1) THEN

● Before you compile and run this, explain what you expect to happen. Take a while to think about this.

● Run the code and explain what happened, and why it happened ● Fix your code so that it runs correctly again.

Please note that the problem in this scenario isn’t real obvious, so you will have to look closely at your output to find it. Simulated Stupid Error #3 For your final simulated problem, I want you to take the statement messagetag = 4 that currently comes before the call to ​MPI_SEND()​ and move it so that it is BETWEEN the MPI_SEND()​ and ​MPI_RECV()​ calls.

● Before you compile and run this, explain what you expect to happen. Take a while to think about this.

● Run the code and explain what happened, and why it happened ● Fix your code so that it runs correctly again.

Order from us and get better grades. We are the service you have been looking for.