[Fortran] 纯文本查看 复制代码
Program Coef_differ
implicit none
integer*4 nargs,iargc,i,dg,od,dgmx,odmx,l,m,ln
integer*4 l1,m1,l2,m2,dotp
integer*4 stat1,stat2
character*160 cha,g1file,g2file,g3file,df_file
character*70 header
character(len=1):: dot='.'
logical back
real*8 dt1,dt2,C1,S1,C2,S2,dC,dS,GM,Rd
nargs=iargc()
call get_command_argument (1,cha)
g1file=cha
call get_command_argument (2,cha)
g2file=cha
write(*,*) g1file
write(*,*) g2file
dotp=scan(g1file,dot,back) !求出"."的位置
g3file=g1file(1:dotp-1)
df_file=g3file(1:len_trim(g3file))//'_df.coe'
open(10,file=g1file,status='old')
open(11,file=g2file,status='unknown')
open(12,file=df_file,status='unknown')
do
read(10,"(2I12,2D24.15)",iostat=stat1) l1,m1,C1,S1
if(stat1/=0) exit
read(11,"(2I12,2D24.15)",iostat=stat2) l2,m2,C2,S2
if(stat2/=0) exit
if (l1 .eq. l2) then
if (m1. eq. m2) then
dC=C1-C2
dS=S1-S2
write(12,'(2I12,2D24.15)') l1,m1,dC,dS
else
write(*,*) 'file format not match in order'
endif
else
write(*,*) 'file format not match in degree'
endif
enddo
End Program Coef_differ