Suppose there’s a female psychiatrist who works with inmates at a penitentiary for the criminally insane. Then suppose the doctor herself goes crazy. Do you suppose they’d put her in the same prison she worked at, so her former patients would now be her cellmates? In “Gothika,” they would.

It is set in New England, where perhaps there is not a wide selection of places to send insane, murderous females. At any rate, it is only one of many oddities about the story and characters contained within this salacious and trashy little thriller.

Halle Berry plays the doctor in question, a bright young shrink named Miranda Grey. She is married, inexplicably, to Charles S. Dutton as a hospital administrator, and both are friends with Robert Downey Jr. (who must have been thrilled to act in a film set in a prison) as another administrator whose interest in Miranda might run deeper than it ought to.

One night during a rainstorm, Miranda sees a woman standing in the middle of the road. Then the woman’s head lights on fire, which cannot be what she expected. Next thing Miranda knows, it’s three days later and she’s locked up for having killed her husband, an act she has no memory of.

Well. Quite a pickle, no? But wait, it gets worse. Miranda also begins to endure visitations by some kind of ghostly presence which seems to be giving her clues about something. Creepy things happen almost constantly, their eeriness intensified by the fact that the prison always seems to be dark, and it always seems to be raining outside.

Give Halle Berry credit for performing with gusto in such a by-the-numbers thriller, and I am utterly delighted with Penelope Cruz, who wins the Christopher Walken award for loopiest supporting performance. (“He came back again and tore me like paper,” she says while recalling a dream. “Ripped me like a flower of pain.” Later, she mentions someone’s Adam’s apple but pronounces it “autumn’s apple.” A good time is had by all.)

French writer/actor Mathieu Kassovitz, making his English directorial debut, gives the film a certain ominous feel, and the camera work of cinematographer Matthew Libatique (“Requiem for a Dream”) carries us through the prison as though we, too, were ghosts, floating through windows and walls carelessly.

In the end, the more lurid the explanations are, the more ludicrous they are, too. It’s silly stuff, but I suppose it’s fine as far as it goes.

C+ (1 hr., 35 min.; R, some profanity, some strong violence, a lot of blood, some partial nudity.)