我在一家公司工作,该公司使用一堆旧的Fortran代码。我已经精通bash脚本,这样我就可以及时地运行所有这些程序。
目前,我必须运行~ 13个不同的Fortran程序才能得到11个扇区中的1个结果。因此,143个程序对应一个完整的结果。我希望能够创建8或9完整的结果使用程序中的不同输入在及时的方式。
理想的情况是在GUI中设置,在不同的选项卡上填写输入表单,然后当所有表单都填写完毕后,只需单击一个按钮即可获得结果。
我正处在一个十字路口,因为我已经有一个bash脚本几乎可以做到这一点。我没有Fortran背景,但我想我可能需要学习如何让它工作。不过,我确实有一点VBA知识。
所以我想问的是,最好的方法是什么?使用VBA编写shell脚本并执行?是否有某种组合的Fortran GUI界面,可以将一堆变量传递给程序?
这些程序被设置为从用户和由先前程序创建的文件中获取输入。到目前为止,shell脚本和程序提示符是如何设置的:
#This file is a combination of NEWlen to bbdist as of now 4/5/2012
#M. Conley
####################################################################################
##################### Please input all of your back break #####################
##################### parameters in the block bellow! #####################
####################################################################################
project="Cobre Panama, Botija -2012"
#Example of format
#sec1="lwmin lwmax rwmin rwmax numberofcells"
#----------------------------
#| S |M |Max|Max| M| N |S
#| e |i |Lft|Pln| a| u |e
#| c |n |Wed| | x| m |c
#| t | | | | | b |t
#| o |L |or |or | R| e |o
#| r |e | | | i| r |r
#| |f |Min|Min| g| |
#| |t |PS |Rgt| h| o |
#| v | | |Wed| t| f |D
#| a |W | | | | |D
#| r |e | | | W| c |R
#| |d | | | e| e |
#| | | | | d| ls|
#---------------------------
sec1="96 166 206 276 20 186"
sec2="127 197 237 307 20 217"
sec3="178 248 288 358 12 268"
sec4="225 295 335 45 21 315"
sec5="258 328 368 78 14 348"
sec6="297 7 47 117 31 27"
sec7="315 25 65 135 32 45"
sec8="342 52 92 162 18 72"
sec9="12 82 122 192 12 102"
sec10="30 100 140 210 18 120"
sec11="45 115 155 225 22 135"
numofsec=2
cmaxdip=90
cmindip=0
smaxdip=90
smindip=20
den=165.0
l1r1prob=0.2000
p1prob=0.2000
jslf=001.00
cellwidth=30
####################################################################################
##################### Start of Automation Loop. All Parameters #####################
##################### Have already been defined above! #####################
##################### DO NOT WRITE BELOW THIS POINT!!!!!!!! #####################
####################################################################################
########## Check for celdisx in directory #######
if [ ! -e celdisx ]; then
echo -e "\a""\x1b[31;01m""You are missing the CNI celdisx program from your directory!"
echo -e "\a""\x1b[32;01m""Terminating Script - No results calculated."
tput sgr0
exit 0
fi
########### Get Length and Spacing ###########
echo "Please enter desired Mean Joint Lenght in meters, use 2 decimal places (#.##)"
read jlen
echo "Please enter desired Joint Spacing in meters, use 2 decimal places (#.##)"
read jspace
temp=$jlen
jlen=$(echo "$temp" | awk '{ printf "%6s", $1}')
temp=$jspace
jspace=$(echo "$temp" | awk '{ printf "%5s", $1}')
replace=$jlen$jspace
#####
########### Get and Make new directory ##########
echo "Please type the name of the new folder you wish to create to place this"
echo "iteration of back break into."
echo "No spaces please. Use _ or - in place of spaces."
read dirname
if [ -d $dirname ]; then
rm -r $dirname
fi
mkdir $dirname
cd $dirname
for (( id = 1 ; id <= $numofsec ; id++ ))
do
if [ -d sec_$id ]; then
rm -r sec_$id
fi
mkdir sec_$id
done
cd ..
########### Copy origional .dgl files into sec dir ####
for (( id = 1 ; id <= $numofsec ; id ++ ))
do
cp s${id}.gld ${dirname}/sec_$id
cp celdisx ${dirname}/sec_$id
cp KNRST ${dirname}/sec_$id
done
####################################################################################
##################### Start of Back break Programs. All Dir & #####################
##################### Root .gld have been placed. #####################
####################################################################################
cd $dirname
for (( id = 1 ; id <= ${numofsec} ; id++ ))
do
#### Change into iteration and sector dir ###
cd sec_$id
#### change 1 to 01 bb prog very specific about 6 char strings wtf #####
ida=${id}
if [ ${#id} -eq 1 ]; then
ida=0${id}
fi
########## Check for celdisx in directory #######
if [ ! -e celdisx ]; then
echo -e "\a""\x1b[31;01m""You are missing the CNI celdisx program from your directory!"
echo -e "\a""\x1b[32;01m""Terminating Script - No results calculated."
tput sgr0
exit 0
fi
#Creates Length File w/ user input Length & Spacing
sed -r "2,$ s/^(.{73})(.{11})/\1$replace/" <s${id}.gld >s${ida}LeN
################### Runs Cell programs #######
secid=sec${id}
set ${!secid}
celsrt<<xxxxx
s${ida}LeN
sec_${ida}.srt
sec_${ida}.f
Y
TEST sec_${ida}
3
1
${2},${1},${cmaxdip},${cmindip}
N
2
${3},${2},${cmaxdip},${cmindip}
N
3
${4},${3},${cmaxdip},${cmindip}
N
sec_${ida}mv.met
xxxxx
met2acad <<xxxxx
sec_${ida}mv.met
e
1
xxxxx
celdisx<<xxxxx
sec_${ida}.srt
sec_${ida}.dis
m
sec_${ida}.tbl
${5}
xxxxx
############# run bbstdi ################
rm -f s${ida}sdi
bbstdi<<xxxxx
1
s${ida}sdi
y
${id}sdi.rpt
sec_${ida}.dis
xxxxx
########### Run bbhst #######
var=sec${id}
set ${!var}
bbhst<<xxxxx
${prjt} - ${area} - Sector ${ida}
99
99
1
s${ida}LeN
${3},${2}
${smaxdip},${smindip}
s${ida}P1h
Sec${ida}_hist.met
xxxxx
met2acad<<xxxxx
Sec${ida}_hist.met
e
1
xxxxx
######### Getting the DIST! ##########
echo "Processing Sector ${ida}!!!"
bbdist<<xxxxx
s${ida}P1h
s${ida}P1d
xxxxx
########## Get set Numbers and run bbrsco ########
lw1setn=$(sed -n "1p" s${ida}sdi | cut -c 11-14)
ps1setn=$(sed -n "2p" s${ida}sdi | cut -c 11-14)
rw1setn=$(sed -n "3p" s${ida}sdi | cut -c 11-14)
#echo -e "$lw1setn\n$ps1setn\n$rw1setn"
bbrsco<<xxxxx
s${ida}rs ${ida}
QUIT ,0.0
GRD,${lw1setn} 100
GRD,${ps1setn} 100
GRD,${rw1setn} 100
END
xxxxx
############ Run bbpldc, create plan shear In ####
var=sec${id}
set ${!var}
bbpldc<<xxxxx
s${ida}rs
${ida},${6}
s${ida}sdi,s${ida}P1d
2,${den}
1
090.
s${ida}P1c,$ps1setn
STOP
NO
xxxxx
########### Calc Plane Shear bbplaf #######
bbplaf<<xxxxx
s${ida}P1c,s${ida}P1f,${ps1setn}
R,090.,090.,001.
R,009.,018.,009.
T
N
xxxxx
######### Compute wedges ##################
var=sec${id}
set ${!var}
bbwedc<<xxxxx
s${ida}rs
${ida},${6}
s${ida}sdi
2,${den}
1
009.
L1R1wc,${lw1setn},${rw1setn}
${2},${1},${smaxdip},${smindip}
${4},${3},${smaxdip},${smindip}
STOP
NO
xxxxx
for infile in L{1..1}R{1..1}wc
do
oufile=$(echo $infile | sed "s/c/f/g")
bbwedf<<xxxxx
${infile},${oufile},4657,1500
R,090.,090.,001.
R,009.,018.,009.
T
M,M
xxxxx
done
######### combine Plane & Wedge Failures ####
bf7com<<xxxxx
YES
${ida}theo
D,${ida}pred,${jslf}
W,L1R1wf,${l1r1prob}
P,s${ida}P1f,${p1prob}
${cellwidth}
xxxxx
######## Plot the Curve ############
var=sec${id}
set ${!var}
bfaplt<<xxxxx
${ida}theo
1
18
DRY
${project} - Backbreak Results
Sector ${ida} Wall Orientation DDR ${6}
Joint Set Lenght Factor ${jslf}
April 2012
Trial Runs
${ida}bfa.met
${ida}theo
9
${ida}pred
18
${ida}pred
9
xxxxx
met2acad <<xxxxx
${ida}bfa.met
e
1
xxxxx
######## Make Table ####
#### Change out of sector name
cd ..
#END LOOP
done
cd ..发布于 2012-04-14 02:32:43
我理解你的困惑,但在这一点上,用现有的数据给出任何明确的建议是非常困难的,如果不是不可能的话。
首先是您的环境;您提到了bash scripting (甚至给出了一个例子),它为我指出了一个*nix盒,但是您又提到了VBA,人们通常会将它与Windows系统联系在一起。
您是否在Windows计算机上,并在cygwin或?等环境中使用bash
第二,fortran程序的“本质”--它们是做什么的?它们是如何被结构化的等等……Fortran确实可以与图形用户界面混合使用-这甚至不是fortran的问题,但更多的是选择兼容版本的fortran编译器和其他环境的问题。mex文件、Excel通过.dll文件...)然后把它们混在一起。这是一个属于自己的领域。
这是可以做到的,而且已经做到了,但我重复一遍,这只是一般的空谈。
还有一些接口,如Fortran、GINO或Winteracter (您可以在谷歌上搜索这些名称以获取更多信息),它们可以创建"Fortran GUI“。我没有和这两个人中的任何一个合作过,但我听说过关于这两个人的好消息。
您的fortran程序,取决于它们现在是如何组织的,可能需要进行一些修改(重新组织)。这是否会带来问题取决于它们最初是如何编写/构造的。您可能需要学习一些有关该语言的知识才能完成此部分。
像这样分离,它们都是可以解决的问题。如果您在SO中搜索处理类似问题的问题,并尝试查看哪种方法最适合您,这将是明智的。在那之后,在你选择了要走的路之后,也许可以改进这个问题。
如果这一切有意义或没有意义,请在评论中给我打个电话。
发布于 2012-04-15 15:08:32
如果你正在使用bash,为什么不试试zenity呢?它可以用来弹出一个可以填写的表单,结果将直接返回给bash,然后您可以按原样使用bash脚本的其余部分。
另一种选择是使用诅咒,或者如果您可以使用Fortran,则使用VT100序列编写您自己的代码。
如果你在windows环境下运行,试着把它写成一个超文本应用程序(HTA)。这基本上是一个带有一点javascript/vbscript (随你喜欢)的网页。从这里开始http://msdn.microsoft.com/en-us/library/ms536496(v=vs.85).aspx
https://stackoverflow.com/questions/10145339
复制相似问题