Ive used every single available lens for nikon in terms of macro on corals and fish.
Here is the list in my opinion.
1. Nikon 105
2. Sigma 150
3. Tamron 90
4. Sigma 100
There are others like the nikon 60, and tonika, etc...but not really user friendly for this application.
The Nikon 105, and the Sigma 150 are amazing, and will AF with the D40.
That Tamron rocks for the money though. Nothing can touch at that price point.
Canon users are lucky with a great canon lens at the same price point, but nikon users have to spend much much more for a genuine Nikkor lens.