Sign Control: S, SP and SS

Your compiler system may or may not print the optional sign of a positive number. If your compiler system does not print the optional plus sign, you can force it to print. On the other hand, if your compiler system does print a plus sign, you can also force the compiler not to print it. Note that whether a plus sign should be printed is not part of the ANSI Fortran 90 standard. A compiler vendor is allowed to make a choice. This choice is called the default setting of your system. Edit descriptors S, SP and SS are used to enforce or suppress the printing of the optional plus sign of a positive number. The forms of these descriptors are as follows:

S,   SP    and   SS

Example

Consider the following example. (Click here to download a copy of this program.) This program prints the values from -5 to 5. For each value, it is converted to a REAL. Each value will be printed with SP and SS to illustrate the result.
PROGRAM  SignControl
   IMPLICIT  NONE
   INTEGER   :: i
   REAL      :: x
   CHARACTER(LEN=*), PARAMETER :: Format  = "(1X,SS,I5,SP,I5,SS,F6.1,SP,F6.1)"
   CHARACTER(LEN=*), PARAMETER :: Heading = "   SS   SP    SS    SP"

   WRITE(*,"(1X,A)") Heading
   DO i = -5, 5
      x = REAL(i)
      WRITE(*,Format)  i, i, x, x
   END DO
END PROGRAM  SignControl
The following is the output. All positive numbers on the second and fourth columns are printed with plus signs since SP is used in the format. All positive numbers on the first and third columns are printed without plus signs because SS is used.
         1    1    2    2
....5....0....5....0....5
    SS   SP    SS    SP
    -5   -5  -5.0  -5.0
    -4   -4  -4.0  -4.0
    -3   -3  -3.0  -3.0
    -2   -2  -2.0  -2.0
    -1   -1  -1.0  -1.0
     0   +0   0.0  +0.0
     1   +1   1.0  +1.0
     2   +2   2.0  +2.0
     3   +3   3.0  +3.0
     4   +4   4.0  +4.0
     5   +5   5.0  +5.0