Adding a new utility  [SOLVED]

Moderator: pouillon

Post Reply
abokhanc
Posts: 24
Joined: Tue Jul 29, 2014 4:28 pm

Adding a new utility

Post by abokhanc » Mon Aug 18, 2014 5:46 pm

So I have a program that i wrote in .F90 that has a .h and util.F files as part of the package. Are there instructions somewhere that i can follow in order to integrate that program into Abinit so i can run it like cut3d for example?

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Adding a new utility

Post by Jordan » Tue Aug 19, 2014 6:00 pm

Hi,

If you want to add a new main program in abinit, you should add you main program file .F90 in the src/98_main directory. I'll refer to this file as foobar.F90 and the name of you program foobar
Put your header file .h in src/incs
Then edit the src/98_main/Makefile.am file and add and modify the following to suit your need :

Code: Select all

foobar_SOURCES = foobar.F90 #fortran files for you program
foobar_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS)
foobar_FCFLAGS = $(AM_FCFLAGS) $(FCFLAGS)
foobar_LDADD = #whatever library you need (e.g $(top_builddir)/src/53_abiutil/lib53_abiutil.a)

If you don't use any module/library of the abinit package the foobar_LDADD should be empty except if you want to link with some of your libraries.

For more information I recommend to read a tutorial about autools and particularly automake.

Cheers,

Jordan

abokhanc
Posts: 24
Joined: Tue Jul 29, 2014 4:28 pm

Re: Adding a new utility

Post by abokhanc » Wed Aug 20, 2014 8:08 pm

Thanks for the reply,

I've edited the Makefile.am file:

Code: Select all

#fftprof

# fold2Bloch.F90 ---> fold2Bloch
fold2Bloch_SOURCES = fold2Bloch.F90
fold2Bloch_CPPFLAGS = \
   $(AM_CPPFLAGS) \
   $(CPPFLAGS)
fold2Bloch_FCFLAGS = \
   $(AM_FCFLAGS) \
   $(FCFLAGS)
fold2Bloch_LDADD =

#ioprof


Then i recompile and it doesn't seem to see it. I reconfigured it and recompiled and still nothing. On top of Makefile.am it says that any manual changes will be overwritten and that i need to edit a make-makefile script or configure file instead.

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Adding a new utility

Post by Jordan » Thu Aug 21, 2014 7:30 pm

Sorry, I forgot to tell you to add the name of your executable in the bin_PROGRAMS variable (line 115 or so) in the same Makefile.am file. It should look like

Code: Select all

bin_PROGRAMS = \
abinit \
... \
... \
fold2Bloch


That should work.

The Makefile.am is indeed written by a script named "makemake" but this is only for developers and it is not part of the user distribution I think since it is the script that write all the autotools files to generate the configure script.

Cheers

Jordan

abokhanc
Posts: 24
Joined: Tue Jul 29, 2014 4:28 pm

Re: Adding a new utility

Post by abokhanc » Thu Aug 21, 2014 7:54 pm

Hi Jordan,

