Okay. You might want to remove your code, because I do not think that there is much that we can do to help you.

Beyond suggesting that you should use strict and -w, which would allow you to notice things like:

open (INPUTFILE, ">$inputfile"); ... close(INTPUTFILE);

And that you should be using lexical file handles within your subroutines. Being IO-bound code, there is not a lot that could be done to speed this up.

I assume from your explanation that most of the CPU bound stuff is going on inside the psi3, and that is outside your remit to tune. Previously, from your mention of PDL, I thought that you were doing the complex math. All that leaves is a little relatively simple, IO-bound code that will not benefit from threading or PDL.

Probably your best bet would be to look at Parallel::ForkManager and see if that fits with you aspirations. It would allow you to start your processes, whilst managing how many run concurrently. If you think that module fits the bill, and you need help on how to use it, I'd suggest posting a new question with that in the title, as I have no experience of it.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re^5: How to vectorize a subroutine--perhapse using PDL piddles or threads by BrowserUk
in thread How to vectorize a subroutine--perhapse using PDL piddles or threads by Feynman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.