Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

t25

program t25
!count and print all numbers from low to high
integer::low,high,step,a
read*,low,high,step
do a=low,high,step
print*,a
 end do
end program t25

test25

program hello
!low to high
integer::low,high,step,x
read*,low,high,step
do x=low,high,step
print*,x
end do
end program Hello

test24

program test4
!program prints out sum and product
integer::m,n,i,a
m=0
n=1
do i=1,10
read*,a
m=m+a
n=n*a
print*,m
print*,n
end do
end program test4

t22

program t22
!sum of numbers from low to high
integer::x,y,sum,i
read*,x,y
print*,"low number is",x
print*,"high number is",y
sum=0
do i=x,y
sum=sum+i
end do
   Print *,'the sum from low to high',sum
   
end program t22

test22

program test2
!sum of numbers from low to high
integer::x,y,sum,i
read*,x,y
print*,'the low number is',x
print*,'the high number is',y
sum=0
do i=x,y
sum=sum+i
end do 
print*,'the sum from low to high number is',sum

end program test2

problem 21

program hi
!square of all numbers from 1 to 10
integer::x,i
do i=1,10
x=i**2
print*,x
end do
end  program hi

test 21

program test1
!square of all numbers from 1 to 10
integer::a,x
do a=1,10
x=a**2
print *,x
end do 
end program test1

Compile and Execute FORTRAN-95 Online

program assign6
implicit none
CHARACTER(LEN=20)  :: file1name, file2name
integer :: row
integer :: col
integer :: i
integer, dimension(:,:), allocatable :: myarray

CALL get_command_argument(1, file1name)
CALL get_command_argument(2, file2name) 

open(1, file = file1name, action='read',status='old')

READ(1,*) row, col
allocate( myarray(row, col))

! read first line of file
! first value in first line is row/height
! second value in first line is column/width


DO i =1, row
    READ(1,*) myarray(i, :)
    write(*,*) myarray(i, :)
END DO

deallocate( myarray)
close(1)


end program















!length parameter 
!value parate
!value 
!parameter to open call




!3 nested loops
!one loop to read in
!one loop to sort the first value of the rows
!one loop to sort the values of each column

fortranagain

!program input
!    implicit none
!        Integer :: N, row, col, i, j
!        Integer, dimension(:, :), allocatable :: myarray
!        character(len = 10) :: fmt
!        
!    read(*,*) N
!    Allocate(myarray(1:N, 1:N2))
!        DO row = 1, N
!        DO col = 1, N
!            READ
!
!
!def gco(idx = 0, length = null, value = null)
!def myfunc(name = "Default", age = "-1", occupation = "None")
!my_func("Josh", occupation = "TA")

!./assign6 myfile my.output


!open file
!read first line
! in a do loop read (1, :)


program assign6
implicit: none
integer :: arg1len
integer :: file1name


allocate(character(arg1len) :: file1name)

get_command.argument(1, row = file1name)
get_command.argument(1, col = file1name)


! read(*,*) name_of_array


!myMatrix(1,1)

end program

Compile and Execute FORTRAN-95 Online

PROGRAM matmult
implicit none
        !! Declarations
        ! Define 3 allocatable 2-dimensional integer arrays
        ! and any temporary variables that you need
        integer, dimension (:,:), allocatable :: array1
        integer, dimension (:,:), allocatable :: array2
        integer, dimension (:,:), allocatable :: array3
        integer, dimension (:), allocatable :: printarray
        integer :: l, m, n
        integer :: i, j
        integer :: temp, x

        !! Create and initialize arrays
        ! Prompt for 3 integers (call them L, M, and N)
        ! They represent the dimensions of the arrays
        ! The first array will be dimension L x M, the second will be M x N
        ! and the product array, L x N
        write(*,*) 'Enter array dimensions'
        read(*,*) l, m, n

        ! Allocate the 3 arrays of the correct size
        allocate (array1(l,m))
        allocate (array2(m,n))
        allocate (array3(l,n))

        !! Initialize arrays
        ! Initialize the first array such that array(i,j) = 10i+j
        do i = 1, m
                do j = 1, l
                    array1(i, j) = (10*i)+j
                end do
         end do

        ! Initialize the second array such that array(i,j) = 20i+2j
        do i = 1, n
                do j = 1, m
                array2(i, j) = (20*i)+(2*j)
                end do
         end do

        ! Multiply arrays
        ! Matrix multiplication C = AB
        ! C(i,j) = the sum product of row i of A and column j of B
        do i = 1, n
          do j = 1, l
                temp = 0
                do x = 1, n
                  temp = temp + array1(j,x) * array2(x,j)
                end do
                array3(i, j) = temp
          end do
         end do

        ! Print the array row-by-row to STDOUT (terminal)
        ! To print elements of an array in a row, you can define a loop as part of the WRITE
        ! Assuming that vec is a one-dimensional array of length 5 and j is a declared variable,
        ! the following will print that vector as a row
        ! WRITE(*,*) (vec(j), j=1, 5)

        allocate(printarray(l))
        do i = 1, n
                do j = 1, l
                  printarray(j) = array3(j, i)
                end do
        write(*,*) printarray
    end do

        ! Deallocate arrays
        ! If you allocate it, you need to deallocate it
        deallocate(array1)
        deallocate(array2)
        deallocate(array3)
        deallocate(printarray)

END PROGRAM matmult

Previous 1 ... 3 4 5 6 7 8 9 ... 111 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.