1

This is a book from 80's, the authors are French, C. Jablon and J. C. Simon. I've got this book in Russian translation. The title "Применение ЭВМ для численного моделирования в физике" means "Applying ECM for numeric modelling in physics", where ECM stands for Electronic Calculating Machine (not sure how it is translated to English, but in Russian they used to call computers by that name). I tried to google for this book in digital form in Russian, English or French, but I didn't find anything. If it helps in anyway here are the photos of it in Russian:

https://drive.google.com/open?id=0B2MCX8tD_-VNLTh3dWx0ejJIZW8

Here is the code exactly as printed in the book

    parameter nn = 100
    dimension a(nn), b(nn), c(nn), d(nn), x(nn), u(nn)
    dimension xex(nn), test(nn)
    common /thomas/ bet(nn), gam(nn)
    common /perm/ ip(10)

    call iniper(10, -1)
    call inhuni(-1)
    read 222, iter, ifin
    print 1000, iter, ifin
    fifin = 1./float(ifin)
    fiter = 1./float(iter)
    pi = 3.14159265
    pi2 = pi * pi
    xa = 1.
    xc = 1.
    read 111, rb
1   continue
    read 222, n
    print 5000, n
    if(n .gt. nn) stop "alerte"
    xb = 2. - rb * p12 / (float(n + 1) ** 2)
    print 2000, xa, xb, xc
    print 3200
    ermoy = 0.
    n1 = n - 1
    do 10 k = 1, n
        a(k) = xa
        b(k) = xb
        c(k) = xc
10  continue
    it = 0
50  continue
    if (it .eq. ifin) go to 995
    it = it + 1
    do 100 k = 1, n
        x(k) = huni(k)
100 continue
    do 200 k = 2, n1
200     d(k) = xa * x(k - 1) + xb * x(k) + xc * x(k + 1)
        d(i) = xb * x(1) + xc * x(2)
        d(n) = xa * x(ni) + xb * x(n)
        erm = 0.
        do 150 l = 1, iter
            call tom(a, b, c, d, 1, n, u)
            err = 0.
            anopm = 0.
            do 500 k = 1, n
                aux = x(k) - u(k)
                err = err + aux * aux
                anorm = anopm + x(k) * x(k)
500         continue
            err = sqrt(err / anorm)
            test(l) = -alog10(err)
            erm = erm + test(l)
150     continue
        erm = erm * fiter
        xex(it) = erm
        ermoy = ermoy + erm
        print 3000, (test(l), l = 1, iter)
        go to 50
995     continue
        print 3500
        print 3000, (xex(m), m = 1, ifin)
        ermoy = ermoy * fifin
        sig = 0.
        do 996 m = 1, ifin
            aux = tex(m) / ermoy - 1.
            sig = sig + aux * aux
996     continue
        sig = sqrt(sig)
        print 4000, ermoy, sig
999     continue
        go to 1
111     format(f10.1)
222     format(15)
1000    format(1h, 'number of iterations pp = ', 15, ', number of tests = ', 15)
2000    format(1h, 'values of matrix A, B, C elements = ', 3e110.4)
3000    format(1h, 10e12.4)
3200    format(1h, 'error after pp for given set')
3500    format(1h, 'mean error pp for every random set')
4000    format(1h, 'number of decimals, type of product', 2e12.5,11)
5000    format(1h, 'size of inverse tridiagonal system', 15)
    end

    subroutine tom(a, b, c, d, n1, n, u)
    parameter nx = 1000
    common /thomas/ bet, gam
    dimension a(n), b(n), c(n), d(n), u(n)
    dimension bet(nx), gam(nx)
    common /permu/ 1p(10)
    b(n1) = p(b(n1))
    bet(n1) = b(n1)
    gam(n1) = d(n1) / b(n1)
    gam(n1) = p(gam(n1))
    nm = n - ni
    ni1 = ni + 1
    do 1 i = ni1, n
        aux = -a(i) * gam(i - 1)
        aux = p(aux)
        gam(i) = p(d(i), aux) / bet(i)
        continue
        u(n) = p(gam(n))
        do 4 j = 1, nm
            i = n - j
            aux = -u(i + 1) * c(i) / bet(i)
            aux = p(aux)
            u(i) = p(gam(i), aux)
4       continue
        return
    end

I tried to compile it using ifort and here is the output

