Cleaning wet carpeting indoors is not a good idea in summer because it adds even more moisture to an already wet area. If the carpeting is installed with track strips, it can be removed, cleaned and reinstalled. If a large area of the padding is saturated, it will be impossible to clean and dry it thoroughly, so it should be removed and replaced.
The subfloor should be checked for moisture as well. If rainwater soaked from the top, it may not have soaked the subfloor. The type of subfloor under the carpet and the length of time it is wet will determine whether it will need to be replaced.
If the subfloor is plywood, the wet carpet and padding should be removed and the subfloor allowed to dry completely before reinstalling. If the subfloor is particleboard, it will swell and disintegrate when it gets wet and stays wet for a few days. Thus, it will need to be replaced.
Carpets that are glued to the floor without a pad can be cleaned in place if the damage is from clean water. Use a shop water vacuum, (if there is electricity) and dry blankets and towels to blot up extra moisture.
Use oscillating fans and the air conditioner to dry the carpet. This should be done within 24 hours of getting wet; otherwise mold and fungi can grow to numbers that present a health risk to you and your family. If the wet carpet cannot be treated within the 24 hours, then it is better to have professionals remove and replace it.
If only a small area of carpet got wet from a roof or pipe leak, pull up and prop the wet carpet to dry. Cut away the wet padding. To discourage mildew and odors, rinse the backing of the carpet with a solution of ¼ cup beach to 1 gallon of water. Brush lightly with a soft bristle brush so that the solution does not soak through and damage the carpet yarns on the other side. Do not use this solution on wool carpets. Use a solution of ¾ cup bleach to 1 gallon of water to disinfect the subfloor. To disinfect, the bleach solution must remain in contact with the surface for at least 10 minutes. Do not replace the padding and carpet until the subfloor is completely dry.