0

Forgive me if this is an easy one but I am a scientist and not much of a programming expert.

I have written some programs that I am running using a Batch file - I have 100+ versions of a similar program in different Folders. (Specifically this is Computational biology and each of These is an Independent cell Simulation).

I decided to do this with a simple command:

@echo off
for /D %%a in ("%cd%\cells\cell_*.*") do cd "%%a\sim1\" & START neuron sim.hoc

The idea I had was to navigate to each Directory and launch the program. This works with less than 32 different programs. Since this is automatically generated Code, I want to scale this arbitrarily, my current Project has 105 different simulations.

When more than 32 are opened, Windows gives me a "console device allocation failure: too many consoles" error (I can't read the specifics before the Windows are closed) and only a small fraction of my programs get executed.

Can someone help me find a way around this? I want to Keep it simple and avoid dealing with "proper" parallelism, since this way doesn't take too Long to run. On the flipside, having to manually only run Batches of 32 is time consuming and frustrating.

I am using Win10 64-bit with 16GB of RAM, if relevant.

  • Why do you need a console? I mean you can direct output to files instead of looking at the console. – Mark Setchell Dec 19 '19 at 12:21
  • 1
    I don't think this is a 'windows' error per-se. Are you running Cygwin by any chance? It has a limitation such as this reported in 2013. – Ben Personick Dec 19 '19 at 12:41
  • I looked into .hoc files, they are neuron coding, looks to fit the basic details of what you've written here. Since you are not using `CMD /C` you are not necessarily instantiating a new Windows console host, and just running `neurons.exe` multiple times, it may be this is a limitation of `neurons.exe`, or its when launched this way , creating multiple cxhild processes. trying to ensure you have separated processes instead of child processes using `CMD /C` may solve the issue, if you use `CMD /K` the outer cmd window will stick around when `neurons` closes and allow you to see results. – Ben Personick Dec 19 '19 at 12:51
  • Ah, it'll be cygwin that's causing the issue, neuron requires MinGW to operate. Thanks for pointing me in the right direction. – Nicholas Hananeia Dec 19 '19 at 14:46
  • [maybe helpful](https://stackoverflow.com/a/49551035/2152082) – Stephan Dec 19 '19 at 15:57
  • You can provide a working folder with `start`, so you don't need to `cd`: `... do START "%%a% /d "%%a\sim1\" neuron sim.hoc` – Stephan Dec 19 '19 at 15:59
  • @BenPersonick, you're misunderstanding the console system. Each console is hosted by an instance of conhost.exe and, in Windows 8+, communicates with its clients via the ConDrv console device. Any process that has no console can call `AllocConsole` or `AttachConsole`. If an executable is flagged as a console process, as neurons.exe apparently is, at process startup the system implicitly attaches the process to the console of its parent, if any, or allocates a new console. The creation flag `CREATE_NEW_CONSOLE` forces the latter, and CMD's `start` uses this flag unless its `/B` option is used. – Eryk Sun Dec 19 '19 at 20:33
  • @ErykSun okay so observed behavior and benefit of using `CMD /C` or `CMD /K` is correct, and so its a limitation of child processes to the parent conhost process, but not neurons.exe, if I follow. – Ben Personick Dec 19 '19 at 22:37
  • Right, I used CMD /k to get a good look at the error... It is in MinGW so the suspicions by Ben Personick were on point. The full error is "console device allocation failure - too many consoles in use, max consoles is 32". A quick workaround I can think of is getting the script to do it in 32-file chunks, but that's messy. – Nicholas Hananeia Dec 20 '19 at 10:41

0 Answers0