Changeset 483 for trunk/src/civ.m
- Timestamp:
- Jun 26, 2012, 11:50:19 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r482 r483 60 60 errormsg=[];%default error message 61 61 xmlfile='PARAM.xml'; 62 test_batch=0;%default: ,no batch mode available 63 sparam=[]; 62 64 if exist(xmlfile,'file') 63 65 try … … 66 68 catch ME 67 69 errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message}; 70 msgbox_uvmat('WARNING',errormsg); 68 71 end 69 72 else 70 errormsg=[xmlfile ' not found: path to civx binaries undefined']; 71 end 72 if ~isempty(errormsg) 73 msgbox_uvmat('WARNING',errormsg); 74 end 75 76 77 test_batch=0;%default: ,no batch mode available 73 %errormsg=[xmlfile ' not found: path to civx binaries undefined']; 74 [s,w]=system('oarstat'); 75 if ~isequal(s,0) 76 [s,w]=system('qstat'); 77 end 78 if isequal(s,0) 79 test_batch=1; 80 end 81 end 78 82 if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') 79 83 batch_mode=sparam.BatchParam.BatchMode; %sge is currently the only implemented batch mod … … 100 104 % set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) 101 105 end 102 if isfield(sparam.RunParam,'CivBin')103 if ~exist(sparam.RunParam.CivBin,'file')104 sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin);105 end106 else107 sparam.RunParam.CivBin='';108 end106 % if isfield(sparam.RunParam,'CivBin') 107 % if ~exist(sparam.RunParam.CivBin,'file') 108 % sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin); 109 % end 110 % else 111 % sparam.RunParam.CivBin=''; 112 % end 109 113 110 114 %% load the list of previously browsed files in the upper bar menu Open/ … … 888 892 drawnow 889 893 end 890 set(hrefresh,'UserData',option_civ) 891 filepath=fileparts(civ_files{1}); 894 StatusData.time_ref=now;% store the current time 895 StatusData.option_civ=option_civ; 896 set(hrefresh,'UserData',StatusData) 897 filepath=fileparts(civ_files{1}); 892 898 set(hlist,'UserData',fileparts(filepath)) 893 899 refresh_GUI(hrefresh,[]) … … 900 906 BarPosition=[0.05 0.81 0.01 0.05]; 901 907 hfig=get(hObject,'parent'); 908 StatusData=get(hObject,'UserData'); 902 909 civ_files=get(hfig,'UserData'); 903 904 905 906 option_civ= get(hObject,'UserData');910 [filepath,filename,ext]=fileparts(civ_files{1}); 911 [tild,SubDir,extdir]=fileparts(filepath); 912 SubDir=[SubDir extdir]; 913 option_civ=StatusData.option_civ; 907 914 nbfiles=numel(civ_files); 915 testrecent=0; 908 916 count=0; 909 testrecent=0; 910 % while count<nbfiles 911 count=0; 912 datnum=zeros(1,nbfiles); 913 for ifile=1:nbfiles 914 detect=exist(civ_files{ifile},'file'); % check the existence of the file 915 option=0; 916 if detect==0 917 option_str='not created'; 917 datnum=zeros(1,nbfiles); 918 filefound=cell(1,nbfiles); 919 for ifile=1:nbfiles 920 detect=exist(civ_files{ifile},'file'); % check the existence of the file 921 option=0; 922 if detect==0 923 option_str='not created'; 924 else 925 datfile=dir(civ_files{ifile}); 926 if isfield(datfile,'datenum') 927 datnum(ifile)=datfile.datenum;%only available in recent matlab versions 928 testrecent=1; 929 end 930 filefound(ifile)={datfile.name}; 931 932 % check the content netcdf file 933 Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix'); 934 option_list={'civ1','fix1','patch1','civ2','fix2','patch2'}; 935 if ~isempty(Data.CivStage) 936 option=Data.CivStage;%case of Matlab civ 918 937 else 919 datfile=dir(civ_files{ifile}); 920 if isfield(datfile,'datenum') 921 datnum(ifile)=datfile.datenum;%only available in recent matlab versions 922 testrecent=1; 923 end 924 filefound(ifile)={datfile.name}; 925 lastfield=''; 926 % check the content netcdf file 927 Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix'); 928 option_list={'civ1','fix1','patch1','civ2','fix2','patch2'}; 929 if ~isempty(Data.CivStage) 930 option=Data.CivStage;%case of Matlab civ 938 if ~isempty(Data.patch2) && isequal(Data.patch2,1) 939 option=6; 940 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 941 option=5; 942 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 943 option=4; 944 elseif ~isempty(Data.patch) && isequal(Data.patch,1); 945 option=3; 946 elseif ~isempty(Data.fix) && isequal(Data.fix,1); 947 option=2; 931 948 else 932 if ~isempty(Data.patch2) && isequal(Data.patch2,1)933 option=6;934 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)935 option=5;936 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);937 option=4;938 elseif ~isempty(Data.patch) && isequal(Data.patch,1);939 option=3;940 elseif ~isempty(Data.fix) && isequal(Data.fix,1);941 option=2;942 else943 option=1;944 end945 946 option_str=option_list{option}; 947 end 948 if option >= option_civ949 count=count+1;950 end951 [filepath,filename,ext]=fileparts(civ_files{ifile});952 Tabchar{ifile,1}=[fullfile(SubDir,filename) ext '...' option_str];953 end 949 option=1; 950 end 951 end 952 option_str=option_list{option}; 953 if datnum(ifile)<StatusData.time_ref 954 option_str=[option_str ' --OLD--']; 955 end 956 end 957 if option >= option_civ 958 count=count+1; 959 end 960 [filepath,filename,ext]=fileparts(civ_files{ifile}); 961 Tabchar{ifile,1}=[fullfile(SubDir,filename) ext '...' option_str]; 962 end 963 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 964 if isempty(datnum) 965 if testrecent 966 message='no civ result created yet'; 967 else 968 message=''; 969 end 970 else 954 971 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 955 if isempty(datnum) 956 if testrecent 957 message='no civ result created yet'; 958 else 959 message=''; 960 end 961 else 962 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 963 [first,ind]=min(datnum); 964 [last,indlast]=max(datnum); 965 % if test_new 966 % message='existing file status, no processing launched yet'; 967 % else 968 message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... 969 ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; 970 % end 971 end 972 %hfig=findobj(allchild(0),'name','civ_status'); 973 % if isempty(hfig)% the status list has been deleted 974 % return 975 % else 976 hlist=findobj(hfig,'tag','list'); 977 hmsgbox=findobj(hfig,'tag','msgbox'); 978 hwaitbar=findobj(hfig,'tag','waitbar'); 979 set(hlist,'String',Tabchar) 980 set(hmsgbox,'String', message) 981 if count>0 %&& ~test_new 982 BarPosition(3)=0.9*count/nbfiles; 983 set(hwaitbar,'Position',BarPosition) 984 end 985 % end 986 % [root,filename,ext]=fileparts(civ_files{1}); 987 % [rootroot,SubDir,extdir]=fileparts(root); 988 % 989 % set(hlist,'UserData',rootroot) 990 % if count<10||(nbfiles-count)<10 991 % pause(.5)% wait 0.5 seconds for next check 992 % else 993 % pause(10)% wait 10 seconds for next check 994 % end 995 % end 972 [first,ind]=min(datnum); 973 [last,indlast]=max(datnum); 974 message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... 975 ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; 976 end 977 hlist=findobj(hfig,'tag','list'); 978 hmsgbox=findobj(hfig,'tag','msgbox'); 979 hwaitbar=findobj(hfig,'tag','waitbar'); 980 set(hlist,'String',Tabchar) 981 set(hmsgbox,'String', message) 982 if count>0 %&& ~test_new 983 BarPosition(3)=0.9*count/nbfiles; 984 set(hwaitbar,'Position',BarPosition) 985 end 986 996 987 997 988 %------------------------------------------------------------------------ … … 1072 1063 path_civ=fileparts(which('civ')); %path to the source directory of uvmat 1073 1064 xmlfile='PARAM.xml'; 1065 s=[]; 1074 1066 if exist(xmlfile,'file')% search parameter xml file in the whole matlab path 1075 1067 t=xmltree(xmlfile); 1076 1068 s=convert(t); 1077 else 1078 errormsg=['no file ' xmlfile]; 1079 return 1080 end 1081 % test_interp=0; %eviter les variables test_ (LG) 1069 end% default configuration 1070 if ~isfield(s,'RunParam') 1071 s.RunParam.Civ1Bin='bin/civ1'; 1072 s.RunParam.Civ2Bin='bin/civ2'; 1073 s.RunParam.FixBin='bin/fix_flag'; 1074 s.RunParam.PatchBin='bin/patch_up'; 1075 s.RunParam.CivmBin='bin/civ_matlab'; 1076 end 1082 1077 if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster 1083 1078 if isfield(s,'BatchParam') … … 1091 1086 end 1092 1087 else 1093 errormsg='no batch civ binaries defined in PARAM.xml'; 1094 return 1088 %standard configuration 1089 Param.xml.Civ1Bin='bin/civ1'; 1090 Param.xml.Civ2Bin='bin/civ2'; 1091 Param.xml.FixBin='bin/fix_flag'; 1092 Param.xml.PatchBin='bin/patch_up'; 1093 s.RunParam.CivmBin='bin/civ_matlab'; 1094 Param.xml.BatchMode='oar';% TODO : allow choice for sge 1095 1095 end 1096 1096 else % run 1097 1097 if isfield(s,'RunParam') 1098 1098 Param.xml=s.RunParam; 1099 else 1100 errormsg='no run civ binaries defined in PARAM.xml'; 1101 return 1102 end 1103 end 1104 1099 else %standard default configuration 1100 s.RunParam.Civ1Bin='bin/civ1'; 1101 s.RunParam.Civ2Bin='bin/civ2'; 1102 s.RunParam.FixBin='bin/fix_flag'; 1103 s.RunParam.PatchBin='bin/patch_up'; 1104 s.RunParam.CivmBin='bin/civ_matlab'; 1105 end 1106 end 1105 1107 1106 1108 %% check if the binaries exist : to move in civ_opening
Note: See TracChangeset
for help on using the changeset viewer.