Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Line Truncation on Fortran

  1. Jul 16, 2010 #1
    I've made a program that uses more than 72 characters per line. When I try to compile it on gfortran, using -ffixed-line-length-n, it returns several errors, all of them derived from a line truncated at the very beggining. How can I compile it or untruncate the line?

    The code is as follows

    Code (Text):
    Program Rotation
    Implicit None
    Double Precision dt,ve,mass,radius,height,pmass,vx,vy,area,rad,de,weight,g,t,tmax,ymax,rangmax,inertia,pweight,tet,ar,torque,vymid,vxmid,dy,dx,ax,ay,rang,w
    Integer nshow,counter
    CALL Opener
    CALL Inserter (dt,ve,de,tet,w,mass,radius,height,pmass,nshow)
    CALL Calc (ve,vx,vy,mass,radius,area,rad,de,weight,g,t,tmax,ymax,rangmax,inertia,pmass,pweight,counter)
    CALL Torq (pweight,tet,ar,inertia,torque)
    CALL Velocitymed (vx,vy,ay,ax,t,dt,vymid,vxmid)
    CALL Drags (vx,vy,vymid,vxmid,dy,dx,area,ax,ay,weight,mass)
    CALL Euler (radius,mass,area,weight,vxmid,vymid,vy,vx,dy,dx,ay,ax,t,dt,height,rang,rangmax,tmax,ymax,ar,w,tet,inertia,torque,pweight,counter,nshow)
    CALL print_table (vx,vy,t,ax,ay,dx,dy,height,rang,tet,w,ar)
    End

    Subroutine inserter (dt,ve,de,tet,w,mass,radius,height,pmass,nshow)
    Implicit None
    Double Precision dt,ve,de,tet,w,mass,radius,height,pmass
    Integer nshow
    Write (*,*) 'Insert time step(s)'
    Read (*,*) dt
    Write (*,*) 'Insert initial height(m)'
    Read (*,*) height
    Write (*,*) 'Insert initial translational speed (m/s)'
    Read (*,*)ve
    Write (*,*) "Insert inital translational speed's angle to the ground (degrees)"
    Read (*,*)de
    Write (*,*) 'Insert initial angular space (rad)'
    Read (*,*) tet
    Write (*,*) 'Insert initial angular speed (rad/s)'
    Read (*,*) w
    Write (*,*) "Insert disk's mass(kg)"
    Read (*,*)mass
    Write (*,*) "Insert point's mass(kg)"
    Read(*,*) pmass
    Write (*,*) 'Insert radius(m)'
    Read (*,*)radius
    Write (*,*) 'Insert number os steps between output'
    Read (*,*)nshow
    End

    Subroutine Calc (ve,vx,vy,mass,radius,area,rad,de,weight,g,t,tmax,ymax,rangmax,inertia,pmass,pweight,counter)
    Implicit None
    Double Precision ve,vx,vy,mass,radius,area,rad,de,weight,g,t,tmax,ymax,rangmax,inertia,pmass,pweight
    Integer counter
    g=-9.8
    t=0.0D0
    rad=de*0.0174532925
    vx=ve*(cos(rad))
    vy=ve*(sin(rad))
    area=3.141592654*(radius**2)
    weight=mass*g
    pweight=pmass*g
    counter = 0
    ymax = -5000
    tmax = -5000
    rangmax = -5000
    inertia=(pmass+mass)*(radius**2)*0.66
    END

    Subroutine Torq (pweight,tet,ar,inertia,torque)
    Implicit None
    Double Precision pweight,tet,ar,inertia,torque
    torque=pweight*cos(tet)
    ar=torque/inertia
    End

    Subroutine Velocitymed (vx,vy,ay,ax,t,dt,vymid,vxmid)
    Implicit None
    Double Precision vx,vy,ay,ax,t,dt,vymid,vxmid
    IF (t .EQ. 0.0D0) vymid = vy
    IF (t .EQ. 0.0D0) vxmid = vx
    IF (t .NE. 0.0D0) vymid = vy+(ay*(dt/2))
    IF (t .NE. 0.0D0) vxmid = vx+(ax*(dt/2))
    END

    Subroutine Drags (vx,vy,vymid,vxmid,dy,dx,area,ax,ay,weight,mass)
    Implicit None
    Double Precision vx,vy,vymid,vxmid,dy,dx,area,ax,ay,weight,mass
    IF (vy .LT. 0.0D0) dy=(vymid**2)*area*0.5D0
    IF (vy .GT. 0.0D0) dy=-(vymid**2)*area*0.5D0
    IF (vx .LT. 0.0D0) dx=(vxmid**2)*area*0.5D0
    IF (vx .GT. 0.0D0) dx=-(vxmid**2)*area*0.5D0
    ay=(dy+weight)/mass
    ax=dx/mass
    END

    Subroutine Euler (radius,mass,area,weight,vxmid,vymid,vy,vx,dy,dx,ay,ax,t,dt,height,rang,rangmax,tmax,ymax,ar,w,tet,inertia,torque,pweight,counter,nshow)
    Implicit None
    Double Precision radius,mass,area,weight,vxmid,vymid,vy,vx,dy,dx,ay,ax,t,dt,height,rang,rangmax,tmax,ymax,ar,w,tet,inertia,torque,pweight
    Integer counter,nshow
    100 IF (mod(counter,nshow) .EQ. 0) Call print_table (vx,vy,t,ax,ay,dx,dy,height,rang,tet,w,ar,radius)
    Call Euler_Disk (mass,area,weight,vxmid,vymid,vy,vx,dy,dx,ay,ax,t,dt,height,rang,counter,nshow)
    Call Euler_pointr (ar,w,tet,dt,inertia,torque,pweight)
    counter = counter + 1
    IF (height .GT. ymax) tmax=t
    IF (height .GT. ymax) rangmax=rang
    IF (height .GT. ymax) ymax=height
    IF (height .LT. 0.0D0) Go to 200
    t=t+dt
    Go to 100
    200 WRITE(11,*) tmax,ymax
    End

    Subroutine Euler_pointr (ar,w,tet,dt,inertia,torque,pweight)
    Implicit None
    Double Precision ar,w,tet,dt,inertia,torque,pweight
    Call Torq (pweight,tet,ar,inertia,torque)
    w=w+(ar*dt)
    tet=tet+(w*dt)
    End

    Subroutine Euler_Disk (mass,area,weight,vxmid,vymid,vy,vx,dy,dx,ay,ax,t,dt,height,rang,rangmax,tmax,ymax,counter,nshow)
    Double Precision mass,area,weight,vxmid,vymid,vy,vx,dy,dx,ay,ax,t,dt,height,rang,rangmax,tmax,ymax
    Integer counter,nshow
    CALL Velocitymed (vx,vy,ay,ax,t,dt,vymid,vxmid)
    CALL Drags (vx,vy,vymid,vxmid,dy,dx,area,ax,ay,weight,mass)
    vy=vy+(ay*dt)
    vx=vx+(ax*dt)
    height=height+(vymid*dt)
    rang=rang+(vxmid*dt)
    End

    Subroutine print_table (vx,vy,t,ax,ay,dx,dy,height,rang,tet,w,ar,radius)
    Implicit None
    Double Precision vx,vy,t,ax,ay,dx,dy,height,rang,tet,w,ar,radius
    WRITE (1,*) t,vx
    WRITE (2,*) t,vy
    WRITE (3,*) t,ax
    WRITE (4,*) t,ay
    WRITE (12,*) t,dx
    WRITE (13,*) t,dy
    WRITE (14,*) t,height
    WRITE (15,*) rang,height
    WRITE (16,*) t,rang
    WRITE (17,*) t,tet
    WRITE (18,*) t,w
    WRITE (19,*) t,ar
    Write (20,*) t, (height+(radius*sin(tet)))
    Write (21,*) (rang+(radius*cos(tet))), (height+(radius*sin(tet)))
    Write (22,*) t, (rang+(radius*cos(tet)))
    END

    Subroutine Opener
    OPEN (Unit=1,FILE="vx.dat")
    OPEN (Unit=2,FILE="vy.dat")
    OPEN (Unit=3,FILE="ax.dat")
    OPEN (Unit=4,FILE="ay.dat")
    OPEN (Unit=11,FILE="heightmax.dat")
    OPEN (Unit=12,FILE="dragx.dat")
    OPEN (Unit=13,FILE="dragy.dat")
    OPEN (Unit=14,FILE="height.dat")
    OPEN (Unit=15,FILE="rangeheight.dat")
    OPEN (Unit=16,FILE="range.dat")
    OPEN (Unit=17,FILE="angle.dat")
    OPEN (Unit=18,FILE="rspeed.dat")
    OPEN (Unit=19,FILE="rotacce.dat")
    OPEN (Unit=20,FILE="point's height.dat")
    OPEN (Unit=21,FILE="Full.dat")
    OPEN (Unit=22,File="point's range.dat")
    END
     
  2. jcsd
  3. Jul 16, 2010 #2

    minger

    User Avatar
    Science Advisor

    You can just use a line continuation, e.g.

    Code (Text):

    Program Rotation
    Implicit None
    Double Precision dt,ve,mass,radius,height,pmass,vx,vy,area,rad,&
    de,weight,g,t,tmax,ymax,rangmax,inertia,pweight,tet,ar,torque,&
    vymid,vxmid,dy,dx,ax,ay,rang,w
    Integer nshow,counter
    CALL Opener
    CALL Inserter (dt,ve,de,tet,w,mass,radius,height,pmass,nshow)
    CALL Calc (ve,vx,vy,mass,radius,area,rad,de,weight,g,t,tmax,ymax,rangmax,&
    inertia,pmass,pweight,counter)
     
    Note the ampersands. As long as your in Fortran 90+, you don't have to worry about special characters on the following line, just a single ampersand will work.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Line Truncation on Fortran
  1. Weird Fortran 77 line (Replies: 2)

Loading...