Hey guys, so I'm brand new to perl. So i'm in quite a pickle, I have the code I need in FORTRAN, but I am trying to translate it into Perl.
Originally posted by Fortran
parameter(ntm=10000,nspc=1000,particles=201,specie s=4)
integer cfg,nt,nxspc(nspc)
double precision tm,ran2
integer nconfg,nbin(ntm),nhist,ndev,ntspc1(ntm,nspc),flag1 ,flag2,flag3,flag4,flag5
integer ntspc2(ntm,nspc),ntspc3(ntm,nspc),ntspc4(ntm,nspc)
integer ntspc5(ntm,nspc),knt1,knt2,knt3,knt4,knt5
double precision histp,histm,avspc(nspc),sumspc(nspc)
double precision hist1(particles,species),TT1,chist1(nspc,nspc)
double precision hist2(particles,species),TT2,chist2(nspc,nspc)
double precision hist3(particles,species),TT3,chist3(nspc,nspc)
double precision hist4(particles,species),TT4,chist4(nspc,nspc)
double precision hist5(particles,species),TT5,chist5(nspc,nspc)
nconfg=4
do j=1,1000
avspc(j)=0.d0
enddo
do i=1,10000
do j=1,1000
ntspc1(i,j)=0
ntspc2(i,j)=0
ntspc3(i,j)=0
ntspc4(i,j)=0
ntspc5(i,j)=0
enddo
enddo
do i=1,1000
nxspc(i)=0
sumspc(i)=0.d0
do j=1,1000
chist1(i,j)=0.d0
chist2(i,j)=0.d0
chist3(i,j)=0.d0
chist4(i,j)=0.d0
chist5(i,j)=0.d0
enddo
enddo
do i=1,particles
do j=1,species
hist1(i,j)=0.d0
hist2(i,j)=0.d0
hist3(i,j)=0.d0
hist4(i,j)=0.d0
hist5(i,j)=0.d0
enddo
enddo
do cfg=1,nconfg
flag1=0
flag2=0
flag3=0
flag4=0
flag5=0
call system("$home\abdurehman1\BioNetGen\Perl2\BNG2.pl rxn1.txt
& > test.txt")
c call system("tac test>>test1")
cc # gives number of lines in the file test
call system("cat test | wc -l > inpl")
cc # gives number of columns in the file test
call system("cat test | tail -3 | head -1|awk '{print NF}'>inpc")
open(unit=10,file='inpl',status='old')
read(10,*)nt
close(10)
open(unit=11,file='inpc',status='old')
read(11,*)ncol
close(11)
c TT1=60.d0
c TT2=160.d0
c TT3=260.d0
c TT4=460.d0
c TT5=760.d0
TT1=60.d0
TT2=100.d0
TT3=200.d0
TT4=660.d0
TT5=2000.d0
open(unit=2,file='test',status='old')
do i=1,nt-1
read(2,*)tm,(nxspc(j),j=1,ncol-1)
if(flag1.eq.0) then
if(tm.ge.TT1)then
flag1=1
do j=1,ncol-1
hist1(nxspc(j)+1,j)= hist1(nxspc(j)+1,j)+1
enddo
endif
endif
if(flag2.eq.0) then
if(tm-TT2.ge.0)then
flag2=1
do j=1,ncol-1
hist2(nxspc(j)+1,j)= hist2(nxspc(j)+1,j)+1
enddo
endif
endif
if(flag3.eq.0) then
if(tm-TT3.ge.0)then
flag3=1
do j=1,ncol-1
hist3(nxspc(j)+1,j)=hist3(nxspc(j)+1,j)+1
enddo
endif
endif
if(flag4.eq.0) then
if(tm-TT4.ge.0)then
flag4=1
do j=1,ncol-1
hist4(nxspc(j)+1,j)=hist4(nxspc(j)+1,j)+1
enddo
endif
endif
if(flag5.eq.0) then
if(tm-TT5.ge.0)then
flag5=1
do j=1,ncol-1
hist5(nxspc(j)+1,j)=hist5(nxspc(j)+1,j)+1
enddo
endif
endif
enddo
close(2)
enddo
open(unit=31,status='unknown')
write(96,*)"# histogram at",TT1,"secs"
do i=1,201
write(96,'(1X,I4,28F15.5)')i-1,(hist1(i,j), j=1,ncol-1)
enddo
integer cfg,nt,nxspc(nspc)
double precision tm,ran2
integer nconfg,nbin(ntm),nhist,ndev,ntspc1(ntm,nspc),flag1 ,flag2,flag3,flag4,flag5
integer ntspc2(ntm,nspc),ntspc3(ntm,nspc),ntspc4(ntm,nspc)
integer ntspc5(ntm,nspc),knt1,knt2,knt3,knt4,knt5
double precision histp,histm,avspc(nspc),sumspc(nspc)
double precision hist1(particles,species),TT1,chist1(nspc,nspc)
double precision hist2(particles,species),TT2,chist2(nspc,nspc)
double precision hist3(particles,species),TT3,chist3(nspc,nspc)
double precision hist4(particles,species),TT4,chist4(nspc,nspc)
double precision hist5(particles,species),TT5,chist5(nspc,nspc)
nconfg=4
do j=1,1000
avspc(j)=0.d0
enddo
do i=1,10000
do j=1,1000
ntspc1(i,j)=0
ntspc2(i,j)=0
ntspc3(i,j)=0
ntspc4(i,j)=0
ntspc5(i,j)=0
enddo
enddo
do i=1,1000
nxspc(i)=0
sumspc(i)=0.d0
do j=1,1000
chist1(i,j)=0.d0
chist2(i,j)=0.d0
chist3(i,j)=0.d0
chist4(i,j)=0.d0
chist5(i,j)=0.d0
enddo
enddo
do i=1,particles
do j=1,species
hist1(i,j)=0.d0
hist2(i,j)=0.d0
hist3(i,j)=0.d0
hist4(i,j)=0.d0
hist5(i,j)=0.d0
enddo
enddo
do cfg=1,nconfg
flag1=0
flag2=0
flag3=0
flag4=0
flag5=0
call system("$home\abdurehman1\BioNetGen\Perl2\BNG2.pl rxn1.txt
& > test.txt")
c call system("tac test>>test1")
cc # gives number of lines in the file test
call system("cat test | wc -l > inpl")
cc # gives number of columns in the file test
call system("cat test | tail -3 | head -1|awk '{print NF}'>inpc")
open(unit=10,file='inpl',status='old')
read(10,*)nt
close(10)
open(unit=11,file='inpc',status='old')
read(11,*)ncol
close(11)
c TT1=60.d0
c TT2=160.d0
c TT3=260.d0
c TT4=460.d0
c TT5=760.d0
TT1=60.d0
TT2=100.d0
TT3=200.d0
TT4=660.d0
TT5=2000.d0
open(unit=2,file='test',status='old')
do i=1,nt-1
read(2,*)tm,(nxspc(j),j=1,ncol-1)
if(flag1.eq.0) then
if(tm.ge.TT1)then
flag1=1
do j=1,ncol-1
hist1(nxspc(j)+1,j)= hist1(nxspc(j)+1,j)+1
enddo
endif
endif
if(flag2.eq.0) then
if(tm-TT2.ge.0)then
flag2=1
do j=1,ncol-1
hist2(nxspc(j)+1,j)= hist2(nxspc(j)+1,j)+1
enddo
endif
endif
if(flag3.eq.0) then
if(tm-TT3.ge.0)then
flag3=1
do j=1,ncol-1
hist3(nxspc(j)+1,j)=hist3(nxspc(j)+1,j)+1
enddo
endif
endif
if(flag4.eq.0) then
if(tm-TT4.ge.0)then
flag4=1
do j=1,ncol-1
hist4(nxspc(j)+1,j)=hist4(nxspc(j)+1,j)+1
enddo
endif
endif
if(flag5.eq.0) then
if(tm-TT5.ge.0)then
flag5=1
do j=1,ncol-1
hist5(nxspc(j)+1,j)=hist5(nxspc(j)+1,j)+1
enddo
endif
endif
enddo
close(2)
enddo
open(unit=31,status='unknown')
write(96,*)"# histogram at",TT1,"secs"
do i=1,201
write(96,'(1X,I4,28F15.5)')i-1,(hist1(i,j), j=1,ncol-1)
enddo
Comment