Advertisement
zrhans

gas_ideal.f95

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