A MacGyver-style astronaut shows his survival skills on the Red Planet in Ridley Scott’s adaptation of Andy Weir’s bestseller. As one would expect of Scott, it’s a technically masterful film. More surprisingly coming from the director of “Alien,” it’s upbeat and dramatically subdued, and will leave viewers in good spirits rather than traumatized. Let’s just say it’s characteristically handsome but uncharacteristically warm-hearted for a Scott film.

Much of the film’s winning character comes from Matt Damon, who stars as Mark Watney, part of the crew on the first manned mission to Mars captained by Melissa Lewis (Jessica Chastain). A ferocious storm comes up unexpectedly during a scientific expedition to the planet’s surface, and Watney is swept away, impaled by an antenna. An intense search after the winds subside fails to find his body and he’s presumed to be dead, so Lewis and the rest of the crew—Rick Martinez (Michael Pena), Beth Johanssen (Kate Mara), Chris Beck (Sebastian Stan) and Alex Vogel (Aksel Hennie)—are persuaded to blast off for the long journey back to earth.

Of course, Mark has survived. He struggles back to the now-deserted base camp, patches his wound (in the scene most likely to cause viewers to avert their eyes) and methodically begins to assess his situation, which is grave. The next mission isn’t planned for another four years, and even with strict rationing he has only enough food to last a quarter of that time. So he has to innovate. A botanist, he undertakes to grow potatoes from his store of them in a most inhospitable environment, lacking both water and fertilizer. Naturally he’ll succeed, using highly unconventional means that he explains in good-natured tones in a video diary he begins filming from his first day and continues throughout his long ordeal, which is filled with small triumphs and major setbacks.

Though his death has been commemorated solemnly back on earth, the fact that he’s still alive becomes evident to the NASA team headed by Teddy Sanders (Jeff Daniels), Vincent Kapoor (Chiwetel Ejiofor) and Mitch Henderson (Sean Bean)—with press aide Annie Montrose (Kristen Wiig) trying to control the news—after glimpses of motion on the Mars surface are picked up by agency’s batteries of cameras. As they establish communication with him—a clever bit involving a discarded rover from a past mission—they begin plotting a rescue attempt, though the time element—as well as the cost—makes the odds against success very high. Happily aeronautics expert Rich Purnell (Donald Glover) comes up with a dangerous scheme that just might work but would require Mark’s fellow crewmen to lose more years going back for him. Even then, however, problems repeatedly crop up on both Mars and earth, and only intervention from an unexpected source—a rival to the US in space—gives the mission an even remote chance. (A few years ago, Russia would have been the likeliest candidate, but in the current international environment a different country must be chosen—one that should certainly appeal to a huge audience of potential viewers.)

In the end, “The Martian” stages a rescue attempt that entails self-sacrifice and split-second timing while the entire human race, it appears, waits with bated breath for news of whether it goes as hoped. As has been the case all along, you might occasionally blanch at accepting the scientific explanations provided—thankfully for the most part in layman’s terms—for what happens onscreen, even though the film has been acclaimed by experts as representing the most realistic and credible depiction of space travel yet put on screen. And Scott never manages to achieve the sheer sense of mystery and grandeur that marked Kubrick’s “2001” and even Alfonso Cuaron’s “Gravity.” But the final sequence is certainly exciting, and it maintains the essential humaneness of the film to the very end.

Depth of characterization isn’t the strong suit here, but Damon brings a loose, ingratiating quality to Watney that makes one immediately empathize with his plight, which is what the role demands. Everyone else in the large ensemble does what’s expected of them with professionalism; Daniels is perhaps the most notable as a man who has to make administrative decisions about what’s practical in the face of pressure from colleagues to do everything, regardless of cost, but Pena is most successful in giving the film a shot of humor to complement Damon’s jocular asides.

But the real stars of “The Martian,” apart from Damon, are the effects, which are beautifully and naturalistically rendered by a small army of craftsmen supervised by Richard Stammers and Barrie Hemsley. Arthur Max’s production design, Marc Homes’ art direction, Celia Bobak’s sets and Janty Yates’ costumes are all first-rate as well, and Dariusz Wolski’s lustrous cinematography mixes everything seamlessly together in gorgeous widescreen images, while Pietro Scalia’s unrushed editing and Harry Gregson-Williams comparatively gentle score add to the film’s ruminative qualities.

Ridley Scott’s career has, like that of most directors, had its share of ups and downs. Particularly after the frantic excesses of “The Counselor” and the silliness of “Exodus: Gods and Kings,” it’s nice to see him return to his best form with a film that, despite its largely extraterrestrial setting, has a very human center.