Aim
I am using multiple text files to set variables and array variables. These are the input arguments to a MATLAB function, that iteratively creates url download strings based on these variables, and then downloads temperature data using MATLAB's websave function. Notably, the MATLAB script uses parfor to parallelise a for loop and spread it over 44 cores on a computing cluster. The MATLAB runs on my laptop, but extremely slowly, that's why I need to run it from the High Performance Cluster.
Issue
I am having issues in passing these variables set in the bash script, to the matlab function. And I am left on the MATLAB command line in the end. Note I have tried removing the single quotes from around the variables in the matlab function call, however I get the same error.
Script
cd CRW_Temp_Profiles
# Set Variables
IFS=$'\r\n' GLOBIGNORE='*' command eval 'LatArray=($(cat Lat.txt))'
IFS=$'\r\n' GLOBIGNORE='*' command eval 'LongArray=($(cat Long.txt))'
IFS=$'\r\n' GLOBIGNORE='*' command eval 'SitesArray=($(cat Sites.txt))'
Site=$(echo ${SitesArray[${SLURM_ARRAY_TASK_ID}-1]})
FileType=".csv"
# Check Variables were read properly
echo 'Site is Number '${Site}
echo 'Row-specific LatLons are:'
echo ' deg N = '${LatArray[${SLURM_ARRAY_TASK_ID}-1]}
echo ' deg S = '${LongArray[${SLURM_ARRAY_TASK_ID}-1]}
echo ' All Lats are'
echo ${LatArray[*]}
# run MATLAB function
module load MATLAB
matlab -nodisplay -nojvm -nodesktop -nosplash -r "try; f_Download_CRW_Temp('$LatArray', '$LongArray', "1985", "2019", '$Site', "44", ".csv"); end; quit;"
module purge
Output and Error Message
Site is Number 1
Row-specific LatLons are:
deg N = -16.5
deg S = 149.8
All Lats are
-16.5 -20 -19.5 -11.5 -23.5 -21.5 -31.5 ..... <100 entries of site latitudes> .... 11.2 11.2
< M A T L A B (R) >
Copyright 1984-2018 The MathWorks, Inc.
R2018b (9.5.0.944444) 64-bit (glnxa64)
August 28, 2018
For online documentation, see https://www.mathworks.com/support
For product information, visit www.mathworks.com.
try; f_Download_CRW_Temp('-16.5', '149.8', 1985, 2019, '1', 44, .csv); end; quit;
|
Error: Invalid use of operator.