Introduction to Programming with Fortran ---------------------------------------- Practical Exercise 7: --------------------- Question 1: ----------- 1.1 Take a copy of the program `Inaccuracy.f90' and its data `inaccuracy.data', compile it, run it and save the results. 1.2 Create a file called `double.f90' containing the following code: MODULE double INTEGER, PARAMETER :: DP = KIND(0.0D0) END MODULE double Compile it to create a module file with the command: nagfor -C=all -c double.f90 Change every occurrence of `REAL' to `REAL(KIND=DP)' in `Inaccuracy.f90', add `_DP' to the end of every floating-point constant, and insert a `USE double' statement immediately before every `IMPLICIT NONE' statement and save the source. Now compile `Inaccuracy.f90' normally, run it and save both it and the results. Compare the two sets of results, and note the much increased accuracy in the second set. Inspect them and the source carefully, and check that you understand why that is. Question 2: ----------- 2.1 Copy the program `CubeRoot.f90' and run it interactively, putting in as many floating-point values (positive, negative or zero) as you feel like. 2.2 Change all occurrences of `REAL' to `COMPLEX', and 'real' to 'complex', compile it, run it interactively, putting in as many complex values as you feel like. Remember that list-directed input takes numbers in the same format as constants, but without any `_DP'. Yes, using complex numbers in Fortran really IS that easy! Question 3: ----------- 3.1 Copy the double precision source of the program `Inaccuracy.f90' (created in question 1) to another file, remove all occurrences of `_DP' (thus changing only the declarations and not the constants to double precision), compile it and run it. What goes wrong and why? 3.2 Fix the errors that are flagged by the compiler and try again. What has gone wrong now, and why?