Skip to content

Workaround for Cray Compilers #76

@fedepedron

Description

@fedepedron

We've been using D3 as a sub-dependency for SIESTA, and unfortunately the library does not compile with Cray compilers (at least, up to 16.0.1) straight out of the box.

This is not a consequence of the library being wrong, but of Cray being extremely picky on certain things. Thankfully enough, the workaround are simple enough: only two files need minor modifications.


First is src/dftd3/output.f90. It seems that Cray does not like the combination of "trim" and "merge" (I tried using only merge and it worked just fine).

@@ -258,8 +258,11 @@ subroutine ascii_damping_param(unit, param, method)
       if (present(method)) then
          write(unit, '(a, "-")', advance="no") method
       end if
-      write(unit, '(a)') &
-         & trim(merge("D3(0)-ATM", "D3(0)    ", abs(param%s9) > 0))
+      if ( abs(param%s9) > 0 ) then
+         write(unit, '(a)') "D3(0)-ATM"
+      else
+         write(unit, '(a)') "D3(0)"
+      endif
       write(unit, '(20("-"))')
       write(unit, '(a4, t10, f10.4)') &
          & "s6", param%s6, &
@@ -275,8 +278,11 @@ subroutine ascii_damping_param(unit, param, method)
       if (present(method)) then
          write(unit, '(a, "-")', advance="no") method
       end if
-      write(unit, '(a)') &
-         & trim(merge("D3(0M)-ATM", "D3(0M)    ", abs(param%s9) > 0))
+           if ( abs(param%s9) > 0 ) then
+         write(unit, '(a)') "D3(0M)-ATM"
+      else
+         write(unit, '(a)') "D3(0M)"
+      endif
       write(unit, '(20("-"))')
       write(unit, '(a5, t10, f10.4)') &
          & "s6", param%s6, &
@@ -293,8 +299,11 @@ subroutine ascii_damping_param(unit, param, method)
       if (present(method)) then
          write(unit, '(a, "-")', advance="no") method
       end if
-      write(unit, '(a)') &
-         & trim(merge("D3(op)-ATM", "D3(op)    ", abs(param%s9) > 0))
+      if ( abs(param%s9) > 0 ) then
+         write(unit, '(a)') "D3(op)-ATM"
+      else
+         write(unit, '(a)') "D3(op)"
+      endif
       write(unit, '(20("-"))')
       write(unit, '(a5, t10, f10.4)') &
          & "s6", param%s6, &
@@ -311,8 +320,11 @@ subroutine ascii_damping_param(unit, param, method)
       if (present(method)) then
          write(unit, '(a, "-")', advance="no") method
       end if
-      write(unit, '(a)') &
-         & trim(merge("D3(BJ)-ATM", "D3(BJ)    ", abs(param%s9) > 0))
+      if ( abs(param%s9) > 0 ) then
+         write(unit, '(a)') "D3(BJ)-ATM"
+      else
+         write(unit, '(a)') "D3(BJ)"
+      endif
       write(unit, '(21("-"))')
       write(unit, '(a4, t10, f10.4)') &
          & "s6", param%s6, &

Second is src/dftd3/reference.f90. Here it seems like it's not really allowed to reference the same array with reshape, when that array is also a parameter. Curiously enough, this can also be fixed by removing reference_cn from the "public" statement, and adding the public tag after the parameter...

       & 0.0000_wp,  2.8878_wp,  0.0000_wp,  0.0000_wp,  0.0000_wp, & ! U
       & 0.0000_wp,  2.9095_wp,  0.0000_wp,  0.0000_wp,  0.0000_wp, & ! Np
       & 0.0000_wp,  1.9209_wp,  0.0000_wp,  0.0000_wp,  0.0000_wp],& ! Pu
-      & shape(reference_cn))
+      & (/max_ref,max_elem/))


    real(wp), allocatable :: reference_c6(:, :, :)

I hope you find this useful :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions