Problem compiling a piece of code using compiler versions

Dear all, I experience a problem during the compilation of a specific piece of code. I compiled the program on a CRAY XT4 machine using PGI 8.0.6, 9.0.4 and also 10.0.0. But the problem always persists.

This is the error

cpp -P -traditional -D__PGI -D__MPI -D__PARA -D__SCALAPACK -D__ACML -D__WALLTIME -I…/include pw2casino_write.f90 -o pw2casino_write.F90
ftn -fastsse -r8 -D__PGI -D__MPI -D__PARA -D__SCALAPACK -D__ACML -D__WALLTIME -I…/include -I…/iotk/src -I…/Modules -I…/EE -I…/PW -I. -c pw2casino_write.F90 -o pw2casino_write.o
/opt/cray/xt-asyncpe/3.6/bin/ftn: INFO: linux target is being used
PGF90-S-0034-Syntax error at or near identifier to_c80 (pw2casino_write.F90: 635)
PGF90/x86-64 Linux 10.0-0: compilation completed with severe errors
make: *** [pw2casino_write.o] Error 2

This is the (piece of) code

      IF(binwrite)THEN
         WRITE(iob)&
            to_c80(title)    ,& ! title
            to_c80("PWSCF")  ,& ! code
            to_c80("DFT")    ,& ! method
            to_c80("unknown"),& ! functional
            to_c80("unknown"),& ! pseudo_type
            dble(ecutwfc/2)  ,&  ! plane_wave_cutoff
            lsda             ,&  ! spin_polarized,
            dble(etot/e2)    ,&  ! total_energy
            dble(ek/e2)      ,&  ! kinetic_energy
            dble(eloc/e2)    ,&  ! local_potential_energy
            dble(enl/e2)     ,&  ! non_local_potential_energy
            dble(ehart/e2)   ,&  ! electron_electron_energy
            dble(ewld/e2)    ,&  ! eionion
            nint(nelec)      ,&  ! num_electrons
            nat              ,&  ! nbasis
            ngtot_g          ,&  ! nwvec
            nk               ,&  ! nkvec
            blipgrid(1:3)    ,&  ! nr
            nbnd             ,&  ! maxband
            blipreal/=0      ,&  ! gamma_only
            .true.           ,&  ! ext_orbs_present
            (/0,0/)          ,&  ! no_loc_orbs
            alat*at(1:3,1)   ,&  ! pa1
            alat*at(1:3,2)   ,&  ! pa2
            alat*at(1:3,3)   ,&  ! pa3
            2                ,&  ! nspin_check
            nbnd                 ! num_nonloc_max

The row number is

WRITE(iob)&

So, what’s wrong?

Many thanks in advance!

Hi filippo.spiga,

I don’t see anything obvious. Because you use continuations, the compiler treats this as one single line and why it list the line number at the start of the WRITE. The actual error has to to with one of the arguments.

What I would do is comment out all the arguments and then add them back one by one until the syntax error occurs. (Be sure to add and subtract the “,&” as needed). Once you have it narrowed down, it may be easier to tell what’s wrong.

Also, please post what “to_c80” is.

Thanks,
Mat

Dear Mat,

Arguments are all correct. To be honest, I already found a way to bypass the problem. I removed all the comments, in this way:

         WRITE(iob) to_c80(title), to_c80("PWSCF"), to_c80("DFT"), to_c80("unknown"), to_c80("unknown"), dble(ecutwfc/2), lsda, dble(etot/e2), &
            dble(ek/e2), dble(eloc/e2), dble(enl/e2), dble(ehart/e2), dble(ewld/e2), nint(nelec), nat, ngtot_g, nk, blipgrid(1:3), nbnd, blipreal/=0, &
            .true., (/0,0/), alat*at(1:3,1), alat*at(1:3,2), alat*at(1:3,3), 2, nbnd

So, what is the difference between the version “with comments” and the version “without comments”? The compiler ignores the comments, isn’t it?

Before call the compiler through ftn CRAY wrapper, I do this command

cpp -P -traditional -D__PGI -D__MPI -D__PARA -D__SCALAPACK -D__ACML -D__WALLTIME -I…/include pw2casino_write.f90 -o pw2casino_write.F90

Does the preprocessor introduce some “tricks” inside the code (around comments in this specific case) that pgf90 is not able to understand correctly?



   FUNCTION to_c80(c)
      CHARACTER(*),INTENT(in) :: c
      CHARACTER(80) :: to_c80
      to_c80=c
   END FUNCTION to_c80

I can provide you the entire file if you think it could be useful to investigate.

Does the preprocessor introduce some "tricks" inside the code (around comments in this specific case) that pgf90 is not able to understand correctly?

Doubtful, but possible. You can try skipping the preprocessor and adding the flag “-Mpreprocess”

ftn -Mpreprocess  <other compile flags> -D__PGI -D__MPI -D__PARA -D__SCALAPACK -D__ACML -D__WALLTIME -I../include pw2casino_write.f90



So, what is the difference between the version “with comments” and the version “without comments”? The compiler ignores the comments, isn’t it?

Yes, the compiler ignores the comments. Note that besides removing the comments, you also removed most of the continuation characters. Hence, it could be something to do with the “&” as well.

I can provide you the entire file if you think it could be useful to investigate.

I do find this odd so don’t mind taking a look. Please send the code to PGI Customer Service (trs@pgroup.com) and ask them to forward it to me.

Thanks,
Mat

Nothing changed.

ftn -Mpreprocess  <other compile flags> -D__PGI -D__MPI -D__PARA -D__SCALAPACK -D__ACML -D__WALLTIME -I../include pw2casino_write.f90





Note that besides removing the comments, you also removed most of the continuation characters. Hence, it could be something to do with the “&” as well.

…I do find this odd so don’t mind taking a look. Please send the code to PGI Customer Service (> trs@pgroup.com> ) and ask them to forward it to me.

I will send you an email tomorrow. Thank you very much again!

Before going on in this discussion, another question comes to my mind.

Starting from .f90 file, I call the preprocessor cpp and I obtain a .F90 file (with capital F). Then I pass this file to ftn CRAY wrapper. Error…

My new question is: does PGI compile in two different ways .f90 and .F90 files?

I’m asking you that because if I force to compile my code without ftn and without cpp, using only pgf90 combined with the flag -Mpreprocess (and, of course, the original .f90 file), the problem doesn’t appear!

Hi filippo.spiga,

does PGI compile in two different ways .f90 and .F90 files?

Yes. Fortran files with a capital letter suffix (i.e. “.F”, “.F90”, “.F95”,".F03",".CUF") get preprocessed by default. Lower case suffix do not unless “-Mpreprocess” is used.

So having cpp preprocess a file from “.f90” to “.F90” means that the fortran compiler will preprocess it again.

  • Mat