Calcular o Tipo da Navegação
Autor: Lucas de Matos Rocha | Publicado: 2012-03-19T14:32:00-07:00




&nbsp; &nbsp;Olá caro leitor,neste post irei apresentar um pequeno software com pouco mais de 120 linhas de código, este foi desenvolvido em linguagem Fortran77 e faz o cálculo do tipo da navegação baseado na informação de profundidade e da distância da costa.Este programa foi compilado gerando um executável com 64,9 kb,seu código fonte tem no total 126 linhas de código entre linhas de comentário,em branco e código fonte propriamente dito.
&nbsp; As regras de navegação foram obtidas através do livro NAVEGAÇÃO : CIÊNCIA E A ARTE, da Marinha do Brasil,o programa irá efetuar um simples cálculo hidroceanográfico.

Tipo da navegação: &nbsp; &nbsp; &nbsp;Águas Restritas

Distância: 3&nbsp;mn
Profundidade: 20 metros
Precisão: 0,05&nbsp;mn
Frequência(atualização):&nbsp;3 minutos


Tipo da navegação: &nbsp; &nbsp;&nbsp;&nbsp;Águas Costeira

Distância:4 a 50 mn
Profundidade: 21 a 200 metros
Precisão: 0,5&nbsp;mn
Frequência(atualização): &nbsp;10 || 30


Tipo da navegação: &nbsp; &nbsp;&nbsp;&nbsp;Águas Oceânica

Distância: 51 + a mn
Profundidade: 500 + metros
Precisão: 1 || 2 mn
Frequência(atualização): &nbsp;3 minutos



mn = milhas náuticas =&gt; 1.852 km
|| =.&gt; sinal em computação numérica significa OU.

(Dados de 2006).

Agora que já obtemos as informações iremos para a parte lógica do nosso programa.

&nbsp; 10 &nbsp;Recebe DISTANCIA&nbsp;
&nbsp; 20 &nbsp;Se DISTANCIA = 0 =&gt; Voltar para 10
&nbsp; 30 &nbsp;Converte DISTANCIA em : &nbsp;mn,m,yd,ft
&nbsp; 40
&nbsp; 50 Recebe PROFUNDIDADE
&nbsp; 60&nbsp;Se
PROFUNDIDADE&nbsp;&nbsp;= 0 =&gt; Voltar para 50
&nbsp; 70&nbsp;Converte&nbsp;
PROFUNDIDADE&nbsp;&nbsp;&nbsp;em : m,yd,ft
&nbsp; 80
&nbsp; 90 Se&nbsp;
DISTANCIA&nbsp;&nbsp;= &nbsp;&lt; 4 &nbsp;|| Se&nbsp;PROFUNDIDADE = &lt; 24
&nbsp;100 NAVEGACAO == AGUAS RESTRITAS
&nbsp;110&nbsp;
&nbsp;120&nbsp;
&nbsp;130&nbsp;Se&nbsp;&nbsp;DISTANCIA&nbsp;&nbsp;= &nbsp;&gt; 4 e &lt; 50 &nbsp;|| Se&nbsp;PROFUNDIDADE =&lt;24 e&gt;&nbsp;201
&nbsp;140&nbsp;NAVEGACAO == AGUAS RESTRITAS
&nbsp;150&nbsp;ESCREVA RESULTADOS
&nbsp;160&nbsp;Se&nbsp;&nbsp;DISTANCIA&nbsp;&nbsp;= &nbsp;&gt; 50 &nbsp;|| Se&nbsp;PROFUNDIDADE = &gt; 500
&nbsp;170&nbsp;NAVEGACAO == AGUAS OCEANICAS
&nbsp;180ESCREVA RESULTADOS
&nbsp;190&nbsp;
&nbsp;200&nbsp;ESCREVA RESULTADOS FINAIS
&nbsp;210 ESCREVA TIPO DA NAVEGAÇÃO.



Veja agora abaixo a "print" do programa em execução e o código fonte.




(Clique para&nbsp;expandir.)





C

C &nbsp; &nbsp; &nbsp;NAME: TNA

C &nbsp; &nbsp; &nbsp;AUTHOR: Lucas de Matos Rocha

C &nbsp; &nbsp; &nbsp;DESCRIPTION: Calcular o tipo da navegação

C &nbsp; &nbsp; &nbsp;DATE:

C



C &nbsp; &nbsp; .START

&nbsp; &nbsp; &nbsp; &nbsp;PROGRAM TIPONAVEG



C &nbsp; &nbsp; &nbsp;.DATA



