I am trying to understand a small read function in my program I am trying to decipher.The code is below
READ (LREST, END=350, ERR=350) ICHR
IF (ICHR .EQ. ICKLNK) THEN
DO L = 1, 4
READ (LREST, END=350, ERR=350)
ENDDO
So basically LREST is some kind of an argument provided for this subroutine this function is in. However, I found that LREST is not defined anywhere(used grep to see where LREST is defined in my *.f files. So my questions is what is that LREST doing there in READ function. I thought the location LREST is at is where the unit is defined.
Second questions is that ICHR is a 16 character string variable define for this subroutine. However, the contents of ICHR have not been assigned. I have no idea what this READ function is trying to read from.
Going over to IF statement, ICKLNK is another 16 character string variable with a defined strings. Because ICHR is not defined, does that mean this if statement never gets entered in?
Finally, the do loop( or for loop) has variable L in it but it is not even being used for read function inside of the loop.
Im a beginning in fortran so I may just be lacking a very basic knowledge but if you know an answer to my question please let me know. Thanks!
Han
答案 0 :(得分:1)
LREST指定单位编号(如果是字符,则为内部文件)是正确的。您似乎建议LREST是此子例程或函数中的参数,这意味着它的值是由调用该函数的任何人传入的。只向我们展示一小段代码,这使得很难提供更多细节。
同样,你说ICHR是一个过程的参数,所以它接受了调用传入的任何值。 ICLNK可能类似,但你没有显示所有代码。
DO(非for)循环使用L作为计数器;它不需要在循环内引用。