| 查看: 448 | 回复: 2 | |||
| 当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖 | |||
[交流]
【求助】为什么两种写法得到的值不一样?
|
|||
|
为什么把if语句放到不同的位置,结果就不一样了呢?请大家帮忙分析一下,多谢。 写法一(判断语句为h0(t)/=0): t0=0 do ntel=1, npoints neworig = .false. if (t0.eq.0) then neworig = .true. elseif (ntel-time0(t0).eq.it0)then neworig = .true. endif if (neworig) then t0 = t0 + 1 ! update number of t=0 time0(t0) = ntel ! store the time of t=0 h0(t0) = h(ntel) endif do t=1, t0 ! update tcf for t=0 delt=ntel-time0(t)+1 ! actual time minus t=0 if(h0(t)/=0.and.(delt.lt.npoints)) then ntime(delt) = ntime(delt)+1d0 tcf(delt)=tcf(delt)+h(ntel)*h0(t) tcf0(delt)=tcf0(delt)+h0(t)*h0(t) endif enddo enddo 写法二(判断语句为if (h(ntel)/=0) then) t0=0 do ntel=1, npoints neworig = .false. if (h(ntel)/=0) then if (t0.eq.0) then neworig = .true. elseif (ntel-time0(t0).eq.it0)then neworig = .true. endif endif if (neworig) then t0 = t0 + 1 ! update number of t=0 time0(t0) = ntel ! store the time of t=0 h0(t0) = h(ntel) endif do t=1, t0 ! update tcf for t=0 delt=ntel-time0(t)+1 ! actual time minus t=0 if(delt.lt.npoints) then ntime(delt) = ntime(delt)+1d0 tcf(delt)=tcf(delt)+h(ntel)*h0(t) tcf0(delt)=tcf0(delt)+h0(t)*h0(t) endif enddo enddo |
» 猜你喜欢
论文终于录用啦!满足毕业条件了
已经有10人回复
2025年遐想
已经有4人回复
投稿Elsevier的杂志(返修),总是在选择OA和subscription界面被踢皮球
已经有8人回复
自然科学基金委宣布启动申请书“瘦身提质”行动
已经有4人回复
求个博导看看
已经有18人回复
» 抢金币啦!回帖就可以得到:
成都理工大学全国重点实验室公开诚聘绿色有机合成方向联培生及科研助理
+1/79
坐标济南,山东农科院招 有机合成 or 药物化学 联培硕士研究生
+1/43
新年快乐!祝各位诸事顺遂!
+1/42
华中科技大学龚江研究员课题组诚招博士研究生、科研助理和博士后
+3/39
西南交通大学前沿院碳中和与物质循环利用课题组招收博士生
+1/29
上海大学昝鹏教授、军事医学研究院伯晓晨研究员/倪铭副研究员 课题组招聘博士生
+2/18
大叔征婚
+1/11
复旦大学聂志鸿团队招聘聚电解质方向博士后和科研助理
+1/10
博士/硕士招生
+1/10
中国科学院苏州纳米所院士团队博士后岗位招聘
+1/5
海南大学化学院—功能分子器件团队博士后招聘
+1/4
西南交通大学李义兵课题组博士及博士后招聘
+1/4
深容SCI智能体四大模块:Method, Introduction, Discussion, Abstract
+1/3
中科院上海有机所何智涛课题组招收2名博士后
+1/3
英国博导招CSC博士生
+1/2
国家级人才课题组招收生物学相关专业2026年入学博士生
+1/2
香港中文大学(深圳)张昭宇教授课题组下一代半导体激光器概念验证中心(筹)招聘工程
+1/2
福州大学梁宇航副教授招收2026年申核制博士研究生/硕士研究生(理论计算方向)
+1/1
2026年国家级海外人才(启明计划&火炬计划)申报政策常见问题及答疑
+1/1
西南交通大学李义兵课题组博士及博士后招聘
+1/1







回复此楼