[DFTB-Plus-User] Compiling dftb+ (1.2/1.2.1) with AMD Open64 4.5.1 compiler. Error on SELECT CASE (type(string))

Nick Papior Andersen nickpapior at gmail.com
Thu Aug 16 15:31:04 CEST 2012


Dear Balint

2012/8/16 Bálint Aradi <balint.aradi at bccms.uni-bremen.de>

> Dear Nick,
>
> > It seems that it cannot do comparisons of type(string) in select case
> > statements if any of the chars are undefined. I tried explicitly
> > creating a char array and do
> >
> > cbuf = char(buffer) ; select case(cbuf)
> >
> > which then worked (however, this can not be generalised to the above
> > statements). I am not entirely sure why and how it was bypassed.
> >
> > Have anybody seen this? And ever better, a solution?
>
>  In my oppinion, this is a compiler bug, but of course I could be
> somewhat biased. :-) If I understood you correctly
>
I have further tested it, and it is in fact a compiler bug (see the end of
the message).
I had simply hoped that it was not the case...

>
> select case(char(buffer))
>
> does not work, why
>
> character(1024) :: cbuf
> :
> cbuf = char(buffer)
> select case(cbuf)
>
> does work. But the two cases should be equivalent, shouldn't they? In
> both cases the function s_to_c (in xmlf90/m_string.f90) is invoked via
> char(), and in both cases it should return the same result. For some
> reasons, your compiler does not recognize the length of the returned
> string correctly, if the char() statement is embedded in the select case
> construct.
>
I agree, this should be exactly the same output.

>
>  The s_to_c function is somewhat fishy, as the length of the returned
> character variable is not known at compile time, but dynamically
> determined via a pure function when char() is called. As this is part of
> the less frequent used features of Fortran 95, I could imagine that this
> bug in the compiler had not been detected yet.
>
I have not found any errors in this (see further down)

>
>   You could try to reduce your problem to a trivial test case, and send
> it to your compiler vendor and ask for fix. Unfortunately, I do not have
> access to Open64 compilers at all, so won't be really able to help much,
> sorry. Alternatively, you could try to compile the current gfortran
>  compiler for your plattform.


I have done this with the following program:

 program test
use m_strings
type(string) :: b
character(len=20) :: a

a = "Test"
b = a

print *,"'",a,"'"
print *,"'",char(b),"'"

select case(char(b))
case("Test")
print *,"Should have shown!!!"
end select

a = char(b)
select case(a)
case("Test")
print *,"Shows correctly"
end select
end program test

My temporary solution is to install gcc-4.7.1 and go with that! That proved
a lot easier. :)

>
>   Best regards,
>
>   Bálint
>
>
>
> --
> Dr. Bálint Aradi
> Bremen Center for Computational Materials Science, University of Bremen
> http://www.bccms.uni-bremen.de/cms/people/b_aradi/
>
>
>
> _______________________________________________
> DFTB-Plus-User mailing list
> DFTB-Plus-User at dftb-plus.info
> http://www.dftb-plus.info/mailman/listinfo/dftb-plus-user
>
>

I will send this to the Open64 team along side with the m_strings.f90 file.
Hopefully they will correct their bug. :)

Kind regards and thanks for your time,

Nick Papior Andersen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.dftb-plus.info/pipermail/dftb-plus-user/attachments/20120816/1503677c/attachment.html>


More information about the DFTB-Plus-User mailing list