Scripting with executables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting with executables
# 8  
Old 05-12-2013
Hi.

OK, good, thanks.

Now where are the variables infile and outfile set (defined, assigned, given a value, etc.) Please post that code ... cheers, drl
# 9  
Old 05-12-2013
here is where they are defined
Code:
      character*70 infile,outfile
      integer run_mode
      common/mode/run_mode,infile

# 10  
Old 05-12-2013
Hi.

OK, now where and how are they set with a value? ... cheers, drl
# 11  
Old 05-12-2013
Code:
      write(*,*) 'input event file: (e.g. events.lhe)'
      read(*,'(a)')  infile
c
      write(*,*) 'name for output file: (e.g. dec-events.lhe)'
      read(*,'(a)')  outfile

# 12  
Old 05-12-2013
Hi.

Here is a sample script that simulates running your Fortran program with 3 pairs of filesnames, but all the remainder of the data is the same.

If the output looks something like you want it to, then I'll post the skeleton Fortran code.
Code:
#!/usr/bin/env bash

# @(#) do-all-files	Processing with static data, but different pairs of files.

pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C gfortran

FILE=${1-"file-pairs"}

pl " File of input, output filename pairs, $FILE:"
head $FILE

i=1
pl " Processing pairs of files:"
while read input output
do
echo 
echo "-----"
echo " Iteration $i"
echo
./a.out <<EOF
3
$input
$output
rho
5
EOF
i=$( expr $i + 1 )
done < <( cat $FILE )

exit 0

producing:
Code:
% ./do-all-files 

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0.8 (lenny) 
bash GNU bash 3.2.39
gfortran GNU Fortran (Debian 4.3.2-1.1) 4.3.2

-----
 File of input, output filename pairs, file-pairs:
i1 o1
input-2 output-2
in_3.txt out_3.txt

-----
 Processing pairs of files:

-----
 Iteration 1


   Input run mode:
  Run mode is            3

 input event file: (e.g. events.lhe)
  input is i1                            

 name for output file: (e.g. dec-events.lhe)
  output is o1                            

  Input particle to be decayed (e.g. t~):
  particle is rho                           

 1   ta- -> vt   e- ve~           
 2   ta- -> vt  mu- vm~           
 3   ta- -> vt   l- vl~ (e+mu)    
 4   ta- -> vt   pi-              
 5   ta- -> vt  rho(770)-         
 your choice is:
  mode is:           5

-----
 Iteration 2


   Input run mode:
  Run mode is            3

 input event file: (e.g. events.lhe)
  input is input-2                       

 name for output file: (e.g. dec-events.lhe)
  output is output-2                      

  Input particle to be decayed (e.g. t~):
  particle is rho                           

 1   ta- -> vt   e- ve~           
 2   ta- -> vt  mu- vm~           
 3   ta- -> vt   l- vl~ (e+mu)    
 4   ta- -> vt   pi-              
 5   ta- -> vt  rho(770)-         
 your choice is:
  mode is:           5

-----
 Iteration 3


   Input run mode:
  Run mode is            3

 input event file: (e.g. events.lhe)
  input is in_3.txt                      

 name for output file: (e.g. dec-events.lhe)
  output is out_3.txt                     

  Input particle to be decayed (e.g. t~):
  particle is rho                           

 1   ta- -> vt   e- ve~           
 2   ta- -> vt  mu- vm~           
 3   ta- -> vt   l- vl~ (e+mu)    
 4   ta- -> vt   pi-              
 5   ta- -> vt  rho(770)-         
 your choice is:
  mode is:           5

Let me know ... cheers, drl
# 13  
Old 05-13-2013
Hi drl,

this is kind of what I want, do you parse the arguments in command line or you simply embed them in your code?
# 14  
Old 05-13-2013
Hi.

These are in a "here document". You can place $1, $2, etc., into the here document if you wanted. Notice that I read a file of filename pairs and placed those variables in the here document.

The reason I used the here document is that the Fortran was coded to read from STDIN (usually the keyboard), so using the here document avoids changing the Fortran.

How would you *like* it to be executed -- what would be a typical run, with (if I understand you) a few input and output files? My understanding is that you wanted to keep the other settings (parameters) constant for a series of runs.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Finding All Pro *C executables

Hi , I want to find all Pro *C executables in a directory say /. When i fire file command on Pro*c file it gives below o/p ELF-64 executable object file - PA-RISC 2.0 (LP64) my system is HP-UX eux012 B.11.23 U 9000/800 151107499 unlimited-user license but when i fire file on a C... (2 Replies)
Discussion started by: Jcpratap
2 Replies

2. Shell Programming and Scripting

Searching for executables

Hello Unix users, this is my first post here. :) I want to search a directory (and subdirectories) for executable files (files with rwx------ permission) and move them to a different folder. What Unix commands can accomplish this? (2 Replies)
Discussion started by: Sagan_Radiation
2 Replies

3. Solaris

C compiler cannot create executables

Hi, I'm trying to compile Apache2.2 (I know it is available as a package) on a fresh install of Solaris Express 11. I've installed gcc-3 and gnu-bintutils via pkg. The config.log is attached (as config.txt). I don't see what I'm missing. Thanks, Doug (1 Reply)
Discussion started by: Doug_M
1 Replies

4. Programming

Compare two executables

Hi - I have two complex (for me at least) make files. The older one creates a succesful executable. The later one uses if statements to conditionally make different versions of the executable. The 2nd produces an executable that fails. I have "eyeballed" the differences in the Make files and run... (18 Replies)
Discussion started by: BrighterLater
18 Replies

5. UNIX for Dummies Questions & Answers

Searching executables datewise

I want to search executable files after a particular time and date , i.e. in a folder if a file has been accessed,modified or changed after a particular date and time ,then that file should be listed , and current date and time should be stored in a file so that when i again run the script ,it ... (6 Replies)
Discussion started by: glamo_2312
6 Replies

6. UNIX for Dummies Questions & Answers

Regarding shell scripts to executables

Hi, I have written a shell script for automating some of our repetitive activities. I want all my colleagues to use my script and do the activities automatically by just running the script. But I do not want them to see the code. Is there a way we can generate something like an executable... (16 Replies)
Discussion started by: lokachari
16 Replies

7. Programming

Error creating executables

hi, I am getting error when trying to create binaaries for Xerces C++ error is configure:error:installation:cofihuration error:compiler cant create executables ??????????? Thanks in advance im using AIX flavour of IBM Im using ./configure command to create binaries.Its saying c... (6 Replies)
Discussion started by: chetan2309
6 Replies

8. Programming

executables ending with *

Hi All, I m very new to unix. I have a basic doubt .. In unix I m seeing that there is a * at the end of by executable name (exe1*).. Wht is the significance of that Thanks a lot in advance (2 Replies)
Discussion started by: binums
2 Replies

9. UNIX for Dummies Questions & Answers

cannot create executables

I am trying to install PROFTPD-1.2.7 on a SCO OpenServer 5.0.6 Server with a gcc-2.95.2 installed the VOLS files from http://www.caldera.com/skunkware. The problem I am having is when I try to run ./configure in the proftpd directory I get this error: # ./configure checking build system... (6 Replies)
Discussion started by: stufine
6 Replies

10. UNIX for Dummies Questions & Answers

cksum all executables on drive

I know I can run the cksum command for multiple files in a directory and send the results to a new file. EX.) # cd /usr # cksum *_ex* > /tmp/cksumusr.txt But I can't figure out how to run this command on multiple files in all directories on drive. Is it possible to do this, without having... (2 Replies)
Discussion started by: crazykelso
2 Replies
Login or Register to Ask a Question