GAMIT/GLOBK软件安装及各类报错解决方案

原博客链接:https://www.astrophel.top

软件介绍

GAMIT/GLOBK是由麻省理工学院、哈佛-史密森天体物理中心(CfA)、斯克里普斯海洋研究所(SIO)和澳大利亚国立大学开发的一个综合GNSS分析包,用于估计台站坐标和速度、地震后变形的随机或函数表示、大气延迟、卫星轨道和地球定向参数。

作为一款开源软件,GAMIT/GLOBK提供了多种系统的支持,包括常见Linux发行版和MacOS等。而对于Windows,则需要使用Linux子系统或虚拟机。

由于软件开发年代较为久远,历史包袱较重,在最新的MacOS Sonoma上安装未免存在诸多问题。本文将结合安装步骤及常见报错,介绍GAMIT/GLOBK软件的基础安装方法。

安装信息

  • 软件版本:GAMIT/GLOBK 10.71
  • 操作系统:MacOS Sonoma
  • gcc版本:Apple clang version 15.0.0 (clang-1500.1.0.2.5)
  • gefortran版本:GNU Fortran (Homebrew GCC 13.2.0) 13.2.0

安装过程及问题解决

开始之前,首先应获取GAMIT/GLOBK软件源码包,GAMIT/GLOBK源码不区分系统,仅在编译时略有不同。

相关依赖包安装

GAMIT/GLOBK官网提供了快速入门指南,可以查阅所有支持系统所需的依赖文件和基本安装步骤。

对于MacOS,需要安装的依赖有:

  • Command Line Tools for Xcode
  • XQuartz
  • gfortran

以上依赖快速入门指南中均有官网提供的安装命令/dmg安装包,在此不再赘述。

P.S. 某些教程可能建议使用旧版本gfortran以避免后续报错,但arm架构的Mac存在版本兼容问题,不建议尝试。报错问题可在下文找到解决方法。

创建安装位置

在适当的目录新建文件夹,将GAMIT/GLOBK软件源码包拷贝入该文件夹,文件结构如下图所示:
在这里插入图片描述

开始安装

打开终端,切换至该目录,为install_software.sh赋予执行权限并执行编译操作:

cd ./gamit10.71
chmod +x install_software
sudo ./install_software

此时,输入y确认,脚本自动执行解压缩操作,将所有文件解压,随后询问是否要查找XQuartz相关依赖包安装位置——此时,可以选择查找(y)或不查找(n),无论选择何种选项均不会影响后续安装,安装脚本也会自动退出。

脚本退出后,来到./gamit10.71/libraries/Makefile.config文件夹下,找到约77行位置,将默认路径X11LIBPATHX11INCPATH注释掉,在下方一系列路径中找到本机系统,Mac选择约90行处的Specific for Mac OS X and macOS,解除下面两行路径的注释,如下所示:

# Specific for Mac OS X and macOS
X11LIBPATH /usr/X11/lib
X11INCPATH /usr/X11/include

按照官方教程,此时可以回到终端,执行

sudo ./install_software

继续安装。如果此前依赖包使用了旧版本gfortran和gcc,则此处可以按照官方文档进行。如果使用了新版编译器,则需继续修改Makefile编译文件,否则会出现如下错误:(不想看具体错误的可以跳至“额外修改”部分)

  1. 错误一:
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(2) / INTEGER (4)).
make: *** [com_lib. a (get_value.o)] Error
Failure in make_gamit -- install_ software terminated
  • 出现该错误的原因是:新版本gfortran已经淘汰了一些不安全的特性,
  • 解决方案:使用 gfortran 10 或更高版本时,取消注释 libraries/Makefile.config 和 gamit/solve/Makefile.generic 中“FFLAGS”的定义,并在后方加入-fallow-argument-mismatch
  • 原理分析:FFLAGS是编译文件中预留的选项更改变量,可以通过改变该变量为Fortran语言编译过程设置参数。
  1. 错误二:
gfortran: error: unrecognized command-line option '-fast'; did you mean '-Ofast'?

gfortran: error: unrecognized command-line option '-Mnobackslash'; did you mean '-fno-backslash'?

gfortran: error: unrecognized command-line option '-Msave'
make: *** [com_lib.a(sd_compbd.o)] Error 1

Failure in make_gamit -- install_software terminated

该原因较为奇怪,猜测原因是官方提供的Makefile中存在语法错误,该错误仅在Mac系统安装时会出现。如果大家知道真实原因欢迎分享。

  • 解决方法:来到libraries/Makefile.config约364行,找到Mac编译设置,将FFLAGS修改为:
FFLAGS = -O3 -Wuninitialized -fno-f2c -ffast-math -fno-automatic -fno-backslash -m64 -fallow-argument-mismatch
  • 原理分析:gfortran不存在参数-fast-Mnobackslash-Msave,修改后的为标准用法。
  1. 错误三:
getdir _gftn.c:77:8: error: call to undeclared function 'fnmatch'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if ((fnmatch(wild, direntp->d_name, 0)) = 0) {
  • 出现该错误的原因是:使用了隐式声明,而新版本gcc编译器已不再支持。简单来说就是C语言调用函数时未声明头文件
  • 解决方案:在libraries/Makefile.config找到CFLAGS,并添加-Wno-implicit-function-declaration忽略隐式声明报错。(或更加安全的方式:为所有报错的文件添加所需头文件,不建议)
  1. 错误四:
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
make: *** [solve_lib.a(covbln.o)] Error 1
Failure in make_gamit -- install_software terminated
  • 出现该错误的原因是:新版本gfortran已经淘汰了一些不安全的特性,
  • 解决方案:使用 gfortran 10 或更高版本时,取消注释 libraries/Makefile.config 和 gamit/solve/Makefile.generic 中“FFLAGS”的定义,并在后方加入-fallow-argument-mismatch
  1. 错误五:
    使用 Ubuntu 系统编译时提示 x1000.h 头文件存在 multiple definition 重定义错误;
  • 原因:x1000.h 中定义了若干变量,编译生成.o 链接文件时多个代码文件均调用了该头文件,使得一个变量被定义多次。
  • 解决方案:为 x1000.h 头文件中报错的变量添加 Static 修饰,添加 Static 后作为全局变量,只会被编译一次,避免了重复定义错误。

额外修改

对于使用了新版编译器的MacOS计算机,为防止出现以上错误,需对libraries/Makefile.configgamit/solve/Makefile.generic两个文件进行以下修改:

来到libraries/Makefile.config文件约369行位置,将下面两个变量修改为:

CFLAGS = -g -m64 -Wno-implicit-function-declaration
FFLAGS = -O3 -Wuninitialized -fno-f2c -ffast-math -fno-automatic -fno-backslash -m64 -fallow-argument-mismatch

来到gamit/solve/Makefile.generic约第8行,修改变量为:

FFLAGS = -O3 -Wuninitialized -Wunused -fno-f2c -ffast-math -m64 -fallow-argument-mismatch #gftn  

修改完成后,回到终端,执行

sudo ./install_software

即可顺利完成安装。如出现其他报错(Error),可参考以上错误解决思路进行解决,绝大部分问题都是由于编译器版本的更迭所造成的。

环境变量设置

出现如下页面代表安装已完成:
在这里插入图片描述

输入y自动生成环境变量添加代码,复制后打开~/.zshrc粘贴复制的代码。(无该文件的自行创建即可,详细可参阅关于Mac环境变量的设置相关文章)

例:路径需修改为本机安装位置

PATH="/Users/[username]/gamit10.71/opt/gamit10.71/com:/Users/haoyuwu/gamit10.71/opt/gamit10.71/gamit/bin:/Users/haoyuwu/gamit10.71/opt/gamit10.71/kf/bin:$PATH"; export PATH
HELP_DIR="/Users/[username]/gamit10.71/opt/gamit10.71/help"; export HELP_DIR

全部操作完成后,新建终端窗口,输入doy,如正确输出,则安装成功。

Overview These tools are provided as a means to help users understand the quality of the results being obtained from GLOBK analyses of GPS data. Their primary aim is to improve the quality and understanding of the results from large GPS analysis projects. Installation The latest tsview/velview mfiles are saved in GGMatlab_mfiles.tar. When running from MATLAB this verion of the m-files should be downloaded. The m-files are in a folder called matlab and in this folder are folders for tsview and velview. To run the velview and tsview programs you should download the Matlab® mfiles for either x86_64 (GGMatlab_x86_64.tar) or for Intel Mac OSX (GGMatlab_maci.tar). These tar files are identical except that each tar file contains the executable program for their respective systems (see details below). The tar files contain directories for velview and tsview. If you have a license for Matlab you can go to the section Running under Matlab® after the files have been untarred. If you do not have a license for Matlab, you should download MCRInstaller.bin for x86_64 systems or MCRInstaller.dmg for Intel Max OSX (These files are each 300Mbytes). Once the appropriate file is downloaded, follow the instructions in the Running as standalone programs section after the tar files above have been untarred. The tar files contain directories for tsview and velview. The executaubles are in these directories along with the Matlab m-files. The tar files can be untarred in any convenient directory. For GAMIT/GLOBK users, the untarred directory can be put at the level of gamit, kf, and library directories. Also available is an example case saved as Example.tar. The examples below use the data in the Example directory. This directory can be placed anywhere in your system.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值