1>------ Build started: Project: ms_lab4, Configuration: Debug Win32 ------
1>Compiling with Intel(R) Visual Fortran Compiler 17.0.1.143 [IA-32]...
1>main.f90
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(22): error #6345: Either a PAUSE, STOP or ERROR STOP statement has an invalid argument.   [ALERTE]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(84): error #6885: A dangling constant exists.   [15]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(83): error #6885: A dangling constant exists.   [11]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(78): error #6181: An extra comma appears in the format list.   [,]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(78): error #6885: A dangling constant exists.   [15]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(77): error #6885: A dangling constant exists.   [15]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(92): error #5143: Missing mandatory separating blank
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(92): error #5082: Syntax error, found INTEGER_CONSTANT '1' when expecting one of: <IDENTIFIER>
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(102): error #6351: The number of subscripts is incorrect.   [P]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(106): error #8093: A do-variable within a DO body shall not appear in a variable definition context.   [I]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(109): error #6351: The number of subscripts is incorrect.   [P]
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(99): error #6321: An unterminated block exists.
1>c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90(99): error #6323: This label is not defined in this scoping unit.   [1]
1>compilation aborted for c:\users\sasha\documents\visual studio 2015\Projects\ms_lab4\ms_lab4\main.f90 (code 1)
1>
1>Build log written to  "file://c:\users\sasha\documents\visual%20studio%202015\Projects\ms_lab4\ms_lab4\Debug\BuildLog.htm"
1>ms_lab4 - 14 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Then I tried to compile the program with gfortran

gfortran -c main.f90
main.f90:2.4:

    parameter nn = 100
    1
Error: Unclassifiable statement at (1)
main.f90:22.22:

    if(n .gt. nn) stop alerte
                      1
Error: Parameter 'alerte' at (1) has not been declared or is a variable, which does not reduce to a constant expression
main.f90:77.18:

222     format(15)
                  1
Error: Unexpected element ')' in format string at (1)
main.f90:78.52:

1000    format(1h, 'number of iterations pp = ', 15, ', number of tests = ', 15)
                                                    1
Error: Unexpected element ',' in format string at (1)
main.f90:83.68:

4000    format(1h, 'number of decimals, type of product', 2e12.5,11)
                                                                    1
Error: Unexpected element ')' in format string at (1)
main.f90:84.60:

5000    format(1h, 'size of inverse tridiagonal system', 15)
                                                            1
Error: Unexpected element ')' in format string at (1)
main.f90:88.4:

    parameter nx = 1000
    1
Error: Unclassifiable statement at (1)
main.f90:92.18:

    common /permu/ 1p(10)
                  1
Error: Syntax error in COMMON statement at (1)
main.f90:106.21:

            i = n - j
                     1
main.f90:99.19:

    do 1 i = ni1, n
                   2
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
main.f90:112.7:

    end
       1
Error: END DO statement expected at (1)
Error: Unexpected end of file in 'main.f90'

Then I thought that maybe I shouldn't compile it with *.f90 extension because the code is older than 90 standard. I renamed file to main.for and tried to compile it with gfortran.

gfortran -c main.for
main.for:2.5:

    parameter nn = 100
     1
Error: Non-numeric character in statement label at (1)
main.for:3.5:

    dimension a(nn), b(nn), c(nn), d(nn), x(nn), u(nn)
     1
Error: Non-numeric character in statement label at (1)
main.for:3.5:

    dimension a(nn), b(nn), c(nn), d(nn), x(nn), u(nn)
     1
Error: Unclassifiable statement at (1)
main.for:4.5:

    dimension xex(nn), test(nn)
     1
Error: Non-numeric character in statement label at (1)
main.for:4.5:

    dimension xex(nn), test(nn)
     1
Error: Unclassifiable statement at (1)
main.for:5.5:

    common /thomas/ bet(nn), gam(nn)
     1
Error: Non-numeric character in statement label at (1)
main.for:5.5:

    common /thomas/ bet(nn), gam(nn)
     1
Error: Unclassifiable statement at (1)
main.for:6.5:

    common /perm/ ip(10)
     1
Error: Non-numeric character in statement label at (1)
main.for:6.5:

    common /perm/ ip(10)
     1
Error: Unclassifiable statement at (1)
main.for:8.5:

    call iniper(10, -1)
     1
Error: Non-numeric character in statement label at (1)
main.for:8.5:

    call iniper(10, -1)
     1
Error: Unclassifiable statement at (1)
main.for:9.5:

    call inhuni(-1)
     1
Error: Non-numeric character in statement label at (1)
main.for:9.5:

    call inhuni(-1)
     1
