sábado, 31 de agosto de 2019

Curso breve de fisica computacional, FORTRAN COURSE ON COMPUTATIONAL PHYSICS ,

Este curso lo lleve en la carrera por cierto pesimamente dado por Ignacio garzon
(https://www.fisica.unam.mx/es/personal.php?id=35 )del IFISICA,
que se ve que no tenia idea de lo que era programar, pésimo profesor y bastante mediocre investigador,
igual que varios del IFISCA que comentare posteriormente.

Pero bueno al menos llevo un excelente libro que es este:








seteando el ambiente, puedes ocupar distintos tipos de compiladores fortran, yo ocupo algunos de distribución libre para linux, y MAC, pero también tengo algunos para windows que tienen una interfaz bastante amigable



algunas definiciones
DEFINICION CORRECTA DE LIMITE, 





CAMINO LIBRE MEDIO MOLECULAR, PARA POSTERIOR USO EN ORAC, 

POTENCIAL INTERMOLECULAR



I will use the classic book of Koonin which is very good specialy in the first chapter

the code is fortran is a very good languaje and you can use the VISUAL FORTRAN
or better the free editions for windows or linux


desde cero

copio el folder fort99 y g95 a c:/>

y seteo variables de ambiente al bin

set up de las variables de ambiente

después compilo el primero

X=1. EXACT=COS(X) 10 PRINT *, 'Enter value of h (.le. 0 to stop)' READ *, H IF(H .LE. 0) STOP FPRIME = (SIN(X+H)-SIN(X-H))/(2*H) DIFF=EXACT-FPRIME PRINT 20,H,DIFF 20 FORMAT(' H=',E15.8, 5X, 'ERROR=',E15.8) GOTO 10 END



PARA G77

C:\fort99\G77>g77 g77: No input files C:\fort99\G77>g77 DERIVADA1.for derivada g77: derivada: No such file or directory C:\fort99\G77> C:\fort99\G77>dir Volume in drive C has no label. Volume Serial Number is D08A-3849 Directory of C:\fort99\G77 12/27/2020 08:45 PM <DIR> . 12/27/2020 08:45 PM <DIR> .. 09/23/2005 11:20 AM 10,860 ar.doc 12/27/2020 08:45 PM <DIR> bin 08/30/2019 10:26 PM 57,686 derivada.exe 08/30/2019 10:26 PM 236 DERIVADA1.for 12/27/2020 08:45 PM <DIR> doc 08/31/2019 09:33 AM 63 g77setup.bat 08/30/2019 09:21 PM 111 hello.f 08/30/2019 09:19 PM 111 hello.f90 09/23/2005 11:20 AM 145 HR.ERR 12/27/2020 08:45 PM <DIR> lib 09/23/2005 11:20 AM 4,861 mytest1.f 09/23/2005 11:20 AM 5,305 mytest2.f 08/31/2019 08:46 AM 1,442 plot.f 09/23/2005 11:20 AM 17,269 readme1.txt 08/31/2019 09:44 AM 57,502 simpson.exe 08/31/2019 09:44 AM 804 SIMPSON.F 08/31/2019 09:40 AM 3,538 SIMSON 14 File(s) 159,933 bytes 5 Dir(s) 6,998,269,952 bytes free C:\fort99\G77>g77 DERIVADA1.for -o derivada C:\fort99\G77>derivada Enter value of h (.le. 0 to stop) 10 H= 0.10000000E+02 ERROR= 0.56969589E+00 Enter value of h (.le. 0 to stop) 100 H= 0.10000000E+03 ERROR= 0.54303819E+00 Enter value of h (.le. 0 to stop) 100000 H= 0.10000000E+06 ERROR= 0.54030210E+00 Enter value of h (.le. 0 to stop) 5 H= 0.50000000E+01 ERROR= 0.64392406E+00 Enter value of h (.le. 0 to stop) 90 H= 0.90000000E+02 ERROR= 0.53493530E+00 Enter value of h (.le. 0 to stop) list in: end of file apparent state: unit 5 (unnamed) last format: list io Interrupt C:\fort99\G77>



X=1.
EXACT=COS(X)
10 PRINT *, 'Enter value of h (.le. 0 to stop)'
READ *, H
IF(H .LE. 0) STOP
FPRIME = (SIN(X+H)-SIN(X-H))/(2*H)
DIFF=EXACT-FPRIME
PRINT 20,H,DIFF
20 FORMAT(' H=',E15.8, 5X, 'ERROR=',E15.8)
GOTO 10
END

C:\fort99\G77>derivada
 Enter value of h (.le. 0 to stop)
10
 H= 0.10000000E+02     ERROR= 0.56969589E+00
 Enter value of h (.le. 0 to stop)
1
 H= 0.10000000E+01     ERROR= 0.85653573E-01
 Enter value of h (.le. 0 to stop)
0.5
 H= 0.50000000E+00     ERROR= 0.22232831E-01
 Enter value of h (.le. 0 to stop)
0.00001
 H= 0.99999997E-05     ERROR= 0.88024139E-03
 Enter value of h (.le. 0 to stop)
0.02
 H= 0.20000000E-01     ERROR= 0.36835670E-04
 Enter value of h (.le. 0 to stop)
0.02
 H= 0.20000000E-01     ERROR= 0.36835670E-04
 Enter value of h (.le. 0 to stop)
0.0000000001
 H= 0.10000000E-09     ERROR= 0.54030228E+00
 Enter value of h (.le. 0 to stop)
0.2
 H= 0.20000000E+00     ERROR= 0.35948157E-02
 Enter value of h (.le. 0 to stop)
0.01
 H= 0.99999998E-02     ERROR= 0.70333481E-05
 Enter value of h (.le. 0 to stop)


EN MAC TIGER LO TENGO ASI



First we are going to use fortran for convenience, since I think it is very clear at the beginning that using C or C ++ the advantage that I see for forran is that it is logically more intuitive and clear,

First you have to take into account that the main operations for a physicist or applied mathematics is the derivation, integration and finding the roots of an equation.

Therefore, we are going to use the Taylor and McLaurin formulas to find the derivatives and integrals by numerical methods.


Primero vamos a usar fortran por comodidad, ya que creo que es mucho as claro al inicio que usar C o C++ la ventaja que le veo a forran es que es lógicamente mas intuitivo y claro,

primero se tiene que tener en cuenta que las operaciones principales para un fisico o matematicas aplicadas es la derivación, integración y encontrar las raices de una ecuación.

Por lo tanto, vamos a usar las formulas de Taylor y McLaurin para encontrar las derivadas e integrales por metodos numericos

PROGRAMA EN FORTRAN PARA DERIVAR E INTEGRAR

LOS COMPILADORES DE WINDOWS FUNCIONANDO BIEN


setup de cero seto la variable ambiente y  12-28-2020



Microsoft Windows [Versión 10.0.17134.950]
(c) 2018 Microsoft Corporation. Todos los derechos reservados.

C:\Users\admin>cd \

C:\>cd g95

C:\g95>g95
g95: no input files

C:\g95>

C:\g95>dir
 El volumen de la unidad C es Windows
 El número de serie del volumen es: CA17-A5F2

 Directorio de C:\g95

08/31/2019  11:55 AM    <DIR>          .
08/31/2019  11:55 AM    <DIR>          ..
07/02/2018  09:44 PM           346,986 a.exe
07/02/2018  09:38 PM    <DIR>          bin
07/21/2018  01:03 AM               254 chap1a.for
07/21/2018  12:43 AM                12 chap1b.for
08/31/2019  11:55 AM               658 chapman1.for
08/30/2019  11:11 PM               952 constants.mod
12/27/2007  09:23 AM             2,192 crt1.o
12/27/2007  09:23 AM             2,288 crt2.o
12/27/2007  09:23 AM             1,239 dllcrt2.o
07/02/2018  09:38 PM    <DIR>          doc
08/30/2019  11:11 PM               592 functions.mod
08/30/2019  09:15 PM           346,986 hello.exe
08/30/2019  09:15 PM               111 hello.f90
07/02/2018  09:38 PM    <DIR>          lib
07/20/2018  11:51 PM               240 nestedloops.f95
07/02/2018  09:22 PM                61 PROG1.f90
07/02/2018  09:27 PM                61 PROG1.f95
07/02/2018  09:22 PM                61 PROG1.txt
08/30/2019  11:15 PM           356,671 program4.exe
08/30/2019  11:15 PM             1,244 PROGRAM4.F90
07/20/2018  11:23 PM           348,105 statisticsDS.exe
07/20/2018  11:22 PM               837 statisticsDS.f95
07/20/2018  09:41 PM               336 tempconvert.f95
07/20/2018  09:41 PM           346,986 tempconverter.exe
07/20/2018  11:38 PM           346,986 testcycle.exe
07/20/2018  11:37 PM               131 testcycle.f95
07/20/2018  11:52 PM           346,986 testexit.exe
07/20/2018  11:52 PM               141 testexit.f95
              25 archivos      2,451,116 bytes
               5 dirs  53,932,896,256 bytes libres

C:\g95>g95 chapman1.for -o chapman1
Error: Unexpected end of file in 'chapman1.for'

C:\g95>g95 chapman1.for -o chapman1
Error: Unexpected end of file in 'chapman1.for'

C:\g95>gfortran
gfortran: no input files

C:\g95>gfortran chapman1.for -o chapman1
Error: Unexpected end of file in 'chapman1.for'

C:\g95>gfortran chapmancorrect1.f90 -o chapman1

C:\g95>chapman1
 This program solves for the roots of a quadratic
 equation of the form A * X**2 + B * X + C = 0.
 Enter the coefficients A, B, and C:
2 4 5
 The coefficients A, B, and C are:    2.0000000       4.0000000       5.0000000
 This equation has complex roots:
 X1 =   -1.0000000      +i    1.2247449
 X2 =   -1.0000000      -i    1.2247449

C:\g95>g95 chapmancorrect1.f90 -o chapman1a

C:\g95>chapman1a
 This program solves for the roots of a quadratic
 equation of the form A * X**2 + B * X + C = 0.
 Enter the coefficients A, B, and C:
2 4 5
 The coefficients A, B, and C are:  2. 4. 5.
 This equation has complex roots:
 X1 =  -1.  +i  1.2247449
 X2 =  -1.  -i  1.2247449

C:\g95>



me estaba dando error el g95 en windows

abro  la VM
 C:\Users\rober\Documents\Virtual Machines\FILENET virtual machine COMPAC VISUAL FORTRAN





aca Agrego el programa se inserta

el recurso de chapman roots





PROGRAM roots

!  Purpose:
!    This program solves for the roots of a quadratic equation of the 
!    form a*x**2 + b*x + c = 0.  It calculates the answers regardless
!    of the type of roots that the equation possesses.
!
!  Record of revisions:
!      Date       Programmer          Description of change
!      ====       ==========          =====================
!    11/06/15    S. J. Chapman        Original code
!
IMPLICIT NONE

! Data dictionary: declare variable types, definitions, & units  
REAL :: a              ! Coefficient of x**2 term of equation
REAL :: b              ! Coefficient of x term of equation
REAL :: c              ! Constant term of equation
REAL :: discriminant   ! Discriminant of the equation
REAL :: imag_part      ! Imaginary part of equation (for complex roots)
REAL :: real_part      ! Real part of equation (for complex roots)
REAL :: x1             ! First solution of equation (for real roots)
REAL :: x2             ! Second solution of equation (for real roots)

! Prompt the user for the coefficients of the equation
WRITE (*,*) 'This program solves for the roots of a quadratic '
WRITE (*,*) 'equation of the form A * X**2 + B * X + C = 0. '
WRITE (*,*) 'Enter the coefficients A, B, and C: '
READ  (*,*) a, b, c

! Echo back coefficients
WRITE (*,*) 'The coefficients A, B, and C are: ', a, b, c  

! Calculate discriminant
discriminant = b**2 - 4. * a * c     

! Solve for the roots, depending upon the value of the discriminant
IF ( discriminant > 0. ) THEN ! there are two real roots, so...

   x1 = ( -b + sqrt(discriminant) ) / ( 2. * a )
   x2 = ( -b - sqrt(discriminant) ) / ( 2. * a )
   WRITE (*,*) 'This equation has two real roots:'
   WRITE (*,*) 'X1 = ', x1
   WRITE (*,*) 'X2 = ', x2

ELSE ( discriminant < 0. ) THEN ! there are complex roots, so ...

   real_part = ( -b ) / ( 2. * a )
   imag_part = sqrt ( abs ( discriminant ) ) / ( 2. * a )
   WRITE (*,*) 'This equation has complex roots:'
   WRITE (*,*) 'X1 = ', real_part, ' +i ', imag_part
   WRITE (*,*) 'X2 = ', real_part, ' -i ', imag_part

ELSE IF ( discriminant == 0. ) THEN ! there is one repeated root, so...

   x1 = ( -b ) / ( 2. * a )
   WRITE (*,*) 'This equation has two identical real roots:'
   WRITE (*,*) 'X1 = X2 = ', x1

END IF

END PROGRAM roots


#######################################################################################################


pasos





console application


2- insert files in workspace





click compile






and then 

3- build roots.exe







RESULTADOS CORRECTOS



USANDO MAC TIGER OX, GFORTRAN


Last login: Sat Aug 31 10:20:15 on ttyp1
Welcome to Darwin!
indefinido-indefinidos-imac-g5:~ indefinidoindefinido$ cd usr~
-bash: cd: usr~: No such file or directory
indefinido-indefinidos-imac-g5:~ indefinidoindefinido$ cd /usr
indefinido-indefinidos-imac-g5:/usr indefinidoindefinido$ ls
]X11R6          include         libexec         sbin            standalone
bin             lib             local           share

indefinido-indefinidos-imac-g5:/usr indefinidoindefinido$ export PATH=$PATH:/usr/local/bin
indefinido-indefinidos-imac-g5:/usr indefinidoindefinido$ gfortran
powerpc-apple-darwin8-gfortran-4.2: no input files
indefinido-indefinidos-imac-g5:/usr indefinidoindefinido$ cd /Users/indefinidoindefinido/Documents/yatested
indefinido-indefinidos-imac-g5:~/Documents/yatested indefinidoindefinido$ ls
DERIVADA1.for   SIMPSON.F       hello.f         plot.f
indefinido-indefinidos-imac-g5:~/Documents/yatested indefinidoindefinido$ gfortran DERIVADA1.for /o derivada
powerpc-apple-darwin8-gfortran-4.2: /o: No such file or directory
powerpc-apple-darwin8-gfortran-4.2: derivada: No such file or directory
indefinido-indefinidos-imac-g5:~/Documents/yatested indefinidoindefinido$ gfortran DERIVADA1.for -o derivada
indefinido-indefinidos-imac-g5:~/Documents/yatested indefinidoindefinido$ ls
DERIVADA1.for   SIMPSON.F       derivada        hello.f         plot.f
indefinido-indefinidos-imac-g5:~/Documents/yatested indefinidoindefinido$ ./derivada

 Enter value of h (.le. 0 to stop)
10
 H= 0.10000000E+02     ERROR= 0.56969589E+00
 Enter value of h (.le. 0 to stop)
0.5
 H= 0.50000000E+00     ERROR= 0.22232831E-01
 Enter value of h (.le. 0 to stop)
0.01
 H= 0.99999998E-02     ERROR= 0.10013580E-04
 Enter value of h (.le. 0 to stop)
0.0002
 H= 0.19999999E-03     ERROR=-0.13828278E-04
 Enter value of h (.le. 0 to stop)
0.02
 H= 0.20000000E-01     ERROR= 0.36835670E-04
 Enter value of h (.le. 0 to stop)
0.000000005
 H= 0.50000000E-08     ERROR= 0.54030228E+00
 Enter value of h (.le. 0 to stop)
^[[A
At line 4 of file DERIVADA1.for
Fortran runtime error: Bad real number in item 1 of list input
indefinido-indefinidos-imac-g5:~/Documents/yatested indefinidoindefinido$ ls
indefinido-indefinidos-imac-g5:~/Documents/yatested indefinidoindefinido$ gfortran SIMPSON.F -o simpson
SIMPSON.F:26: warning: no newline at end of file
indefinido-indefinidos-imac-g5:~/Documents/yatested indefinidoindefinido$ ./simpson
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
4
     N=    4     ERROR=-0.37193298E-04
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
8
     N=    8     ERROR=-0.23841858E-05
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
16
     N=   16     ERROR=-0.35762787E-06
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
32
     N=   32     ERROR= 0.00000000E+00
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
64
     N=   64     ERROR=-0.35762787E-06
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
128
     N=  128     ERROR=-0.11920929E-06
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
1000
     N= 1000     ERROR=-0.59604645E-06
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
150000
     N=*****     ERROR=-0.10609627E-04
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)
15000000
     N=*****     ERROR= 0.34258723E-01
 ENTER N PAR (EVEN), (.LT. 2 TO STOP)

REFERENCIA DE WIKIPEDIA PARA RECORDAR

Recordando que

Serie de Taylor

Ir a la navegaciónIr a la búsqueda

A medida que aumenta el grado del polinomio de MacLaurin, se aproxima a la función. Se ilustran las aproximaciones de MacLaurin a sen(x), centradas en 0, de grados1357911 y 13.

La gráfica de la función exponencial (en azul), y la suma de los primeros n+1 términos de su serie de Taylor en torno a cero (en rojo).
En matemáticas, una serie de Taylor es una aproximación de funciones mediante una serie de potencias o suma de potencias enteras de polinomios como  llamados términos de la serie, dicha suma se calcula a partir de las derivadas de la función para un determinado valor o punto  suficientemente derivable sobre la función y un entorno sobre el cual converja la serie. A la serie centrada sobre el punto cero, , se le denomina también serie de MacLaurin.
Esta aproximación tiene tres ventajas importantes:
  • la derivación e integración de una de estas series se puede realizar término a término, que resultan operaciones triviales;
  • se puede utilizar para calcular valores aproximados de funciones;
  • es posible calcular la optimidad de la aproximación.
Algunas funciones no se pueden escribir como serie de Taylor porque tienen alguna singularidad. En estos casos normalmente se puede conseguir un desarrollo en serie utilizando potencias negativas de x (véase Serie de Laurent). Por ejemplo f(x) = exp(−1/x²) se puede desarrollar como serie de Laurent.











Definición[editar]

La serie de Taylor de una función f real o compleja ƒ(xinfinitamente diferenciable en el entorno de un número real o complejo a es la siguiente serie de potencias:
que puede ser escrito de una manera más compacta como la siguiente suma:
,
donde:
  • n! es el factorial de n
  • f (n)(a) denota la n-ésima derivada de f para el valor a de la variable respecto de la cual se deriva.
La derivada de orden cero de f es definida como la propia f y tanto (x − a)0 como  son ambos definidos como 1 ( = 1). En caso de ser a = 0, como ya se mencionó, la serie se denomina también de McLaurin.
Cabe destacar que en una serie de Taylor de potencias centrada en a de la forma  siempre se puede hacer el cambio de variable  (con lo que  en la función a desarrollar original) para expresarla como  centrada en 0. Luego hay que deshacer el cambio de variable. Por ejemplo, si se quiere desarrollar la función  alrededor de a = 1 se puede tomar , de manera que se desarrollaría  centrada en 0.


Función exponencial y logaritmo natural[editar]

Serie geométrica[editar]

Funciones trigonométricas[editar]

Donde Bs son los Números de Bernoulli.

Funciones hiperbólicas[editar]

Función W de Lambert[editar]

Los números Bk que aparecen en los desarrollos de tan(x) y tanh(x) son Números de Bernoulli. Los valores C(α,n) del desarrollo del binomio son los coeficientes binomiales. Los Ekdel desarrollo de sec(x) son Números de Euler.

Varias variables[editar]

La serie de Taylor se puede generalizar a funciones de  variables:
donde  es un coeficiente multinomial. Como ejemplo, para una función de 2 variables, x e y, la serie de Taylor de segundo orden en un entorno del punto (ab) es:


Un polinomio de Taylor de segundo grado puede ser escrito de manera compacta así:
donde  es el gradiente y  es la matriz hessiana. Otra forma:


biblio

Print

Statement Purpose

The print statement is used to send output to the standard output unit ( usually your monitor, or sometimes your printer ) of your computer system.

Examples and Rules of Use

The concept of the PRINT statement is a pretty basic thing for most people to understand. You need only remember a few details of the details of its use. For starters take a look at the following print statement.
		print *, 'The velocity on impact is', v1
The first thing that you should notice right away is the '*' that follows the initial print statement. This star tells the computer to output the data that follows in a format compatible with the type of items contained in the following comma delimmited list.

The next thing that you should look at is the data list that is slated to be output. It contains a combination of a character string and a variable ( v1 ). A comma like the one that separates the character string and the variable v1 is always used to separate two different output list items. Next, the entire character string in the above print statement except for the single quotes will be printed. In FORTRAN 77 you had to use single quotes to encapsulate any character string marked for output, but in FORTRAN 90 it is equally valid to use double quotes. If you have a need to output a character string that contains either a single quote or double quote, you'll can place two quotes in a row as in the following example so the computer knows that the quotes are not being used to mark the end of the character string.
		Print *, 'The car''s speed is', cspeed, 'mph'          
Alternately, knowing that you want single quotes in your output, you can bound the entire string with double quotes, removing confusion (Fortran 90 only).
		Print *, "The car's speed is", cspeed, "mph" 	
Although the "*" (list directed) format is good for many situations, it is sometimes necessary to use a specific output format for full control of output appearance. This can be accomplished using the format statement. To reference a format statement a statement label should be inserted in place of the '*' in the print statement. The following example should clarify this point.
			Print 1000, x,y,z
		1000 format (1x,3(f5.2))
Remember that PRINT always routes your output to the standard output unit for your system. Now, the standard output unit for most systems is your computer's monitor. Although, you should be aware that there are still a few systems that use the printer as its standard output device. If you need to write your output to a file, or put it into a character variable, use the write statement.

Before I close the book on the print statement I want to point out one more thing concerning the print statement. In the format statement for the above print statement you'll notice that I used the X edit descriptor to skip one space before I begin to actually output my results. The reason why I do this is to make sure that the output of my results don't get messed up by the printer control variables. Printer control variables date to the dawn of FORTRAN. They really aren't necessary anymore, but like a few other outdated constructs in FORTRAN we can't seem to get rid of them. The story behind the control variables was that the first character in a line from PRINT or WRITE statements was interpreted by the printer as a special command. It told the printer how many lines to scroll down before it began printing. There were four primary characters that were used to do this, two of which were zero and one. Zero told the printer to double space things and one told it scroll to the top of the next page. So, if the very first thing you output is a number that begins with zero or one you run the risk of invoking the old printer control variables. This problem is normally encountered when routing the output to some printers. Therefore, it is a good idea to skip a space before you begin printing using a format statement to control the layout of your output.

http://www.personal.psu.edu/jhm/f90/statements/print.html 


https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnap/index.html

PRINT

The PRINT statement writes from a list to stdout.

PRINT f [, iolist]

PRINT grname

Parameter 

Description 

f

Format identifier 

iolist

List of variables, substrings, arrays, and records 

grname

Name of the namelist group 

Description

The PRINT statement accepts the following arguments.

Format Identifier

f is a format identifier and can be:

  • An asterisk (*), which indicates list-directed I/O. See "List-Directed I/O " on for more information.

  • The label of a FORMAT statement that appears in the same program unit.

  • An integer variable name that has been assigned the label of a FORMAT statement that appears in the same program unit.

  • A character expression or integer array that specifies the format string. The integer array is nonstandard. @

Output List

iolist can be empty or can contain output items or implied DO lists. The output items must be one of the following:

  • Variables

  • Substrings

  • Arrays

  • Array elements

  • Record fields

  • Any other expression

A simple unsubscripted array name specifies all of the elements of the array in memory storage order, with the leftmost subscript increasing more rapidly.

Implied DO lists are described on "Implied DO Lists".

Namelist-Directed PRINT

The second form of the PRINT statement is used to print the items of the specified namelist group. Here, grname is the name of a group previously defined by a NAMELIST statement.

Execution proceeds as follows:

  1. The format, if specified, is established.

  2. If the output list is not empty, data is transferred from the list to standard output.

    If a format is specified, data is edited accordingly.

  3. In the second form of the PRINT statement, data is transferred from the items of the specified namelist group to standard output.

Restrictions

Output from an exception handler is unpredictable. If you make your own exception handler, do not do any FORTRAN output from it. If you must do some, then call abort right after the output. Doing so reduces the relative risk of a program freeze. FORTRAN I/O from an exception handler amounts to recursive I/O. See the next point.

Recursive I/O does not work reliably. If you list a function in an I/O list, and if that function does I/O, then during runtime, the execution may freeze, or some other unpredictable problem may occur. This risk exists independent of parallelization.

Example: Recursive I/O fails intermittently:


       PRINT *, x, f(x)                 Not allowed because f() does I/O.
       END
       FUNCTION F(X)
       PRINT *, X
       RETURN
       END

Examples

Example 1: Formatted scalars:


       CHARACTER TEXT*16 
       PRINT 1, NODE, TEXT 
1     FORMAT (I2, A16) 

Example 2: List-directed array:


       PRINT *, I, J, (VECTOR(I), I = 1, 5) 

Example 3: Formatted array:


       INTEGER VECTOR(10) 
       PRINT '(12 I2)', I, J, VECTOR 

Example 4: Namelist:


       CHARACTER LABEL*16 
       REAL QUANTITY 
       INTEGER NODE 
       NAMELIST /SUMMARY/ LABEL, QUANTITY, NODE 
       PRINT SUMMARY 

No hay comentarios:

Publicar un comentario

zen consultora

Blogger Widgets

Entrada destacada

Platzy y el payaso Freddy Vega, PLATZI APESTA, PLATZI NO SIRVE, PLATZI ES UNA ESTAFA

  Platzy y los payasos fredy vega y cvander parte 1,  PLATZI ES UNA ESTAFA Hola amigos, este post va a ir creciendo conforme vaya escribiend...