Sponsored Content
Full Discussion: Nonsense error in FORTRAN
Top Forums UNIX for Beginners Questions & Answers Nonsense error in FORTRAN Post 303045973 by AkaAlteir on Monday 20th of April 2020 04:18:33 PM
Old 04-20-2020
Nonsense error in FORTRAN

Hello, I've been trying to set up a code for fortran, it's about integration, the problem comes when I try to compile the program, the log shows 2 errors: "Error: Expected a right parenthesis in expression " 2 times, and only in 1 shows the line in which it's apparently located (32), I'm going crazy cause i can't find the problem, does anyone know what's wrong?, the code is:

Code:
program main
  implicit none
  integer :: n,i,k
  real*8 :: a,b,x,trapecio,s,suma1,suma2,x2,formula1,formula2,eps,div,h

  !variables
  n=3
  a=0d8
  b=4d8


  !calculate the additions 1 a n-1 y 2 a n-2

  suma1=0d0
  suma2=0d0
  do n=3,300,2*n
   h=(b-a)/dble(n)

        do i=1,n-1,2
            x=a+dble(i)*h
            formula1= 1/(1+(x^2))
            suma1=  suma1 + formula1
        end do

        do k= 2,n-2,2
            x2=a+dble(k)*h
            formula2 =1/(1 + (x2^2)
            suma2= suma2+ formula2
        end do

     trapecio= h/3* &
     (1+ 4*suma1 + 2*suma2 + 1(1/n^2))
     div= trapecio/(trapecio/2)
            if (div < 1d-6) then
                exit
            end if

    write(*,*), trapecio
   end do
  end

 

4 More Discussions You Might Find Interesting

1. Programming

Error running FORTRAN code

Hi, I am new to this forum and do not know whether this is the appropriate place to post this question. Anyway am trying my luck. I have a fortran program swanhcat.ftn, which is part of a wave modelling system. There is also a file hcat.nml which is required to run this program. The program's... (9 Replies)
Discussion started by: sandhyakg
9 Replies

2. Programming

Fortran runtime error: Insufficient data descriptors in format after reversion

Hello, I have some Fortran code that is providing the following error: At line 1165 of lapc_shells_2.f Fortran runtime error: Insufficient data descriptors in format after reversion Here are the lines just above and including 1165: WRITE (*,"('ATTEMPTING TO READ PLATE... (1 Reply)
Discussion started by: jm4smtddd
1 Replies

3. Homework & Coursework Questions

FORTRAN error *** glibc detected ***

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I'm doing aproximation of derivative called five-point stencil. For every value of x, in interval , in step... (0 Replies)
Discussion started by: antonija
0 Replies

4. Programming

Error in my FORTRAN program

I have a Fortran program and I am writing out to logical unit 7. The program is reading from a text file and writing to the new file formatted. It gets through the read and writes some to the file but then stops with the following error: 1525-013 The sequential WRITE statement cannot be... (5 Replies)
Discussion started by: KathyB148
5 Replies
abs(3)							     Library Functions Manual							    abs(3)

delim $$

NAME
abs, div, labs, ldiv - Computes absolute value and division of integers LIBRARY
Standard C Library (libc.a) SYNOPSIS
#include <stdlib.h> int abs ( int i ); long labs ( long i ); div_t div ( int numerator , int denominator); ldiv_t ldiv ( long numerator, long denominator); PARAMETERS
For abs(), specifies some integer. For labs(), specifies some long integer. For div(), specifies some integer. For ldiv(), specifies some long integer. For div(), specifies some integer. For ldiv(), specifies some long integer. DESCRIPTION
The abs() function returns the absolute value of its integer operand. The div() function computes the quotient and remainder of the division of the numerator numerator by the denominator denominator. If the division is inexact, the sign of the resulting quotient is that of the algebraic quotient, and the magnitude of the resulting quotient is the largest integer less than the magnitude of the algebraic quotient. If the result cannot be represented (for example, if the denominator is 0), the behavior is undefined. The div() function returns a value of type div_t, comprising both the quotient and the remainder. The labs() and ldiv() functions perform the same functions as abs() and div() respectively, but accept long integers rather than integers as parameters. The ldiv() function returns a value of type ldiv_t, comprising both the quotient and the remainder. NOTES
The abs(), labs(), div(), and ldiv() functions are supported for multithreaded applications. A two's-complement integer can hold a negative number whose absolute value is too large for the integer to hold. When given this largest negative value, the abs() function returns the same value. Full use RETURN VALUES
The abs() function and labs() function return the absolute value of their arguments. The div() function returns a value of type div_t and the ldiv() function returns a value of type ldiv_t. RELATED INFORMATION
Functions: floor(3) delim off delim off abs(3)
All times are GMT -4. The time now is 02:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy