! OPREDELIA REDA NA GRUPATA GENERIRANA OT ZADADENI OBRAZUVASHTI CHREZ FILTERA NA FURST,raboti korektno s umnojenie j otliavo i otdiasno, i pri samo j otdiasno,no pri j samo otliavo greshi !31.3.21 IMPLICIT INTEGER*2(A-Z) INTEGER MBRPREDS PARAMETER(NM=546,MNGEN=60,MBRPREDS=NM*(NM-1)/2) ! PARAMETER(NM=546,MNGEN=35,MBRPREDS=500000) REAL*8 ORDER REAL T1,T2 INTEGER DATE_TIME (8) INTEGER*2 GEN(NM,MNGEN) INTEGER*2 T(NM,NM),C(NM),PREDST(NM,MBRPREDS),P(NM) CHARACTER (LEN = 12) REAL_CLOCK (3) CHARACTER*120 INPUTFILE,NAME WRITE(*,*) ' ENTER FILE NAME ' ! INPUTFILE='GENfaradj1.DAT' ! INPUTFILE='GENPP16_19.DAT' ! INPUTFILE='GENa25.DAT' INPUTFILE='GENGIRA.DAT' ! READ(*,'(A\)')INPUTFILE open(2,FILE=INPUTFILE,STATUS='OLD',& ACCESS='SEQUENTIAL',FORM='FORMATTED') ! open(3,FILE='REZ1.DAT',STATUS='OLD', open(3,FILE='REZ1.DAT',& ACCESS='SEQUENTIAL',FORM='FORMATTED') READ(2,111)name 111 FORMAT(A120) READ(2,*)N 32 FORMAT(24(I5)) READ(2,*) !READ(2,*)((GEN(I,J),I=1,N),J=1,NGEN) I=1 DO READ(2,*,END=101)(GEN(J,I),J=1,N) I=1+I ENDDO 101 NGEN=I-1 CALL CPU_TIME(T1) DO I=1,N C(I)=1 DO J=1,N T(I,J)=0 END DO END DO BRPREDST=0 DO I=1,NGEN CALL FILTER(N,GEN(1,I),T,PREDST,BRPREDST,C,IVMAKV) END DO do pyti=1,2 11 I=0 PREDST(1,BRPREDST+1)=0 1 I=I+1 ! IF(PREDST(1,I).EQ.0)GOTO 10 !IF(PREDST(1,I).EQ.0)cycle IF(I.GT.BRPREDST)GOTO 10 J=0 2 J=J+1 !IF(PREDST(1,J).EQ.0)GOTO 1 IF(J.GT.I)GOTO 1 CALL AUTMULT(N,PREDST(1,J),PREDST(1,I),P,BRFIX) IF(BRFIX.NE.N)THEN CALL FILTER(N,P,T,PREDST,BRPREDST,C,IVMAKV) IF(IVMAKV.NE.0)PREDST(1,BRPREDST+1)=0 ENDIF CALL AUTMULT(N,PREDST(1,I),PREDST(1,J),P,BRFIX) IF(BRFIX.NE.N)THEN CALL FILTER(N,P,T,PREDST,BRPREDST,C,IVMAKV) IF(IVMAKV.NE.0)PREDST(1,BRPREDST+1)=0 ENDIF GOTO 2 GOTO 1 enddo 10 ORDER=1 DO I=1,N ORDER=ORDER*C(I) END DO WRITE(3,*)'ORDER=',ORDER,(I,'(',C(I),')',I=1,N) WRITE(*,*)'ORDER=',ORDER,(I,'(',C(I),')',I=1,N) ! WRITE(*,*)'ORDER=',ORDER,(C(I),I=1,N) CALL CPU_TIME(T2) WRITE(3,*) 'Time of operation was ', T2-T1, ' seconds' WRITE(*,*) 'Time of operation was ', T2-T1, ' seconds' STOP END subroutine FILTER(N,A,T,PREDST,BRPREDST,C,IVMAKV)!DESNI SYKLASOVE,BRPREDST-BROIA NA PODGRUPITE,oporite ne sa dadeni i zapochvat ot 1,za daden avtomorfizym A se tyrsi v koi vyzel !se izobraziava opornia vyzel j (nomera na podgrupata) IMPLICIT INTEGER*2(A-Z) INTEGER MBRPREDS parameter(NM=546,MBRPREDS=NM*(NM-1)/2) ! PARAMETER(NM=546,MNGEN=35,MBRPREDS=500000) INTEGER*2 A(NM),AOBR(NM),T(NM,NM),C(NM),PREDST(NM,MBRPREDS) IVMAKV=0 ! DO 1 J=1,N-1 DO 1 J=1,N AJ=A(J) IF(AJ.EQ.J)GOTO 1 IF(T(AJ,J).EQ.0)THEN BRPREDST=BRPREDST+1 DO 2 I=1,N PREDST(I,BRPREDST)=A(I) 2 CONTINUE T(AJ,J)=BRPREDST C(J)=C(J)+1 IVMAKV=J RETURN ELSE CALL OBRATEN(N,A,AOBR) CALL AUTMULT(N,PREDST(1,T(AJ,J)),AOBR,A,BRFIX)!DESNI SYKLASOVE,Y.alfa**-1 !CALL AUTMULT(N,AOBR,PREDST(1,T(AJ,J)),A,BRFIX)!LEVI SYKLASOVE,alfa**-1.Y IF(BRFIX.NE.N)GOTO 1 GOTO 99 END IF 1 CONTINUE 99 RETURN END SUBROUTINE OBRATEN(N,A,AOBR) IMPLICIT INTEGER*2(A-Z) parameter(NM=546) INTEGER*2 A(NM),AOBR(NM) DO I=1,N AOBR(A(I))=I END DO RETURN END SUBROUTINE AUTMULT(N,X,Y,Z,BRFIX) IMPLICIT INTEGER*2(A-Z) parameter(NM=546) INTEGER*2 X(NM),Y(NM),Z(NM) BRFIX=0 DO 1 I=1,N Z(I)=Y(X(I)) IF(Z(I).EQ.I)BRFIX=BRFIX+1 1 CONTINUE RETURN 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]