Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
Setting and passing string variable in SLURM job script

I have a SLURM job script as follows:

#!/bin/bash


#SBATCH -o ./out/%x.%j.%N.out
#SBATCH -e ./out/%x.%j.%N.err
#SBATCH -D ./
#SBATCH -J matlab_serial_batch_job
#SBATCH --nodes=1
#SBATCH --tasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0:30:00
 

module load slurm_setup
module load matlab/R2021a-generic
 

NROWA=1000
NCOLA=2000
NROWB=2000
NCOLB=5000
MYSTRING='blablabla'
 

# Run MATLAB
matlab -nodisplay -singleCompThread \
       -r "matmul_serial([$NROWA $NCOLA], [$NROWB $NCOLB], $MYSTRING);"

As you might see, I would like to set and pass a string variable called MYSTRING to the MATLAB function matmul_serial. However, I got the following error:

Unrecognized function or variable 'blablabla'

For those integer variables NROWA, NROWB, NCOLA and NCOLB, they work pretty fine. How do I properly set and pass the string variable MYSTRING in this context?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Actually, the single quotes will be striped by Bash during the assignment.

❯ MYSTRING='blablabla'
❯ echo $MYSTRING
blablabla

You can try to escape the quotes like this:

❯ MYSTRING=\'blablabla\'
❯ echo $MYSTRING
'blablabla'

Otherwise, Matlab wrongly believe blablabla is the name of a variable or a function and not a string literal. The error message is misleading though as it adds a single quote around blablabla. But those single quotes are not the ones that you inserted in the MYSTRING=... assignment, as shown here below in an interactive Matlab session.

$ matlab
MATLAB is selecting SOFTWARE OPENGL rendering.

                                                                            < M A T L A B (R) >
                                                                  Copyright 1984-2019 The MathWorks, Inc.
                                                                  R2019a (9.6.0.1072779) 64-bit (glnxa64)
                                                                               March 8, 2019


To get started, type doc.
For product information, visit www.mathworks.com.

>> blablabla
Undefined function or variable 'blablabla'.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda