Ubuntu 24.04 LTS 安装GAMIT
熟悉GAMIT的朋友应该都知道,在GAMIT官网有一则Known Issue:不要在Ubuntu 24.04上安装GAMIT
MIT的几位佬测试,换了多个版本的gcc/gfortran编译都不成功,报错:
bash
ar: creating libsofa.a
*** Now type 'make test' to install the library and run tests ***
cp libsofa.a ../../../../libsofa.a
Segmentation fault (core dumped)
Failure in make_gamit -- install_software terminated
哥们头铁,我就想在Ubuntu 24.04上装GAMIT,有没有办法呢?有的兄弟,有的。
错误定位
这个错误发生在make_gamit
这个脚本里,发生这个错误之前的操作就是用make编译了libsofa这个库。而我们可以发现,在对应目录下的命令行里执行这个命令屁事没有。
bash
make FC=gfortran
那么问题很明确了,就是这个版本的csh执行到这里内存管理出问题了...
卸载csh
ok,按照GAMIT作者的测试结论,Ubuntu 25.10并没有问题,那么我们自己编译一个最新版的csh替换掉就行了。在此之前,先把csh卸掉
bash
sudo apt purge csh tcsh -y
编译tcsh
首先从官网下载tcsh的源码,当前最新的是6.24.10
bash
wget http://ftp.funet.fi/pub/mirrors/ftp.astron.com/pub/tcsh/tcsh-6.24.10.tar.gz
然后利用configure生成makefile,以默认设置编译即可。
bash
./configure
make -j$(nproc)
sudo make install
编译好的tcsh放在/usr/local/bin
下,建立一个csh的链接
bash
sudo ln -s /usr/local/bin/tcsh /usr/bin/csh
测试一下,没啥问题,命令行只会显示一个>
bash
>
🆗
GAMIT配置修改
参考官网Known Issues中的建议,将libraries/Makefile.config
和gamit/solve/Makefile.generic
中的FFLAGS添加-fallow-argument-mismatch
GAMIT代码修改
由于GAMIT采用的C语言标准较老,kf/plot/
中调用了X11的部分出现了重定义的问题。因此,需要对头文件x1000.h
进行更改,把全局变量添加extern
c
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <stdio.h>
/* #include <math.h> */
#include "x1000.icon"
#define WINFRAC 2 /* x1k window fraction of largest window (1/WINFRAC)*/
#define MAXSTRLEN 256
/* maximum length of a label */
extern Display *display;
extern int screen;
extern GC gc;
extern XGCValues gcv;
extern XFontStruct *font_info;
extern XEvent report;
extern XSizeHints size_hints;
extern Window win;
extern Pixmap icon_pixmap ;
extern Pixmap clip_mask ;
extern XSetWindowAttributes setwinattr;
extern unsigned long valuemask;
/* Definitions for defining the plotting area and the size of this
area */
extern float xvl, xvr, xvb, xvt ;
/* Virtual corrdinates of the cornors of the
area for plot (left, right, bottom, top */
extern float xwl, xwr, xwb, xwt;
/* World coordinates of the cornors of the
virtual area */
extern int Window_width; /* current width of window in pixels */
extern int Window_height; /* current height of window in pixels */
extern int curr_charsize[2]; /* current character size for actual font used
width and height (pixels) */
extern int usr_charsize ; /* User character size in pixels */
extern int Curx; /* current x coord of cursor (viewport scale) */
extern int Cury; /* current y coord of cursor (viewport scale) */
/* Current font style and info */
extern float jcenter; /* Defines the centering to be used 0-1
for left through right justification */
extern float jheight; /* Justification in height for strings
(0-1.0 for bottom to top justifcation */
extern int jor_tan; /* Defines orientation of baseline of the text
strings given as tan of angle */
extern int jzse; /* Current character size as specified by user
which is different from current font size
(pixels) */
extern int jdash; /* Current dash pattern (init to solid line)*/
extern int jwidth; /* Current width of lines (init to 1 pixel)*/
extern int jclip ; /* Set to one to enable clipping, 0 for no clipping*/
extern char font[MAXSTRLEN] ; /* Name of current font to be used */
然后在check_window.c
内定义相关变量:
c
#include "x1000.h"
/* global variables */
Display *display;
int screen;
GC gc;
XGCValues gcv;
XFontStruct *font_info = NULL;
XEvent report;
XSizeHints size_hints;
Window win;
Pixmap icon_pixmap;
Pixmap clip_mask;
XSetWindowAttributes setwinattr;
unsigned long valuemask = 0;
float xvl, xvr, xvb, xvt;
float xwl, xwr, xwb, xwt;
int Window_width;
int Window_height;
int curr_charsize[2];
int usr_charsize = 0;
int Curx, Cury;
float jcenter;
float jheight;
int jor_tan;
int jzse;
int jdash;
int jwidth;
int jclip;
char font[MAXSTRLEN];
/*以下代码不变*/
然后正常执行./install_software
即可。
GAMIT 不处理GPS L2C的小bug
现在编译没啥问题了,之前还发现了一个小bug:20250901这个更新里面并没有读取GPS的L2C的观测值,在算项目数据时出现了这样的情况,GPS双频观测值是L1C和L2C,用LC_AUTCLN模式死活算不出来...
参考文献:
改代码的位置在gamit/lib/sel_obtyp.f
第67行 附近,添加载波相位观测值
fortran
if( gnsslf.eq.'G5' ) then
call fill_obtypx(2,'L5 ',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L5X',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L5I',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L5Q',nobtyp,rxobtyp,iobtypx)
else
call fill_obtypx(2,'LC ',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L2 ',nobtyp,rxobtyp,iobtypx)
c ADD
call fill_obtypx(2,'L2C',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L2X',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L2L',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L2Y',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L2S',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(2,'L2W',nobtyp,rxobtyp,iobtypx)
endif
和第98行附近,添加伪距观测值
FORTRAN
if( gnsslf.eq.'G5' ) then
call fill_obtypx(4,'C5 ',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C5X',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C5I',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C5Q',nobtyp,rxobtyp,iobtypx)
else ! Default selection
call fill_obtypx(4,'CC ',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C2 ',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'P2 ',nobtyp,rxobtyp,iobtypx)
c ADD
call fill_obtypx(4,'C2C',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C2X',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C2L',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C2Y',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C2S',nobtyp,rxobtyp,iobtypx)
call fill_obtypx(4,'C2W',nobtyp,rxobtyp,iobtypx)
然后重新编译即可。