Silverfrost Forums

Welcome to our forums

Using GET_FILES@ doesn't work in Plato, or does it?

24 Jul 2009 9:48 #4822

Hi everyone. I use Plato 4.2.0 recently dowloaded in my laptop, Windows Vista. GET_FILES@ is a standard subroutine in F77 language also carried on in FTN95. So I am not sure what's going on. I use the following subroutine call and produces nothing (no compiling errors either, only warnings) although it should give me the files names in current working directory. Any suggestions? Your help is very much appreciated.

subroutine GET_FILES@(wildcard, files, maxfiles, nfiles, error_code) character (len=*), intent(in) :: wildcard integer (kind=2), intent(in) :: maxfiles character(256), intent(out) :: files(maxfiles) integer (kind=2), intent(out) :: nfiles, error_code end subroutine GET_FILES@

27 Jul 2009 5:22 #4823

The following programs runs OK on my Vista machine...

INTEGER (KIND=2),PARAMETER::MAXFILES=50
INTEGER (KIND=2) NFILES, ERROR_CODE
CHARACTER (LEN=256)::FILES(MAXFILES)
CALL GET_FILES@('*.f90', FILES, MAXFILES, NFILES, ERROR_CODE)
DO I=1,NFILES
  PRINT*, FILES(I)(1:LEN_TRIM(FILES(I)))
ENDDO  
END
28 Jul 2009 6:50 #4829

Any ideas why it might not be working on my Plato? Maybe I need to set up some compiling options or something?

program getingfiles
integer (kind=2),parameter ::MAXFILES=50
integer (kind=2) NFILES, ERROR_CODE
character (LEN=256)::FILES(MAXFILES)
call GET_FILES@('*.pdf', FILES, MAXFILES, NFILES, ERROR_CODE)
do I=1,NFILES
  print*, FILES(I)(1:LEN_TRIM(FILES(I)))
enddo
end getingfiles

subroutine GET_FILES@(wildcard, files, maxfiles, nfiles, error_code)
character (len=*), intent(in) :: wildcard
integer (kind=2), intent(in) :: maxfiles
character(256), intent(out) :: files(maxfiles)
integer (kind=2), intent(out) :: nfiles, error_code
end subroutine GET_FILES@
28 Jul 2009 7:03 #4830

You don't need any special compiler options. Just run the code as I presented it. The routine is built-in and does not need the subroutine code that you have included.

The effect of your code is to create your own version of the subroutine and your version returns without doing anything.

28 Jul 2009 7:10 #4831

Paul, thank you so much. I thought I needed to define the subroutine but you were right is built in and what I had done was wrong. Appreciate your time and help.

28 Jul 2009 12:50 #4832

You may have been trying to use an interface definition.

program getingfiles 
!
INTERFACE
subroutine GET_FILES@(wildcard, files, maxfiles, nfiles, error_code) 
character (len=*), intent(in) :: wildcard 
integer (kind=2), intent(in) :: maxfiles 
character(256), intent(out) :: files(maxfiles) 
integer (kind=2), intent(out) :: nfiles, error_code 
end subroutine GET_FILES@
END INTERFACE
!
integer (kind=2),parameter ::MAXFILES=50 
integer (kind=2) NFILES, ERROR_CODE 
character (LEN=256)::FILES(MAXFILES) 
!
call GET_FILES@('*.pdf', FILES, MAXFILES, NFILES, ERROR_CODE) 
do I=1,NFILES 
  print*, TRIM (FILES(I)) 
enddo 
!
print*, 'ERROR_CODE =', ERROR_CODE
print*, 'NFILES =', NFILES
end getingfiles 
29 Jul 2009 2:05 #4834

Paul,

I could not get my INTERFACE example to compile ? I even tried to clean out the KIND warnings, but that didn't help. Is there a problem with :- my use of INTERFACE, defining for GET_FILES@, which is a Salford routine, or is there a problem with FTN95 ?

My 'cleaned' code is now:

program getingfiles 
! 
INTERFACE 
 subroutine GET_FILES@ (wildcard, file_list, max_files, num_files, error_code) 
  character*(*), intent(in)  :: wildcard 
  integer*2,     intent(in)  :: max_files 
  character*256, intent(out) :: file_list(max_files) 
  integer*2,     intent(out) :: num_files
  integer*2,     intent(out) :: error_code 
 end subroutine GET_FILES@ 
END INTERFACE 
! 
integer*2, parameter :: MAXFILES=50 
integer*2     NFILES, ERROR_CODE, I 
character*256 FILES(MAXFILES) 
! 
call GET_FILES@ ('*.pdf', FILES, MAXFILES, NFILES, ERROR_CODE)
! 
do I=1,NFILES 
  print*, TRIM (FILES(I)) 
enddo 
! 
print*, 'ERROR_CODE =', ERROR_CODE 
print*, 'NFILES =', NFILES 
end getingfiles 

And the error message when compiling with /debug is:

[FTN95/Win32 Ver. 5.30.0 Copyright (c) Silverfrost Ltd 1993-2009]

  1. call GET_FILES@ ('*.pdf', FILES, MAXFILES, NFILES, ERROR_CODE) *** Error 326: SUBROUTINE GET_FILES@ has been called with too many arguments 1 ERROR [<GETINGFILES> FTN95/Win32 v5.30.0] *** Compilation failed
29 Jul 2009 2:36 #4840

Your code demonstrates a previously unknown bug that takes the form of a missing error message (say).

What happens is this. The @ symbol at the end of GET_FILES@ is reserved for FTN95 intrinsics, none of which require an interface.

Instead of providing a warning or error message as it should, the compiler soldiers on after the INTERFACE but with a blank argument list and then there is an argument miss-match when it encounters the call.

We can change the compiler to make it flag an error (or fix it in some other way) but in the mean time routines that end in @ should not appear in an INTERFACE.

13 Aug 2009 2:05 #4901

The next release of FTN95 will give a fatal error report when you try to provide an INTERFACE for an FTN95 intrinsic.

Please login to reply.