WIEN2k-FAQ: Compiling WIEN2k under Vast f90

©2001 by P. Blaha, K. Schwarz and J. Luitz


Back to:


Problem: Compilation of WIEN2k using Vast f90

Solution: (has been submitted by Sharat Chandra sharat@igcar.ernet.in)

(Some of the required code changes may already present in a newer version of WIEN2k)

#!/bin/tcsh -f
###############################################################################
# The procedure to be adopted to compile the WIEN_2k programs with vast f90   #
# compiler is:                                                                #
#									      #
# First run this script on the untarred package and make all the required     #
# changes. After that siteconfig_lapw can be run generate the Makefiles for   #
# L1 system using g77 (choose f90) and gcc compilers. Then after giving all   #
# other options, compile the programs.                                        #
#                                                                             #
# f90 compiler works as an overlayer for the g77. It first converts the code  #
# to f77 and then compiles it using g77. The problems with this compiler are  #
# 1) It recognizes only the .f (fixed), .f90 (free) and .mod (module) files   #
# 2) It is not able to understand the c++ style statements that g77 and other #
#    compilers can do (in the .F files).                                      #
#                                                                             #
# Create file "temp" in the $WIENROOT dir with ".SUFFIXES: .f90" content for  #
# making changes in the Makefile in all the SRC_* directories (line to be     #
# added to Makefile). Change the extensions of all the .f and .frc files to   #
# .f90 and .frc90 and preprocess the .F files by the cpp command (taking care #
# that the // in the statements are processed properly) to generate the       #
# corresponding .f90 (in SRC_lapw0) and .F90 (in SRC_lapw1 and SRC_lapw2)     #
# sequential files. These can then be used to extract the real and the complex#
# versions. Use the -O3 optimization to compile all the programs. In addition #
# to these changes, some changes are to be made in the source code manually.  #
#                                                                             #
# The changes are:							      #
# SRC_dstart: dstart.f: change line 11 to				      #
#             parameter (npt=1051) from parameter(npt=ipinst+nrad)	      #
#             ipinst=170, nrad=881 in SRC_dstart/param.inc		      #
#									      #
# SRC_irrep: init.f: change line 141 to					      #
#            529 FORMAT(1X,....) from 529 FORMAT(X,.....)		      #
#            rmprop.f change lines 287-291 to				      #
#            ... FORMAT(1X,....) from ... FORMAT(X,.....)		      #
#									      #
# SRC_lapw0: th1.f: change line 10 to					      #
#            INTEGER ICONR(21), IPRI from INTEGER ICONR(21) 		      #
#            th2.f: change line 11 to					      #
#            INTEGER ICONR(19), IPRI from INTEGER ICONR(19) 		      #
#            vxclm2.f: add INTEGER index (at line 5)			      #
#            these changes are made so as to avoid save data errors.	      #
#            Makefile.orig: FGEN: add -fno-globals -Wno-globals (before       #
#                           $PARALLEL)                                        #
#									      #
#									      #
# SRC_lapw1: All INTRINSIC DCONJG declarations have to be changed to DOUBLE   #
#            COMPLEX DCONJG to avoid f90 errors which f90 compiler is unable  #
#            to recognize as intrinsic function.		              #
#            prtkpt.F: change line 153 to				      #
#            CALL TAPEWF(KNAME(POINT),EIGVAL(J) or (1), .... & from	      #
#            CALL TAPEWF(KNAME(POINT),EIGVAL, .... &			      #
#            EIGVAL is translated as two element array with null first element#
#            Makefile.orig: FGEN: add -fno-globals -Wno-globals (before       #
#                                 $PARALLEL)                                  #
#                           .F90.o: all .F90 (3 in no.) to be changed to .f90 #
#                                                                             #
# SRC_lapw2: All INTRINSIC DCONJG declarations have to be changed to 	      #
#            DOUBLE COMPLEX DCONJG					      #
#            fermi.f: comment out IMPLICIT REAL*8 (A-H,O-Z) in subroutines    #
#            fermi and fermi_tetra, lines 13 and 385, which give	      #
#            errors with line 2 INTEGER,PARAMETER :: IBLOCK= 128 in	      #
#            modules.F (I dont know why!!)				      #
#	     comment line 1557 (intrinsic abs, exp)			      #
#            fermi5.f: comment out line 26 implicit real*8 (a-h,o-z) and      #
#            add real*8 de, betha, f1, f2, emax, emin due to error	      #
#            same as above.						      #
#            l2main.F: change lines 115 to 119 from			      #
#            1 J=2*I-1               | to | DO I=1,49			      #
#              FCT(J)=Y              |    | J=2*I-1			      #
#              Y=Y*I                 |    | FCT(J)=Y			      #
#              I=I+1                 |    | Y=Y*I			      #
#              IF(I.LT.50) GOTO 1    |    | END DO			      #
#            This is necessary as the f90 to f77 interpreter does not	      #
#            convert the original loop properly.			      #
#	     Makefile.orig: FGEN: add -fno-globals -Wno-globals (before       #
#                                 $PARALLEL)                                  #
#	                    .F90.o: all .F90 (3 in no.) to be changed to .f90 #
#									      #
# SRC_lapw7: grdgen.f: change lines 258 and 260 to			      #
#            2090 FORMAT(' abs(',A1,...) from 2090 FORMAT(' abs('A1,..)       #
#            2110 FORMAT(....'F10.7 ...) from 2110 FORMAT(..',F10.7 ..)	      #
#            (add a comma before A1 and F10.7)				      #
#	     Makefile.orig: change lines 110 & 111 to .. moduls.f90 .. from   #
#                           .. moduls.f ..                                    #
#									      #
# SRC_lapwdm: modules.frc: line 226, MODULE ams				      #
#             change the line 231 REAL*8 :: atom_mass(103) to		      #
#             REAL*8 :: a_m(103) to avoid double declaration of atom_mass(103)#
#									      #
# SRC_lcore: insld.f: line 24 and 25: data new /1/; save new:		      #
#            add line integer new to avoid save data errors as in             #
#            SRC_lapw0							      #
#									      #
# SRC_lib: Use the blas and lapack libraries supplied by the RedHat.	      #
#									      #
# SRC_optic: Makefile.orig: lines 105,106 to .. modules.frc90 .. from         #
#                           ..modules.frc ..                                  #
#									      #
# SRC_optimize: optimize.f: line 152, 153 and 155			      #
#               comment line 152,					      #
#               replace 'backslash' by '\' in line 153			      #
#               replace ',backslash' by '\' in line 155			      #
#               as g77 gives formatting error.				      #
#									      #
# SRC_orb: couplx.f: lines 10, 19 and 20:				      #
#          change dimag to dmag to avoid clash with intrinsic DIMAG in g77    #
#          orbmom.f: lines 10, 19 and 20:				      #
#          change dimag to dmag to avoid clash with intrinsic DIMAG in g77    #
#          (f90 replaces aimag with dimag)				      #
#									      #
#									      #
# Now use siteconfig_lapw to set up all the options and compile the programs. #
# In addition to these changes, after compilation is over, compile the complex#
# versions of aim, filtvec, lapw1,2,3,5,7,dm and optic as these file are not  #
# created by siteconfig_lapw (go to the respective directories and type 'make #
# complex'). Copy the binaries to $WIENROOT. Also compile and copy extra      #
# programs available # in balsac_utils and fsgen.                             #
###############################################################################

