Errata File "OOP via F90" This is only the beginning of an errata for the text based on comments from readers. As of June 2004 I have not yet verified the suggested errors. I hope to review them when I start the summer break in July 2004. Please feel free to send your comments. Prof. Akin The Errata will cite pages in the published book, which will differ from the PDF drafts here, especially for Chapter 9. ------------------------------- 1 -------------------------------------- One reviewer suggests that the source code line numbers should be moved from the left margin to the right margin. This will be done in any future release. ------------------------------- 2 -------------------------------------- Date: Fri, 4 Jul 2003 19:40:51 +0100 From: Alistair Mills To: akin@rice.edu Subject: Object oriented Fortran 90 Professor Akin I have just come across your very interesting book. I think that this is a book which has been waiting to be written! It is very interesting. I hope that you will not be offended by what I have to say. It is intended to be constructive. Your book is a very readable account of the subject, and is much more comprehensible than other things which I have read on the same matter! I do not know how you can find time to be a professor at a major school of engineering, do research, and write such things also! I have also found your web site, and I have found that you have indexes to the figures and the files. This is very helpful, as it was taking me time to work out which source code files correspond to the text. I found that the page numbers are not correct, but the figure numbers are approximately correct. For example, I have changed the page numbers for chapter 7, and a couple of the figure numbers. I will send you a complete updated index, if you are interested. That would then agree with the published page numbers. class_Stack.f90 7.2 160 *** See expanded list below *** stack_check.f90 7.3 161 class_Queue.f90 7.5 163 queue_check.f90 7.6 165 singly_linked_list.f90 7.10 169 Test_SLL_Integers.f90 7.11 171 Integer_Objects.f90 7.12 172 doubly_linked_list.f90 7.14 173 Test_DLL_Integers.f90 7.15 175 random_access.f90 7.16 176 interface_Queue Section_7.3 exceptions.f90 none object_type.f90 none I have also observed a couple of coding errors. There is quite a serious one in chapter 7. Test_DLL_Integers.f90 7.15 175 Line 156 should read as follows: point_to_Obj_3 => Get_Ptr_to_Obj (container, Obj_3) ! There is also an error on the printed version on this line [20] and [21] Rather than: point_to_Obj_3 = Get_Ptr_to_Obj (container, Obj_3) The program fails at run time when using both DVF 6.6 and Intel 7.0. The error is a common one. The assignment statement on the original attempts to copy the contents of the object at the end of the pointer to the contents of the object at the end of point_to_Obj_3. As there is nothing yet on the end of point_to_Obj_3, the run time system fails with an access violation. There is also an error in chapter 4. Line 19 of passing_types.f90 is "call by value". Fortran only does call by address. If you change line 19 to eliminate the additional parentheses, then the results are different. The parentheses force the creation of a temporary location containing a copy of Input_val. The value in the temporary location is changed, but this is not copied back to the source ie Input_Val. So the effect is the same, although the reasons are different. ! pass by value call No_Change ( Input_Val ) ! Use but do not change print *, "After No_Change it is ", Input_Val If you find what I have to say constructive, then I may have more when I have completed reading the book! With best wishes Alistair Mills ------------------------------- 3 te: Tue, 8 Jul 2003 20:10:48 +0100 From: Alistair Mills To: 'Ed Akin 221 Cox x4879' Cc: Alistair.Mills@btinternet.com Subject: RE: Object oriented Fortran 90 Prof Akin Thanks for pointing out the link, and thank you for including my comments. Here is my version of the source code index. Alistair Source Figure Page hello.c 1.3 09 hello.cpp 1.3 09 hello.f90 1.3 09 hello.m 1.3 09 Math_Constants.f90 2.1 29 Fibonacci.f90 2.6 34 create_a_type.f90 Section_2.2 29 use_a_type.f90 Section_2.2 30 Geometric_Classes.f90 3.3,3.4 39 Test_Geometry.f90 3.3,3.4 40 class_Date.f90 3.6 42 Test_Date.f90 3.7 43 class_Person.f90 3.9 44 Test_Date_Person.f90 3.10 45 class_Student.f90 3.12 46 Test_Student.f90 3.13 47 class_Rational.f90 3.15 49 Test_Rational.f90 3.16 52 generic_geometry.f90 none generic_geometry_2.f90 none arithmetic.f90 4.1 61 do_for.f90 4.2 65 array_index.f90 4.3 65 more_or_less.f90 4.4 70 if_else.f90 4.5 70 and_or_not.f90 4.6 71 clip.f90 4.7 79 maximum.f90 4.8 80 cpu_time.f90 4.10 82 exceptions.f90 4.11 83 passing_types.f90 4.12 86 string_use.f90 4.13 89 string_or_integer.f90 4.14 90 upper_lower.f90 4.15,4.16 91 struct_access.f90 4.17 96 fractions.f90 4.18 97 test_overload.f90 4.19 98 pt_expression.f90 4.20 101 linear_fit.f90 4.21 106 sort_reals.f90 4.23 109 sort_string.f90 4.24 110 integer_sort.f90 4.25 111 test_bubble.f90 4.27 113 cases.f90 none vector_norm.f90 none array_pointer.f90 none interp_vs_compil.f90 none interface 5.2 122 class_Drill.f90 5.3 123 test_Drill.f90 5.4 124 class_Angle.f90 5.6 126 class_Position_Angle.f90 5.8 130 class_Global_Position.f90 5.10 132 class_Great_Arc.f90 5.12 139 GPS_library.f90 5.13 135 non_poly_pos_ang.f90 none 6.5 139 6.6 140 6.7 141 6.8 143 6.9 143 6.10 144 6.11 145 6.12 146 6.13 147 6.14 148 6.15 149 6.16 150 Test_Is_A_Member.f90 6.17 153 member_1_class.f90 6.18 153 member_2_class.f90 6.19 154 is_a_member_class.f90 6.20 155 class_Stack.f90 7.1 160 stack_check.f90 7.3 161 class_Queue.f90 7.5 163 queue_check.f90 7.6 165 singly_linked_list.f90 7.10 169 Test_SLL_Integers.f90 7.11 171 Integer_Objects.f90 7.12 172 doubly_linked_list.f90 7.14 173 Test_DLL_Integers.f90 7.15 175 random_access.f90 7.16 176 interface_Queue Section_7.3 exceptions.f90 none object_type.f90 none trans_opt.f90 8.1 191 Matrix_Operators.f90 none array_demo.f90 none display_real.f90 none elem_type_data_class.f90 9.1 210 memory_leak.f90 9.2 212 No_Copy_Reallocate.f90 9.4 214 9.6 219 System_Constants.f90 none ------------------------------- 4 --------------------------------- Date: Sun, 20 Jun 2004 03:56:44 -0700 (PDT) From: Wayne B'Rells To: akin@rice.edu Subject: Errata for "OO Programming via Fortran 90/95"? Dear Dr. Akin: I recently picked up your book on OO programming with Fortran 90/95. I have only read up to section 2.4, but have discovered a few errors in the text and in the sample programs. Specifically, line [19] of the Fibonacci example (Figure 2.6 ) references 'num%exists', which does not exist in the definition of the 'Fibonacci_Number' type. This new logical variable is also mentioned in the text, but not seem to be USED in the code. Would you, perhaps, have an Errata listing for your book? (Such a listing of corrections would make it a bit easier to follow some of your examples...) BTW, I will be converting many of your examples so they can be compiled with the 'F' compiler. This compiler seems to include all the new F90/95 features, but leaves out those F77 constructs which are now redundant. Hoping to hear from you, Wayne B'Rells Schenectady, NY wbrells@yahoo.com ------------------------------- 5 --------------------------------- Date: Mon, 21 Jun 2004 05:16:37 -0700 (PDT) From: Wayne B'Rells To: Ed Akin 221 Cox x4879 Subject: Re: Errata for "OO Programming via Fortran 90/95"? Dr. Akin: I was able able to look at the 'errata', but did not notice my specific problem. On the other hand, the code on the CD was correct in that it did NOT include any reference to "num%exists". FYI, the homepage for the F compiler is: http://www.swcp.com/~walt/ As I see it, the major advantages of the F compiler are: 1) It is free. 2) It is available for both the PC and Unix. 3) It FORCES users to strictly adhere to Fortran 90/95 coding practices and to explicitly declare all variables, access privileges, etc. This seems particularly desirable from a pedagogical point of view. My "conversion" of the Fibonaccci example to F did suggest a few places where the code could be "cleaned up" a bit: 1) The "implicit none" statements in the contained functions of the "class_Fibonacci_Number" module were flagged as errors by the F compiler. According to the Metcalf & Reid book ("Fortran 90/95 Explained"): "...and if there is an implicit none statement there must be no other implicit statement in the scoping unit." In other words, the implicit none statement at the module level is inherited by the contained functions via host association. (I suspect that many F90 compilers just treat the extra implicit none statements as redundant and ignore them...) 2) In F, all contained functions must be explicitly given the 'public' or 'private' access attribute. Therefore, I had to add 'new_Fibonacci_Number' to the list of public module functions. 3) In F, the 'intent' of all dummy arguments must be specified. Therefore, I had to add "intent(in)" to the list of attributes for the 'max' argument in the 'new_Fibonacci_Number' function. These were the major modifications that I found necessary. The minor changes included: 1) Putting only one statement per line 2) Changing ' to ". 3) Putting output formats directly in the write statements Best wishes, Wayne ------------------------------- 6 ---------------------------------