New Reply

Gfortran Compiling Error

 
Share Thread Thread Tools
Apr26-12, 11:33 AM   #1
 

Gfortran Compiling Error


I'm new to programming in Fortran, but have programmed for quite a while in C, Matlab, and Python.

This is my code. It's incomplete at the moment (the subroutines are unreferenced), though it should still compile, but won't.
Code:
PROGRAM bunkers
      IMPLICIT NONE

      SUBROUTINE lininterp(ulist,vlist,hlist,targetlvl,u,v)
            IMPLICIT NONE

            !Dummy argument declarations
            REAL, INTENT(IN) :: ulist,vlist,hlist,targetlvl
            REAL, INTENT(OUT) :: u,v

            !Local variable declaration 
            REAL :: spacing

            spacing = hlist(2) - hlist(1)
            DO i=1,SIZE(hlist)
                  IF (targetlvl>hlist(i) .and. targetlvl < hlist(i+1)):
                        u=(ulist(i+1)-ulist(i))/spacing*(targetlvl-hlist(i))+ulist(i)
                        v=(vlist(i+1)-vlist(i))/spacing*(targetlvl-hlist(i))+vlist(i)
                  END IF
            END DO
            RETURN
      END SUBROUTINE lininterp

      SUBROUTINE meanwind(ulist,vlist,hlist,blayer,tlayer,meanwind)
            IMPLICIT NONE

            !Dummy argument declarations
            REAL, INTENT(IN) :: ulist,vlist,hlist,blayer,tlayer
            REAL, INTENT(OUT) :: meanwind

            !Local variable declaration
            REAL :: vmod, i, j, umodmean, vmodmean
            REAL, ALLOCATABLE, DIMENSION(:) :: tailvect,headvect
            REAL, DIMENSION(2) ::   vector,modheadvect,vect,modmean, meanwind
            REAL, DIMENSION (2,2) :: rotation,counter

            !Find head and tail wind vectors
            DO i=1,SIZE(hlist)
                  IF (hlist(i) .eq. blayer) THEN
                        ALLOCATE(tailvect(2))
                        tailvect = (/ ulist(i),vlist(i) /)
                  ELSE IF (hlist(i) .eq. tlayer) THEN
                        ALLOCATE(headvect(2))
                        headvect = (/ ulist(i), vlist(i) /)
                  ELSE IF (hlist(i) >= tlayer) THEN
                        EXIT
                  ELSE
                        EXIT
                  END IF
            END DO

            IF (.not. allocated(tailvect)) 
                  CALL lininterp(ulist,vlist,hlist,blayer,u,v)
                  tailvect = (/ u,v /)
            END IF

            IF (.not. allocated(headvect))
                  CALL lininterp(ulist,vlist,hlist,tlayer,u,v)
                  headvect = (/ u,v /)
            END IF
            RETURN 
      END SUBROUTINE meanwind     
      STOP
END PROGRAM bunkers
Output:
Code:
Larissas-MacBook-Pro:Sounding_Codes Larissa$ gfortran -o idmethod idmethod.f90
idmethod.f90:4.6:

      SUBROUTINE lininterp(ulist,vlist,hlist,targetlvl,u,v)
     1
Error: Unclassifiable statement at (1)
idmethod.f90:5.25:

            IMPLICIT NONE
                        1
Error: Duplicate IMPLICIT NONE statement at (1)
idmethod.f90:14.27:

            spacing = hlist(2) - hlist(1)
                          1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'hlist' at (1)
idmethod.f90:16.37:

                  IF (targetlvl>hlist(i) .and. targetlvl < hlist(i+1)):
                                    1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'hlist' at (1)
idmethod.f90:17.32:

                        u=(ulist(i+1)-ulist(i))/spacing*(targetlvl-hlist(i))+ul
                               1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'ulist' at (1)
idmethod.f90:18.32:

                        v=(vlist(i+1)-vlist(i))/spacing*(targetlvl-hlist(i))+vl
                               1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'vlist' at (1)
idmethod.f90:19.21:

                  END IF
                    1
Error: Expecting END DO statement at (1)
idmethod.f90:22.7:

    END SUBROUTINE lininterp
      1
Error: Expecting END PROGRAM statement at (1)
idmethod.f90:24.6:

      SUBROUTINE meanwind(ulist,vlist,hlist,blayer,tlayer,meanwind)
     1
