Silverfrost Forums

Welcome to our forums

Error messages do not quite point to the error

25 Mar 2023 1:19 #30095

In the following source code, I had left out the END SUBROUTINE statement for the CONTAINed subroutine just before the last line.

! Utility for taking routines declared as untyped externals in
!    SLATEC sources, and checking if they are implicitly typed
!    external functions or are actually subroutines
program scanfuncs
implicit none
integer, parameter :: NFUN = 500
character(10) fnames(NFUN)
character(150) line,linetrim
character(10) rname
integer i,ll,iw,lu,ib,ie,nf
logical found
!
open(11,file='funcs.txt',status='old')
do i=1, NFUN
   read(11,'(A)',end=10) fnames(i)
end do
10 close(11)
open(11,file='exts.txt',status='old')
rewind(11)
nf = i-1
print *,nf,' functions recognized'
do
   read (11,'(A)',end = 100) line
   ll = len_trim(line)
   iw = index(line,'external')
   if(iw == 0)iw = index(line,'EXTERNAL') ! will miss if mixed case in input!
   if (iw /= 0) then
      linetrim = line(iw+9:ll) // ','
      lu = len_trim(linetrim)
      ib = 1
      do
         ie = index(linetrim(ib:lu),',')
         if(ie==0)then
            print *,line
            print *,linetrim
            stop 'Error, no comma found at end'
         endif
         ie = ie+ib-1
         rname = linetrim(ib:ie-1)
         call search(rname,fnames,nf,found) !print *,rname
         if(found)then
            print *,' Input Line:'
            print '(8x,A,/)',line
         endif
         ib=ie+2
         if(ib > lu)exit
      end do
   else
      print *,''external' not found in line: '
      print *,line
   endif
end do
100 close(11)
stop

contains
   !Could use binary search, but linear search is fast enough
   subroutine search(rname,fnames,nf,found)
   integer, intent(in) :: nf
   character(10), intent(in) :: fnames(nf)
   character(10), intent(in) :: rname
   logical, intent(out) :: found
   integer i
   found = .false.
   do i=1,nf
      if(rname .eq. fnames(i))then
         print 10,trim(rname)
         found = .true.
      endif
   end do
   return
10 format('Routine ',A,' is a known function')
!   end subroutine  ! commented out to display compiler behaviour
end program

The compiler output error messages that had me confused for a few moments.

ERROR S:\ALGO\slatec\IBED\src\hide\scanfnc.F90 15:  FNAMES appears on the left hand side of an assignment yet has the INTENT(IN) attribute
ERROR S:\ALGO\slatec\IBED\src\hide\scanfnc.F90 20:  NF appears on the left hand side of an assignment yet has the INTENT(IN) attribute
ERROR S:\ALGO\slatec\IBED\src\hide\scanfnc.F90 39:  RNAME appears on the left hand side of an assignment yet has the INTENT(IN) attribute
ERROR S:\ALGO\slatec\IBED\src\hide\scanfnc.F90 40:  Compilation abandoned
25 Mar 2023 6:37 #30097

Thank you for the feedback. I have made a note of this fault.

11 Nov 2023 4:17 #30730

This has now been cleaned up for a future release of FTN95.

12 Nov 2023 1:51 #30732

Thanks.

Please login to reply.