Running a CMD using fortran

Hi, is there a way to run a cmd using Fortran?
Hi guys,

I usually used a batch file to run to be executed in CMD. Right now, there are too many number of execution, and it’s just nice to print a line like “running (10/100).”

I can do this by just processing the batch file in Fortran and add a Echo line something like this, so that my batch file have a printing line:

i=1
do i=1,n
write "(file,format)", "cmd/c Echo running (",i,"/",n,")"
write "(file,format)", "cmd/c (my execution)"
end do

But it kind of not elegant because the line of “cmd/c Echo running (i/n)” stays on the cmd, and the next line is the line “running (i/n)”. Something like:

(Path) cmd/c Echo running 1/2
running 1/2

It would be nice if I can choose to not showing the “Echo” line, or run directly the CMD using Fortran.

Anyone has a similar experience?
Thanks for your help

You can use the subroutine execute_command_line for this. See for instance: EXECUTE_COMMAND_LINE - The GNU Fortran Compiler.

1 Like

thanks, it worked!!