Fortran portability warning

George Corliss georgec at boris.mscs.mu.edu
Mon Jul 23 23:38:22 AEST 1990


Veteran Fortran hackers may already know this, but it was news to me.  To
retain absolute portability in your Fortran programs, avoind the backslash
character, even in literal fields.  There follows a little test program to
demonstrate.

George Corliss
Marquette University
georgec at boris.mscs.mu.edu

c  PORTABILITY WARNING
c  Author:  George Corliss, 22-JUL-1990
c  Purpose: Test Sun Fortran compiler handling of "\" character.
c  Conclusion:  The backslach "\" character is treated as a C-like 
c               escape character.  "\t" = <TAB>, "\n" = <RETURN>, etc.
c  AT&T 3B15 Unix system gave the same results as the Sun.
c  VAX VMS gave the (naively) expected results.

      write (6, 1010)
 1010 format (' \/\/\/\/\/')
c  Sun + AT&T output:  /////
c  Vax output       :  \/\/\/\/\/

      write (6, 1020)
 1020 format (' \\/\\/\\/\\/\\/')
c  Sun + AT&T output:  \/\/\/\/\/
c  Vax output       :  \\/\\/\\/\\/\\/

      write (6, 1030)
 1030 format (' \tGeorge\n Corliss')
c  Sun + AT&T output:         George
c                      Corliss
c  Vax output       :  \tGeorge\n Corliss

c1040 format (' \/\/\/\/\')
c     With this line, I get the compiler output:
c f77 testslash.f
c testslash.f:
c  MAIN:
c "testslash.f", line 9: Error: unbalanced quotes; closing quote supplied
c "testslash.f", line 9: Error: unbalanced parentheses, statement skipped
c "testslash.f", line 9: Error: unclassifiable statement

      stop
      end



More information about the Comp.sys.sun mailing list