Re: Compiling SPECFUN and similar libraries



On 31 juil, 16:54, deltaquattro <deltaquat...@xxxxxxxxx> wrote:
Hi,

I often find in libraries downloaded from Netlib that some lines start
with CS or CD, like this:

CS REAL
CD DOUBLE PRECISION

To compile a single/double precision version of the code, all
occurences of CS/CD in the first two columns must be changed to
blanks. How can I do this automatically? Most text editors can replace
a string with another, also specifying that the first string must be a
whole word (in this way I avoid eliminating occurences of CS/CD inside
bigger strings) but I'd prefer to explicitly specify that CS/CD must
occur in the first two columns of a line. Maybe I want to be a bit too
safe :-) but since I have seen this "trick" so often in many
libraries, I was wondering if there is some standard Unix utility
which is commonly used to do this.

Best Regards,

deltaquattro

sed -e "s/^CS//" myfile.f > myfile.withoutCS

sed is called the Stream EDitor. To change CS and CD together :

sed -e "s/^CS//" -e "s/^CD//" myfile.f > myfile.withoutCSCD

meaning of the string after -e :

" : start of an instruction
s : change
/ : delimiter
^ : start of a line
CD : the string to modify
/ : delimiter
.... : the replacing string (here empty)
/ : final delimiter
" : end of the instruction

Of course you can apply it on many files using a loop :

for i in *.f ; do
j=`basename $i`
sed -e "s/^CS//" -e "s/^CD//" $i > $j.withoutCSCD
done

.



Relevant Pages

  • Compiling SPECFUN and similar libraries
    ... To compile a single/double precision version of the code, ... a string with another, also specifying that the first string must be a ... whole word (in this way I avoid eliminating occurences of CS/CD inside ... bigger strings) but I'd prefer to explicitly specify that CS/CD must ...
    (comp.lang.fortran)
  • Re: Why (0.09+0.01-0.1) is not equal to 0.09+0.01-0.1 ?
    ... > gives full accuracy by default, but also includes rounding algorithms ... > partitioned mantissa by without risk of overflow ... > Function D2BAs String ... the work involved in avoiding lost precision due to type ...
    (microsoft.public.excel)
  • Re: Programmers unpaid overtime.
    ... tokenizing a string correctly. ... ability to specify a set of delimiter tokens, ... >> postmodern attack on language itself, ... An the scientists, in turn, think a lot of that artistic talk about ...
    (comp.programming)
  • Re: Surprise in StrConv using vbProperCase
    ... > Your code will capitalize the first letter of a string. ... Use Split(string into array of words using blank as delimiter); ...
    (microsoft.public.access.modulesdaovba)
  • Re: VB vs C#
    ... Dim delimiter As String ... Dim testname As String ...
    (microsoft.public.dotnet.general)