%% Script to run multiple crayfish dispersal models (function: Crayfish_dispersal_v2.m) on a work cluster % Author: Dr Jim Kerr % Description: Sets up a cluster and assigns identical models to be run as % tasks on individual workers. Model input parameters are specified below % as amendments to the structure 'Param'. % Last modified: May 2020 clearvars close all %% Setup the cluster and the job cluster1 = parcluster; job = createJob(cluster1); %% Setup input parameter values Param.RunNumber='RunX'; % Model identifier/name Param.RiverLength=50000; % River length (m) Param.Startdate=150; % Julian day Param.ModelDuration=5; % Model duration in years Param.NoCray=100; % Number of crayfish at start of the model Param.MeanAgeCray=3; % Mean age (yrs) of crayfish at start of the model Param.StdAgeCray=0.3; % Standard deviation of age of crayfish at start of the model Param.MeanBreedingPeriod=274; % Mean breeding day (julian day)- Holdich et al. 2014 states breeding occurs late september to early October Param.RangeBreedingPeriod=15; % Breeding period range (+/- days)- Holdich et al. 2014 states breeding occurs late september to early October Param.SexuallyMatureLength=39; % Size (CL = mm) at which males and females are condsidered sexually mature (Guan and Wiles, 1999) Param.Gestation_Time=223; % Gestation time for crayfish - Holdich et al. 2014 states that the gestation time is between 166 and 280. Mean value used here. Param.StartPosition=25000;% Release location for the first crayfish - mid point of the test stretch Param.Plot=0; % Plot figure (1) or not (0) Param.Video=0; % Save a video (1) or not (0) Param.BarrierLoc=12500; % Barrier Location Param.Obstruct=0; % Input obstruction or not %% Create tasks for the job for i=1:4 t(i) = createTask(job,@Crayfish_dispersal_v2,4,{Param}); end %% Submit the job to be run on seperate clusters submit(job); stop % Required so that the job can complete before the rest of the code can be implemented %% Retrieve the results Results=getAllOutputArguments(job(1)); FrontUpLoc=vertcat(Results{:,1}); FrontDwnLoc=vertcat(Results{:,2}); DailyMeanBiomass=vertcat(Results{:,3}); Crayfish_Alive=vertcat(Results{:,4}); clear Results %% Save outputs save(strcat(Param.RunNumber,'.mat'),'Param','FrontDwnLoc','FrontUpLoc','DailyMeanBiomass','Crayfish_Alive') clearvars -except Param FrontDwnLoc FrontUpLoc DailyMeanBiomass Crayfish_Alive % cancel(t(1)) % delete(job) % delete('matlab_metadata.mat')