How to break to new line in Fortran when printing?

后端 未结 2 1494
名媛妹妹
名媛妹妹 2021-01-14 15:56

It is very simple query but I\'m not able to find the exact solution. How to break to new line when printing in Fortran?

for example

print*,\'This i         


        
2条回答
  •  情书的邮戳
    2021-01-14 16:17

    There are a number of ways to manage what you want. We can either print blank records or explicitly add a newline character.

    A newline character is returned by the intrinsic function NEW_LINE:

    print '(2A)', 'First line', NEW_LINE('a')
    print '(A)', 'Second line'
    

    NEW_LINE('a') is likely to have an effect like ACHAR(10) or CHAR(10,KIND('a')).

    A blank record can be printed by having no output item:

    print '(A)', 'First line'
    print '(A)'
    print '(A)', 'Second line'
    

    Or we can use slash editing:

    print '(A,/)', 'First line'
    print '(A)', 'Second line'
    

    If we aren't using multiple print statements we can even combine the writing using these same ideas. Such as:

    print '(A,:/)', 'First line', 'Second line'
    print '(*(A))', 'First line', NEW_LINE('a'), NEW_LINE('a'), 'Second line'
    

    NEW_LINE('a') could also be used in the format string but this doesn't seem to add much value beyond slash editing.

提交回复
热议问题