Advertisement
zrhans

gases_ideais.f90

Jun 9th, 2015
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program gases_ideais
  2. implicit none
  3.  
  4. real :: T,P,N,VOLUME
  5. real :: le_valor, gas_ideal
  6.  
  7.     T = le_valor('o valor da temperatura');
  8.     P = le_valor('o valor da pressão');
  9.     N = le_valor('o numero de mols');
  10.  
  11.     volume = gas_ideal(T,P,N)
  12.  
  13.     write(*,*)"Volume: ",volume
  14.  
  15. end program gases_ideais
  16.  
  17. ! ==================================
  18. ! FUNCOES
  19. ! ==================================
  20.  
  21. ! Esta funcao calcula o volume de um gas ideal
  22. real function gas_ideal(temp,press,n_mols)
  23. implicit none
  24. !integer,intent(in) :: n_mols
  25. real :: temp, press,N_MOLS
  26.     gas_ideal = n_mols*8.314*temp/press
  27.     return
  28. end function
  29.  
  30. ! Esta funcao auxilia na leitura de valores digitados pelo usuario
  31. real function le_valor(msg)
  32. implicit none
  33.  
  34.     character(len=*), intent(in) :: msg
  35.  
  36.     ! Mostra a mensagem pedindo para o usuario entrar algum valor
  37.     write(*, '(A,A,A)', ADVANCE = "NO") "Por favor entre ",msg,": "
  38.     read(*,*) le_valor
  39. end function le_valor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement