This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Accepts invalid?


On Friday 29 August 2008 19:50:51 Smith-Rowland, Edward M wrote:
> 2.  Does/Is there a way to make - gfortran flag an error?
>     When I checked on a gcc mainline build it went through without a hitch.

Make the interface explicit, e.g. by including the subroutine into the program 
with the CONTAINS statement. Then you get:

$> gfortran -Wall pr/getlwr.f90
pr/getlwr.f90:5.18:

      CALL GETLWR(FOO,BAR)
                 1
Warning: Character length of actual argument shorter than of dummy 
argument 'strin' (6/40) at (1)


> 3.  Language related: Is there a better way to convert cases in Fortran
> these days?

Found this a while ago:

!  * Google Groups, comp.lang.fortran
!    "How to convert uppercase to lowercase in fortran"
!  http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/9eb0e
afc4ed5d7b6


FUNCTION tolower(instr) RESULT (outstr)
  CHARACTER(len=*), INTENT(in) :: instr
  CHARACTER(len=len(instr))    :: outstr

  CHARACTER(*), PARAMETER :: lowercase = 'abcdefghijklmnopqrstuvwxyzäöü'
  CHARACTER(*), PARAMETER :: uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ'

  INTEGER :: i, k

  outstr = instr
  DO i = 1, len_trim(outstr)
    k = index(uppercase, outstr(i:i))
    if (k /= 0) outstr(i:i) = lowercase(k:k)
  END DO
END FUNCTION


Hope this helps

	Daniel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]