Skip to main content
Research Highlight | Mathematics and Computer Science

Using generative AI for scientific coding

Insights from Argonne researchers on utilizing LLMs and AI for problem-solving and code development.

Coding often involves time-consuming and repetitive tasks. Researchers are interested in using large language models (LLMs) to save time on such work. But how hard is it to create effective prompts? Which LLMs work best? Can the results be trusted, or is human input still needed? Do LLMs actually improve productivity in software development? 

To answer these questions, Anshu Dubey and Akash Dhruv from the Mathematics and Computer Science division at the U.S. Department of Energy’s Argonne National Laboratory gave a webinar on July 9, 2025, titled Using Generative AI for Coding Tasks in Scientific Software.” They discussed two main use cases. 

Use Case 1: New Code 

In the first use case, the problem involved an astrophysics code in which particles and mesh exchange data to calculate density and forces. Simple methods such as reverse halo cell filling are easy to implement for uniform meshes but struggle with more complex ones. Dubey, a senior computational scientist, explained how she used an iterative approach with an LLM to generate a new communication algorithm that can replace reverse halo-fill in complex meshes. 

Prompts need to be clear, and that means thinking carefully about code design,” Dubey said. But debugging a prompt is easier than debugging the generated code, and it improves logical thinking.” 

Use Case 2: Code Translation 

The second use case involved code translation. The task was to translate a Monte Carlo simulation code used in hadron colliders from Fortran into GPU-compatible C++.   

Our first try at translating simple code snippets was successful — the syntax was correct,” said Dhruv, an assistant computational scientist. But we needed more than just correct syntax.” 

The researchers tried different strategies: writing prompts that described conversion rules,  providing small examples, then letting the LLM generate correct code and complete the full translation with the original source code.  

Takeaways 

So, how well did the LLMs perform? Here are four key takeaways: 

  • LLMs, combined with scripts and human input, can help with tedious tasks.

  • Among the four LLMs tested, GPT 4.0 performed best in reducing review and testing time (see Fig. 1). 

  • LLMs aren’t reliable enough to work on their own yet.  

  • LLMs still struggle with refactoring — improving the code’s internal structure without changing the external behavior or functionality. 

This webinar was part of the series HPC Best Practices Webinars. Watch the recording

Argonne National Laboratory seeks solutions to pressing national problems in science and technology by conducting leading-edge basic and applied research in virtually every scientific discipline. Argonne is managed by UChicago Argonne, LLC for the U.S. Department of Energy’s Office of Science.

The U.S. Department of Energy’s Office of Science is the single largest supporter of basic research in the physical sciences in the United States and is working to address some of the most pressing challenges of our time. For more information, visit https://​ener​gy​.gov/​s​c​ience.