Fortran recursive I/O operation
文章目录
【注意】最后更新于 September 14, 2016,文中内容可能已过时,请谨慎使用。
最近在调试启用了OpenMP的fortran程序时,总是会报错并终止,错误信息如下
forrtl: severe (40): recursive I/O operation, unit -1, file unknown
Google相关信息,找到如下结果:
runtime I/O error in recursive function.
FAQ|MPC
递归IO占用问题 (Recursive I/O operation)
报错原因是“The Fortran standard prohibits starting an I/O operation on a unit while another operation on that same unit is in progress. ”
就是在write或print在调用一个通道号,且没有执行完毕时,调用了另一个函数,或者另一个线程,而这个函数或线程中又向相同的通道号输出了数据,造成了递归调用。
之后注释掉并行部分代码中的print *,...
以及write(*,*)...
,程序不再报错。
若想输出相关信息,根据Intel的Steve的说法,要先写入到变量中,之后再输出变量的值。
文章作者 Izumiko
上次更新 2016-09-14