24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 653  |  回复: 1

yhwsmile

金虫 (小有名气)

[交流] 【求助】求助:帮忙看下这个程序是怎么转二进制的咯,谢谢啊 已有1人参与

麻烦各位帮忙看看,这是一个对数据进行简单加密后,对数据进行二进制转换,子程序write_hd就是转二进制,子程序xzen_ja是数据加密~~~~

fortran不能面向对象,我现在想把这个程序转成VB,现在我看不懂这个程序是怎么转二进制的,麻烦各位虫友帮忙看看~~~

图片1为station.txt
图片2为数据格式
CODE:
program data_conv
      integer ns
      integer,allocatable :: sta(:)
      character t_r*3,cst*5
      integer(kind=2) tm(367)
      integer ln,ld,i_dim,ieof
      character datdir*50,outdir*50,hisdir*50,logdir*50   !!!!资料目录,输出结果目录,阈值文件存储目录

          !!!!!!!读取目录文件
          open(10,file='config.txt',err=2050)
          read(10,'(12x,i4)',err=2050)ns
          read(10,'(12x,a50)',err=2050)datdir  !二进制文件的存储路径
          read(10,'(12x,a50)',err=2050)outdir
          read(10,'(12x,a50)',err=2050)hisdir
          read(10,'(12x,a50)',err=2050)logdir
          close(10)
          goto 90
2050  print*,'input the direct access is err, the run will stop'
      stop 9999

90    continue

    allocate(sta(ns))
      t_r='ctm'
