def share_file(comm, path):
localrank, _ = get_local_rank_size(comm)<EOL>if comm.Get_rank() == <NUM_LIT:0>:<EOL><INDENT>with open(path, '<STR_LIT:rb>') as fh:<EOL><INDENT>data = fh.read()<EOL><DEDENT>comm.bcast(data)<EOL><DEDENT>else:<EOL><INDENT>data = comm.bcast(None)<EOL>if localrank == <NUM_LIT:0>:<EOL><INDENT>os.makedirs(os.path.dirname(path), exist_ok=True)<EOL>with open(path, '<STR_LIT:wb>') as fh:<EOL><INDENT>fh.write(data)<EOL><DEDENT><DEDENT><DEDENT>comm.Barrier()<EOL>
Copies the file from rank 0 to all other ranks
Puts it in the same place on all machines