def topoheaderwrite (topoheader,outputfile,closefile=True):

    """
    topoheaderwrite(topoheader,outputfile) opens an ascii topography data file and writes the header
    using the dictionary "topoheader"

    The header is of the following form with columns containing the topoheader value and key respectively.

         int ncols
         int nrows
         float xll
         float yll
         float cellsize
         float nodata_value


    if closefile==True: the file is closed. Otherwise return the open file object.
    """

    fout=open(outputfile,'w')

    fout.write("%s %s\n" % (topoheader['ncols'],"ncols"))
    fout.write("%s %s\n" % (topoheader['nrows'],"nrows"))
    fout.write("%s %s\n" % (float(topoheader['xll']),"xll"))
    fout.write("%s %s\n" % (float(topoheader['yll']),"yll"))
    fout.write("%s %s\n" % (float(topoheader['cellsize']),"cellsize"))
    fout.write("%s %s\n" % (topoheader['nodata_value'],"nodata_value"))
    if closefile:
        fout.close()
    else:
       return fout
    #end headerwriter=========================================================================