c - Swiss Ephemeris 程序 swetest - Windows 和 Ubuntu 中的不同输出

标签 c windows ubuntu-18.04

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

最近,我尝试将我的应用程序迁移到 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版本中生成的经度值不同。差异不大,但仍然显着。特别是对于上升点。

实际编译可以看this URL

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

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

最佳答案

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

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

演示如何完成此操作的示例 Colab 笔记本是 shared here .

关于c - Swiss Ephemeris 程序 swetest - Windows 和 Ubuntu 中的不同输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57230312/

相关文章:

自定义 strcpy 函数不返回预期的指针

python - 如何在 Windows 命令行中覆盖/打印当前行?

python - Ubuntu 18.04 中的 PIP 问题 (pkg_resources.DistributionNotFound : The 'pip==10.0.1' distribution was not found and is required by the application)

python - Ubuntu18.04(Virtualbox) 上滑动背景的问题

c - OSX 上 C OpenGL 程序的基本框架

c - C语言方形障碍数值模拟中如何使高斯包移动

c++ - 使用 clang API 编译程序

windows - 将路径列表转换为文件名列表

windows - 任何我不应该在我的Visual C++程序中添加GUID验证的原因?

ubuntu - Artifactory + 18.04 artifactoryManage.sh 不创建 PID 文件