fortran


Increase Steps in 2D Self Avoiding Random Walk


I am trying to increase the number of possible steps in the following Fortran self avoiding random walk program.
Increasing the number of steps would result in more accuracy regarding the square mean distance
I would appropriate your solutions and suggestions.
PROGRAM Two_dimensional_Self_Avoiding__Random_Walks
implicit none
integer, dimension(:,:), allocatable :: lattice
integer, dimension(1:46):: na
integer :: i,x,y,xt,yt,id,step,xx, ns,n,ii,III,choice
real :: r,dis,dis2,square,d,d2
Logical :: terminate,newsite
CALL RANDOM_SEED()
! intial values for end to end distance
read(*,*) choice
if (choice == 1) then
print*, ' Enter ns and n '
read(*,*) ns
na = (/(III, III=5, 50, 1)/)
do ii= 1, 46
dis = 0.0; dis2 = 0.0
n = na(ii)
allocate(lattice(-n:n,-n:n))
CALL walks() ! self avoiding walks
IF (ALLOCATED (lattice)) DEALLOCATE (lattice)
enddo
elseif (choice == 2) then
print*, ' Enter ns and n '
read(*,*) ns , n
dis = 0.0; dis2 = 0.0
allocate(lattice(-n:n,-n:n))
CALL walks()
endif
CONTAINS
SUBROUTINE walks
DO i = 1,ns
lattice = 0; x = 0; y = 0
step = 0; terminate = .FALSE.
DO WHILE ((.NOT. terminate) .AND. (step <= n))
xt = x; yt = y
xx = lattice(x+1,y)+lattice(x-1,y) &
+lattice(x,y+1)+lattice(x,y-1)
IF (xx == 4) THEN
terminate = .TRUE.
ELSE
newsite = .FALSE.
DO WHILE (.NOT. newsite)
CALL RANDOM_NUMBER(r)
id = INT(r*4.0)
IF (id == 0) THEN
x = xt + 1; y = yt
ELSEIF (id == 1) THEN
x = xt - 1; y = yt
ELSEIF (id == 2) THEN
x = xt; y = yt + 1
ELSEIF (id == 3) THEN
x = xt; y = yt - 1
ENDIF
IF (lattice(x,y) == 0) newsite = .TRUE.
ENDDO
step = step + 1; lattice(x,y) = 1
ENDIF
write(7,*) x,y
ENDDO
write(10,*),step
square = float(x**2+y**2)
dis = dis + sqrt(square); dis2 = dis2 + square
d = dis/ns; d2=dis2/ns
ENDDO
write(11,*), ns,n, d, d2
print*, ns,n, d, d2
END SUBROUTINE walks
END PROGRAM Two_dimensional_Self_Avoiding__Random_Walks

Related Links

Writing specific parts of the file to another file
Print every 6th and 7th lines
How to exit “repeat until loop” in fortran?
Compiler difference between gfortran and ifort (allocatable arrays and global variables)
Syntax error in function arguments in fortran
Fortran read statement gives no compilation error
Conditional shared status in OpenMP
ODE solver in F90
Add number and move it in the same Array in Fortran
Metis 5.1 gives Memory allocation failed for SetupCtrl: ctrl->tpwgts
Do loop is stuck at the first subarray in MPI SCATTER and GATHER
vectorized sum in Fortran
Incorrect eigenvalues with cgeev
Fortran F90 Unclassifiable Statement (Basic)
Allocate large array in PGI Fortran
Error: Unclassifiable state at (1)

Categories

HOME
c#
leaflet
postgresql-9.3
symfony-sonata
yacc
sahi
ldap-query
fastreport
aggregate
appsettings
loss
simd
google-street-view
loader
project-structure
url-parameters
datazen-server
dev-c++
multipart
aws-iot
bootstrap-accordion
ithit-webdav-server
poisson
restangular
2checkout
foxpro
jmsserializerbundle
ilog
zimbra
dropdownbox
idea-plugin
socketcluster
flume-ng
web-technologies
colorbox
bootstrap-carousel
logan-square
niagara-ax
azure-data-catalog
google-chrome-storage
g77
denodo
esprima
huawei
ownership
git-cherry-pick
diameter-protocol
shtml
aws-kms
3d-rendering
nd4j
web-optimization
custom-build-step
sqldataadapter
ewam
nonblocking
magnet-uri
ultraedit
connection-timeout
esri-arc-engine
nsq
drools-guvnor
qf-test
clearcanvas
react-os
yosemite
selenium-grid2
oxygenxml
time-frequency
pyalgotrade
kuka-krl
nomachine
imaplib
php-amqplib
ie-developer-tools
ojb
objectdatasource
usersettings
windows-scheduler
pudb
simplemembership
setcookie
rfc822
report-viewer2010
certificate-revocation
mcpd
log-shipping
vectorwise
backlight
hs-err
text-manipulation
google-local-search
miniport
ihtmldocument2

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App