Error: Unclassifiable statement at (1)
main.for:10.5:

    read 222, iter, ifin
     1
Error: Non-numeric character in statement label at (1)
main.for:10.5:

    read 222, iter, ifin
     1
Error: Unclassifiable statement at (1)
main.for:11.5:

    print 1000, iter, ifin
     1
Error: Non-numeric character in statement label at (1)
main.for:11.5:

    print 1000, iter, ifin
     1
Error: Unclassifiable statement at (1)
main.for:12.5:

    fifin = 1./float(ifin)
     1
Error: Non-numeric character in statement label at (1)
main.for:13.5:

    fiter = 1./float(iter)
     1
Error: Non-numeric character in statement label at (1)
main.for:14.5:

    pi = 3.14159265
     1
Error: Non-numeric character in statement label at (1)
main.for:15.5:

    pi2 = pi * pi
     1
Error: Non-numeric character in statement label at (1)
main.for:16.5:

    xa = 1.
     1
Error: Non-numeric character in statement label at (1)
main.for:17.5:

    xc = 1.
     1
Error: Non-numeric character in statement label at (1)
main.for:18.5:

    read 111, rb
     1
Error: Non-numeric character in statement label at (1)
main.for:18.5:

    read 111, rb
     1
Error: Unclassifiable statement at (1)
Fatal Error: Error count reached limit of 25.

P. S. the code begins at page 127 on photo IMG_0192, as you can see there is a comment section in Russian, I would try to translate it or any other page if it helps

5
  • 2
    It looks like f66/77 standard source format except that many fields which must begin in column 7 or beyond are at column 5. Commented Jan 28, 2017 at 21:16
  • I bet those formats should be I5 letter i, not fifteen. Commented Jan 29, 2017 at 0:34
  • Looking at the source images they are clearly numeral one's -- I suspect its an error in the book. I note also in the original there were a bunch of continued lines you elected to unwrap so you are likely past col 72. Commented Jan 29, 2017 at 1:09
  • those 1h edit descriptors look wrong (anybody make sense of that? some kind of non standard printer control? It doesn't make sense as hollerith). Try deleting the 1h, if its causing a compile error. Commented Jan 29, 2017 at 1:24
  • 1h requires something of length 1 behind the h, so either a space (common) or two commas. Commented Jan 30, 2017 at 20:38

2 Answers 2

5

There are a few issues, including several examples of transcription errors when preparing the printed text (which should scare you):

  • As others have said, the code is (approximately) fixed form. Compilers generally require a file extension of .f or .for to identify a file as fixed form source. Various columns in fixed form have particular meaning - you will need to make sure that your transcription (and their transcription!) lines things up correctly. Significantly, statements should begin in column seven (and finish at or before column 72), numeric statement labels should be somewhere in columns 1 to 5. A non-blank/non-zero character in column six is a continuation character - in the images of the original source there are a few of these (they use * as their continuation character, but the printed text often has it in the wrong column) in the format specifications, you may have already accounted for these with your translation (but check that your statements do not now exceed column 72!).

  • One of fixed source forms other quirks is that, outside of a character context, blanks in statements are not significant. This can create significant confusion, for code authors, code readers and code compilers. By the standard, the opening statement will actually be parsed by a conforming Fortran compiler as an misplaced assignment statement to a variable parameternn. That was probably meant to be a parameter statement - the syntax of which is parameter(nn=100). A similar statement appears in the subroutine. The syntax in the source may have been supported by whatever compiler they were using as an (inconsistent) extension to the language.

  • Because the source uses implicit typing, note that transcription errors in variable names can go undetected. You will also need to consider the possibility of these sorts of errors in any numeric literals. You will have to carefully inspect the source to see that it actually makes sense. Cases that I picked up include a format specification of 15 in the statement labelled 222, which probably should be I5, and a variable named 1P in a common block specification, the leading 1 shouldn't be there. Also, some of the format specifications use hollerith edit descriptors, in a way that doesn't make a lot of sense - I suspect a comma and a space have been swapped.

In many cases, you will need to reverse engineer the original author's intent.

Sign up to request clarification or add additional context in comments.

Comments

0

Non-numeric character in statement label at (1)that sounds like you don't formatted it correctly for fixed format, that means column 1 is reserved for the letter C - means the whole line is a comment or a number as a jump marker, column 6 is reserved for a marker in case of multiline code and column 7 till 72 is for actual code, see this link the a german wiki https://de.wikibooks.org/wiki/Fortran:_FORTRAN_77:_Programmaufbau

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.