- #1
abdulsulo
- 14
- 0
Hello everybody,
I have a source code which gives me as a result an array of 2 columns and 3001 rows (2d array). By using fortran90.
I was trying to have the values inside these cells into .dat file and tried to generate a subroutine and call my main array inside this. But somehow I get errors. Linking the code below any help is appreciated.
<<Moderator's note: code tags added. Next time, you must do that yourself, otherwise your post may be deleted.>>
I have a source code which gives me as a result an array of 2 columns and 3001 rows (2d array). By using fortran90.
I was trying to have the values inside these cells into .dat file and tried to generate a subroutine and call my main array inside this. But somehow I get errors. Linking the code below any help is appreciated.
Fortran:
program hw1
REAL G, Ks, DVIS, EPS,LENGTH,D,Vs,Re,Vi,V0,FFACT,DELt,I,Vi1,J
INTEGER H, T, PHO
real, dimension(3001,2):: VTARR
G=9.81
D=0.3
H=8
ks=0.0001
T=60
DVIS=0.001
PHO=1000
EPS=0.01
DELt=0.02
WRITE (*,*) 'INPUT CYLINDER DIAMETER D:'
READ (*,*) D
WRITE (*,*)'INPUT PIPE LENGTH L'
READ (*,*) LENGTH
IF (LENGTH==50) THEN
Vs=6.586 !10.2655
ELSE IF (LENGTH==100) THEN
Vs=5.00
ELSE IF (LENGTH==200) THEN
Vs=3.669
ELSE IF (LENGTH==500) THEN
Vs=2.36
end if
Re=PHO*Vs*D/DVIS
FFACT=0.25/((log10((ks/(3.7*D))+(5.74/Re**0.9)))**2)
J=1
do I=0.02,60,0.02
IF (I==0.02) THEN
V0=0
Vi=DELt*H*G/LENGTH
VTARR(J,1)=Vi
VTARR(J,2)=I
J=J+1
WRITE (*,*) Vi
ELSE IF (I/=0.02) THEN
!Re=PHO*Vi*D/DVIS
!FFACT=0.25/(log((ks/(3.7*D))+(5.74/Re**0.9)))**2
Vi1=Vi+(DELt*(H-((1+(FFACT*LENGTH/D))*((Vi**2)/(2*G))))*G/LENGTH)
Vi=Vi1
VTARR(J,1)=Vi
VTARR(J,2)=I
J=J+1
END IF
WRITE (*,*) Vi
end do
CALL outputdata(VTARR)
PAUSE
END PROGRAM
SUBROUTINE outputdata(X)
implicit none
REAL,DOUBLE PRECISION, INTENT(IN) :: X(:,:)
integer :: i
! output data into a file
open(1, file='data1.dat', status='new')
do i=1,ubound(X,1)
write(1,*) x(1,i), X(2,i)
end do
close(1)
! opening the file for reading
open (2, file='data1.dat', status='old')
end