Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
Quote:
Originally Posted by LMHmedchem
...
FORTRAN is a beast for io. All input has to be precisely formatted because you have to tell the FORTRAN code what to do with each individual character, including spaces, trailing zeros, etc. This doesn't look like f77, because the DO loop doesn't have a numbered CONTINUE statement. If you are using a more updated version of FORTRAN, it may be a little easier to use.
In my experience, the easiest thing to to with code like this is to create a c or cpp function to read the input file instead of reading it with the FORTRAN. In cpp, you can just create in input stream and say it's space delimited and dump your data into a vector. Then you can parse it out of the vector however you want. ...
Comments:
There are at least 2 methods to make input into Fortran easy. First is list-directed-input. That is signaled by the use of "*" as the format. That is apparently used in the OP fragment, and I show an example below.
I quite agree that a well-structured source is easier to understand (and therefore maintain) compared to mangled, messy code. That is why there are programs that do reformatting. One such is illustrated below.
Here is a script that demonstrates the points:
producing:
The source can be a mixture of leading 6-space or TABs. The formatter does a lot more than that, making reserved words UPPER case, indenting, etc.
Note that the input files are essentially free-format. The first has whitespace and commas for separators that are ignored, the second only whitespace, and leading zeros are ignored.
It is true that if one has fixed-form data, then one needs to craft matching formats. However, as shown, one can use the flexibility of Fortran features to make one's computing life pleasant.
Compared to writing c++ io routines (possibly necessitating learning yet another language) and fitting it into the scheme of linking with Fortran object code, I have generally chosen list-directed-input, or have taken a few minutes to work with specific formats.
I'm looking for some help in figuring why my little bit of code will not process any entries other then the first one in my list.
while read line ;do
hostname=${line//\"}
a=`ssh user@$hostname uptime;echo $?`
if ];then
dt=`date`
touch... (6 Replies)
hello guys,
i am having the below piece of code
error
()
{
echo"Press y /n"
read ans
case $ans in
y) main;;
n) exit
esac
}
In the abve code, read statement is not working i.e not waiting for user to enter input.
,i tested exit status its 1.
could anyone help me to do this
... (11 Replies)
While working on awk programming, i found that it doesn't understand 'read' statement. Then what's the use of 'continue' and 'break' statement in awk.
For ex:
awk '{k=1; while (k<10) {print $0; k++}}' emp.lst
Now, please say if I want to put the logic that after priting 1 line, it will ask for... (13 Replies)
hi,
this is my script #!/bin/ksh
cat temp_file.dat | while read line
do
read test
if ]; then
break
else echo "ERROR"
fi
done
when i execute this code , the script does wait for the user input . it directly prints "ERROR" and terminates after the no. of times as there... (3 Replies)
Hi Guys..
need some urgent help... I am stuck in something badly
I need to write a script which would read a sql statement (which might be a join/inner join/select/sub select etc. )
I need to read that sql statement ... and in the output I want all the table names and columns (doesn't... (4 Replies)
Hi there
I want to ask to a user something about each line of a file. This is my code:
#cat test.txt
first line
second line
third line
#cat test.sh
#!/bin/ksh
read_write () {
echo "Do you want to print the line (YES/NO)?\n"
read TEST
case ${TEST} in
YES) return 0;;
... (3 Replies)
Hi, I am reading the contents of a file in variables as -
cat ${var_file_name} | while read COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11
The problem is ... my file can have any number of columns - 5, 10, 11 ....
So i want a dynamic variable list as -
cat ${var_file_name} |... (8 Replies)
I have a script consisting of certain functions whose input is a file at same location. In that file i have written the name of anothe file at same location. The third file contains a word which act as a function in the first script.Let me give an example
i have a scrip file say 1.sh in which i am... (7 Replies)
Pls this is emergency.I have written a script which is taking input from another script. and the contents of my second script are acting as functions to my main script.Now the problem is that in one of the functions i want the script ececution to stop and start when user enters any character r... (2 Replies)
I was searching for an option where i can echo some strings together with the contents of a file.
Eg. I was to echo the below string to a file
"alter application PMS_ add variable CurrYear Y2009;" >> ${ESS_MAXL_DIR}/PMS_SUB.txt
The value 2009 is coming from a file called date.txt without the... (3 Replies)