How to use string variables for geometry filenames in do loops?

13 views
Skip to first unread message

Joseph Van Forst

unread,
Sep 17, 2025, 7:01:11 AMSep 17
to molpro-user
I'm trying to process multiple geometry files in a loop using string variables, but I'm getting an error. Here's my input:

```
memory, 605,m; 
bohr !use bohr units globally 
numbs = ['geom1.xyz', 'geom2.xyz', 'geom3.xyz']
 do i =1,#numbs 
               geometry=numbs(i) 
               basis=sto-3g !
              {put,xyz,rt$n.xyz,new} 
end do
```
I'm getting the error:
```
File /appl/soft/molpro/molpro_2025.2/lib/include/numbs(i) does not exist Input error
```

The problem is that Molpro interprets numbs(i) literally as a filename "numbs(i)" rather than evaluating it as an array element containing the actual geometry filename (e.g., 'geom1.xyz').

I also tried using an intermediate variable:

```
n = numbs(i) 

geometry=n

```

This is also not working, 

I know about command-line variables (geometry=geom$n.xyz with molpro -V n=1), but I specifically want to handle multiple files within a single input file using a loop. Because I want to define all the geometry file names within the input file and launch it as a single job. 

Any help would be appreciated!


Reply all
Reply to author
Forward
0 new messages