I got fortran code of nasty old syntax and want to port to new syntax.
My sed command
sed -nr 'N;s/\n\s*\d\D\s*//g' file
should find numbered line breaks, but doesn't work for a reason I don't know. I already had a look in numberous multiline-sed questions here and I still can't fid my misunderstanding. From my understanding the command works like this:
N append next line to pattern space; thus pattern space has two lines with \n in between
s///g usual search-replace
\n\s*\d\D\s* matches a newline followed by \s*, a digit, a non-digit and a \s* again
The source code looks like
if(condition) then
call func1(v1, v2, v3, v4
1 ,v5,v6,v7)
else
call func2(v1, v2, v3, v4
1 ,v5,v6,v7)
endif
call MPI_BCAST(num(1),1,MPI_DOUBLE_PRECISION
1 ,masterid,comm,mpinfo)
21 format(' text',2x,f10.5)
and should transform to the target code
if(condition) then
call func1(v1, v2, v3, v4,v5,v6,v7)
else
call func2(v1, v2, v3, v4,v5,v6,v7)
endif
call MPI_BCAST(num(1),1,MPI_DOUBLE_PRECISION,masterid,comm,mpinfo)
21 format(' text',2x,f10.5)