How to create a new ypp interface

From The Yambo Project
Jump to navigation Jump to search

The choice for “section” and the “short_opt” comes from an analysis of the outcome of “ypp_df -h”

0) Adding an option in ypp.in input file: Edit the file src/driver/options_ypp.c

#if defined _YPP_DF
*i_opt=*i_opt+1;
options[*i_opt].short_desc="Write_here_a_short_description_of_the_flag";
options[*i_opt].long_opt=  "short_name_of_your_new_flag";
options[*i_opt].short_opt='d';      
options[*i_opt].bin="associated_executable";  % for example ypp_df
options[*i_opt].yambo_string="short_name_of_your_new_flag";
options[*i_opt].section="Choose_your_section";  
#endif

Imagine you want to create a new ypp interface, you will want to make some variables to appear in your new input file.

1) Edit the file ypp/modules/mod_YPP.F

  logical            :: l_defects
  character(lchlen)  :: superc_path

2) Initialize the non logical variable in ypp/modules/YPP_SET_defaults.F

  #if defined _YPP_DF
  !
  superc_path='none'
  !
  #endif

3) Edit ypp/interface/INIT_load_ypp.F in order to instruct the code to switch on the flag in the ypp.in input file

  #if defined _YPP_DF
   use YPPm,          ONLY:superc_path
  #endif
  #if defined _YPP_DF
   call it(defs,'SupercPATH',  'Path to the supercell with defect',superc_path)
  #endif

4) Edit ypp/interface/INIT_ypp.F

  #if defined _YPP_DF
    l_defects   =  trim(rstr_piece(i1)) == 'dsuperc'
  #endif

Notice that ‘dsuperc’ has been introduced in options_ypp.c. So if the code “sees” this flag it associates .true. to the logical l_defects.

  #if defined _YPP_DF
   if (l_defects)       call initactivate(1,'dsuperc')
  #endif
  #if defined _YPP_DF
   l_defects=runlevel_is_on('dsuperc')
  #endif
  #if defined _YPP_DF
   if(l_defects) call initactivate(1,"SupercPATH")
  #endif

5) Create directory ypp/defects/ and the file .objects:

  #if defined _YPP_DF
    DF_objects = DEFECTS_driver.o
  #endif
   objs = $(DF_objects)

and then DEFECTS_driver.F:

  subroutine DEFECTS_driver(en,k)
  !
  use R_lattice,      ONLY:bz_samp
  use electrons,      ONLY:levels
  !
  #include<memory.h>
  !
  type(levels)  :: en
  type(bz_samp) :: k
  end subroutine 

Finally "git add defects".

  YPPDF_LIBS         = $(YPP_LIBS) defects
  YPPDF_LIBS_LD      = $(YPP_LIBS_LD) defects