FORTRAN90阵列读取空白值作为空 [英] Fortran90 Array read blank values as null

查看:251
本文介绍了FORTRAN90阵列读取空白值作为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读数据FRAM一个外部文本文件(30行,第7列),每个行被分隔以一,。我已经缺失值重新psented为$ P $,,。当我读数据到一个二维数组的缺失值被替换为0.00,但我已经在数据中的0.00太超值了。当我计算平均计数(件数(n))showd是计数 - (缺失值的数目)。如何动态挑缺失值。

谢谢
斯里兰卡

DATA

  337.60,220.40,0.00,0.00,200.42,216.61,261.04
323.00,249.20,65.30,0.00,201.93,210.91,309.98
116.80,474.80,0.00,0.00,203.43,215.76,234.93
72.10,505.90,0.00,0.00,204.93,215.72,233.47
148.30,771.70,0.00,0.00,206.44,217.00,239.05
90.70,287.20,0.00,0.00,207.94,215.43,216.85
337.20,334.50,10.20,0.00,209.45,226.85,306.57
142.50,142.80,0.00,0.00,210.95,240.09,240.31
279.10,289.60,51.80,0.00,212.45,227.75,262.30
273.60,337.70,0.00,0.00,213.96,256.86,223.66
332.40,425.60,0.00,0.00,215.46,238.36,237.63
45.70,299.30,0.00,0.00,216.96,223.92,241.41
49.10,529.40,0.00,0.00,218.47,235.81,282.17
185.30,331.80,38.00,0.00,219.97,235.81,309.29
552.90,454.80,0.00,0.00,221.47,224.60,269.09
176.20,441.60,0.00,0.00,222.98,232.44,293.95
170.00,0.00 ,,,, 327.96
200.00,0.00 ,,,, 291.69
241.20,156.00,0.00,0.00,227.49,235.55,278.66
118.00,383.20,3.20,0.00,228.99,269.28,325.31
62.00,189.70,0.00,0.00,230.50,248.73,266.95
400.20,244.20,0.00,0.00,232.00,239.70,271.27
163.70,826.60,0.00,500.00,233.50,245.06,294.98
250.40,236.60,0.00,0.00,235.01,261.72,288.24
51.30,684.20,0.00,0.00,236.51,245.06,237.37
412.50,128.90,0.00,500.00,238.01,245.16,268.66
452.00 ,,,,,, 314.68
481.00,155.50,0.00,0.00,241.02,278.72,348.44
162.20,201.90,0.00,500.00,242.52,250.36,255.58
171.80,152.00,0.00,500.00,244.03,246.85,339.06


解决方案

您似乎没有在你的数据负值,如何将数据传递到FORTRAN,在那里你替换之前做一些pre-处理',,'具有一个负值,例如用

  SED的/ ,, /, -  1 / G'

然后你就可以很容易地在Fortran程序识别这些无效的数据,并相应地对待它。

I'm reading data fram a external text file (30 Rows, 7 Columns), each row is seperated with a ",". I have missing values represented as ",,". When i read data into a two dimensional array the missing value is replaced with 0.00, but i have a 0.00 value in the data too. When i am computing average the count (number of items (n)) showd be count - (number of missing values). How can i pick the missing values dynamically.

Thanks Sri

DATA

337.60,220.40,0.00,0.00,200.42,216.61,261.04
323.00,249.20,65.30,0.00,201.93,210.91,309.98
116.80,474.80,0.00,0.00,203.43,215.76,234.93
72.10,505.90,0.00,0.00,204.93,215.72,233.47
148.30,771.70,0.00,0.00,206.44,217.00,239.05
90.70,287.20,0.00,0.00,207.94,215.43,216.85
337.20,334.50,10.20,0.00,209.45,226.85,306.57
142.50,142.80,0.00,0.00,210.95,240.09,240.31
279.10,289.60,51.80,0.00,212.45,227.75,262.30
273.60,337.70,0.00,0.00,213.96,256.86,223.66
332.40,425.60,0.00,0.00,215.46,238.36,237.63
45.70,299.30,0.00,0.00,216.96,223.92,241.41
49.10,529.40,0.00,0.00,218.47,235.81,282.17
185.30,331.80,38.00,0.00,219.97,235.81,309.29
552.90,454.80,0.00,0.00,221.47,224.60,269.09
176.20,441.60,0.00,0.00,222.98,232.44,293.95
170.00,,0.00,,,,327.96
200.00,,0.00,,,,291.69
241.20,156.00,0.00,0.00,227.49,235.55,278.66
118.00,383.20,3.20,0.00,228.99,269.28,325.31
62.00,189.70,0.00,0.00,230.50,248.73,266.95
400.20,244.20,0.00,0.00,232.00,239.70,271.27
163.70,826.60,0.00,500.00,233.50,245.06,294.98
250.40,236.60,0.00,0.00,235.01,261.72,288.24
51.30,684.20,0.00,0.00,236.51,245.06,237.37
412.50,128.90,0.00,500.00,238.01,245.16,268.66
452.00,,,,,,314.68
481.00,155.50,0.00,0.00,241.02,278.72,348.44
162.20,201.90,0.00,500.00,242.52,250.36,255.58
171.80,152.00,0.00,500.00,244.03,246.85,339.06

解决方案

You do not seem to have negative values in your data, how about doing some pre-processing before passing the data to fortran, where you replace the ',,' with a negative value, for example with

sed 's/,,/,-1,/g'

Then you can easily identify these invalid data in your Fortran program and treat it accordingly.

这篇关于FORTRAN90阵列读取空白值作为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