CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   copy cache file to each processor (

newOFuser August 6, 2012 16:54

copy cache file to each processor

I have to copy a data file, that each processor would require, into the respective constant directories of the processors.

Is there a simpler way to do this, than to manually do "cp constant/cachefile processor(n)/constant" for each of the N processors whenever I try to run a case.

Maybe a script that I can write just once, and use whenever a case is run?

Any help is appreciated.


wyldckat August 7, 2012 05:50

Hi newOFuser,

This command line will copy the file "file_name" as you asked:

for a in processor*; do cp constant/file_name $a/constant/file_name; done
The way I see it, you have 3 options:
  1. You can create an alias command for this line. For example, add this line to "~/.bashrc":

    alias copy_constant_file='for a in processor*; do cp constant/file_name $a/constant/file_name; done'
  2. You can create a script and place it somewhere visible, namely in OpenFOAM's "bin" folder or on your home folder "~/bin".
  3. Or the best option, which gives you a better implied documentation method: use the same types of scripts as Allrun and Allclean that OpenFOAM's tutorials use! See for example the ones in "incompressible/simpleFoam/motorBike/".
Best regards,

newOFuser August 7, 2012 17:06


Option 3 works like a charm! ;)

All times are GMT -4. The time now is 08:53.