Publicado el 4 de Marzo del 2020
427 visualizaciones desde el 4 de Marzo del 2020
660,8 KB
16 paginas
Creado hace 16a (26/08/2008)
Programación modular
Subdivisión en programas más
pequeños
35
LMM
Características
• Independientes y autosuficientes (contienen
toda la información necesaria)
• Tienen una función específica bien definida
• Tienen puntos de entrada y salida
En Fortran y C se llaman procedimientos
(cortos)
(procedure)
Tipos
Función (function) un solo resultado
Subrutina (subroutine) varios resultados
36
LMM
Fortran
Summary Tables
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
The Fortran procedures and statements have been organized into the following tables:
Program Unit Calls and Definition
Program Control Statements and Procedures
Specifying Variables
System, Drive, and Directory Procedures
File Management
Input/Output Procedures
Random Number Procedures
Date and Time Procedures
Keyboard and Speaker Procedures
Error Handling
Argument Inquiry
Memory Allocation and Deallocation Procedures
Array Procedures
Numeric and Type Conversion Procedures
Trigonometric, Exponential, Root, and Logarithmic Procedures
Floating-Point Inquiry and Control Procedures
Character Procedures
Bit Operation and Representation Procedures
QuickWin Procedures
Graphics Procedures
Dialog Procedures
General Compiler Directives
National Language Standard Procedures
Portability Procedures
COM and Automation Procedures
Serial Port Procedures
Miscellaneous Run-Time Procedures (FOR_* routines)
Functions Not Allowed as Actual Arguments
Tablas con procedimientos e instrucciones en Visual
( buscarlas en Helpindexintrinsic functionLanguage
Summary=resumen
resumen
Summary=
, los
algunas, los
procedimientos puede
puede
usaremos algunas
Solo usaremos
Solo
ListaLista de de procedimientos
verse en
verse en
En En HelpHelpIndex
proceduresOverview
procedures
procedures (seleccionar
procedures (
O subroutines, segsegúúnn el el casocaso).).
O subroutines,
Indexintrinsic
intrinsic
Overview of intrinsic
of intrinsic
seleccionar functions
functions
37
LMM
Funciones intrínsecas elementales
(buscarlas en Helpindexintrinsic
functionstrigonometric…)
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Trigonometric, Exponential, Root, and Logarithmic Procedures: table
NameDescriptionArgument/Function Type
ACOS ACOS(x). Returns the arc cosine of x in radians between 0 and pi. When ACOS is passed as an argument, x must be REAL(4). x: Real result:
same type as x
ACOSD ACOSD(x). Returns the arc cosine of x in degrees between 0 and 180. When ACOSD is passed as an argument, x must be REAL(4). x: Real
result: same type as x
ALOG ALOG(x). Returns natural log of x. x: REAL(4) result: REAL(4)
ALOG10 ALOG10(x). Returns common log (base 10) of x. x: REAL(4) result: REAL(4)
ASIN ASIN(x). Returns arc sine of x in radians between ±pi/2. When ASIN is passed as an argument, x must be REAL(4). x: Real result: same type as x
ASIND ASIND(x). Returns arc sine of x in degrees between ±90°. When ASIND is passed as an argument, x must be REAL(4). x: Real result: same
type as x
ATAN ATAN(x). Returns arc tangent of x in radians between ±pi/2. When ATAN is passed as an argument, x must be REAL(4). x: Real result: same
type as x
ATAND ATAND(x). Returns arc tangent of x in degrees between ±90°. When ATAND is passed as an argument, x must be REAL(4). x: Real result:
same type as x
ATAN2 ATAN2(y, x). Returns the arc tangent of y/x in radians between ±pi . When ATAN2 is passed as an argument, y and x must be REAL(4). y: Real
x: same as y
result: same type as y
ATAN2D ATAN2D(y, x). Returns the arc tangent of y/x in degrees between ±180°. When ATAN2D is passed as an argument, y and x must be
REAL(4). y: Real x: same as y
result: same type as y
COS COS(x). Returns cosine of x radians. When COS is passed as an argument, x must be REAL(4). x: Real or Complex result: same type as x
COSD COSD(x). Returns cosine of x degrees. When COSD is passed as an argument, x must be REAL(4). x: Real result: same type as x
COSH COSH(x). Returns the hyperbolic cosine of x. When COSH is passed as an argument, x must be REAL(4). x: Real result: same type as x
COTAN COTAN (x). Returns cotangent of x in radians. x: Real result: same type as x
COTAND COTAND (x). Returns cotangent of x in degrees. x: Real result: same type as x
EXP EXP(x). Returns value of e**x. When EXP is passed as an argument, x must be REAL(4). x: Real or Complex result: same type as x
LOG LOG(x) Returns the natural log of x. x: Real or Complex result: same type as x
LOG10 LOG10(x). Returns the common log (base 10) of x. x: Real result: same type as x
SIN SIN(x). Returns the sine of x radians. When SIN is passed as an argument, x must be REAL(4). x: Real or Complex result: same type as x
SIND SIND(x). Returns the sine of x degrees. When SIND is passed as an argument, x must be REAL(4). x: Real result: same type as x
SINH SINH(x). Returns the hyperbolic sine of x. When SINH is passed as an argument, x must be REAL(4). x: Real result: same type as x
SQRT SQRT(x). Returns the square root of x. When SQRT is passed as an argument, x must be REAL(4). x: Real or Complex result: same type as x
TAN TAN(x). Returns the tangent of x radians. When TAN is passed as an argument, x must be REAL(4). x: Real result: same type as x
TAND TAND(x). Returns the tangent of x degrees. When TAND is passed as an argument, x must be REAL(4). x: Real result: same type as x
TANH TANH(x). Returns the hyperbolic tangent of x. When TANH is passed as an argument, x must be REAL(4). x: Real result: same type as x
PRECISIÓÓN SIMPLE,
PRECISI
N SIMPLE, cambian
cambian con
con precisi
precisióónn
38
LMM
Funciones intrínsecas usuales
(buscarlas en Helpindexintrinsic
functionstrigonometric…)
• ACOS(x). arc cosine of x in radians between 0 and pi. *
• ALOG(x). natural log of x. x: REAL(4) result: REAL(4)
• ASIN(x). arc sine of x in radians between ±pi/2. *
• ATAN(x). arc tangent of x in radians between ±pi/2. *
• COS(x). cosine of x radians. *
• COSH(x). Returns the hyperbolic cosine of x. *
• COTAN (x). cotangent of x in radians.
• EXP(x). value of e**x. *
• LOG(x) the natural log of x.
• LOG10(x). the common log (base 10) of x.
• SIN(x). the sine of x radians. *
• SINH(x). hyperbolic sine of x. *
• SQRT(x). the square root of x. *
• TAN(x). the tangent of x radians. *
• TANH(x). the hyperbolic tangent of x. *
Pueden cambiar
Pueden
cambiar con la
con la precisi
precisióónn
ABSABS(x(x) valor
) valor absoluto
absoluto
SQRT(x(x): ): raraíízz cuadrada
SQRT
cuadrada
((SQuare
SQuare RooTRooT))
•Resultado real según el tipo del
argumento.
•Algunas son también complejas.
* Cuando son argumento de otra función,
deben ser REAL(4)
39
LMM
Funciones
Funciones
• Formato
FUNCTION nombre(arg1,arg2)
bloque de la función
nombre= valor
RETURN
END
FinFin
Llamada
Llamada
resultado=nombre(arg1,arg2)
=nombre(arg1,arg2)
resultado
Argumentos mudos
mudos
Argumentos
(dummy)
(dummy)
Declaraciones, ,
Declaraciones
instrucciones,entrada/salida,etc..
instrucciones,entrada/salida,etc
Asigna valor a
Asigna
coincider con
coincider
valor a resultado
resultado, variable
con nombre
nombre
, variable debe
debe
estar en el
en el mismomismo
deben
nombre deben
programa principal
principal
••Puede
Puede estar
archivo del del programa
archivo
••El El tipotipo y precision de
y precision de
resultado y y nombre
resultado
coincidir
coincidir
Para agregar
••Para
agregar
archivo:ProjectAddAdd to project
to project
archivo:Project
MismoMismo archivo
archivo
40
LMM
Ejemplo Función
en el mismo archivo del programa principal
41
LMM
Ejemplo Función
secuencia de las instrucciones
42
LMM
Subrutinas
Subrutinas
• Formato
SUBROUTINE nombre(arg1,arg2)
bloque de subrutina
Argumentos mudos
mudos
Argumentos
(dummy): datos
(dummy):
datos y y resultados
resultados
Declaraciones, ,
Declaraciones
instrucciones,entrada/salida,,
instrucciones,entrada/salida
Asignacióónn de de valores
valores, , etc.etc.
Asignaci
RETURN
END
Llamada
Llamada
Retorno y finy fin
Retorno
CALLCALL nombre(arg1,arg2)
nombre(arg1,arg2)
MismoMismo archivo
archivo
LMM
estar en el
en el mismomismo
programa principal
principal
••Puede
Puede estar
archivo del del programa
archivo
••Para
Para agregar
agregar
archivo:ProjectAddAdd to project
to project
archivo:Project
primero
••Convenci
Convencióónn: : primero
variables de datos
datos, , luego
variables de
de de resultados
resultados
••Variables de
Variables de entrada
modificarse en la
modificarse
entrada pueden
pueden
43
luego los
los
en la subrutina
subrutina
Ejemplo Subrutina
en el mismo archivo del programa principal
44
LMM
Digital Visual Fortran
Digital Visual Fortran
Sin gráficas
45
Digital Visual Fortran
• Acceso: en Visual Fortran Developer
Studio
• Proyecto: archivos fuente y
especificaciones para construir el
programa (nombre.dsp)
• Espacio de trabajo: puede contener
múltiples proyectos (nombre.dsw)
46
LMM
Espacio de trabajo
Barras de Herramientas
Herramientas
Barras de
File View :
File View :
Archivos ligados
ligados
Archivos
al al proyecto
proyecto
Archivo fuente
Archivo
fuente en en edici
edicióónn
Mensajes durante
Mensajes
durante compilaci
compilacióónn, , ligaliga y y ejecuci
ejecucióónn
47
LMM
Procedimiento para construir y correr
programas en Digital Visual Fortran
• Editar el programa fuente:
FileNewFilesFortran Fixed Format Source
File
Dar nombre de archivo (nombre) y directorio
donde se crea: genera nombre.for
• Compilar (Compile): Crear nuevo proyecto
genera nombre.obj
• Ligar (Build) : genera archivo ejecutable
nombre.exe y ejecuta
48
LMM
Procedimiento para construir proyectos en
Digital Visual Fortran: nuevo
• File New (Project) Fortran Console AplicationAn empty
project
(Si damos A
Comentarios de: Programación modular Subdivisión en programas más pequeños (0)
No hay comentarios