Changeset 26744 for issm/trunk/src/m/classes/clusters/maui.m
- Timestamp:
- 12/22/21 10:39:44 (4 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 25837-25866,25868-25993,25995-26330,26332-26733,26736-26739,26741
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/classes/clusters/maui.m
r25836 r26744 1 %MAUI cl ass definition1 %MAUI cluster class definition 2 2 % 3 3 % Usage: … … 7 7 8 8 classdef maui 9 properties (SetAccess=public) 10 % {{{11 name = 'maui'12 login = '';13 numnodes = 1;14 cpuspernode = 8;15 port = 0;16 projectaccount = '';17 partition = 'nesi_research';18 codepath = '';19 executionpath = '';20 interactive = 0;21 time = 24*60;22 memory = 2;23 end24 %}}}25 methods26 function cluster=maui(varargin) % {{{9 properties (SetAccess=public) 10 % {{{ 11 name = 'maui' 12 login = ''; 13 numnodes = 1; 14 cpuspernode = 8; 15 port = 0; 16 projectaccount = ''; 17 partition = 'nesi_research'; 18 codepath = ''; 19 executionpath = ''; 20 interactive = 0; 21 time = 24*60; 22 memory = 2; 23 end 24 %}}} 25 methods 26 function cluster=maui(varargin) % {{{ 27 27 28 %initialize cluster using default settings if provided29 if (exist('maui_settings')==2), maui_settings; end28 %initialize cluster using default settings if provided 29 if (exist('maui_settings')==2), maui_settings; end 30 30 31 %use provided options to change fields32 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);33 end34 %}}}35 function disp(cluster) % {{{36 % display the object37 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));38 disp(sprintf(' name: %s',cluster.name));39 disp(sprintf(' login: %s',cluster.login));40 disp(sprintf(' port: %i',cluster.port));41 disp(sprintf(' numnodes: %i',cluster.numnodes));42 disp(sprintf(' cpuspernode: %i',cluster.cpuspernode));43 disp(sprintf(' np: %i',cluster.cpuspernode*cluster.numnodes));44 disp(sprintf(' projectaccount: %s',cluster.projectaccount));45 disp(sprintf(' partition: %s',cluster.partition));46 disp(sprintf(' codepath: %s',cluster.codepath));47 disp(sprintf(' executionpath: %s',cluster.executionpath));48 disp(sprintf(' interactive: %i',cluster.interactive));49 disp(sprintf(' time: %i',cluster.time));50 disp(sprintf(' memory: %i',cluster.memory));51 end52 %}}}53 function numprocs=np(cluster) % {{{54 %compute number of processors55 numprocs=cluster.numnodes*cluster.cpuspernode;56 end57 %}}}58 function md = checkconsistency(cluster,md,solution,analyses) % {{{31 %use provided options to change fields 32 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster); 33 end 34 %}}} 35 function disp(cluster) % {{{ 36 % display the object 37 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1))); 38 disp(sprintf(' name: %s',cluster.name)); 39 disp(sprintf(' login: %s',cluster.login)); 40 disp(sprintf(' numnodes: %i',cluster.numnodes)); 41 disp(sprintf(' cpuspernode: %i',cluster.cpuspernode)); 42 disp(sprintf(' np: %i',cluster.nprocs())); 43 disp(sprintf(' port: %i',cluster.port)); 44 disp(sprintf(' projectaccount: %s',cluster.projectaccount)); 45 disp(sprintf(' partition: %s',cluster.partition)); 46 disp(sprintf(' codepath: %s',cluster.codepath)); 47 disp(sprintf(' executionpath: %s',cluster.executionpath)); 48 disp(sprintf(' interactive: %i',cluster.interactive)); 49 disp(sprintf(' time: %i',cluster.time)); 50 disp(sprintf(' memory: %i',cluster.memory)); 51 end 52 %}}} 53 function numprocs=nprocs(cluster) % {{{ 54 %compute number of processors 55 numprocs=cluster.numnodes*cluster.cpuspernode; 56 end 57 %}}} 58 function md = checkconsistency(cluster,md,solution,analyses) % {{{ 59 59 60 available_partitions={'nesi_research'}61 partition_requirements_time=[24*60];62 partition_requirements_np=[80];60 available_partitions={'nesi_research'} 61 partition_requirements_time=[24*60]; 62 partition_requirements_np=[80]; 63 63 64 QueueRequirements(available_partitions,partition_requirements_time,partition_requirements_np,cluster.partition,cluster.np,1)64 QueueRequirements(available_partitions,partition_requirements_time,partition_requirements_np,cluster.partition,cluster.nprocs(),1) 65 65 66 %Miscelaneous67 if isempty(cluster.login), md = checkmessage(md,'login empty'); end68 if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end69 if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end70 end71 %}}}72 function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{73 error('not implemented yet');74 end75 %}}}76 function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{66 %Miscellaneous 67 if isempty(cluster.login), md = checkmessage(md,'login empty'); end 68 if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end 69 if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end 70 end 71 %}}} 72 function BuildKrigingQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{ 73 error('not implemented yet'); 74 end 75 %}}} 76 function BuildQueueScript(cluster,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling) % {{{ 77 77 78 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end79 if(isgprof), disp('gprof not supported by cluster, ignoring...'); end78 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end 79 if(isgprof), disp('gprof not supported by cluster, ignoring...'); end 80 80 81 %write queuing script82 fid=fopen([modelname '.queue'],'w');83 fprintf(fid,'#!/bin/bash\n');84 fprintf(fid,'#SBATCH --job-name=%s\n',modelname);85 fprintf(fid,'#SBATCH --account=%s \n',cluster.projectaccount);86 fprintf(fid,'#SBATCH --partition=%s \n',cluster.partition);87 fprintf(fid,'#SBATCH --ntasks=%i \n',cluster.numnodes);88 fprintf(fid,'#SBATCH --cpus-per-task=%i\n',cluster.cpuspernode);89 fprintf(fid,'#SBATCH --time=%i\n',cluster.time); %walltime is in minutes90 fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory);91 fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);92 fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname);93 fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME94 fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n'); %FIXME95 fprintf(fid,'module swap PrgEnv-cray PrgEnv-intel\n');96 fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);97 fprintf(fid,'srun -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);98 if ~io_gather, %concatenate the output files:99 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);100 end101 fclose(fid);81 %write queuing script 82 fid=fopen([modelname '.queue'],'w'); 83 fprintf(fid,'#!/bin/bash\n'); 84 fprintf(fid,'#SBATCH --job-name=%s\n',modelname); 85 fprintf(fid,'#SBATCH --account=%s \n',cluster.projectaccount); 86 fprintf(fid,'#SBATCH --partition=%s \n',cluster.partition); 87 fprintf(fid,'#SBATCH --ntasks=%i \n',cluster.numnodes); 88 fprintf(fid,'#SBATCH --cpus-per-task=%i\n',cluster.cpuspernode); 89 fprintf(fid,'#SBATCH --time=%i\n',cluster.time); %walltime is in minutes 90 fprintf(fid,'#SBATCH --mem-per-cpu=%igb\n',cluster.memory); 91 fprintf(fid,'#SBATCH -o %s.outlog \n',modelname); 92 fprintf(fid,'#SBATCH -e %s.errlog \n\n',modelname); 93 fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME 94 fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n'); %FIXME 95 fprintf(fid,'module swap PrgEnv-cray PrgEnv-intel\n'); 96 fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname); 97 fprintf(fid,'srun -n %i %s/issm.exe %s %s %s\n',cluster.nprocs(),cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname); 98 if ~io_gather, %concatenate the output files: 99 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname); 100 end 101 fclose(fid); 102 102 103 %in interactive mode, create a run file, and errlog and outlog file104 if cluster.interactive,105 fid=fopen([modelname '.run'],'w');106 fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname);107 if ~io_gather, %concatenate the output files:108 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);109 end110 fclose(fid);111 fid=fopen([modelname '.errlog'],'w');112 fclose(fid);113 fid=fopen([modelname '.outlog'],'w');114 fclose(fid);115 end116 end %}}}117 function UploadQueueJob(cluster,modelname,dirname,filelist)% {{{103 %in interactive mode, create a run file, and errlog and outlog file 104 if cluster.interactive, 105 fid=fopen([modelname '.run'],'w'); 106 fprintf(fid,'mpiexec -n %i %s/issm.exe %s %s %s\n',cluster.nprocs(),cluster.codepath,solution,[cluster.executionpath '/' dirname],modelname); 107 if ~io_gather, %concatenate the output files: 108 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname); 109 end 110 fclose(fid); 111 fid=fopen([modelname '.errlog'],'w'); 112 fclose(fid); 113 fid=fopen([modelname '.outlog'],'w'); 114 fclose(fid); 115 end 116 end %}}} 117 function UploadQueueJob(cluster,modelname,dirname,filelist) % {{{ 118 118 119 %compress the files into one zip.120 compressstring=['tar -zcf ' dirname '.tar.gz '];121 for i=1:numel(filelist),122 compressstring = [compressstring ' ' filelist{i}];123 end124 if cluster.interactive,125 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];126 end127 system(compressstring);119 %compress the files into one zip. 120 compressstring=['tar -zcf ' dirname '.tar.gz ']; 121 for i=1:numel(filelist), 122 compressstring = [compressstring ' ' filelist{i}]; 123 end 124 if cluster.interactive, 125 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog ']; 126 end 127 system(compressstring); 128 128 129 disp('uploading input file and queueing script');130 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});129 disp('uploading input file and queueing script'); 130 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']}); 131 131 132 end %}}}133 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{132 end %}}} 133 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch) % {{{ 134 134 135 disp('launching solution sequence on remote cluster');136 if ~isempty(restart)137 launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue '];138 else139 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...140 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && hostname && sbatch ' modelname '.queue '];141 end142 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);143 end %}}}144 function Download(cluster,dirname,filelist)% {{{135 disp('launching solution sequence on remote cluster'); 136 if ~isempty(restart) 137 launchcommand=['cd ' cluster.executionpath ' && cd ' dirname ' && hostname && sbatch ' modelname '.queue ']; 138 else 139 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ... 140 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz && hostname && sbatch ' modelname '.queue ']; 141 end 142 issmssh(cluster.name,cluster.login,cluster.port,launchcommand); 143 end %}}} 144 function Download(cluster,dirname,filelist) % {{{ 145 145 146 %copy files from cluster to current directory147 directory=[cluster.executionpath '/' dirname '/'];148 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);146 %copy files from cluster to current directory 147 directory=[cluster.executionpath '/' dirname '/']; 148 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist); 149 149 150 end %}}}150 end %}}} 151 151 end 152 152 end
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/trac/issm/chrome/common/trac_banner.png)