def write_shadow_surface(s, xx, yy, outFile='presurface.dat'):
    """
      write_shadowSurface: writes a mesh in the SHADOW/presurface format
      SYNTAX: 
           out = write_shadowSurface(z,x,y,outFile=outFile)
      INPUTS:
           z - 2D array of heights
           x - 1D array of spatial coordinates along mirror width.
           y - 1D array of spatial coordinates along mirror length.
     
      OUTPUTS:
           out - 1=Success, 0=Failure
           outFile - output file in SHADOW format. If undefined, the
                     file is names "presurface.dat"
     
    """
    out = 1
    try:
        fs = open(outFile, 'w')
    except IOError:
        out = 0
        print("Error: can't open file: " + outFile)
        return
    else:
        fs.write(repr(xx.size) + ' ' + repr(yy.size) + ' \n')
        for i in range(yy.size):
            fs.write(' ' + repr(yy[i]))
        fs.write('\n')
        for i in range(xx.size):
            tmps = ''
            for j in range(yy.size):
                tmps = tmps + '  ' + repr(s[j, i])
            fs.write(' ' + repr(xx[i]) + ' ' + tmps)
            fs.write('\n')
        fs.close()
        print('write_shadow_surface: File for SHADOW ' + outFile +
            ' written to disk.')
