FORTRAN WRITE() [英] FORTRAN WRITE()

查看:347
本文介绍了FORTRAN WRITE()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开始之前,我必须先说明我是FORTRAN的新手。我正在维护一段从1978年开始的遗留代码。它的目的是从文件中读取一些数据值,处理这些值,然后将处理后的值输出到另一个文本文件中。



给定以下FORTRAN代码:

  INTEGER NM,STUBS,I,J,K 
PARAMETER NM = 67,STUBS = 43)
INTEGER * 4 MDS(STUBS,NM)

CALL OPEN $ A(A $ RDWR,'/ home / test / data.txt',MAXPATHLEN ,1)
CALL OPEN $ A(A $ WRIT,'out',11,2)

DO 90 I = 1,2
READ(1,82)STUB
! - 数据处理 - !
WRITE(2,80)STUB,(MDS(I,J),J = 1,24)
90继续

80格式(/ 1X,A24,25I5)
82 FORMAT(1X,A24,25F5,1)

我的问题是关于 WRITE()语句。

据我所知,(2,80)是指打开的文件输出流并指向文件'out'并由数字2引用。我知道80引用了标签80引用的格式语句。



STUB 用于存储从文件输入1读取的值。这些值是处理内容,并保存到 MDS(I,J) code>在我已经省略的! - 数据处理 - !部分中。



我假设(MDS(I,J),J = 1,24)会写24个整数值到输出文件?换句话说,从1到24循环?

解决方案

是的,您是正确的。语法(MDS(I,J),J = 1,24)是一个隐含DO循环,并且通常用于这种情况。


Before I begin, I must preface by stating that I am a novice when it comes to FORTRAN. I am maintaining a legacy piece of code from 1978. It's purpose is to read in some data values from a file, process the values, and then output the processed values to another text file.

Given the following FORTRAN code:

      INTEGER NM,STUBS,I,J,K
      PARAMETER (NM=67,STUBS=43)
      INTEGER*4 MDS(STUBS,NM)

      CALL OPEN$A(A$RDWR,'/home/test/data.txt', MAXPATHLEN,1)
      CALL OPEN$A(A$WRIT,'out',11,2)

      DO 90 I=1,2
          READ(1,82) STUB     
          !-- data processing --!     
          WRITE(2,80) STUB,(MDS(I,J),J=1,24)
90    CONTINUE

80    FORMAT(/1X,A24,25I5)
82    FORMAT(1X,A24,25F5,1)

My question is in regards to the WRITE() statement.

I understand that (2,80) refers to the file output stream opened and pointing to the file 'out' and referenced by the numeral 2. I understand that 80 refers to the format statement referenced by label 80.

STUB is used to store the values read from file input 1. These values are what is processed, and saved into MDS(I,J) in the !-- data processing --! section that I have omitted.

Am I correct in assuming that (MDS(I,J),J=1,24) will write 24 integer values to the output file? In other words, looping from 1 to 24?

解决方案

Yes, you are correct. The syntax (MDS(I,J), J=1,24) is an "implied DO-loop" and is commonly used in situations like this.

这篇关于FORTRAN WRITE()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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