📄 fm_pcode.m
字号:
copyfiles(psatfolder,[psatfolder,'archive',filesep,pcodedir,filesep],'*.*') % =============================================================================== pcodebar(10) pcodelist('2. creating p-code files') a = what; n = length(a(1).m); cd([psatfolder,'archive',filesep,pcodedir]) for i = 1:n pcode(a(1).m{i}) pcodebar(10+20*i/n) end % =============================================================================== pcodebar(32) pcodelist('3. removing old files ') archfolder = [psatfolder,'archive',filesep,pcodedir,filesep,'psat']; pcodebar(35) pcodelist(' --> create psat folders ') wipefolder([psatfolder,'archive',filesep,pcodedir],'psat') pcodebar(38) pcodelist(' --> create internal folders ') wipefolder(archfolder,'themes') wipefolder(archfolder,'build') wipefolder(archfolder,'tests') wipefolder(archfolder,'images') wipefolder(archfolder,'filters') wipefolder(archfolder,'gams') % =============================================================================== pcodebar(40) pcodelist('4. copying new files ') pcodebar(42) pcodelist(' --> copying m files ') files = {'Contents.m','fm_dynidx.m','fm_install.m','fm_var.m', ... 'pert.m','fm_base.m','fm_dynlf.m','fm_m2cdf.m', ... 'fm_xfirst.m','psat.m','fm_call.m','fm_inilf.m','fm_ncomp.m', ... 'pgrep.m','psed.m'}; for i = 1:length(files) [status,msg] = copyfile([psatfolder,'archive',filesep,pcodedir,filesep,files{i}], ... [psatfolder,'archive',filesep,pcodedir,filesep,'psat', ... filesep,files{i}]); if ~status, fm_disp(msg), end end pcodebar(45) pcodelist(' --> copying p files ') folder1 = [psatfolder,'archive',filesep,pcodedir,filesep]; folder2 = [psatfolder,'archive',filesep,pcodedir,filesep,'psat',filesep]; copyfiles(folder1,folder2,'*.p') copyfiles(folder1,folder2,'*.ini') copyfiles(folder1,folder2,'*.txt') copyfiles(folder1,folder2,'*.mat') copyfiles(folder1,folder2,'*.mdl') copyfiles(folder1,folder2,'*.gms') pcodebar(47) pcodelist(' --> removing superflous p files ') files = {'Contents.p','fm_dynidx.p','fm_install.p','fm_var.p', ... 'pert.p','fm_base.p','fm_dynlf.p','fm_m2cdf.p','fm_xfirst.p', ... 'psat.p','fm_call.p','fm_inilf.p','fm_ncomp.p','pgrep.p','psed.p'}; cd(folder2) for i = 1:length(files), delete(files{i}), end if exist('psatsol.p'), delete('psatsol.p'), end pcodelist('5. creating internal folders') pcodebar(50) pcodelist(' --> build ') copyfiles([psatfolder,'build',filesep],[archfolder,filesep,'build',filesep],'*.m') pcodebar(55) pcodelist(' --> themes ') copyfiles([psatfolder,'themes',filesep],[archfolder,filesep,'themes',filesep],'*.thm') copyfiles([psatfolder,'themes',filesep],[archfolder,filesep,'themes',filesep],'*.txt') pcodebar(60) pcodelist(' --> tests ') copyfiles([psatfolder,'tests',filesep],[archfolder,filesep,'tests',filesep],'*.mdl') pcodebar(65) pcodelist(' --> images ') copyfiles([psatfolder,'images',filesep],[archfolder,filesep,'images',filesep],'*.*') pcodebar(70) pcodelist(' --> gams ') copyfile([psatfolder,'gams',filesep,'matout.gms'],[archfolder,filesep,'gams',filesep,'matout.gms']) copyfile([psatfolder,'gams',filesep,'psatout.gms'],[archfolder,filesep,'gams',filesep,'psatout.gms']) copyfile([psatfolder,'gams',filesep,'gams.m'],[archfolder,filesep,'gams',filesep,'gams.gms']) pcodebar(73) pcodelist(' --> filters ') copyfiles([psatfolder,'filters',filesep],[archfolder,filesep,'filters',filesep],'*psat') copyfiles([psatfolder,'filters',filesep],[archfolder,filesep,'filters',filesep],'sim*') pcodebar(75) pcodelist('6. creating archive file ') cd([psatfolder,'archive',filesep,pcodedir]) pcodebar(80) if isunix pcodelist(' --> creating tarball') !tar cf psat-x.y.z.tar psat pcodebar(85) pcodelist(' --> g-zipping tar file ') !gzip -9 psat-x.y.z.tar end pcodelist(' --> creating zip file') !zip -r -9 -q psat-x.y.z.zip psat % =============================================================================== pcodebar(90) if isunix tarball = ['psat-pcode-',v1,'.',v2,'.',v3,'.M',Ver(1:3),'.tar.gz']; end zipball = ['psat-pcode-',v1,'.',v2,'.',v3,'.M',Ver(1:3),'.zip']; pcodelist('7. moving and renaming archive') if isunix % moving and saving the tarball a = dir([psatfolder,'archive/',tarball]); Settings.ok = 1; if ~isempty(a), Settings.ok = 0; uiwait(fm_choice(['Overwrite "',tarball,'"?'])) end if Settings.ok, pcodelist(' --> archive overwritten in ./psat/archive') [status,msg] = copyfile('psat-x.y.z.tar.gz',[psatfolder,'archive',filesep,tarball]); if ~status, fm_disp(msg), end else pcodelist(' --> archive stored in ./psat/archive/pcode') end end % moving and saving the zipball a = dir([psatfolder,'archive',filesep,zipball]); Settings.ok = 1; if ~isempty(a), Settings.ok = 0; uiwait(fm_choice(['Overwrite "',zipball,'"?'])) end if Settings.ok, pcodelist(' --> archive overwritten in ./psat/archive') [status,msg] = copyfile('psat-x.y.z.zip',[psatfolder,'archive',filesep,zipball]); if ~status, fm_disp(msg), end else pcodelist(' --> archive stored in ./psat/archive/pcode') end Settings.ok = 0; pcodebar(100) pcodelist('9. end of operations ') cd([psatfolder,'archive']) pcodelist(' ') pcodelist('===== a r c h i v e c o m p l e t e d ======') pcodelist(' ') pcodelist(' ') % =============================================================================== cd(d)end% =================================================================================function pcodebar(x)global Themexnew = x/100;p = get(gcf,'UserData');xold = p(4);if x >= 5, set(p(2), ... 'Position',[xold, 0.5, 0], ... 'String',[' ',num2str(round(xold*100)),'%']);endset(p(2), ... 'Position',[xnew, 0.5, 0], ... 'String',[' ',num2str(round(xnew*100)),'%']);set(p(1),'XData',[0, 0, xnew, xnew]);p(4) = xnew;set(gcf,'UserData',p);if x == 100, set(p(1),'FaceColor',Theme.color11), set(p(2), ... 'Position',[1e-3, 0.5, 0], ... 'String',' '); p(4) = 1e-3; set(p(1), ... 'XData',[0 0 1e-3 1e-3], ... 'FaceColor',Theme.color08), set(gcf,'UserData',p);enddrawnow% =================================================================================function pcodelist(string)p = get(gcf,'UserData');hlist = p(3);string_update = get(hlist,'String');string_update{end+1} = string;set(hlist, ... 'String',string_update, ... 'ListboxTop',max(1,length(string_update)-10));drawnow% =================================================================================function copyfiles(dir1,dir2,string)currentdir = pwd;cd(dir1)folder = dir(string);files = {folder.name};types = [folder.isdir];for i = 1:length(files) if ~types(i) [status,msg] = copyfile([dir1,files{i}],[dir2,files{i}]); if ~status, fm_disp(msg), end endendcd(currentdir)% =================================================================================function wipefolder(parent,folder)currentdir = pwd;cd(parent)existence = exist([parent,filesep,folder]);switch existencecase 7 delallfiles(folder)case 0 [status,msg] = mkdir(folder); if ~status, fm_disp(msg), endendcd(currentdir)% ===================================================================================function delallfiles(fold)currentdir = pwd;cd(fold)folder = dir('*.*');files = {folder.name};types = [folder.isdir];for i = 1:length(files) if ~types(i) & ~strcmp(files{i},'..') & ~strcmp(files{i},'..') delete(files{i}) endendcd(currentdir)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -