The GRASS program r.in.ascii can be used to perform the reverse function, converting an ASCII file in suitable format to GRASS raster map format.
To write a SURFER .grd ASCII GRID file (with reverted row order and different header) use the -s flag:
r.out.ascii -s input=inname output=outname.grd [dp=value]
To write a LISFLOOD .dem ASCII GRID file (with different header) use the -l flag:
r.out.ascii -l input=inname output=outname.dem
ncols 1514 nrows 2747 xllcorner 212236 yllcorner 2910116 cellsize 120 NODATA_value -9999
r.out.ascii input=soils output=- > out.file
To export the raster values as x,y,z values of cell centers (one per line) use the r.out.xyz module.
Surfer support by Markus Neteler