gfortran error: unexpected element '\' in format string at (1)

后端 未结 3 1878
名媛妹妹
名媛妹妹 2020-12-21 15:25

I have a project written in VS2010 with Intel Visual Fortran. I have a dump subroutine to write a 2D matrix into file:

subroutine Dump2D(Name,Nx,Ny,Res)
             


        
3条回答
  •  [愿得一人]
    2020-12-21 16:01

    The edit descriptor \ relates to backslash editing. This is a non-standard extension provided by the Intel compiler (and perhaps others). It is not supported by gfortran.

    Such backslash editing is intended to affect carriage control. Much as in this answer such an effect can be handled with the (standard) non-advancing output.1

    As you simply want to output each column of a matrix to a record/line you needn't bother with this effort.2 Instead (as you'll see in many other questions):

    do i=1,Ny
       write(10,fmt="(*(D21.13))") Res(:,i)
    end do
    

    There are also other approaches which a more general search will find.


    1 The Intel compiler treats \ and $ in the same way.

    2 There are subtle aspects of \, but I'll assume you don't care about those.

提交回复
热议问题