open(110,file='station.txt')  !读文件名,只有站号。
do i=1,ns
read(110,*)sta(i)
enddo
close(110)
do ln=1,ns
       write(cst,'(i5)')sta(ln)
       tm=32766
       open(20,file='e:\extr\原始资料\hisctm\'//t_r//cst//'.dat',err=999)  !指示文本文件的路径
98     read(20,*,end=999)nsta,nya
       read(20,'(30i6)',end=999)(tm(ld),ld=1,366)
       ly=nya-1950
       ieof=6915
       call write_hd(t_r,sta(ln),ly,i_dim,tm,ieof,datdir)
       goto 98   
999   continue               
      close(20)
      enddo  !!!for do ln=1,ns  
      deallocate(sta)   
      
end program data_conv

subroutine write_hd(t_r,ist,irecs,i_dim,b0,ieof,wysm)
       parameter(nn=7)   !!!!定义需要处理的变量数
       integer(kind=2) b0(i_dim)
       integer ieof,ist,irecs
       character t_r*3,stat*5,ysm(nn)*3,ysf(nn)*7,wysm*50
       data ysm/'crd','crr','ctm','ctn','ctd','crs','cci'/
       data ysf/'hiscrd\','hiscrr\','hisctm\','hisctn\','hisctd\','hiscrs/','hiscci\'/
           integer len1
!!!!!!!crd08-08时降水量,crr20-20时降水量,ctm20-20时最高气温,ctn20-20时最低气温,ctd20-20时平均气温
      
    if(ieof/=6915)then
       ieof=-99
       print*,'您无权进行此操作,请联系管理员'
       return
       endif
      
       if(i_dim/=367)then
       ieof=-10
       print*,'资料数组长度错误,i_dim=   ',i_dim
       return
       endif
      
       if(i_dim==367)then
!!!!!!!判断当前需要写入的变量        
        do k=1,nn
        if(t_r==ysm(k))kk=k
        enddo
        
        do i=1,i_dim-1
        ix0=b0(i)
!!!!!!!对当前写入数据做简单的变换        
     if(t_r(1:2)=='cr') call xzen_ja(ist,i+5,ix0)
        if(t_r(1:2)=='ct') call xzen_ja(ist,i+10,ix0)
        b0(i)=ix0
        enddo
        b0(i_dim)=irecs+1950   !!!!!!数组最后一个值赋为年
        
!!!!!!!写数据文件
        write(stat,'(i5)')ist
        close(8)
                len1=len_trim(wysm)
        open(8,file=wysm(1:len1)//ysf(kk)//ysf(kk)//stat//'.dat',access='direct',recl=2*i_dim,err=99)

        write(8,rec=irecs,err=999)b0

        close(8)
        ieof=1
        return
        
       endif
      
99     ieof=0
       print*,'打开文件错误',wysm(1:len1),ysf(kk),ysm(kk),stat,'.dat'
       close(8)
       return
999    ieof=-2
       print*,'写入文件错误',wysm(1:len1),ysf(kk),ysm(kk),stat,'.dat'
       close(8)
       return
      
end subroutine write_hd

!!!!对输入的数值ix0做简单转换
subroutine xzen_ja(ist,i,ix0)
      integer ist,i,ix0
      integer maxx,mins
      
      maxx=30000
      mins=-9990
      is3=mod(ist,3)
      it3=mod(i,3)
      it5=mod(i,5)
      it7=mod(i,7)
      it11=mod(i,11)
      it13=mod(i,13)
      it17=mod(i,17)
      
      if(ix0mins)then
      if(is3==0)then
       if(it3==0)ix0=ix0+it5+it17+it13
       if(it3==1)ix0=ix0+it7+it17+it11
       if(it3==2)ix0=ix0+it5+it11+it13
      else
       if(it3==0)ix0=ix0+it7+it11+it13
       if(it3==1)ix0=ix0+it3+it13+it11
       if(it3==2)ix0=ix0+it5+it11+it17
      endif
      else
       ix0=ix0
      endif
      
      return
end subroutine xzen_ja




[ Last edited by nono2009 on 2010-11-11 at 07:26 ]
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zyj8119

木虫 (著名写手)

引用回帖:
Originally posted by yhwsmile at 2010-09-29 09:40:37:
麻烦各位帮忙看看,这是一个对数据进行简单加密后,对数据进行二进制转换,子程序write_hd就是转二进制,子程序xzen_ja是数据加密~~~~

fortran不能面向对象,我现在想把这个程序转成VB,现在我看不懂这个程序是 ...

逐项相除法求余???
好好学习,天天向上。
2楼2010-11-09 19:49:54
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 yhwsmile 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 266分,求材料相关专业调剂 +4 哇呼哼呼哼 2026-03-30 4/200 2026-03-30 16:17 by wangjy2002
[考研] 283求调剂(080500) +14 A child 2026-03-27 14/700 2026-03-30 12:06 by 探123
[考研] 材料与化工272求调剂 +21 阿斯蒂芬2004 2026-03-28 21/1050 2026-03-30 10:52 by 晴空210210
[考研] 282求调剂 +4 wcq131415 2026-03-24 4/200 2026-03-30 10:39 by Delta2012
[考研] 375求调剂 +6 雨夏整夜 2026-03-29 6/300 2026-03-30 10:21 by herarysara
[考研] 【求调剂】085601材料工程专硕 | 总分272 | +7 脚滑的守法公民 2026-03-27 7/350 2026-03-29 20:21 by dophin1985
[考研] 考研调剂 +7 小蜡新笔 2026-03-29 7/350 2026-03-29 19:00 by 学员8dgXkO
[考研] 289求调剂 +5 BrightLL 2026-03-29 5/250 2026-03-29 17:24 by zhyzzh
[考研] 一志愿北京理工大学本科211材料工程294求调剂 +8 mikasa的围巾 2026-03-28 8/400 2026-03-29 12:48 by 无际的草原
[硕博家园] 招收生物学/细胞生物学调剂 +4 IceGuo 2026-03-26 5/250 2026-03-29 01:25 by griffith2014
[考研] 本科新能源科学与工程,一志愿华理能动285求调剂 +7 AZMK 2026-03-28 11/550 2026-03-28 21:01 by xxxsssccc
[考研] 一志愿南京航空航天大学材料学硕求调剂 +3 @taotao 2026-03-28 3/150 2026-03-28 10:26 by JourneyLucky
[考研] 340求调剂 +5 jhx777 2026-03-27 5/250 2026-03-28 04:18 by fmesaito
[考研] 298调剂 +3 jiyingjie123 2026-03-27 3/150 2026-03-27 11:57 by wxiongid
[考研] 调剂 +4 柚柚yoyo 2026-03-26 4/200 2026-03-26 20:43 by fmesaito
[考研] 一志愿 南京邮电大学 288分 材料考研 求调剂 +3 jl0720 2026-03-26 3/150 2026-03-26 13:39 by zzll406
[考研] 网络空间安全0839招调剂 +4 w320357296 2026-03-25 6/300 2026-03-25 17:59 by 255671
[考研] 347求调剂 +4 L when 2026-03-25 4/200 2026-03-25 13:37 by cocolv
[考研] 一志愿南航材料专317分求调剂 +5 炸呀炸呀炸薯条 2026-03-23 5/250 2026-03-24 16:52 by 星空星月
[考研] 085404电子信息284分求调剂 +4 13659058978 2026-03-24 4/200 2026-03-24 12:15 by syl20081243
信息提示
请填处理意见