! VSEP4P_PUB4F90CNOVA(10.4.21),FROM vsep4P_PUB4F90,no v PART1 za vsiako nivo L da se vika tree4 ili samo vilka i da se izbira vyzel ot min orbita za L+1,adjtriang e vkliuchena module opashka type opelem INTEGER, allocatable :: starn(:,:) INTEGER, allocatable :: novn(:,:) type (OpElem), pointer :: nextst end type TYPE PointOp TYPE (opelem), POINTER :: DD END TYPE PointOp end module OPASHKA !contains USE OPASHKA TYPE(opelem), pointer:: NACHOP2,KROP2 integer n,m n=7;m=3 allocate (nachop2) NULLIFY(nachop2) allocate (krop2) NULLIFY(krop2) allocate(nachop2%starn(n,m)) allocate(krop2%starn(n,m)) NULLIFY(nachop2%nextst) NULLIFY(krop2%nextst) !contains INTERFACE SUBROUTINE SHIRINA2(n,NACHOP1,KROP1) USE OPASHKA IMPLICIT INTEGER(A-Z) TYPE(opelem), pointer :: NACHOP1,KROP1 logical pyrvi end END INTERFACE call SHIRINA2(n,NACHOP2,KROP2) END SUBROUTINE SHIRINA2(n,NACHOP1,KROP1) USE OPASHKA IMPLICIT INTEGER(A-Z) TYPE(opelem), pointer :: NACHOP1,KROP1 logical pyrvi n=10;pyrvi=.true. if(pyrvi)then allocate (nachop1) NULLIFY(nachop1) allocate (krop1) NULLIFY(krop1) ! DO II=1,GR ! allocate (hsh1(II)%A) ! allocate (hsh2(II)%A) ! nullify (hsh1(II)%A) ! nullify (hsh2(II)%A) ! ENDDO endif call ZapElemSledKrai2(n,NACHOP1,KROP1) contains subroutine ZapElemSledKrai2(n,head,krai)!zapis na nov element sled kraia na opashkata USE OPASHKA integer n TYPE(opelem),intent(inout),pointer :: head,krai type (OpElem), pointer:: pom integer a(n,1),b(n) logical status ! n=10 a(1:n,1)=5 b(1:n)=7 !allocate(head%dd) ! nullify(head%dd) nullify(pom) allocate (pom) allocate (pom%starn(n,1)) pom%starn(1:n,1)=a(1:n,1) ! allocate (head%dd) ! NULLIFY(head%dd) STATUS = ASSOCIATED(head) if(.NOT.STATUS)then allocate (head) !PRINT *,'ZAPOPASH1-DPTH,POM%SP=',POM%SP,'HSH1=',HSH1(X)%A%SP head=>pom ! head%dd%starn(1:n,1)=a(1:n,1) else endif end END
Write, Run & Share Fortran code online using OneCompiler's Fortran online compiler for free. It's one of the robust, feature-rich online compilers for Fortran language, running on the latest version 7. Getting started with the OneCompiler's Fortran compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Fortran
and start coding.
OneCompiler's Fortran online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Fortran program which takes name as input and prints hello message with your name.
program hello
character :: name*30
read *, name
print *, "Hello ", name
end program hello
Fortran language was initially developed for scientific calculations by IBM in 1957. It has a number of in-built functions to perform mathematical calculations and is ideal for applications which has more mathematical calculations.
Data type | Description | Usage |
---|---|---|
Integer | To store integer variables | integer :: x |
Real | To store float values | real :: x |
Complex | To store complex numbers | complex :: x,y |
Logical | To store boolean values True or false | logical :: x=.True. , logical :: x = .FALSE. |
Character | To store characters and strings | character :: x |
Variable is a name given to the storage area in order to manipulate them in our programs.
data type :: variable_name
Array is a collection of similar data which is stored in continuous memory addresses.
data-type, dimension (x,y) :: array-name
integer, dimension(3,3) :: cube
Do is used to execute a set of statement(s) iteratively when a given condition is true and the loop variable must be an integer.
do i = start, stop [,step]
! code
end do
Do-While is used to execute a set of statement(s) iteratively when a given condition is true.
do while (condition)
!Code
end do
If is used to execute a set of statements based on a condition.
if (logical-expression) then
!Code
end if
If is used to execute a set of statements based on a condition and execute another set of statements present in else block, if condition specified in If block fails.
if (logical-expression) then
!code when the condition is true
else
!code when the condition fails
end if
Case is similar to switch in C language.
[name:] select case (regular-expression)
case (value1)
! code for value 1
... case (value2)
! code for value 2
...
case default
! default code
...
end select [name]