/u/restricteddata, who is a frequent poster here, had this to say in 2015: http://blog.nuclearsecrecy.com/2015/03/06/to-demonstrate-or-not-to-demonstrate.
Hopefully he stops by here with some more comments!
To add to the link from /u/a2soup, there's a pretty extensive section of our FAQ on the bombs and bomb targeting. Of particular interest to you may be these threads:
Did the US *have* to nuke Japan in WWII? by /u/restricteddata
Were the Japanese planning to surrender before the dropping of the atomic bombs? by /u/restricteddata
There has been some controversy on the true effect of the atomic bombing of Japan. Was it the bomb, or the Soviet declaration of war that ended WWII? by /u/t-o-k-u-m-e-i
Is it true that before the bombing of Hiroshima and Nagasaki the USA dropped leaflets on the cities to warn the citizens? by /u/restricteddata
During the decision to create the atomic bomb, was there any thought of creating 'smart bombs' instead, to reduce civilian casualties? by /u/restricteddata
Did the atomic bombings in Japan indirectly prevent the deaths of more Japanese citizens than they killed? by u/restricteddata
The very short answer to your question is that the bombs were intended to be weapons of terror; they were intended to be used on cities and indeed some cities, including Hiroshima, were "reserved" from "normal" firebombing that was being used on Japanese cities to see the effect of the bombs; and that there was no warning issued to citizens of Hiroshima or Nagasaki before the bombings. (Nagasaki got warning leaflets the day after the bombing.)
They wouldn't have been able to test the effects on a populated area if they did that. Little Boy droped on Hiroshima 6th of August, used Uranium, while Fat Man droped on Nagasaki 9th of August, used Plutonium. Studies were later carried out to monitor the different affects on the populations.
It took nearly a week for Japan to take stock of the damage and announce their surrender. It wasn't until September 2 that an official agreement was signed.