Fortran 读取gps广播星历和精密星历

更新时间:2020/5/12
星历下载见博客:
https://blog.csdn.net/Gou_Hailong/article/details/100809806

广播星历结构体:
在这里插入图片描述
精密星历结构体:
在这里插入图片描述
源码:
1.结构体+读文件

    !fortran read file
module typedef_and_read
    implicit none
    !igs - sp3
    type POINT
        real::x,y,z,det
        character(len=5)::prn
    end type
    type EPOCH
        integer sec_day         !the second of a day
        type(point):: pt(50)    !the number of sat in an epoch
    end type
    type SP3
        integer:: year,month,day
        integer:: num_epoch,num_sat
        integer:: gpsweek,gpssec
        integer:: ep_sec    !the time between two epochs
        integer:: julian_day_whole
        real julian_day_round
        character:: typ     !P or V
        type(epoch) ep(100)
    end type
    !Brdc - renix
    type DATANODE
        integer prn
        integer gps_week,toe,time
        real iode,a0,a1,a2,sec_day
        real a_sqrt,e
        real Cuc,Cus,Crc,Crs,Cic,Cis
        real Dn,OMEGA_,omega,i0,M0
        real i_dot,OMEGA_dot,TGD
    end type
    type DATALINE
        integer year,month,day,hour,minute,second,toc
        type(datanode) nod(35)
    end type
    type BRDC
        type(dataline) lin(30)
        real a(4),b(4),A0,A1
        integer T,W,leap_sec,year,mon,day
    end type
    
    
    contains 
        subroutine read_brdc(filename,brd)
            implicit none
            character(len=80),intent(in) ::filename !input
            type(BRDC),intent(out) :: brd           !output
            character(len=80)::buf
            integer,parameter::fileid=10
            integer::status=0,i=1,j=1
            logical alive
            
            integer prn,sec_day                    !temp data
            real gps_week,toe,time
            real iode,a0,a1,a2
            real a_sqrt,e
            real Cuc,Cus,Crc,Crs,Cic,Cis
            real Dn,OMEGA_,omega,i0,M0
            real i_dot,OMEGA_dot,TGD,second,toc
            integer year,month,day,hour,minute
            real a                                !unuseful data
            
            inquire(file=filename,exist=alive)!exist?
    
            if(alive)then!exist!
                write(*,*) 'BRDC Reading...'
                open(unit=fileid,file=filename,access="sequential",status="old")
                read(unit=fileid,fmt="(A80)",iostat=status)buf!1
                read(unit=fileid,fmt="(A80)",iostat=status)buf!2
                read(unit=fileid,fmt="(A80)",iostat=status)buf!3
                read(unit=fileid,fmt="(2X,4D12.4)",iostat=status)brd.a(1),brd.a(2),brd.a(3),brd.a(4)!4
                read(unit=fileid,fmt="(3X,4D12.4)",iostat=status)brd.b(1),brd.b(2),brd.b(3),brd.b(4)!5
                read(unit=fileid,fmt="(3X,2D19.12,2I9)",iostat=status)brd.A0,brd.A1,brd.T,brd.W!6
                read(unit=fileid,fmt="(I6)",iostat=status)brd.leap_sec!7
                read(unit=fileid,fmt="(A80)",iostat=status)buf!8 end of head
                
                do while(.true.)
                    !read(unit=fileid,fmt="()",iostat=status),prn
                    read(unit=fileid,fmt="(I2,1X,I2.2,4(1X,I2),F5.1,3D19.12)",iostat=status)prn,year,&!1
                    &month,day,hour,minute,second,a0,a1,a2
                    if(status==-1)then !read over?
                        write(*,*) 'Read over!'
                        exit
                    endif
                    read(unit=fileid,fmt="(3X,4D19.12)",iostat=status) iode,Crs,Dn,M0        !2
                    read(unit=fileid,fmt="(3X,4D19.12)",iostat=status) Cuc,e,Cus,a_sqrt      !3
                    read(unit=fileid,fmt="(3X,4D19.12)",iostat=status) TOE,Cic,OMEGA_,Cis    !4
                    read(unit=fileid,fmt="(3X,4D19.12)",iostat=status) i0,Crc,omega,OMEGA_dot!5
                    read(unit=fileid,fmt="(3X,4D19.12)",iostat=status) i_dot,a,gps_week,a    !6
                    read(unit=fileid,fmt="(3X,4D19.12)",iostat=status) a,a,TGD,a             !7
                    read(unit=fileid,fmt="(3X,4D19.12)",iostat=status) time,a,a,a            !8
                    if(j>1)then
                        if(prn<=brd.lin(i).nod(j-1).prn)then
                            i=i+1;j=1
                        endif
                    endif
                    if(j==1)then
                        brd.lin(i).year=year
                        brd.lin(i).month=month
                        brd.lin(i).day=day
                        brd.lin(i).hour=hour
                        brd.lin(i).minute=minute
                        brd.lin(i).second=second
                        brd.lin(i).toc=TOE
                    end if
                    brd.lin(i).nod(j).prn=prn; brd.lin(i).nod(j).a0=a0; brd.lin(i).nod(j).a1=a1; brd.lin(i).nod(j).a2=a2
                    brd.lin(i).nod(j).iode=iode; brd.lin(i).nod(j).Crs=Crs; brd.lin(i).nod(j).Dn=Dn; brd.lin(i).nod(j).M0=M0
                    brd.lin(i).nod(j).Cuc=Cuc; brd.lin(i).nod(j).e=e; brd.lin(i).nod(j).Cus=Cus; brd.lin(i).nod(j).a_sqrt=a_sqrt
                    brd.lin(i).nod(j).TOE=TOE; brd.lin(i).nod(j).Cic=Cic; brd.lin(i).nod(j).OMEGA_=OMEGA_; brd.lin(i).nod(j).Cis=Cis
                    brd.lin(i).nod(j).i0=i0; brd.lin(i).nod(j).Crc=Crc; brd.lin(i).nod(j).omega=omega; brd.lin(i).nod(j).OMEGA_dot=OMEGA_dot
                    brd.lin(i).nod(j).i_dot=i_dot; brd.lin(i).nod(j).gps_week=gps_week
                    brd.lin(i).nod(j).TGD=TGD; brd.lin(i).nod(j).time=time
                    brd.lin(i).nod(j).sec_day=brd.lin(i).hour*3600+ brd.lin(i).minute*60+ brd.lin(i).second
                    j=j+1                  
                end do
                close(fileid)
                brd.year=brd.lin(1).year;brd.mon=brd.lin(1).month;brd.day=brd.lin(1).day
            else!don't exist!
                write(*,*)trim(filename),"File doesn't exist."
            end if
        end subroutine
        
        subroutine read_sp3(filename,sp)
            implicit none
            character(len=80),intent(in) ::filename !input
            type(SP3),intent(out) :: sp           !output
            character(len=80)::buf
            integer,parameter::fileid=10
            integer::status=0,i=1,j=1
            logical alive
            
            inquire(file=filename,exist=alive)!exist?
            if(alive)then!exist!
                write(*,*) 'SP3 Reading...'
                open(unit=fileid,file=filename,access="sequential",status="old")
                
                
            else!don't exist!
                write(*,*)trim(filename),"File doesn't exist."
            end if
        end subroutine   
    end module

2.主程序

!main program   
program main
    use typedef_and_read
    implicit none
    character(len=80)::filename1,filename2,st
    character(len=80)::buffer
    integer,parameter::fileid=10
    integer::status=0,points
    logical alive
    real a
    type(POINT),allocatable::pt(:)
    type(brdc) brd
    type(sp3) sp
    
    filename1='data\brdc2400.19n'
    call read_brdc(filename1,brd)
    
    filename2='data\igs20683.sp3'
    call read_sp3(filename2,sp)
    
    st='-0.110050197691D-03'
    read(st,'(D19.12)'),a
    write(*,*) st,a
    pause
end      

此坑待填:精密星历没写!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

流浪猪头拯救地球

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值