If I remember correctly, in Guns of August, the part about eastern front, the author mentions briefly something about Russians sending a message that German field mathematician had no trouble deciphering. How common it was to send mathematicians like this with an army? Had they any other duties than than deciphering enemy messages? Thanks.
You have a lot of Mathematicians and Physicists doing relevant work in WW1.
First thing, lets answer your question. From my reading, it's very rare that mathematicians would go with the army like this. While you have some anecdotal evidence of this happening, WW1 codebreaking, unlike WW2 was much more a linguistic practise, being carried out by Linguists, using some combinatorial and statistical techniques.
However, this does not mean that mathematicians and physicists didn't play a role in WW1. Instead of codebreaking however, most ended up being attached to Artillery regiments, or in aeronautics.
Artillery ones are the mathematicians that you would be most likely to hear about during WW1, if talking about the front line (many more mathematicians would be working in other developments at home, as well as things such as cartography) where they would be used to calculate trajectories.
Possibly the most well known of these would be the German physicist Karl Schwarzschild, who while working in Artillery (he achieved the rank of lieutenant) managed to provide the first exact solution to the Einstein field equations of general relativity, as well as wrote another paper on Max Planck's quantum theory, explaining that the Stark e ffect, namely the splitting of the spectral lines of hydrogen by an electric fi eld (the amount being proportional to the field strength), could be proved from the postulates of quantum theory.
His role in the Artillery meant he was in charge of of a weather station and of computing ballistic trajectories, which are both major roles in what a mathematician would have had in WW1. He however, died in 1916 due to an auto immune disease.
There are many other mathematicians with similar roles, including Otto Neugebauer, who was a leading historian of Ancient mathematics and astronomy. He served as an artillery lieutenant on the Italian front, before eventually being captured. After the war he founded mathematical review journals Zentralblatt fur Mathematik und ihre Grenzgebiete and the Mathematical Reviews.
This source is an extremely good read if you want to go into more detail with WW1 mathematics.
http://hal.archives-ouvertes.fr/docs/00/83/01/21/PDF/00_Aubin-Goldstein.pdf