fortran-时间的格式化输出
来源:互联网 发布:mac删除虚拟机 编辑:程序博客网 时间:2024/06/05 21:00
1 声明部分
implicit none real :: read_null # 用于读取时跳过输入文件中不需要的列 integer :: leap_year # 用于判断是否为闰年。 0是平年;1是闰年 integer,allocatable :: year(:), month(:), day(:), hour(:) # 时间间隔为1小时debug
2 输出时间格式生成
# 输出的时间格式生成,起始时段为净雨量文件中的起始时段 allocate(year(size(Q)),month(size(Q)),day(size(Q)),hour(size(Q))) ! 数组长度等于径流的长度 ! 读取初始时间 filename = trim(Address)//'\'//'data_rs.txt' open(10,file=filename,access='sequential',status='old') read(10,*) year(1),month(1),day(1),hour(1) close(10) do t=2,size(Q) leap_year = 0 ! 一般情况下,“小时”+1,而“日,月,年”不变,把它们放在后边处理 hour(t) = hour(t-1)+1 day(t) = day(t-1) month(t) = month(t-1) year(t) = year(t-1) !判断是否为闰年,确定二月的天数 if(mod(year(t),100)==0) then if(mod(year(t),400)==0) then leap_year = 1 end if else if(mod(year(t),4)==0) then leap_year = 1 end if end if ! 24时统一记为第二天0时 if(hour(t) == 24) then hour(t)=0 day(t) = day(t)+1 end if !超出一个月的最大天数,则计入下一个月 select case(month(t)) case(1,3,5,7,8,10,12) if (day(t)==32)then day(t) = 1 month(t)= month(t)+1 end if case(4,6,9,11) if(day(i)==31)then day(t) = 1 month(t)= month(t)+1 end if case(2) if(leap_year==1 .AND. day(t)==30)then day(t) = 1 month(t)= month(t)+1 elseif(leap_year==0 .AND. day(t)==29)then day(t) = 1 month(t)= month(t)+1 end if end select end do
3 输出
filename=trim(Address)//'\'//'output_path' open(10,file=filename) !write(10,"(5A6)") "year" ,"month", "day", "hour" ,"Q" do i=1,size(Q) write(10,"(4I5,F10.3)")year(i),month(i),day(i),hour(i),Q(i) end do close(10)
阅读全文
0 0
- fortran-时间的格式化输出
- fmt 格式化时间的输出
- fortran的输出格式
- 日期时间输出的格式化DateTime Formating
- C#日期和时间的格式化输出
- javascript格式化时间输出
- android格式化输出时间
- 格式化输出时间
- struts2格式化输出时间
- PHP 时间格式化输出
- 时间格式化输出SimpleDateFormat
- 格式化输出当前时间
- 时间格式化输出
- PHP格式化时间输出
- 时间格式化输出
- 时间格式化输出
- MFC中时间类的使用以及格式化输出时间
- Linux下的时间函数以及格式化输出时间
- 深度分析CNKI知网论文查重软件的系统区别
- 常用命令
- C++编程中类class的编写(二):含指针数据的类
- HDFS精华文章汇总
- 语音增强
- fortran-时间的格式化输出
- 决策树归纳算法Decision Tree
- AT&T-汇编语言与C语言联合编程
- 序列化与反序列化
- 设计reverse函数,将一个整数转化为其逆序数。
- Qt如何上传zip文件
- 无线局域网,有线局域网
- 【机器学习】GBDT梯度提升算法调参法总结II
- VMware Workstation虚拟机自动安装CentOS问题的解决方法