INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Trying to rewrite a program

Trying to rewrite a program

(OP)
Hi
I am tring to rewrite the program as this link: Exemplo I and II (page from 1 to 8) http://paginas.fe.up.pt/~tavares/ensino/CFAC/Downl...

but i dont know why it is not working.

this is the program I wrote:

thanks !!!!!

PROGRAM EXERCICIO2
DIMENSION A(2,2), B(2,2), C(2,2)
C
C VAI DEFINIR OS PONTOS A
C
A(1,1)=0.0
A(1,2)=0.0 ! CONSIDERE, POR EXEMPLO, OS
A(2,1)=10.0 !PONTOS EXTREMOS DE UM SEGMENTO DE RETA
A(2,2)=0.0
C
C VAI LER O ANGULO DE ROTAÇÃO

WRITE(*,'(A\)')' ANGULO:'
READ(*,*)TETA
PI=4*ATAN(1.0) !DEFINE A CTE PI
TETA=TETA*PI/180 !CONVERTE GRAUS EM RADIANOS
C
C DEFINE MATRIZ DE ROTAÇAO EM TORNO DA ORIGEM
C
B(1,1)=COS(TETA)
B(2,1)=SIN(TETA)
B(2,1)=-SIN(TETA)
B(2,2)=COS(TETA)
C
CALL MULTMAT(A,B,C) !CHAMA A SUB ROTINA MULTMAT
C
C ESCREVE A MATRIZ RESULTANTE DO PRODUTO C(...)
C
DO 20 I=1,2
WRITE(*,*)(C(I,J),J=1,2) !CICLO DO INTERNO EM J
20 CONTINUE
STOP
END
C
C SUB ROTINA PARA O PRODUTO DE DUAS MATRIZES 2X2
C
SUBROUTINE MULTMAT (A,B,C)
DIMENSION A(2,2), B(2,2), C(2,2)
C
C FAZ CICLO SOB O NUMERO DE LINHAS I
C
DO 1 I=1,2
C
C FAZ PRODUTO COM A MATRIZ QUADRADA B
C
DO 2 J=1,2
AB=0.0 !INICIA VALOR DA POSIÇÃO DA MATRIZ
DO 3 K=1,2
AB=AB+A(I,K)*B(K,J) !ADICIONA CONTRIBUIÇOES
3 CONTINUE
C(I,J)=AB !GUARDA VALOR NA POSIÇÃO DA MATRIZ
2 CONTINUE
1 CONTINUE
C
RETURN
END

RE: Trying to rewrite a program

As you know, this is computer and programming stuff...you can't just hand wave (american idiom)...you need to tell exactly what you are doing, exactly what you are getting and why/how is different from what you were expecting.

What is the extension of the source file? This matters! ...*.F, *.FOR, *.F77, *.F90?
What compiler are you using and what exactly is the compilation command?
What do you get?

Please copy and paste as much as you can...trying to explain things when you don't know what you are doing does not come across well.

Finally...if I could convince you, please do not bother to learn Fortran 77...the presentation you are reading is from 2001, yet, we have had modern Fortran since 1995...please, please, please drop that tutorial and look for literature and tutorials for Fortran90 or Fortran95...it is sooooo much nicer.

Tutorials.
Wikipedia.

RE: Trying to rewrite a program

What is not working about it - does it not compile or does it not run as expected. If the latter, then what are you expecting and what are you getting?

RE: Trying to rewrite a program

It worked for me when I replaced '\' with '$' line 13.
I compile with g77.

This doesn't work for me: write(*,'(A)',advance='no')

WRITE (*, '(A$)') ' ANGULO : ' !! TRY $ TO REPLACE \

CODE --> 77

PROGRAM exercicio2
      DIMENSION A(2, 2), B(2, 2), C(2, 2)
C
C VAI DEFINIR PONTOS A(...)
C
      A(1, 1) = 0.0
      A(1, 2) = 0.0  ! Considere, por exemplo, os
      A(2, 1) = 10.0 ! pontos extremos dum segmento de recta
      A(2, 2) = 0.0
C
C VAI LER O ÂNGULO DE ROTAÇÃO
C
      !WRITE (*, '(A\)') '  ANGULO : ' !! TRY $ TO REPLACE       WRITE (*, '(A$)') '  ANGULO : ' !! TRY $ TO REPLACE       READ (*, *) TETA
      PI = 4*ATAN(1.0)     ! Define a constante p (pi)
      TETA = TETA*PI/180   ! Converte graus em radianos
C
C DEFINE MATRIZ DE ROTAÇÃO em torno da origem
C
      B(1, 1) = COS(TETA)
      B(1, 2) = SIN(TETA)
      B(2, 1) = -SIN(TETA)
      B(2, 2) = COS(TETA)
C
      CALL MULTMAT(A, B, C)! Chamada da subrotina MULTMAT
C
C ESCREVE A MATRIZ RESULTANTE DO PRODUTO C(...)
C
      DO 20 I = 1, 2
      WRITE (*,*) (C(I, J), J = 1, 2)   ! Ciclo DO interno em J
   20 CONTINUE
      STOP
      END
C
C Subrotina para o produto de duas matrizes de 2x2
C
      SUBROUTINE MULTMAT(A, B, C)
      DIMENSION A(2, 2), B(2, 2), C(2, 2)
C
C    faz ciclo sobre o número de linhas I
C
      DO 1 I = 1, 2
C
C    faz produto com a matriz quadrada  B
C
        DO 2 J = 1, 2
          AB = 0.0       ! Inicia valor da posição da matriz
          DO 3 K = 1, 2
            AB = AB+A(I, K)*B(K, J) !Adiciona contribuições
    3     CONTINUE
          C(I, J) = AB    ! Guarda valor na posição da matriz
    2   CONTINUE
    1 CONTINUE
C
      RETURN
      END 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close