Skip to content

callfemm.n not reading numeric data #1

@amaurigmartins

Description

@amaurigmartins

Hello. I've been using femm under Kubuntu with Wine, Matlab 2022 and your modifications to the solver calls. When I tried to perform a co_lineintegral() to extract results I was receiving the following output: '~/.wine/drive_c/femm42/bin/ofile.txt' and not the actual result.

After some debugging and a bit of trial and error, I modified the callfemm script to read as below, now it seems to be working well on extracting numeric data. Note the workaround at line 70 to properly read complex numbers.

% ActiveFEMM (C)2006 David Meeker, [email protected]

function z=callfemm(x)
global ifile ofile HandleToFEMM

isWindows = ispc;
isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0;

if (exist('actxserver') && isWindows)

    z=invoke(HandleToFEMM,'mlab2femm',x);
    if (length(z)~=0)
        if (z(1)=='e')
            error(sprintf('FEMM returns:\n%s',z));
        else
            z=strrep(z,'I','i');
            z=eval(z);
        end
    end
else
    % Form that I'd previously used in Octave:
    try
        [fid,msg]=fopen(ifile,'wt');
    catch
        [fid,msg]=fopen(ifile,'w');
    end
    fprintf(fid,'flput(%s)',x);
    fclose(fid);

    if (isOctave)
        do
        do
        try
            [fid,msg]=fopen(ofile,'rt');
        catch
            [fid,msg]=fopen(ofile,'r');
        end
        if (fid==-1) pause(0.001); end
        until (fid~=-1)
        u=fgets(fid);
        fclose(fid);
        until (u~=-1)
        z=eval(u);
    else
        u=-1; fid = -1;
        while (u ==-1)
            while (fid ==-1)
                try
                    [fid, msg]=fopen(ofile,'rt');
                catch
                    [fid, msg]=fopen(ofile,'r');
                end
                if (fid==-1)
                    pause(0.001);
                end
            end
            u=[];
            try
                u=fgetl(fid);
            end
            %             tline = fgetl(fid)
            fclose(fid);
        end
        z=(u);
    end
    pause(0.001);
    delete(ofile);
    u=strrep(u,'I*','1i*');
    try
        z=eval(u);
    catch
        z=u;
    end
    %     z=eval(u);

end 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions