Skip to content
Snippets Groups Projects
Commit e0151e2b authored by Olivier Sauter's avatar Olivier Sauter
Browse files

add function to recreate empty ids files automatically (to replace files in...

add function to recreate empty ids files automatically (to replace files in gdat...TCV_IMAS/ids_empty
parent 79172dc4
No related branches found
No related tags found
1 merge request!160add function to recreate empty ids files automatically (to replace files in...
Pipeline #203876 passed
function [empty_dir_out,ids_empty_structures,okflags] = idses_empty_to_mfile(dirname_for_files,varargin)
%
% [empty_dir_out,ids_empty_structures,okflags] = idses_empty_to_mfile(dirname_for_files,varargin);
%
% dirname_for_files: folder to save files, if not provided or empty, use /tmp/$USER/idses_empty_to_mfile
%
% generate empty ids structures and save them with writestruct_to_mfile as ascii .m files defining the structures
% Add json output when ready
%
% varargin{1}: option for outputs: 1 (default) to mfiles, 2 to mfiles and json files, 3 to json files
%
if nargin < 1 || isempty(dirname_for_files) || ~exist(dirname_for_files,'dir')
dirname_for_files = sprintf('/tmp/%s/idses_empty_to_mfile',getenv('USER'));
unix(['rm -rf ' dirname_for_files]);
unix(['mkdir -p ' dirname_for_files]);
warning('no folder provided, files will be written to: %s\n',dirname_for_files);
end
empty_dir_out = dirname_for_files;
write_option = 1;
if nargin>=2 && ~isempty(varargin{1})
write_option = varargin{1};
end
ids_list_to_generate = IDS_list;
imas_version = getenv('IMAS_VERSION');
n_prec = 15; % for 1e40 and -1e9+1
provenance_text = sprintf('writestruct_to_mfile with n=%d, with ids_gen to generate empty IDS within IMAS version %s',n_prec,imas_version);
for i=1:length(ids_list_to_generate)
ids_empty_structures.(ids_list_to_generate{i}) = ids_gen(ids_list_to_generate{i});
okflags(i) = writestruct_to_mfile(ids_empty_structures.(ids_list_to_generate{i}), ...
fullfile(dirname_for_files,['ids_empty_',ids_list_to_generate{i},'.m']),n_prec,provenance_text);
end
if any(okflags~=1)
warning('some flags not ok')
end
% save ids_structures_IMAS326.mat ids_structures ids_list_to_generate ids_list_all
% then use ids_structures_mat_to_m to save all the structures as ids_empty_xx.m files
% [empty_dir_out] = ids_structures_mat_to_m('/tmp/sautero/ids_structures_IMAS331.mat','/tmp/sautero/ids_empty')
%
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment