Index: ../trunk-jpl/src/m/classes/clusters/discovery.m =================================================================== --- ../trunk-jpl/src/m/classes/clusters/discovery.m (revision 26994) +++ ../trunk-jpl/src/m/classes/clusters/discovery.m (revision 26995) @@ -35,16 +35,17 @@ function disp(cluster) % {{{ % display the object disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1))); - disp(sprintf(' name: %s',cluster.name)); + disp(sprintf(' name: %s',cluster.name)); disp(sprintf(' login: %s',cluster.login)); - disp(sprintf(' numnodes: %i',cluster.numnodes)); + disp(sprintf(' numnodes: %i',cluster.numnodes)); disp(sprintf(' cpuspernode: %i',cluster.cpuspernode)); + disp(sprintf(' time: %i hours',cluster.time)); + disp(sprintf(' memory: %i Gb',cluster.memory)); + disp(sprintf(' email: %s (notifications: BEGIN,END,FAIL)',cluster.email)); disp(sprintf(' port: %i',cluster.port)); - disp(sprintf(' codepath: %s',cluster.codepath)); + disp(sprintf(' codepath: %s',cluster.codepath)); disp(sprintf(' executionpath: %s',cluster.executionpath)); disp(sprintf(' interactive: %i',cluster.interactive)); - disp(sprintf(' time: %i hours',cluster.time)); - disp(sprintf(' memory: %i Gb',cluster.memory)); end %}}} function numprocs=nprocs(cluster) % {{{ @@ -90,7 +91,46 @@ end %}}} function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{ - error('not implemented yet'); + + if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end + if(isgprof), disp('gprof not supported by cluster, ignoring...'); end + + %write queuing script + fid=fopen([modelname '.queue'],'w'); + fprintf(fid,'#!/bin/bash\n'); + fprintf(fid,'#SBATCH --job-name=%s\n',modelname); + fprintf(fid,'#SBATCH -o %s.outlog \n',modelname); + fprintf(fid,'#SBATCH -e %s.errlog \n',modelname); + fprintf(fid,'#SBATCH --nodes=%i\n',cluster.numnodes); + fprintf(fid,'#SBATCH --ntasks-per-node=%i\n',cluster.cpuspernode); + fprintf(fid,'#SBATCH --time=%s\n',datestr(cluster.time/24,'HH:MM:SS')); %walltime is in HH:MM:SS format. cluster.time is in hour + fprintf(fid,'#SBATCH --mem=%iG\n',cluster.memory); + if ~isempty(cluster.email) + fprintf(fid,'#SBATCH --mail-type=%s\n',cluster.email); + end + fprintf(fid,'\n'); + fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); + fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n'); + fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname); + fprintf(fid,'mpirun -n %i %s/issm.exe %s %s %s\n',cluster.nprocs(), cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname); + if ~io_gather, %concatenate the output files: + fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname); + end + fclose(fid); + + %in interactive mode, create a run file, and errlog and outlog file + if cluster.interactive, + fid=fopen([modelname '.run'],'w'); + fprintf(fid,'mpirun -n %i %s/issm.exe %s %s %s\n',cluster.nprocs(), cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname); + if ~io_gather, %concatenate the output files: + fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname); + end + fclose(fid); + fid=fopen([modelname '.errlog'],'w'); + fclose(fid); + fid=fopen([modelname '.outlog'],'w'); + fclose(fid); + end end %}}} function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{