MATLAB和SPICE工具包和PARFOR

46次观看(最近30天)
Leos Pohl
Leos Pohl 2021年6月9日
Edited: 三井 在17 Dec 2021
我在用 NASA's SPICE toolkit MICE 对于Matlab。相关代码是
addpath(path_to_spice_src);
addpath(path_to_spice_lib);
cspice_furnsh('spice.ker');
tmutc ='2004 jun 15 9:32:00';
tmet = cspice_str2et(tmutc);
tend = tmet + 30*24*3600;
T_V = TMET:100:TERD;
sun_pos = zeros(length(t_v),3);
为了i = 1:长度(t_v)
sun_pos_tmp = zeros(1,3);
% ask SPICE where the sun is
时间= t_v(i);
%这是问题发生的地方
[r,〜] = cspice_spkpos('太阳',,,,time,'moon_me',,,,'LT+S',,,,'MOON');
[〜,lon,lat] = cspice_reclat(r);
sun_pos_tmp(1)=时间;
sun_pos_tmp(2)= rad2deg(lon);
sun_pos_tmp(3)= rad2deg(lat);
sun_pos(i,:) = sun_pos_tmp;
结尾
When I run it like this all works. As usual, when i switch to parfor, i get into trouble:
Error使用cspice_spkpos(第874行)
Errorusing mice
香料(未知框):[spkpos_c-> spkpos-> spkezp]参考框架子系统未识别请求的输出框架“ moon_me”。请检查是否已加载适当的内核,并正确输入输出框架的名称。
我想这与MATLAB无能为工人提供变量有关,我无法真正更改Spice Toolkit或它的设计方式。有没有办法,我可以与Spice Toolkit一起使用Parfor?
I hava provided the necessary kernels including the 'spice.ker' file here

答案(2)

三井
三井 在17 Dec 2021
Edited:三井 在17 Dec 2021
When using SPICE libraries, I run the cspice_furnsh function for each parallel thread before 将使用它们的PARFOR循环:
% Initialize SPICE in each worker
c = parcluster('当地的');%构建“本地”群集对象
numWorkers = c.NumWorkers;
parfori = 1:numWorkers
%添加路径并提供内核
结尾
% Run N computations that use SPICE functions and kernels in parallel
parfori = 1:n
% ...
结尾
I first get the number of workers because I run this on different machines with different amount of workers available, but e.g. parfori = 1:8 如果您总是要使用8名工人,则可以正常工作。

Edric Ellis
Edric Ellis 2021年6月11日
我对香料一无所知,但可以猜测,您可能需要在工人身上初始化香料。我会尝试添加
获取图(parfevalOnAll(@()cspice_furnsh('spice.ker'),0);
在尝试之前 parfor loop. (You technically aren't requesting any outputs from your Parfevalonall 打电话,但是 获取图 will throw an error if something goes wrong...)
3条评论
Leos Pohl
Leos Pohl 2021年6月11日
我正在使用本地游泳池。

登录发表评论。

标签

下载188bet金宝搏


Release

R2018b

社区寻宝

在Matlab Central中找到宝藏,发现社区如何为您提供帮助!

Start Hunting!