2017-08-17 17 views
1

標準のioから読み込む必要がある並列プログラムを実行する必要があります。 slurm sbatchでファイルをどのように渡すことができますか?私は-inputコマンドを試しましたが、動作しませんでした。ここに私のsbatchスクリプトがslurm sbatch標準IOリダイレクト

#!/bin/sh 

    #SBATCH -p main 
    #SBATCH --nodes=1 
    #SBATCH --ntasks=1 
    #SBATCH --time 0-23:59:59 
    #SBATCH --reservation=VR0188 
    #SBATCH --input /vlsci/VR****/phillis/input.txt 


    # Run info and srun job launch 

    echo 'start work--------------------' 

    srun helloworld 

であり、ここで私のテストコードは次のとおりです。

#include <stdio.h> 
    #include <omp.h> 

    main(int argc, char *argv[]) { 

    int nthreads, tid; 

    #pragma omp parallel private(tid) 
     { 
     /* Obtain and print thread id */ 
     tid = omp_get_thread_num(); 
     printf("Hello World from thread = %d\n", tid); 

     } /* All threads join master thread and terminate */ 

     int a; 
     scanf("%d", &a); 
     printf("file input read as %d\n",a); 
    } 

このプログラムが正常に送信して実行することができますが、scanf関数の結果は常にある:

 file input read as 0 
+0

あなたは 'srun helloworld Gilles

答えて

0

sbatchの--inputオプションは、あなたのプログラムのものではなく、提出スクリプトを置いて標準にファイルを転送します。あなたは、アクションの3つのコースがあります。

  1. 移動srunコールに--input引数:srun --input /vlsci/VR****/phillis/input.txt helloworld

  2. 転送srunのそれに提出スクリプトの標準入力、順番にhelloworldに転送されます:cat | srun helloworld

  3. は、明示的に--inputパラメータと使用のリダイレクトを無視:srun helloworld < /vlsci/VR****/phillis/input.txt

+0

私はそれらのすべてを試しましたが、同じエラー結果を得ました: "slurmstepd:error:execve():helloworld:許可が拒否されました" –

+0

これは気にしません。 scanfを並列ブロックの外側に置くだけでよい。どうもありがとうございました! –

関連する問題