CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Automate execution of command line (https://www.cfd-online.com/Forums/openfoam-programming-development/99524-automate-execution-command-line.html)

wyldckat August 7, 2012 08:16

Greetings to all!

@samiam1000: The first line shouldn't have quotes:
Code:

#!/bin/bash
There is a major flaw in your current script: "foamJob -p" will launch and run in the background automatically, leading the rest of the script to executed immediately after foamJob is executed. A quick fix would be to run with "foamJob -s -p".

By what I can understand, it's not foamJob that needs nohup, it's the call to this script that needs this! For example, if you call this script "runcase.sh", you'll need to:
  1. The script should be something like this:
    Code:

    #!/bin/bash

    foamJob -s -p buoyantPimpleFoam

    reconstructPar

    cd ../1DegNew/

    mapFields -consistent ../1DegStartNew -sourceTime 100

    decomposePar

    buoyantPimpleDyMFoam_MS

    sed -i 's/1/2/' system/controlDict

    buoyantPimpleDyMFoam_MS

    sed -i 's/2/3/' system/controlDict

    buoyantPimpleDyMFoam_MS

    sed -i 's/3/4/' system/controlDict

    buoyantPimpleDyMFoam_MS

    sed -i 's/4/5/' system/controlDict

    buoyantPimpleDyMFoam_MS

    sed -i 's/5/6/' system/controlDict

  2. After you edit and save the script for the first time, make sure it is an executable script:
    Code:

    chmod a+x runcase.sh
  3. Then for running the script:
    Code:

    nohup ./runcase.sh
Last but not least, why aren't you following the examples shown in the tutorials? For example, see "incompressible/simpleFoam/turbineSiting/Allrun". The downside of this example is that it will only run in the machine where it is launched...


Best regards,
Bruno

gschaider August 7, 2012 08:21

Quote:

Originally Posted by samiam1000 (Post 375808)
If I understood well, I can write a launch.sh file like this:

Code:

'#!/bin/bash'

nohup foamJob -p buoyantPimpleFoam;

reconstructPar;

cd ../1DegNew/;

mapFields -consistent ../1DegStartNew -sourceTime 100;

decomposePar;

buoyantPimpleDyMFoam_MS;

sed -i 's/1/2/' system/controlDict;

buoyantPimpleDyMFoam_MS;

sed -i 's/2/3/' system/controlDict;

buoyantPimpleDyMFoam_MS;

sed -i 's/3/4/' system/controlDict;

buoyantPimpleDyMFoam_MS;

sed -i 's/4/5/' system/controlDict;

buoyantPimpleDyMFoam_MS;

sed -i 's/5/6/' system/controlDict;

Is that correct?

Thanks a lot,
Samuele

No. I was answering the mpirun-issue. I don't use foamJob so I can't comment on your script


All times are GMT -4. The time now is 18:01.