Re: Parallel programming with FORALL?
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 26 Jan 2011 06:52:52 +0000 (UTC)
David Thompson <dave.thompson2@xxxxxxxxxxx> wrote:
(snip, I wrote)
The Unix C shell (/bin/csh) also has a similar foreach construct.
You can do things like:
foreach i ( `ls *.f` )
echo $i
gfortran $i
end
(snip)
But in both cases it is better to just use *.f instead of `ls *.f`
since the latter must be tokenized and if any of your filenames
include whitespace will produce wrong results, whereas globbing is
done in the shell and preserved (except in the very oldest original
shells no one would encounter by accident today). And if you have any
directories named something.f the former will give a clearer error
message, but neither will work right so don't do that.
When I was first working with unix, someone wrote a csh script
for me similar to:
#!/bin/csh
foreach i ( *$1* )
set j=`echo $i | sed s/$2/$3/`
echo mv $i $j
mv $i $j
end
(well, I have rewritten it a few times since, so it might not
be quite the same)
This allows one to do what on other systems can be done
with a rename command, like
rename *.for *.xyz
or
rename abc.* xyz.*
or a few other combinations that were useful at the time.
But I have also done foreach with more complicated `` expressions,
such as ones containing grep.
-- glen
.
- References:
- Parallel programming with FORALL?
- From: Daniel Carrera
- Re: Parallel programming with FORALL?
- From: Paul Thomas
- Re: Parallel programming with FORALL?
- From: Daniel Carrera
- Re: Parallel programming with FORALL?
- From: steve
- Re: Parallel programming with FORALL?
- From: nmm1
- Re: Parallel programming with FORALL?
- From: Uno
- Re: Parallel programming with FORALL?
- From: glen herrmannsfeldt
- Re: Parallel programming with FORALL?
- From: David Thompson
- Parallel programming with FORALL?
- Prev by Date: Re: Locate function for logical array
- Next by Date: Re: OT Does this look right?
- Previous by thread: Re: Parallel programming with FORALL?
- Next by thread: Re: Parallel programming with FORALL?
- Index(es):
Relevant Pages
|