echo "This file changes the .f and .frc extensions to .f90 and .frc90"
echo "and  .F extensions to .f90  or .F90 after extracting sequential"
echo "or parallel version from the WIEN_2k LAPW  code for compilation"
echo "with Pacific Sierra Vast F90 or HPF90 Compiler Personal Version"
echo "This script is based on the code extracted from siteconfig_lapw \n"

alias wait          'echo "";echo "     Press RETURN to continue";'\
                    'set yn = ($<)'
foreach i (SRC_*)
    if (-d $i) then
        cd $i
          echo "\n Change .f and .frc to .f90 & .frc90 in $i?  (y/n) \n"
          set yn = ($<)
            if( $yn == 'y' ) then
             if (-e Makefile.orig) then
            cat /wien2k/temp Makefile.orig > tmp #change pathname to $WIENROOT
            mv tmp Makefile.orig
             endif
          set a=(`ls *.f *.frc`)
          foreach ii ($a)
            set newname= ($ii\90)
            mv $ii $newname
          end
	  if ($i == SRC_lib) then
	    cd blas_lapw
             if(-e Makefile.orig) then
            cat /wien2k/temp Makefile.orig > tmp #change pathname to $WIENROOT
            mv tmp Makefile.orig
             endif
	    set a=(`ls *.f *.frc`)
	    foreach ii ($a)
		set newname= ($ii\90)
		mv $ii $newname
	    end
	    cd ../lapack_lapw
             if(-e Makefile.orig) then
            cat /wien2k/temp Makefile.orig > tmp #change pathname to $WIENROOT
            mv tmp Makefile.orig
             endif
	    set a=(`ls *.f *.frc`)
	    foreach ii ($a)
		set newname= ($ii\90)
		mv $ii $newname
	    end
	    cd ..
	  endif
        echo "All *.f and *.frc files changed to f90, frc90 in $i \n"
         endif
        cd ..
    endif
end
wait
foreach i (SRC_lapw0 SRC_lapw1 SRC_lapw2)
    if (-d $i) then
        cd $i
          echo "extract sequential or parallel in $i?  (s/p) \n"
          set sp = ($<)
            if( $sp == 's' ) then
            set a=(`ls *.F`)
            foreach ii ($a)
             set jj=$ii:r
           if ($i == SRC_lapw0) then
            /usr/bin/cpp -P -C -traditional $ii $jj
            set newname= ($jj\.f90)
            set oldname=($ii\.OLD)
            mv $jj $newname
            mv $ii $oldname
            echo "$ii extracted to $newname and $ii moved to $oldname"
            end
            cd ..
           else
            /usr/bin/cpp -P -C -traditional $ii $jj
            set newname= ($jj\.F90)
            set oldname=($ii\.OLD)
            mv $jj $newname
            mv $ii $oldname
            echo "$ii extracted to $newname and $ii moved to $oldname"
            end
            cd ..
          endif
        endif
            if( $sp == 'p' ) then
            set a=(`ls *.F`)
            foreach ii ($a)
             set jj=$ii:r
           if ($i == SRC_lapw0) then
            /usr/bin/cpp -P -C -traditional -D Parallel $ii $jj
            set newname= ($jj\.f90)
            set oldname=($ii\.OLD)
            mv $jj $newname
            mv $ii $oldname
            echo "$ii extracted to $newname and $ii moved to $oldname"
            end
            cd ..
           else
            /usr/bin/cpp -P -C -traditional -D Parallel $ii $jj
            set newname= ($jj\.F90)
            set oldname=($ii\.OLD)
            mv $jj $newname
            mv $ii $oldname
            echo "$ii extracted to $newname and $ii moved to $oldname"
           end
          cd ..
        endif
    endif
end


Peter Blaha,