I had noticed that right away and added that line there.
I saw a message somewhere (don't remember where, trying to recreate it now) saying i need autotools-1.11. When i type which automake it give me:

Code: Select all

[stud2@feynman build]$ which automake
/usr/bin/automake


So it's there, plus the Makefile.in are created for which i believe automake has to work.
i'm just trying to learn how to integrate a program in abinit for now so my program is very simple:

Code: Select all

program fold2Bloch

open(unit=100, file="fold2Bloch.text", form="formatted", status="unknown")
write(100, *) "TEST TEST TEST"

end program fold2Bloch


Am i missing a special header of some kind? I looked at other and the only difference is they include the common.h which i don't, but even then it doesn't work.
Also, when i check the Makefile.in, the fold2Bloch isn't there. It just doesn't see it. :x

User avatar
pouillon
Posts: 651
Joined: Wed Aug 19, 2009 10:08 am
Location: Spain
Contact:

Re: Adding a new utility

Post by pouillon » Tue Aug 26, 2014 12:14 pm

To add a main program in Abinit, you have to add an entry for it in the config/specs/binaries.conf file and run the ./config/scripts/makemake program for the top source directory. Only then will it be built with the rest of Abinit.

Regarding the location of the files, what Jordan told you is perfectly fine. The file extension of your program has indeed to be .F90 to have it fully taken into account.
Yann Pouillon
Simune Atomistics
Donostia-San Sebastián, Spain

abokhanc
Posts: 24
Joined: Tue Jul 29, 2014 4:28 pm

Re: Adding a new utility

Post by abokhanc » Wed Sep 03, 2014 5:07 pm

So after getting all my auto tools up to date, i managed to run the makemake from the abinit top directory and this is what i got:

Code: Select all

[stud2@feynman abinit-7.4.3]$ config/scripts/makemake
[makemake] Starting at 2014/09/03 14:59:43 +0000
[makemake] -------------------------------------
[makemake] === Source tree consistency ===
[makemake]   Enabling write permission for all dirs & files
[makemake] === Source tree update ===
[makemake]   Generating CPP option dumper
[makemake]   Updating routines inside 57_iovars
[makemake]   Removing build examples
[makemake]   Generating build examples
[makemake] Updating Fortran interfaces
[makemake] ---> running ./config/scripts/abilint  --dependencies --dump_dtset bindings/parser/dtset.pickle . . 1>abilint.out 2>&1
[makemake]   Generating dtset source files
[makemake] === Build system update ===
[makemake]   Resetting configuration dumper
[makemake]   Generating macros for the Autotools
[makemake]   Generating macros for dumpers
[makemake]   Generating macros for environment variables
[makemake]   Generating macros for command-line options
[makemake]   Generating macros for hints
[makemake]   Generating macros for debugging
[makemake]   Generating macros for default optimizations
[makemake]   Generating macros for per-directory optimizations
[makemake]   Generating macros for core libraries
[makemake]   Generating macros for fallback linking
    make-macros-linking: Could not find config file (fallbacks/config/specs/fallbacks.conf).
    make-macros-linking: Aborting now.
[makemake] Aborting now!
[stud2@feynman abinit-7.4.3]$ make
make: *** No targets specified and no makefile found.  Stop.
[stud2@feynman abinit-7.4.3]$


When i check the directory, indeed there is not specs folder in abinit/fallbaks/config
there is only "gnu" and "m4" folders.

abokhanc
Posts: 24
Joined: Tue Jul 29, 2014 4:28 pm

Re: Adding a new utility

Post by abokhanc » Thu Sep 04, 2014 5:11 pm

I thought maybe fallbacks.conf was deleted by a clean up, so i unpacked the original Abinit 7.4.3 archive, yet it still isn't there. Where is this file suppose to come from?

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Adding a new utility  [SOLVED]

Post by Jordan » Thu Sep 04, 2014 8:23 pm

I guess the file is missing in the distribution version.
I've copy paste the file content below (abinit-7.8.2). It just specifies information related to fallback if the build system needs to download one of them.

Code: Select all

#
# Config file for the fallbacks of Abinit
#

# Permitted options: binaries, description, distribute, headers,
#                    libraries, modules, name, nickname, urls,
#                    depends, configure, makej

# Do *NOT* modify the following section
#
## BEGIN BUILD
##   linalg fox netcdf etsf_io libxc atompaw bigdft wannier90
## END BUILD

[DEFAULT]
distribute = yes
configure = yes
makej = 4

[atompaw]
name = atompaw-3.1.0.2
description = AtomPAW version 3.1.0.2 (upstream release)
md5sum = e580f7575f0922356520d2075f0bee3a
makej = 1
urls =
  http://www.wfu.edu/~natalie/papers/pwpaw/atompaw-3.1.0.2.tar.gz
  http://forge.abinit.org/fallbacks/atompaw-3.1.0.2.tar.gz
binaries =
  atompaw
  graphatom
libraries =
  libatompaw.a
install_bins = yes
depends = linalg libxc

[bigdft]
name = bigdft-1.7.0.93
description = BigDFT library 1.7.0.93 (upstream release)
nickname = bigdft-1.7.0.93
md5sum = 2300b5a8c4dfc13b9e602b97c533f5c8
urls =
  http://inac.cea.fr/L_Sim/BigDFT/bigdft-1.7.0.93.tar.gz
libraries =
  libyaml.a
  libabinit.a

  libbigdft-1.a
modules =
  yaml_strings.mod
  dictionaries.mod
  dictionaries_base.mod
  yaml_output.mod
  yaml_parse.mod
  metadata_interfaces.mod
  dynamic_memory.mod
  randomdata.mod
  memory_profiling.mod
  exception_callbacks.mod
  module_fft_sg.mod
  wrapper_linalg.mod
  wrapper_mpi.mod
  poisson_solver.mod
  bigdft.h
  bigdft_input_keys.h
  module_base.mod
  module_defs.mod
  module_types.mod
  module_interfaces.mod
  module_private_api.mod
  module_xc.mod
  overlap_point_to_point.mod
  module_input.mod
  gaussians.mod
  bigdft_api.mod
  vdwcorrection.mod
  module_fragments.mod
  constrained_dft.mod
  diis_sd_optimization.mod
  input_old_text_format.mod
  module_input_keys.mod
  bigdft_cst.h
  bigdft_api.mod
depends = linalg netcdf etsf_io

[etsf_io]
name = etsf_io-1.0.4
description = ETSF I/O library 1.0.4 (upstream release)
md5sum = 8994bc14b6958d3a4a6c4cf6d2e7c4b6
urls =
  http://forge.abinit.org/fallbacks/etsf_io-1.0.4.tar.gz
  http://ypouillon.free.fr/abinit/etsf_io-1.0.4.tar.gz
binaries =
  etsf_io
libraries =
  libetsf_io.a
  libetsf_io_utils.a
  libetsf_io_low_level.a
modules =
  etsf_io.mod
  etsf_io_file.mod
  etsf_io_low_level.mod
  etsf_io_tools.mod
depends = netcdf

[fox]
name = FoX-4.1.2
description = FoX Fortran XML library 4.1.2 (upstream release)
md5sum = e99bbf2950f2d0bf83be6151c305f27c
urls =
  http://www1.gly.bris.ac.uk/~walker/FoX/source/FoX-4.1.2.tar.gz
  http://forge.abinit.org/fallbacks/FoX-4.1.2.tar.gz
binaries =
  FoX-config
libraries =
  libFoX_common.a
  libFoX_fsys.a
  libFoX_utils.a
  libFoX_sax.a
modules =
  fox_common.mod
  fox_m_fsys_abort_flush.mod
  fox_m_fsys_array_str.mod
  fox_m_fsys_count_parse_input.mod
  fox_m_fsys_format.mod
  fox_m_fsys_parse_input.mod
  fox_m_fsys_realtypes.mod
  fox_m_fsys_string.mod
  fox_m_fsys_string_list.mod
  fox_m_utils_mtprng.mod
  fox_m_utils_uri.mod
  fox_m_utils_uuid.mod
  fox_sax.mod
  fox_utils.mod
  m_common_attrs.mod
  m_common_buffer.mod
  m_common_charset.mod
  m_common_content_model.mod
  m_common_element.mod
  m_common_elstack.mod
  m_common_entities.mod
  m_common_entity_expand.mod
  m_common_error.mod
  m_common_io.mod
  m_common_namecheck.mod
  m_common_namespaces.mod
  m_common_notations.mod
  m_common_struct.mod
  m_sax_operate.mod
  m_sax_parser.mod
  m_sax_reader.mod
  m_sax_tokenizer.mod
  m_sax_types.mod
  m_sax_xml_source.mod

[libxc]
name = libxc-2.0.3
description = LibXC library 2.0.3 (upstream release)
md5sum = f23586d54a5e73e7aa634560c9bab3e9
makej = 1
urls =
  http://www.tddft.org/programs/octopus/down.php?file=libxc/libxc-2.0.3.tar.gz
  http://forge.abinit.org/fallbacks/libxc-2.0.3.tar.gz
headers =
  xc.h
  xc_config.h
  xc_funcs.h
libraries =
  libxc.a
modules =
  libxc_funcs_m.mod
  xc_f90_lib_m.mod
  xc_f90_types_m.mod

[linalg]
name = lapack-abinit_6.10
description = Oldish BLAS/LAPACK implementation customized for Abinit
nickname = lapack-abinit_6.10
md5sum = 12169d5c702ccc63117f4591cd3f1225
makej = 5
urls =
  http://forge.abinit.org/fallbacks/lapack-abinit_6.10.tar.gz
  http://ypouillon.free.fr/abinit/lapack-abinit_6.10.tar.gz
libraries =
  libblas.a
  liblapack.a
configure = no

[netcdf]
name = netcdf-4.1.1
description = NetCDF library 4.1.1 (upstream release)
md5sum = 79c5ff14c80d5e18dd8f1fceeae1c8e1
makej = 1
urls =
  http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.1.1.tar.gz
  http://forge.abinit.org/fallbacks/netcdf-4.1.1.tar.gz
binaries =
  nc-config
  nccopy
  ncdump
  ncgen
  ncgen3
headers =
  netcdf.h
libraries =
  libnetcdf.a
  libnetcdf.la
modules =
  netcdf.inc
  netcdf.mod
  typesizes.mod

[wannier90]
name = wannier90-1.2.0.1
description = Wannier90 program 1.2.0.1 (special edition hacked by YP)
md5sum = 59afbb7cda21af1865c526126dd7cb3f
urls =
  http://forge.abinit.org/fallbacks/wannier90-1.2.0.1.tar.gz
  http://ypouillon.free.fr/abinit/wannier90-1.2.0.1.tar.gz
binaries =
  wannier90.x
libraries =
  libwannier90.a
install_bins = yes
depends = etsf_io linalg


Cheers

Jordan

abokhanc
Posts: 24
Joined: Tue Jul 29, 2014 4:28 pm

Re: Adding a new utility

Post by abokhanc » Thu Sep 04, 2014 10:14 pm

Thank you all very much. It finally compiled my test program so now i can start working in my actual program.

Cheers,

Anton Bokhanchuk

Post Reply