This is from the 1945 Naval Regulations.
The Navy of the United States shall be governed by the following articles (R. S. sec. 1624):
CONDUCT AND MORALS IN GENERAL.
1.
Commander's duties of example and correction.
The commanders of all fleets, squadrons, naval stations, and vessels belonging to the Navy, are required to show in themselves a good example of virtue, honor, patriotism, and subordination; to be vigilant in inspecting the conduct of all persons who are placed under their command; to guard against and suppress all dissolute and immoral practices, and to correct, according to the laws and regulations of the Navy, all persons who are guilty
--3--
of them; and any such commander who offends against this article shall be punished as a court-martial may direct. (R. S. sec. 1624, art. 1.)
2.
Divine service.
The commanders of vessels and naval stations to which chaplains are attached shall cause divine service to be performed on Sunday, whenever the weather and other circumstances allow it to be done; and it is earnestly recommended to all officers, seamen, and others in the naval service diligently to attend at every performance of the worship of Almighty God. (R. S. sec. 1624, art. 2.)
3.
Irreverent behavior.
Any irreverent or unbecoming behavior during divine service shall be punished as a court-martial may direct. (R. S. sec. 1624, art 3; February 16, 1909, ch. 131, secs. 1, 2, 35 Stat. 621.)
Separation of church and state my sweet ass.