[esp-r] Re: Perl script

David Garcia david.garcias at gmail.com
Tue Jul 27 10:57:04 BST 2010


Normally it should be perl but other users told me that python is more
useful,

Personaly I used PERL, to start programming, I recommend you to read the
book "Learning Perl" from Randal L.Schwartz,(O'reilly).

Normally your perl file should look like this: (FOR YOUR CHANGE GEOMETRY
SECTION)

--------------------------------------------------------------
$file = $ARGV[0];
$largo = $ARGV[1];
$ancho = $ARGV[2];
$alto = $ARGV[3];
$angulo = $ARGV[4];
$base = $largo*$ancho;

# Parse the perl sign pound (#)
$val = "#";

# open up MYFILE for writing
open(MYFILE,">$file");

#or die "Can't open up myfile: $file\n"; if we want the file to be readed!

# now this line format will automatically apply to MYFILE
format MYFILE =
@<geometry of test_zonep defined in: ../zones/test_zonep.geo
$val
GEN  test_zonep  test_zonep describes a for testing in perl  # type, name,
descr
       8       6   @###.###    # vertices, surfaces, rotation angle
        $angulo
@< X co-ord, Y co-ord, Z co-ord
$val
      0.00000     0.00000     0.00000  # vert   1
   @###.#####     0.00000     0.00000  # vert   2
    $largo,
   @###.#####  @###.#####     0.00000  # vert   3
    $largo,   $ancho
      0.00000  @###.#####     0.00000  # vert   4
          $ancho  .... CONTINUE
----------------------------------

and you can invoke it in linux by type:


./changegeo.pl ARGV1 ARGV2 ARGV3

then for your SIMULATE option check the cookbook for runing espr in text
mode.

you can so do a for in a bash file, and then take out the value you are
interested with "awk" (a language like perl) using this command: (FOR YOUR
EVALUATE SECTION)

awk '/Totals/ {print $2 "\n"}' prueba$i.cfg.wc_res.data > TOTAL

then put your statement

if Total == ValueYouWant

Exit for

and then voilà! :)

Is a little bit rudimentary but I hope this could help you.

Regards

-- 
David GARCIA SANCHEZ
------------------------------------------------------------
Département Systèmes Énergétiques Environnement
Ecole des Mines de Nantes
4, Rue Alfred Kastler
44300 Nantes
France
------------------------------------------------------------
Email: david.garcia-sanchez at emn.fr
Tel: +33 (0) 2 51 85 82 14
Mobile: +33 (0) 6 78 15 08 09
Fax: +33 (0) 2 51 85 82 99
------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.strath.ac.uk/archives/esp-r/attachments/20100727/7e86eca2/attachment.html 


More information about the esp-r mailing list