Jump to content
PDS Geosciences Node Community

SUN YU

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by SUN YU

  1. This fortran code will convert the LP ODF data on PDS node to ASCII records so that it would be much easier to convert it to another data format. This program is designed to run on a PC with window OS and Compaq Visual Fortran (6.6 or heigher virsion (a lower vision donnot have data type integer*8), you don't have to change it too much to transfer it to another platform or compile it with other compliers. If you have any questions, please donnot hesitate to contact me at sunyuwoody@126.com ---------------------- the following is the original code ----------------------------- C Program ReadODF Program ReadODF CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C C This program will transform the LP ODF format (descriped by the interface C C file trk-2-18) to ASCII records C C C C Note* This Program need to be run in a 6.6 or higher virsion.Since there C C is no data type integer*8 in Compaq Visual Fortran C C C C SUN YU.( 2010 ) Shandong University of Science and Technology, Qingdao 266510, Shanddong Province, China C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C ------------ Begin of Data Type Definition------------------ Implicit None Integer*4 i,R,Iramp Integer*4 Idat_four(10),IRampG_four(10),IRampGH_four(10) Integer*4 IOrbitG_four(10),IOrbitGH_four(10) Real*8 RRange_M,RM_M,Rmout(19) Integer*8 IOrbitG_eight(2) Character*50 PrefixInputfile,Inputfile,TrimInputfile Character*8 Char_eight(2) Character*20 Char_twenty(2) Logical Flag,Alive,exist C -------------End of Data Type Definition-------------------- C ---------------Format----------------- 105 Format(F15.3,F15.10,F20.10,3I6,I4,2I5,6I3,F17.3,I5,2I9) c108 Format(I15,f6.3,f22.10,2I4,I20,f20.5,F22.10,I4) c109 Format(I10,I10,3I5,2F25.10) c110 Format(2I10,2I5,2D25.14) C --------------------------------------- C Begin of executable codes CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C Open binary files C C LP ODF file has eight independent data files, all of them are C C in the form of binary,the format description is included in C C the interface file "trk-2-18" which is also provided together C C with the data. C C C C * Note C C To read this file, you need to notice what kind of work station C C or computer you are using in oder to figure out how the binary C C files are handled on your machine, it is either Big_endian(MSB) or C C Little_endian(LSB). For example, if you are using a PC, it would be C C Little_endian, but if it is a SUN work station, there is a good C C chance that it is Big_endian. C C C C In this case, we are running the program on a PC and we need to be C C aware that it is Little_endian. However, The LP ODF files cannot C C be recognized as you can see in the interface file that the data C C type is MSB_INTEGER. If you are using a Big_endian machine, there C C should be no problem. C C C C * How to solve this problem C C This problem can be easily solved by adding the OPTION C C "conver='big_endian'" in the OPEN STATMENT C C C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C Inputfile='./LPODF/lpodfcase1' Write(6,*) ' ***********************' Write(6,*) Write(6,*) ' PROGRAM READ LPODF ' Write(6,*) Write(6,*) ' ***********************' Write(6,*) Write(6,*) Write(6,*) ' -------------- INPUTFILE-------------' Write(6,*) ' ' Write(6,*) ' Plese Select Inputfiles ' Write(6,*) ' From lpodfcase1 to 8 ' Write(6,*) ' ' Write(6,*) ' -------------------------------------' Write(6,*) Write(6,*) Write(6,*) '-----------------------' Write(6,*) ' The Input file is:' C Read (*,*) Inputfile Inputfile='lpodfcase1' PrefixInputfile='./LPODF/'//Inputfile TrimInputfile=PrefixInputfile(1:Len(Trim(PrefixInputfile))) Write(6,*) '------------------------' Write(6,*) 'The ODF file selected is' write(*,*) TrimInputfile Inquire(file=TrimInputfile,exist=Alive) If (alive) Then Write(6,*) ' ----------------READIND--------------' Write(6,*) Write(6,*) ' Start to read file ','Inputfile', 1 '…………' Write(6,*) Write(6,*) ' -------------------------------------' Flag=Alive Else Write(6,*) ' -----------------ERROR---------------' Write(6,*) Write(6,*) ' The Inputfile dose not exist ' Write(6,*) ' Please check the Inputfile ' Write(6,*) Write(6,*) ' -------------------------------------' Stop Endif If (Flag) Then Open(10,file=TrimInputfile,convert='big_endian',form='binary', 1 access='direct',recl=36) C Open the OUTPUT files Open(20,file='LPODF_ALLData_ASCII') C First, the first 4 records we be read and write out C !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! C Record 1:ODF lable group header Read(10,rec=1) (Idat_four(i),i=1,9) Write(20,*) 'LPODF ASCII OUTPUT:' Write(20,*) '===================================== 1==============' Write(20,*) '----------Label Group: Header Record- 1--------------' Write(20,*) 'Prime_Key Second_Key Log_Rec_Len 1 Gp_St_Pkt_No' Write(20,'(I8,2X,I8,6X,I8,8X,I8)') (Idat_four(i),i=1,4) Write(20,*) '----------------------Data----------- 1--------------' Write(6,*) Write(6,*) ' Label Group: Header Record' Endif C Record 2: ODF lable group Read(10,rec=2) (Char_eight(i),i=1,2),(Idat_four(i),i=1,5) Write(20,*) 'SystemID ProgramID SCID CrDate CrTime 1 FRefDate FRefTime' Write(20,'(A10,A9,I6,I8,X,I8,3X,I8,3X,I6.6)') 1 (Char_eight(i),i=1,2),(Idat_four(i),i=1,5) Write(20,*) '====================================== 1==============' Write(6,*) Write(6,*) ' Label Group Data' C Record 3:ODF identifier goup header Read(10,rec=3) (Idat_four(i),i=1,9) Write(20,*) '--------Identifier Group: Hearder Record- 1--------------' Write(20,*) 'Prime_Key Second_Key Log_Rec_Len 1 Gp_St_Pkt_No' Write(20,'(I8,2X,I8,6X,I8,8X,I8)') (Idat_four(i),i=1,4) Write(20,*) '----------------------Data----------- 1--------------' Write(6,*) Write(6,*) ' Identifier Group:Header Record' C Record 4: ODF identifier goup data Read(10,rec=4) (Char_eight(i),i=1,2),Char_twenty(1) Write(20,*) ' Item_1 Item_2 Item_3' Write(20,'(4X,A8,3X,A8,5X,A20)') 1 (Char_eight(i),i=1,2),Char_twenty(1) Write(20,*) '====================================== 1==============' Write(6,*) Write(6,*) ' Identifier Group Data' C !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! R=5 Do While (.True.) !This program will never stop Read(10,rec=R) Idat_four(1) !unless you tell them to If (Idat_four(1).EQ.-1) Then !-1 means the EOF Read(10,rec=R) (Idat_four(i),i=1,9) !we always have to figure whether !it's the end of the data file Write(20,*)'--------End of File Group: Hearder Record 1------------' Write(20,*) 'Prime_Key Second_Key Log_Rec_Len 1 Gp_St_Pkt_No' Write(20,'(I8,2X,I8,6X,I8,8X,I8)') (Idat_four(i),i=1,4) Write(20,*) '----------------------Data----------- 1--------------' Write(6,*) Write(6,*) ' End of the ODF file' Goto 9999 !if it is the end of the data file !then read the End of File Group !and write it done, after that,exit C!!!!!!!!!!!!!!!!!!!!!!! Reading the Orbit Data Group !!!!!!!!!!!!!!!!!!!!!! Elseif (Idat_four(1).EQ.109) Then !find out if it is the Orbit Data !Group. 3333 Read(10,rec=R) (IOrbitGH_four(i),i=1,9) Write(20,*) '----------Orbit Data Group: Hearder Record 1------------' Write(20,*) 'Prime_Key Second_Key Log_Rec_Len 1 Gp_St_Pkt_No' Write(20,'(I8,2X,I8,6X,I8,8X,I8)') (IOrbitGH_four(i),i=1,4) Write(20,*) '----------------------Data----------- 1--------------' Write(6,*) Write(6,*) ' Orbit Data Group: Hearder' Write(6,*) Write(6,*) ' Orbit Data Group' Write(20,'(A12,A15,A20,A10,2A6,A4,A6,7A3,A17,3A8)') 1'Time Tag', 'DL_delay','Observable','Fmt','DSSr','DSSt','Net', 2'D_Typ','DL','UL','Ex','V','2S','SC','17', 3'Reference Freq','Item_20','Item_21','Item_22' R=R+1 !if it is the Orbit Data Group, !write out the Header first. after !the Header is the data group, !read these data and write out !till the EOF Do While (.True.) Read(10,rec=R) Idat_four(1) If (Idat_four(1).EQ.-1) Then Read(10,rec=R) (Idat_four(i),i=1,9) Write(20,*)'--------End of file Group: Hearder Record 1------------' Write(20,*) 'Prime_Key Second_Key Log_Rec_Len 1 Gp_St_Pkt_No' Write(20,'(I8,2X,I8,6X,I8,8X,I8)') (Idat_four(i),i=1,4) Write(20,*) '----------------------Data----------- 1--------------' Write(6,*) Write(6,*) ' End of the ODF file' Goto 9999 Elseif (Idat_four(1).EQ.109) Then !this is in case there is more !than one Orbit Data Group, !though, there shoulb be only one Goto 3333 Elseif (Idat_four(1).EQ.2030) Then Goto 4444 Else Read(10,rec=R) (IOrbitG_four(i),i=1,5),(IOrbitG_eight(i),i=1,2) Write(20,105) 1IOrbitG_four(1)+ibits(IOrbitG_four(2),22,10)*1.D-3, !Record Time Tag 3ibits(IOrbitG_four(2),0,22)*1.D-9, !Downlink_delay 4IOrbitG_four(3)+IOrbitG_four(4)*1.D-9, !Observable 5ibits(IOrbitG_four(5),29,3), !Format ID=2 5ibits(IOrbitG_four(5),22,7), !Receiving Station ID NO.--DSSr 5ibits(IOrbitG_four(5),15,7), !Transmittiong Station ID NO.--DSSt 5ibits(IOrbitG_four(5),13,2), !Network ID for Transmitting Station 5ibits(IOrbitG_four(5),7,6), !Data Type ID.--D_Typ 5ibits(IOrbitG_four(5),5,2), !Downlink band ID.--DL 5ibits(IOrbitG_four(5),3,2), !Uplink band ID.--UL 5ibits(IOrbitG_four(5),1,2), !Exciter band ID.--Ex 5ibits(IOrbitG_four(5),0,1), !Data Validity Indicator (0 for good) 6ibits(IOrbitG_eight(1),57,7), !2nd Receiving station ID 6ibits(IOrbitG_eight(1),47,10), !Spacecraft ID 6ibits(IOrbitG_eight(1),46,1), !Receiver/Exciter Independet flag(1:yes) 6ibits(IOrbitG_eight(1),24,22)*1.D4+ 6ibits(IOrbitG_eight(1),0,24), ! 7ibits(IOrbitG_eight(2),44,20), ! 7ibits(IOrbitG_eight(2),22,22), ! 7ibits(IOrbitG_eight(2),0,22) ! Endif R=R+1 Enddo !the most important data needed in !the ODF file is the Orbit Data Groups !and there should be only one of them !in each ODF file. 4444 Continue C!!!!!!!!!!!!!!!!!!! Reading the Ramp Group !!!!!!!!!!!!!!!!!!!!!!!!!! Elseif (Idat_four(1).EQ.2030) Then !if it is not the EOF, then find !out if it is the Ramp Group. Iramp=1 2222 Read(10,rec=R) (IRampGH_four(i),i=1,9) Write(20,*) '-----------Ramp Group: Hearder Record- 1--------------' Write(20,*) 'Prime_Key Second_Key Log_Rec_Len 1 Gp_St_Pkt_No' Write(20,'(I8,2X,I8,6X,I8,8X,I8)') (IRampGH_four(i),i=1,4) Write(20,*) '----------------------Data----------- 1--------------' Write(6,*) Write(6,*) ' Ramp Group',Iramp Iramp=Iramp+1 Write(20,'(A5,A23,A18,2A21)') 1'DSS', 'Ramp Start Time','Ramp Rate', 2'Start Frequency','Ramp End Time' R=R+1 !if it is the Ramp Group, then !write out the Header first. after !the Header is the data group, !read these ramp data and write out !till the EOF Do While (.True.) Read(10,rec=R) Idat_four(1) If (Idat_four(1).EQ.-1) Then Read(10,rec=R) (Idat_four(i),i=1,9) Write(20,*)'--------End of file Group: Hearder Record 1------------' Write(20,*) 'Prime_Key Second_Key Log_Rec_Len 1 Gp_St_Pkt_No' Write(20,'(I8,2X,I8,6X,I8,8X,I8)') (Idat_four(i),i=1,4) Write(20,*) '----------------------Data----------- 1--------------' Write(6,*) Write(6,*) ' End of the ODF file' Goto 9999 Elseif (Idat_four(1).EQ.2030) Then !there is more than one ramp group !in an ODF file. Goto 2222 Else Read(10,rec=R) (IRampG_four(i),i=1,9) Write(20,'(I4,F25.10,F18.10,2F23.10)') 1ibits(IrampG_four(5),0,10), 2(IRampG_four(1)+IRampG_four(2)*1.D-9), 3IRampG_four(3)+IRampG_four(4)*1.D-9, 4ibits(IRampG_four(5),10,22)*1.D9+IRampG_four(6)+ 4IRampG_four(7)*1.D-9, 5(IRampG_four(8)+IRampG_four(9)*1.D-9) Endif R=R+1 Enddo Endif R=R+1 Enddo Close(10) Close(20) 9999 Continue End Program
×
×
  • Create New...