悲催的科学匠人 - 冷水's blog
合并plot3d function文件
tecplot不支持导入多个function文件,这导致我计算出的速度数据文件和压强数据文件以及涡量数据文件没法在一个图中操作显示。
没法,写个小玩意克服一下
使用方法
$ mergep3df newp3df newname p3df1 name1 p3df2 name2 p3df3 name3 ...
MODULE mergep3d CONTAINS SUBROUTINE mergep3dfunc(ndatafiles, datafiles, & nb,ni,nj,nk, nvar, newp3df) IMPLICIT NONE INTEGER,INTENT(IN) :: ndatafiles, nvar(:) CHARACTER(LEN=*),DIMENSION(:),INTENT(IN) :: datafiles CHARACTER(LEN=*),INTENT(IN) :: newp3df INTEGER,POINTER,DIMENSION(:) :: ni,nj,nk INTEGER,INTENT(in) :: nb ! local INTEGER nvars, tmpint, b, n, i,j,k,l INTEGER,POINTER,DIMENSION(:) :: offset, funit,shift REAL(4),POINTER,DIMENSION(:,:,:,:) :: gdata nvars = SUM( nvar(1:ndatafiles) ) OPEN(33,FILE=TRIM(newp3df),action='write', form='unformatted') WRITE(33) nb WRITE(33) (ni(b),nj(b),nk(b),nvars, b=1,nb) ALLOCATE( offset(ndatafiles), funit(ndatafiles), shift(ndatafiles) ) offset=0 shift = 0 DO n=1, ndatafiles funit(n) = 1000 + n OPEN(UNIT=funit(n),FILE=TRIM(datafiles(n)),action='read', form='unformatted') READ(funit(n)) tmpint READ(funit(n)) (tmpint,tmpint,tmpint,tmpint, b=1,nb) offset(n) = FTELL(funit(n)) shift(n+1) = shift(n) + nvar(n) ENDDO DO b=1, nb ALLOCATE( gdata(ni(b),nj(b),nk(b), nvars) ) DO n=1, ndatafiles READ(funit(n)) (( ((gdata(i,j,k,l),i=1,ni(b)),j=1,nj(b)),k=1,nk(b) ), & l=shift(n)+1,shift(n+1) ) ENDDO WRITE(33) (( ((gdata(i,j,k,l),i=1,ni(b)),j=1,nj(b)),k=1,nk(b) ), l=1,nvars ) ENDDO END SUBROUTINE SUBROUTINE checkp3dfunc(ndatafiles, datafiles, & nb, ni, nj, nk, ierr) IMPLICIT NONE INTEGER,INTENT(IN) :: ndatafiles CHARACTER(LEN=*),DIMENSION(:),INTENT(IN) :: datafiles INTEGER,POINTER,DIMENSION(:) :: ni,nj,nk INTEGER,INTENT(OUT) :: nb, ierr ! local INTEGER :: n,b,db,nfunc,dfunc INTEGER,DIMENSION(:),POINTER :: di,dj,dk OPEN(33,FILE=TRIM(datafiles(1)),action='read', form='unformatted') READ(33) nb; WRITE(*,*) 'nblock=',nb ALLOCATE(ni(nb),nj(nb),nk(nb), & di(nb),dj(nb),dk(nb), ) READ(33) (ni(b),nj(b),nk(b),nfunc, b=1,nb) WRITE(*,*) 'done read' !DO n=1,nb ! WRITE(*,*) ni(n),nj(n),nk(n),nvar(n) !ENDDO CLOSE(33) ierr = 0 DO n=1,ndatafiles OPEN(33,FILE=TRIM(datafiles(n)),action='read', form='unformatted') READ(33) db IF(db /= nb) THEN ierr = 1 CLOSE(33) RETURN ENDIF READ(33) (di(b),dj(b),dk(b),dfunc, b=1,nb) DO b=1,nb IF(di(b) /= ni(b) .OR. dj(b) /= nj(b) .OR. dk(b) /= nk(b) ) THEN WRITE(*,*) 'block ',b, di(b),dj(b),dk(b), ni(b),nj(b),nk(b) ierr = 2 CLOSE(33) RETURN ENDIF ENDDO CLOSE(33) ENDDO END SUBROUTINE SUBROUTINE getvarnames(ndatafiles, datafiles,varnames, nvar) IMPLICIT NONE INTEGER,INTENT(OUT) :: ndatafiles INTEGER,DIMENSION(:), INTENT(OUT) :: nvar CHARACTER(LEN=*),DIMENSION(:),INTENT(OUT) :: varnames,datafiles ! local CHARACTER(LEN=128) :: tmpstr INTEGER :: IO, argn,n,i LOGICAL :: notend argn = command_argument_count() ndatafiles = (argn - 2)/2 WRITE(*,*) 'argn=',argn,'ndatafiles =',ndatafiles i=0 DO n=1,ndatafiles nvar(n)=0 CALL get_command_argument(n+n+1, datafiles(n)) CALL get_command_argument(n+n+2, tmpstr) !WRITE(*,*) tmpstr OPEN(33,FILE=TRIM(tmpstr)) notend = .TRUE. DO WHILE (notend) READ(33, *, IOSTAT = IO ) tmpstr IF(IO>=0) THEN nvar(n) = nvar(n) + 1 i = i + 1 varnames(i) = tmpstr WRITE(*,*) i, TRIM( varnames(i) ) ELSE notend = .FALSE. ENDIF ENDDO CLOSE(33) ENDDO !DO n=1,i ! WRITE(*,*) TRIM( varnames(n) ) !ENDDO !WRITE(*,*) nvar(1:ndatafiles) END SUBROUTINE SUBROUTINE mergename(ndata, nvar, varnames, namefile) INTEGER,INTENT(IN) :: ndata INTEGER,DIMENSION(:),INTENT(IN) :: nvar CHARACTER(LEN=*),DIMENSION(:),INTENT(IN) :: varnames CHARACTER(LEN=*),INTENT(IN) :: namefile ! local INTEGER :: i,j,n OPEN(33,FILE=TRIM(namefile)) j = 0 DO n=1, ndata DO i=1, nvar(n) j=j+1 WRITE(33, *) TRIM(varnames(j)) ENDDO ENDDO END SUBROUTINE END MODULE PROGRAM main USE mergep3d IMPLICIT NONE INTEGER :: ndata,nvar(1024),nb,ierr INTEGER,POINTER,DIMENSION(:) :: ni,nj,nk CHARACTER(LEN=64) :: fnames(1024),varnames(1024),newp3df,newname CALL getvarnames(ndata, fnames, varnames, nvar) CALL checkp3dfunc(ndata, fnames, nb,ni,nj,nk, ierr) WRITE(*,*) 'ierr=',ierr CALL get_command_argument(2,newp3df) CALL get_command_argument(3,newname) CALL mergep3dfunc(ndata, fnames, nb,ni,nj,nk, nvar, TRIM(newp3df) ) CALL mergename(ndata, nvar, varnames, TRIM(newname) ) END
【轮子DIY】一个比较通用的fortran90程序make系统
一个项目中的副产品,目的是为fotran90项目构造简单的make系统
目录结构是主目录下必须包含bin,src和make目录。make目录下是一些makefile,而src就是源代码了。由于fortran的module特殊性,如果有module,src必须包含一个mod目录。如果包含fortran77代码,我也专门开辟一个f77目录包含这些文件,当然叶可以采用其它办法。此外,如果包含混编的c代码,我放入anisc目录。其它代码那找类别分别创建src的子目录即可。一个例子如下
poject +---bin +---make +---src +---mod +---f77 +---anisc +---main
make目录中关键的文件有
- make.inc,定义所有编译参数
- make_mod,专用于编译module
- make_f77,专用于编译fortran77代码
- make_clib,专用于编译c文件
- make_sub,用于编译其它src下子目录中fortran90代码
- Makefile,主make文件
make.inc
# CMODE # options: # gnu, # pgi, # intel COMPILER=gnu # path PROJECT_HOME=.. SRCDIR=$(PROJECT_HOME)/src OBJDIR=$(PROJECT_HOME)/obj_$(COMPILER)/$(CMODE) MODDIR=$(PROJECT_HOME)/mod BINDIR=$(PROJECT_HOME)/bin # PGI fortran and C ifeq ($(COMPILER),pgi) FC=mpif90 LINK=mpif90 CC=pgcc ifeq ($(CMODE),debug) FFLAGS0 = -module $(OBJDIR) -g -r8 -Kieee -C else CMODE = release FFLAGS0 = -module $(OBJDIR) -O2 -r8 -Kieee endif ARCH = ar ARCHFLAG = cr endif # Intel fortran and C ifeq ($(COMPILER),intel) FC=mpif90 LINK=mpif90 CC=icc ifeq ($(CMODE),debug) FFLAGS0 = -module $(OBJDIR) -g -r8 -check all else CMODE = release FFLAGS0 = -module $(OBJDIR) -O2 -r8 endif ARCH = ar ARCHFLAG = cr endif # GNU fortran and C ifeq ($(COMPILER),gnu) FC=mpif90 LINK=mpif90 CC=gcc ifeq ($(CMODE),debug) FFLAGS0 = -J$(OBJDIR) -fdefault-real-8 -frecord-marker=4 -g -fcheck=all -fbacktrace else CMODE = release FFLAGS0 = -J$(OBJDIR) -O2 -fdefault-real-8 -frecord-marker=4 endif ARCH = ar ARCHFLAG = cr endif FFLAGS = $(FFLAGS0) # LIB dir 这里加入必要的库和路径 LIBDIR= #-L$(BLASDIR) -L$(LAPACKDIR) LIBS = # # output exe file, 你可以修改run为其它名称 EXE=$(BINDIR)/run_$(COMPILER)_$(CMODE)
make_f77
include make.inc MYSRC= $(wildcard $(SRCDIR)/$(SUB)/*.f) MYTMP= $(patsubst %.f,%.o, $(MYSRC)) MYOBJ= $(patsubst $(SRCDIR)/$(SUB)%,$(OBJDIR)%, $(MYTMP)) all: $(MYOBJ) $(MYOBJ): $(OBJDIR)/%.o: $(SRCDIR)/$(SUB)/%.f $(FC) -c $(FFLAGS) $< -o $@ clean: rm -f $(MYOBJ) submit:
make_clib
include make.inc MYSRC= $(wildcard $(SRCDIR)/$(SUB)/*.c) MYTMP= $(patsubst %.c,%.o, $(MYSRC)) MYOBJ= $(patsubst $(SRCDIR)/$(SUB)%,$(OBJDIR)%, $(MYTMP)) all: $(MYOBJ) $(MYOBJ): $(OBJDIR)/%.o: $(SRCDIR)/$(SUB)/%.c $(CC) -c $< -o $@ clean: rm -f $(MYOBJ) submit:
make_sub
include make.inc MYSRC= $(wildcard $(SRCDIR)/$(SUB)/*.f90) MYTMP= $(patsubst %.f90,%.o, $(MYSRC)) MYOBJ= $(patsubst $(SRCDIR)/$(SUB)/%,$(OBJDIR)/$(DEST)/%, $(MYTMP)) all: $(MYOBJ) $(MYOBJ): $(OBJDIR)/$(DEST)/%.o: $(SRCDIR)/$(SUB)/%.f90 $(FC) -c $(FFLAGS) $< -o $@ clean: rm -f $(MYOBJ) submit:
make_mod
include make.inc SUB=mod # 这里必须按照一定顺序填写module源代码文件 MYSRC = $(SRCDIR)/$(SUB)/mod1.f90 \ $(SRCDIR)/$(SUB)/mod2.f90 \ $(SRCDIR)/$(SUB)/mod3.f90 MYTMP= $(patsubst %.f90,%.o, $(MYSRC)) MYOBJ= $(patsubst $(SRCDIR)/$(SUB)%,$(OBJDIR)%, $(MYTMP)) all: $(MYOBJ) $(MYOBJ): $(OBJDIR)/%.o: $(SRCDIR)/$(SUB)/%.f90 $(FC) -c $(FFLAGS) $< -o $@ clean: rm -f $(MYOBJ)
Makefile
include make.inc TMPLIB = $(OBJDIR)/../libmytmp_$(CMODE).a all: objs main main: $(TMPLIB) $(LINK) $(TMPLIB) $(LIBDIR) $(LIBS) $(FFLAGS) -o $(EXE) #编译所有obj文件并构造库,在make_mod后列出所有src子目录的编译命令 make -f make_sub "SUB=子目录名称" objs: make -f make_mod make -f make_sub "SUB=main" make -f make_f77 "SUB=f77" make -f make_clib "SUB=anis_c" $(ARCH) $(ARCHFLAG) $(OBJDIR)/../libmytmp_$(CMODE).a $(OBJDIR)/*.o #删除所有obj文件、mod文件和库,在make_mod后列出所有src子目录的编译命令 make -f make_sub "SUB=子目录名称" clean 来清理给定类别的obj文件 #这里只是举例说明可以指定clean一部分文件,在某些场合下可以采用这个方法进行较为精确的clean控制 cleanall: make -f make_mod clean make -f make_sub "SUB=main" clean make -f make_f77 "SUB=f77" clean make -f make_clib "SUB=anis_c" clean rm -f $(OBJDIR)/../libmytmp_$(CMODE).a rm -f $(OBJDIR)/*.mod #粗暴的删除所有编译生成的文件, clean: rm -f $(OBJDIR)/../libmytmp_$(CMODE).a rm -f $(OBJDIR)/*.mod rm -f $(OBJDIR)/*.o #创建obj文件目录 dir: mkdir ../obj_$(COMPILER) mkdir ../obj_$(COMPILER)/debug mkdir ../obj_$(COMPILER)/release
具体使用时,只需要为module手工填写文件名,其它非module的代码一律自动寻找。第一次编译,需要先 make dir创建目录,而后再make。默认编译优化版本,使用make CMODE=debug会编译调试版本。
使用ipv6的几个常识
在浏览器地址栏输入ipv6地址必须用[]包起来
ssh支持ipv6的问题,两点。
1 修改配置文件,转自http://knowledgelayer.softlayer.com/procedure/configuring-ssh-listen-ipv6-addresses
To enable IPv6 on a Linux server’s SSH, edit the /etc/ssh/sshd_config file. Look for ListenAddress, Then uncomment the #ListenAddress :: line.
ListenAddress 0.0.0.0
ListenAddress ::
This will bind sshd to every address on your machine.
2 ssh登录时直接使用ipv6地址,不必加[]
在ubuntu 11.04上搭建phpZoteroWebDAV 2.0的几个问题
必须安装php-curl
sudo apt-get install curl sudo apt-get install php5-curl
必须安装php-pear
sudo apt-get install php-pear
zotero目录下的data和cache必须是可写。为了安全,设置访问权限控制,可以用htpasswd或者在htconf中写
可能由于zotero API的变更,每个收藏条目的附件信息没法显示。需要修改一下源代码details.php,把所有的"<entry>"修改为"<entry"即可。
其他参考 http://blog.holz.ca/2011/11/phpzoterowebdav-installation/
最后,如果可以,服务器地址可以考虑采用ipv6,这样更有优势。