40 minutes is a little tight but doable.
If you must be there on the booked flight from ATL-SAN, then I would take the earlier BOS-ATL flight.
If missing your connection and arriving a couple of hours late into SAN does not make a difference, then you can try the 40 minute connection.
Cheers