Error: Unclassifiable statement at (1)
idmethod.f90:25.25:

            IMPLICIT NONE
                        1
Error: Unexpected IMPLICIT NONE statement at (1)
idmethod.f90:28.37:

            REAL, INTENT(IN) :: ulist,vlist,hlist,blayer,tlayer
                                    1
Error: Symbol 'ulist' at (1) already has basic type of REAL
idmethod.f90:29.41:

            REAL, INTENT(OUT) :: meanwind
                                        1
Error: Unexpected data declaration statement at (1)
idmethod.f90:32.50:

            REAL :: vmod, i, j, umodmean, vmodmean
                                                 1
Error: Unexpected data declaration statement at (1)
idmethod.f90:33.64:

            REAL, ALLOCATABLE, DIMENSION(:) :: tailvect,headvect
                                                               1
Error: Unexpected data declaration statement at (1)
idmethod.f90:34.77:

          REAL, DIMENSION(2) ::   vector,modheadvect,vect,modmean, meanwind
                                                                          1  
Error: Unexpected data declaration statement at (1)
idmethod.f90:35.53:

            REAL, DIMENSION (2,2) :: rotation,counter
                                                    1
Error: Unexpected data declaration statement at (1)
idmethod.f90:39.27:

                  IF (hlist(i) .eq. blayer) THEN
                          1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'hlist' at (1)
idmethod.f90:40.41:

                        ALLOCATE(tailvect(2))
                                        1
Error: Syntax error in ALLOCATE statement at (1)
idmethod.f90:41.43:

                        tailvect = (/ ulist(i),vlist(i) /)
                                          1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'ulist' at (1)
idmethod.f90:42.32:

                  ELSE IF (hlist(i) .eq. tlayer) THEN
                               1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'hlist' at (1)
idmethod.f90:43.41:

                        ALLOCATE(headvect(2))
                                        1
Error: Syntax error in ALLOCATE statement at (1)
idmethod.f90:44.43:

                        headvect = (/ ulist(i), vlist(i) /)
                                          1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'ulist' at (1)
idmethod.f90:45.32:

                  ELSE IF (hlist(i) >= tlayer) THEN
                               1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'hlist' at (1)
idmethod.f90:47.22:

                  ELSE
                     1
Error: Unexpected ELSE statement at (1)
idmethod.f90:49.21:

                  END IF
                    1
Error: Expecting END DO statement at (1)
Fatal Error: Error count reached limit of 25.
Any ideas?
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> King Richard III found in 'untidy lozenge-shaped grave'
>> Google Drive sports new view and scan enhancements
>> Researcher admits mistakes in stem cell study
Apr26-12, 12:53 PM   #2
 
Mentor
Don't put the subroutines inside the program section.

Also, you main program should actually do something useful, like call the subroutines.

Your code should look something like this:
Code:
PROGRAM bunkers
  ! declarations 
  ! statements
END PROGRAM bunkers

SUBROUTINE lininterp( ... )
  ! declarations 
  ! statements
END SUBROUTINE lininterp

SUBROUTINE meanwind( ... )
  ! declarations 
  ! statements
END SUBROUTINE meanwind
Apr26-12, 12:57 PM   #3
 
Quote by Mark44 View Post
Don't put the subroutines inside the program section.

Also, you main program should actually do something useful, like call the subroutines.

Your code should look something like this:
Code:
PROGRAM bunkers
  ! declarations 
  ! statements
END PROGRAM bunkers

SUBROUTINE lininterp( ... )
  ! declarations 
  ! statements
END SUBROUTINE lininterp

SUBROUTINE meanwind( ... )
  ! declarations 
  ! statements
END SUBROUTINE meanwind
I have successfully fixed most of the other errors, but this was the biggest problem I was running in to. Thanks so much! :)
Apr26-12, 02:53 PM   #4
 
Mentor

Gfortran Compiling Error


You're welcome!
New Reply
Thread Tools


Similar Threads for: Gfortran Compiling Error
Thread Forum Replies
C++ Urgent help, compiling error, Assignment due in 1 hour! Engineering, Comp Sci, & Technology Homework 1
fortran compiling error Programming & Comp Sci 9
Error compiling in Fortran (Ubuntu) Programming & Comp Sci 2
ifort -> gfortran error Programming & Comp Sci 0
cuda for gfortran ? Programming & Comp Sci 4