.
+
+
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/README b/README
deleted file mode 100644
index 7e61e78..0000000
--- a/README
+++ /dev/null
@@ -1,6 +0,0 @@
-
-miniseed2dmc - send specific Mini-SEED to the IRIS DMC
-
-See miniseed2dmc(1) for more details.
-
-Chad Trabant, IRIS Data Management Center
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c764c81
--- /dev/null
+++ b/README.md
@@ -0,0 +1,29 @@
+# miniseed2dmc - send Mini-SEED to a Data Managment Center
+
+This program transfers selected Mini-SEED data records from the localxi
+computer to a remote Data Managment Center. Prior to using this program
+coordination with DMC is required.
+
+To track the Mini-SEED data transferred the program writes SYNC files
+representing the data coverage. Additionally, a state file is maintained
+to track the progress of data transfer. This tracking means that the client
+can be shut down and then resume the transfer when the client is restarted.
+More importantly it allows the client to determine when all records from
+a given data set have been transferred preventing them from being transferred
+again erroneously.
+
+For usage infromation see the [miniseed2dmc manual](doc/miniseed2dmc.md) in the
+'doc' directory.
+
+## Building
+
+In most Unix/Linux environments a simple 'make' will build the program.
+
+The CC and CFLAGS environment variables can be used to configure
+the build parameters.
+
+## Licensing
+
+GNU LGPL version 3. See included LICENSE file for details.
+
+Copyright (c) 2017 Chad Trabant
diff --git a/doc/miniseed2dmc.md b/doc/miniseed2dmc.md
new file mode 100644
index 0000000..6414876
--- /dev/null
+++ b/doc/miniseed2dmc.md
@@ -0,0 +1,188 @@
+# miniseed2dmc
+### Transfer Mini-SEED data to a DMC
+
+1. [Name](#)
+1. [Synopsis](#synopsis)
+1. [Description](#description)
+1. [Options](#options)
+1. [Selection File](#selection-file)
+1. [Examples](#examples)
+1. [Notes](#notes)
+1. [Author](#author)
+
+## Synopsis
+
+
+miniseed2dmc [options] host:port files|directories ...
+
+
+## Description
+
+miniseed2dmc transfers selected Mini-SEED data records from the local computer to a remote Data Managment Center. Prior to using this program coordination with DMC is required and the user must have been assigned a host and port indicating where the data should be sent.
+
+Mini-SEED to be transfered can be identified 3 different ways:
+
+1 - files on the command line
+2 - directories on the command line which will be searched
+3 - files containing lists of files and/or directories
+
+
+If directories are specified on the command line or in list files all files they contain are assumed to be input files and all sub-directories will be searched (the level of recursion can be limited with the -r option).
+
+List files are identified by prefixing the file name with '@' on the command line or by using the -l option.
+
+A state file is maintained by miniseed2dmc to track the progress of data transfer. This tracking means that the client can be shut down and then resume the transfer when the client is restarted. More importantly it allows the client to determine when all records from a given data set have been transferred preventing them from being transferred again erroneously. By default the state file is written to a file named, creatively, 'statefile' in the working directory (see the -w option). The default state file location may be overridden using the -S option.
+
+To track the Mini-SEED data transferred miniseed2dmc writes SYNC files representing the data coverage. The SYNC files are written to the working directory (see the -w option). The SYNC file names contain the connection start and end times as a record of when the data was sent. A separate SYNC file listing is written for each time the program is executed.
+
+## Options
+
+-V
+
+Print the program version and exit.
+
+-h
+
+Print the program help/usage and exit.
+
+-v
+
+Be more verbose. This flag can be used multiple times ("-v -v" or "-vv") for more verbosity.
+
+-p
+
+Pretend, process input files as usual and write the state file and SYNC file but do not connect or send data to the submission server. Useful for client side testing, the transfer statistics will not be accurate. After running the program in this mode the state file (and probably the SYNC file) created must be removed prior to actually transferring the data.
+
+-r level
+
+Specify the maximum number of directories to recurse into, default is no limits.
+
+-fn
+
+Embed a relative path and filename in the data stream packets sent to the server, this information can be used by the remote server to re-create the local file names and organization.
+
+-E
+
+Exit the program on connection errors. By default miniseed2dmc will continuously try to connect to the specified server until all data has been sent.
+
+-q
+
+Be quiet, do not print the default diagnostic messages or transmission summary.
+
+-NS
+
+Do not write a SYNC file after sending data, by default a SYNC file representing the data set sent is written for each session. All SYNC files are written to the "work directory" (the -w option).
+
+-ACK
+
+Request and require acknowledgements from the server for each Mini-SEED record sent, this guarantees that each record sent was written to the filesystem by the remote server. This should not be necessary since TCP performs this function for the network layer, leaving only a very small potential that a server crash will lose data sent by the client. It will also significantly slow down the transfer rate.
+
+-mr maxrate
+
+Specify a maximum transmission rate in bits/second. The suffixes K, M and G are recognized for the maxrate value, e.g. '100M' is understood to be 100 megabits/second. The transmission rate is not limited by default.
+
+-I
+
+Print the transfer rate at a specified interval (the -It option) during transmission.
+
+-It interval
+
+Specify interval in seconds at which to print transfer rate statistics during transmission, default is 30 seconds. This option implies the -I option.
+
+-w workdir
+
+The working directory is where the (default) state file and SYNC listing will be written, default is the current working directory.
+
+-S statefile
+
+A state file is written to track the status of the transmission. It is recommended to use a unique state file for each separate data set. By default a file named "statefile" will be written to the workdir. If the specified value is not an absolute path it is relative to the current working directory (not workdir).
+
+-l listfile
+
+The listfile is a file containing a list of files and/or directories containing Mini-SEED to be sent. This is an alternative to prefixing an input file with the '@' which identifies it as a list file.
+
+-s selectfile
+
+Limit processing to Mini-SEED records that match a selection in the specified file. The selection file contains parameters to match the network, station, location, channel, quality and time range for input records. As a special case, specifying "-" will result in selection lines being read from stdin. For more details see the \fBSELECTION FILE\fR section below.
+
+host:port
+
+The required host and port arguments specify the server where the Mini-SEED records should be sent.
+
+## Selection File
+
+A selection file is used to match input data records based on network, station, location and channel information. Optionally a quality and time range may also be specified for more refined selection. The non-time fields may use the '*' wildcard to match multiple characters and the '?' wildcard to match single characters. Character sets may also be used, for example '[ENZ]' will match either E, N or Z. After a '#' character is read the remaining portion of the line will be ignored.
+
+Example selection file entires (the first four fields are required)
+
+#net sta loc chan qual start end
+IU ANMO * BH?
+II * * * Q
+IU COLA 00 LH[ENZ] R
+IU COLA 00 LHZ * 2008,100,10,00,00 2008,100,10,30,00
+
+
+## Examples
+
+For the below examples the host and port are specified as host:port, in real usage these must be a real host name and port.
+
+Example 1
+
+The most simple example is sending a couple of files containing Mini-SEED:
+
+
+> miniseed2dmc host:port 080101.mseed 080102.mseed
+
+
+In this case the state file and SYNC files will be written to the current directory.
+
+Example 2
+
+If there is a directory called 'data' that contains only files of Mini-SEED they can all be sent using:
+
+
+> miniseed2dmc host:port data
+
+
+The program automatically distinguishes between files and directories.
+
+Example 3
+
+A list file named 'mseeds.txt' contains:
+
+---- mseeds.txt
+/data/080101.mseed
+/data/080102.mseed
+----
+
+
+This file can be used with miniseed2dmc using the follow sytax (both are equivalent):
+
+
+> miniseed2dmc host:port @mseeds.txt
+> miniseed2dmc host:port -l mseeds.txt
+
+
+Example 4
+
+A recommended organization of data is to have a directory for each data set and keep all the Mini-SEED files in a sub-directory. For example, a monthly data set can be kept in /archive/Jan2008/ with all the January 2008 Mini-SEED files kept in /archive/Jan2008/data/. miniseed2dmc could then we executed in the following manner:
+
+
+> miniseed2dmc host:port -w /archive/Jan2008/ /archive/Jan2008/data/
+
+
+This will result in all the Mini-SEED data in /archive/Jan2008/data/ being transferred and the related state and SYNC file(s) being written to /archive/Jan2008/.
+
+## Notes
+
+This program is intended to transfer static data sets, it is not designed for transfer of real-time streaming data.
+
+## Author
+
+
+Chad Trabant
+IRIS Data Management Center
+
+
+
+(man page 2017/01/17)