&nbsp; &nbsp; &nbsp; &nbsp; REAL TNV;

C &nbsp; &nbsp; &nbsp; REAL TNV = Tipo navegacao

&nbsp; &nbsp; &nbsp; &nbsp; REAL D,P;

C &nbsp; &nbsp; &nbsp; REAL D = Distancia

C &nbsp; &nbsp; &nbsp; REAL P = Profundidade

&nbsp; &nbsp; &nbsp; &nbsp; CHARACTER MSG*(10);

C &nbsp; &nbsp; &nbsp; CHAR MSG = &nbsp;Mensagens

&nbsp; &nbsp; &nbsp; &nbsp; CHARACTER SPC_*(30);

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SPC_='...........................';

C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ESPACO 30 CHARACTERS



C &nbsp; &nbsp; &nbsp;.CODE

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),SPC_,'TIPO DA NAVEGACAO ',SPC_;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PRINT'(a)',' '!PULAR LINHA

C

C &nbsp; &nbsp; &nbsp; &nbsp; #### DISTANCIA ####

C

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WRITE(*,*),'INSIRA A DISTANCIA:(KM)' ;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; READ (*,*),D;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; DO WHILE (D==0)

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'A Distancia nao pode ser 0 (ZERO).'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WRITE(*,*),'INSIRA A DISTANCiA:(KM)'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; READ (*,*),D;

&nbsp; &nbsp; &nbsp; &nbsp; END DO

&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)','_DISTANCIA_'



&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'NM:',D/1.852 ,' &nbsp; &nbsp; &nbsp; &nbsp;Milhas N uticas'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'M :',D/1000 &nbsp;,' &nbsp; &nbsp; &nbsp; &nbsp;Metros'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'YD:',D/0.91439920429,' &nbsp; &nbsp; &nbsp; &nbsp;Jardas'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'FT:',D/0.3048,' &nbsp; &nbsp; &nbsp; &nbsp;Pes'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

C

C &nbsp; &nbsp; &nbsp; &nbsp;#### PROFUNDIDADE &nbsp;####

C

&nbsp; &nbsp; &nbsp; &nbsp; WRITE(*,*),'INSIRA A PROFUNDIDA:(M)'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; READ (*,*),P;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PRINT'(a)',' '!PULAR LINHA



&nbsp; &nbsp; &nbsp; &nbsp; DO WHILE (P==0)

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'A Profundidade nao pode ser 0 (ZERO).'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WRITE(*,*),'INSIRA A Profundidade:(M)'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; READ (*,*),P;

&nbsp; &nbsp; &nbsp; &nbsp; END DO

&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PRINT'(a)','_PROFUNDIDADE_'



&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'M :',P,' &nbsp; &nbsp; &nbsp; &nbsp;Metros'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'YD:',P/0.91439920429,' &nbsp; &nbsp; &nbsp; &nbsp;Jardas'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WRITE(*,*),'FT:',P/0.3048,' &nbsp; &nbsp; &nbsp; &nbsp;Pes'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA



C &nbsp; &nbsp; &nbsp; &nbsp; #### &nbsp; &nbsp; OCEANICA &nbsp; ####

C

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IF(D&gt;50)THEN

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IF(P&gt;500)THEN

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)','TIPO DA NAVEGACAO [( OCEANICA )]'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ENDIF

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ENDIF

C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;####





C &nbsp; &nbsp; &nbsp; &nbsp; #### &nbsp; &nbsp; COSTEIRA &nbsp; &nbsp;####

C

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IF(D&lt;50)THEN

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IF(D&gt;4)THEN

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IF(P&lt;500)THEN

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IF(P&gt;24 )THEN

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)','TIPO DA NAVEGACAO [( COSTEIRA )]'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ENDIF

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ENDIF

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ENDIF

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ENDIF

C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;####





C

C &nbsp; &nbsp; &nbsp; &nbsp; #### &nbsp; &nbsp; RESTRITA &nbsp; &nbsp;####

C

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IF(D&lt;4)THEN

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IF(P&lt;24)THEN

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)','TIPO DA NAVEGACAO [( &nbsp;RESTRITA &nbsp;)]'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ENDIF

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ENDIF

C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;####





C &nbsp; &nbsp; &nbsp;.END BLOCK

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PRINT'(a)','Lucas Softwares 2010-2012'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)','Scientific Software'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)','Free Softwre GPL 3.0 &nbsp;'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' Pressione "ENTER"'!

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PRINT'(a)',' '!PULAR LINHA

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PAUSE

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RETURN;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; STOP

&nbsp; &nbsp; &nbsp; &nbsp;END



;