Search code examples
fortranopenmp

How to continue an OpenMP directive on the next line in free-from Fortran?


I have a line of a Fortran code, e.g.,

    !$omp do private(aa, bb, cc) schedule(dynamic) reduction(+:alpha, beta, gamma) 

Suppose this line contains several arguments and the length exceeds 132 characters, gfortran will lead to error message. I tried to use & to break the line. But I am not sure how to start the next line. As other case, directly start the next line without ! leads to Error: Syntax error in OpenMP variable list at (1).

How to break the 132 characters limit for omp line?


Solution

  • You can write multiline omp statements by ending with & and staring a newline with $omp.

    Example

    !$omp do private(aa, bb, cc) &
    !$omp schedule(dynamic)      &
    !$omp reduction(+:alpha, beta, gamma) 
    ...
    !$omp end do