首页 > 解决方案 > Swiss Ephemeris program swetest - Windows 和 Ubuntu 中的不同输出

问题描述

我一直在使用与 Swiss Ephemeris 软件捆绑在一起的 SWETEST 程序来计算各种行星的经度位置。到目前为止,我一直在使用 Windows10,并且获得了与流行的商业软件相当的价值。

最近,我尝试将我的应用程序迁移到 Ubuntu(特别是 Google Colab 附带的 Ubuntu VM),第一个挑战是,与 Windows 不同,该站点上没有可用的 Linux 可执行文件。他们提供 C 代码和 Makefile 来编译它们。

我使用 Colab gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0 上可用的 gcc 和 Make 文件来编译文件。有一些警告,但程序按预期编译和执行。

问题是在 Windows 版本中生成的经度值与在 Ubuntu 版本中生成的经度值不同。差别不大,但还是很显着的。尤其是对于上升者。

实际编译可以在这个网址看到

有没有办法解决这个问题,如果有,我从哪里开始?

make 命令的输出如下所示

cc   -c -g -Wall -fPIC         swetest.c     
swetest.c: In function ‘main’:
swetest.c:1377:9: warning: format not a string literal and no format arguments [-Wformat-security]
  printf(stimeout);
         ^~~~~~~~
swetest.c:1712:4: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
    if (hpos_meth == 1)
    ^~
swetest.c:1714:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
      if (ipl == SE_FIXSTAR)
      ^~
swetest.c:1833:12: warning: format not a string literal and no format arguments [-Wformat-security]
     printf(smod);
            ^~~~
swetest.c: In function ‘print_line’:
swetest.c:2017:32: warning: format not a string literal and no format arguments [-Wformat-security]
         if (is_label) { printf(slon); break; }
                                ^~~~
swetest.c:2026:32: warning: format not a string literal and no format arguments [-Wformat-security]
         if (is_label) { printf(slon); break; }
                                ^~~~
swetest.c:2046:32: warning: format not a string literal and no format arguments [-Wformat-security]
         if (is_label) { printf(slon); break; }
                                ^~~~
cc   -c -g -Wall -fPIC         swedate.c     
cc   -c -g -Wall -fPIC         swehouse.c     
cc   -c -g -Wall -fPIC         swejpl.c     
cc   -c -g -Wall -fPIC         swemmoon.c     
cc   -c -g -Wall -fPIC         swemplan.c     
cc   -c -g -Wall -fPIC         swepcalc.c     
cc   -c -g -Wall -fPIC         sweph.c     
cc   -c -g -Wall -fPIC         swepdate.c     
cc   -c -g -Wall -fPIC         swephlib.c     
swephlib.c: In function ‘swe_get_astro_models’:
swephlib.c:4271:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (imod == SEMOD_PREC_DEFAULT) imod = 0; break;
  ^~
swephlib.c:4271:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  if (imod == SEMOD_PREC_DEFAULT) imod = 0; break;
                                            ^~~~~
swephlib.c:4273:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (imod == SEMOD_PREC_DEFAULT_SHORT) imod = 0; break;
  ^~
swephlib.c:4273:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  if (imod == SEMOD_PREC_DEFAULT_SHORT) imod = 0; break;
                                                  ^~~~~
swephlib.c:4275:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (imod == SEMOD_NUT_DEFAULT) imod = 0; break;
  ^~
swephlib.c:4275:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  if (imod == SEMOD_NUT_DEFAULT) imod = 0; break;
                                           ^~~~~
swephlib.c:4277:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (imod == SEMOD_SIDT_DEFAULT) imod = 0; break;
  ^~
swephlib.c:4277:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  if (imod == SEMOD_SIDT_DEFAULT) imod = 0; break;
                                            ^~~~~
swephlib.c:4279:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (imod == SEMOD_BIAS_DEFAULT) imod = 0; break;
  ^~
swephlib.c:4279:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  if (imod == SEMOD_BIAS_DEFAULT) imod = 0; break;
                                            ^~~~~
swephlib.c:4281:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (imod == SEMOD_JPLHOR_DEFAULT) imod = 0; break;
  ^~
swephlib.c:4281:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  if (imod == SEMOD_JPLHOR_DEFAULT) imod = 0; break;
                                              ^~~~~
swephlib.c:4283:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (imod == SEMOD_JPLHORA_DEFAULT) imod = 0; break;
  ^~
swephlib.c:4283:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  if (imod == SEMOD_JPLHORA_DEFAULT) imod = 0; break;
                                               ^~~~~
swephlib.c:4285:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (imod == SEMOD_DELTAT_DEFAULT) imod = 0; break;
  ^~
swephlib.c:4285:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  if (imod == SEMOD_DELTAT_DEFAULT) imod = 0; break;
                                              ^~~~~
cc   -c -g -Wall -fPIC         swecl.c     
swecl.c: In function ‘swe_rise_trans_true_hor’:
swecl.c:4444:11: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
           if (!do_fixstar)
           ^~
swecl.c:4447:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
      if (rsmi & SE_BIT_GEOCTR_NO_ECL_LAT)
      ^~
cc   -c -g -Wall -fPIC         swehel.c     
swehel.c: In function ‘calc_rise_and_set’:
swehel.c:478:1: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
 else
 ^~~~
swehel.c:484:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’
   iflag = epheflag|SEFLG_SPEED|SEFLG_EQUATORIAL;
   ^~~~~
ar r libswe.a   swedate.o swehouse.o swejpl.o swemmoon.o swemplan.o swepcalc.o sweph.o swepdate.o swephlib.o swecl.o swehel.o
ar: creating libswe.a
cc   -g -Wall -fPIC        -o swetest swetest.o -L. -lswe -lm -ldl

标签: cwindowsubuntu-18.04

解决方案


这个练习背后的动机——在 Ubuntu 中重新编译程序——是出于从 Windows 迁移到 Unix/Ubuntu 平台的需要或愿望,特别是在像 Google Colab 这样的托管 VM 环境中。现在通过完全不同的途径实现了相同的目标。

存在一个名为pyswisseph的 Python 包,如果安装它,您可以直接调用必要的相关函数以获得相同的结果。此处共享了

演示如何完成此操作的示例 Colab 笔记本。


推荐阅读