From f9f3fac7ffa8c73e69b4170dc8d165606935bb67 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 3 Apr 2014 11:19:41 +0200 Subject: [PATCH] Make all_modules and all_clean compiles in parallel. Added NEEDED_MODULES --- README.rst | 1 + scripts/check_dependencies.sh | 4 +- scripts/create_Makefile.sh | 12 ++- scripts/create_Makefile_depend.sh | 2 +- scripts/create_module.sh | 75 ++++++++++++++++- src/.gitignore | 2 +- src/AOs/Makefile | 4 +- src/AOs/NEEDED_MODULES | 1 + src/Bitmask/Makefile | 4 +- src/Bitmask/NEEDED_MODULES | 1 + src/Electrons/Makefile | 4 +- src/Electrons/NEEDED_MODULES | 1 + src/Electrons/README.rst | 3 + src/Ezfio_files/Makefile | 4 +- src/Ezfio_files/NEEDED_MODULES | 0 src/Ezfio_files/get_unit_and_open.irp.f | 15 ++++ src/MOs/Makefile | 4 +- src/MOs/NEEDED_MODULES | 1 + src/MOs/README.rst | 12 +++ src/Makefile | 36 ++++---- src/Makefile.common | 12 +-- src/NEEDED_MODULES | 1 + src/Nuclei/Makefile | 4 +- src/Nuclei/NEEDED_MODULES | 1 + src/Output/Makefile | 4 +- src/Output/NEEDED_MODULES | 1 + src/README.rst | 105 ++++++++++++++++++++++++ src/Utils/Makefile | 4 +- src/Utils/NEEDED_MODULES | 1 + src/coding_rules.rst | 77 ----------------- 30 files changed, 272 insertions(+), 124 deletions(-) create mode 100644 src/AOs/NEEDED_MODULES create mode 100644 src/Bitmask/NEEDED_MODULES create mode 100644 src/Electrons/NEEDED_MODULES create mode 100644 src/Electrons/README.rst create mode 100644 src/Ezfio_files/NEEDED_MODULES create mode 100644 src/MOs/NEEDED_MODULES create mode 100644 src/MOs/README.rst create mode 100644 src/NEEDED_MODULES create mode 100644 src/Nuclei/NEEDED_MODULES create mode 100644 src/Output/NEEDED_MODULES create mode 100644 src/README.rst create mode 100644 src/Utils/NEEDED_MODULES delete mode 100644 src/coding_rules.rst diff --git a/README.rst b/README.rst index 8de94373..5dfa5b65 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,4 @@ +=============== Quantum package =============== diff --git a/scripts/check_dependencies.sh b/scripts/check_dependencies.sh index db832bfb..943c5211 100755 --- a/scripts/check_dependencies.sh +++ b/scripts/check_dependencies.sh @@ -25,7 +25,7 @@ fi if [[ $1 == "-" ]] then - COMMAND_LINE=$(grep -e "^INCLUDE_DIRS" Makefile 2>/dev/null | cut -d '=' -f 2) + COMMAND_LINE=$(cat NEEDED_MODULES) else COMMAND_LINE=$(unique_list $@) fi @@ -44,7 +44,7 @@ DEPS_LONG="" for i in $COMMAND_LINE do DEPS_LONG+=" $i " - DEPS_LONG+=$(grep -e '^INCLUDE_DIRS' ${QPACKAGE_ROOT}/src/${i}/Makefile 2>/dev/null | cut -d '=' -f 2) + DEPS_LONG+=$(cat ${QPACKAGE_ROOT}/src/${i}/NEEDED_MODULES) done DEPS=$(unique_list $DEPS_LONG) diff --git a/scripts/create_Makefile.sh b/scripts/create_Makefile.sh index 0c21609a..b3b96b06 100755 --- a/scripts/create_Makefile.sh +++ b/scripts/create_Makefile.sh @@ -11,7 +11,7 @@ DEPS_LONG="" for i in $@ do DEPS_LONG+=" $i " - DEPS_LONG+=$(grep 'INCLUDE_DIRS' ${QPACKAGE_ROOT}/src/${i}/Makefile 2>/dev/null | cut -d '=' -f 2) + DEPS_LONG+=$(cat ${QPACKAGE_ROOT}/src/${i}/NEEDED_MODULES) done DEPS=($( @@ -21,12 +21,16 @@ do done | sort | uniq )) +# Create the NEEDED_MODULES file +cat << EOF > NEEDED_MODULES +${DEPS[@]} +EOF + # Create the Makefile cat << EOF > Makefile default: all -# Define here all other modules on which the current module depends -INCLUDE_DIRS = ${DEPS[@]} +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -38,7 +42,7 @@ include \$(QPACKAGE_ROOT)/src/Makefile.config include \$(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: \$(filter-out IRPF90_temp/%, \$(wildcard */*.irp.f)) \$(wildcard *.irp.f) \$(wildcard *.inc.f) Makefile \$(EZFIO) +irpf90.make: \$(filter-out IRPF90_temp/%, \$(wildcard */*.irp.f)) \$(wildcard *.irp.f) \$(wildcard *.inc.f) Makefile \$(EZFIO) NEEDED_MODULES \$(IRPF90) Makefile.depend: Makefile diff --git a/scripts/create_Makefile_depend.sh b/scripts/create_Makefile_depend.sh index af78033a..74749050 100755 --- a/scripts/create_Makefile_depend.sh +++ b/scripts/create_Makefile_depend.sh @@ -8,7 +8,7 @@ SRC="" OBJ="" -DEPS=$(grep "INCLUDE_DIRS" Makefile 2>/dev/null | cut -d '=' -f 2) +DEPS=$(cat NEEDED_MODULES) for M in ${DEPS} do diff --git a/scripts/create_module.sh b/scripts/create_module.sh index e8f88269..b8fafbb7 100755 --- a/scripts/create_module.sh +++ b/scripts/create_module.sh @@ -7,10 +7,35 @@ # All remaining aruments are dependencies. # Thu Apr 3 01:44:58 CEST 2014 +DEBUG=0 + +# If DEBUG=1, the print debug info. +function debug() +{ + if [[ $DEBUG -eq 1 ]] + then + function debug() + { + echo "$@" + } + else + function debug() + { + } + fi + debug $@ +} + + + + MODULE=$1 shift DEPS=$@ + + + # Check if module already exists if [ -d ${MODULE} ] then @@ -18,11 +43,57 @@ then exit 1 fi +debug "Module does not already exist: OK" + + +# Set up dependencies +ALL_MODULES=$(cat NEEDED_MODULES) + + + +if [[ 1 -eq 0 ]] ; then # TODO + # Create module directory and go into it -mkdir ${MODULE} -cd ${MODULE} +if [[ ! mkdir ${QPACKAGE_ROOT}/src/${MODULE} ]] +then + print "Unable to create module directory." + exit 1 +fi + +if [[ ! -d ${QPACKAGE_ROOT}/src/${MODULE} ]] +then + print "Something strange happened: the" + print ${QPACKAGE_ROOT}/src/${MODULE} + print "directory was not created." + exit 1 +fi + +cd ${QPACKAGE_ROOT}/src/${MODULE} +if [[ ${PWD} != ${QPACKAGE_ROOT}/src/${MODULE} ]] +then + print "Something strange happened: we should be in" + print ${QPACKAGE_ROOT}/src/${MODULE} + print "but we are in" + print ${PWD} + exit 1 +fi + +debug "Module directory is created." + + +fi # TODO + + + + # Create the Makefile ${QPACKAGE_ROOT}/create_Makefile.sh +# Update module list in main NEEDED_MODULES +ALL_MODULES+=" ${MODULE}" +cd ${QPACKAGE_ROOT}/src +echo ${ALL_MODULES} > NEEDED_MODULES +debug "Updated NEEDED_MODULES" + diff --git a/src/.gitignore b/src/.gitignore index d8f57d33..70d555dc 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -6,4 +6,4 @@ Makefile.config *tags *.o *.mod -*/Makefile.depend +*Makefile.depend diff --git a/src/AOs/Makefile b/src/AOs/Makefile index 6db64f54..ad986c3d 100644 --- a/src/AOs/Makefile +++ b/src/AOs/Makefile @@ -1,7 +1,7 @@ default: all # Define here all other modules on which the current module depends -INCLUDE_DIRS = Ezfio_files Nuclei Utils +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -13,7 +13,7 @@ include $(QPACKAGE_ROOT)/src/Makefile.config include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) Makefile.depend: Makefile diff --git a/src/AOs/NEEDED_MODULES b/src/AOs/NEEDED_MODULES new file mode 100644 index 00000000..e829976c --- /dev/null +++ b/src/AOs/NEEDED_MODULES @@ -0,0 +1 @@ +Ezfio_files Nuclei Utils diff --git a/src/Bitmask/Makefile b/src/Bitmask/Makefile index 3387b857..37d4b456 100644 --- a/src/Bitmask/Makefile +++ b/src/Bitmask/Makefile @@ -1,7 +1,7 @@ default: all # Define here all other modules on which the current module depends -INCLUDE_DIRS = AOs Electrons Ezfio_files MOs Nuclei Utils +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -13,7 +13,7 @@ include $(QPACKAGE_ROOT)/src/Makefile.config include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) Makefile.depend: Makefile diff --git a/src/Bitmask/NEEDED_MODULES b/src/Bitmask/NEEDED_MODULES new file mode 100644 index 00000000..454e95bb --- /dev/null +++ b/src/Bitmask/NEEDED_MODULES @@ -0,0 +1 @@ +AOs Electrons Ezfio_files MOs Nuclei Utils diff --git a/src/Electrons/Makefile b/src/Electrons/Makefile index 1827854f..ad986c3d 100644 --- a/src/Electrons/Makefile +++ b/src/Electrons/Makefile @@ -1,7 +1,7 @@ default: all # Define here all other modules on which the current module depends -INCLUDE_DIRS = Ezfio_files +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -13,7 +13,7 @@ include $(QPACKAGE_ROOT)/src/Makefile.config include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) Makefile.depend: Makefile diff --git a/src/Electrons/NEEDED_MODULES b/src/Electrons/NEEDED_MODULES new file mode 100644 index 00000000..d9eaf57c --- /dev/null +++ b/src/Electrons/NEEDED_MODULES @@ -0,0 +1 @@ +Ezfio_files diff --git a/src/Electrons/README.rst b/src/Electrons/README.rst new file mode 100644 index 00000000..158fb1bf --- /dev/null +++ b/src/Electrons/README.rst @@ -0,0 +1,3 @@ +This module contains the data relative to electrons: the number of alpha and beta electrons. + + diff --git a/src/Ezfio_files/Makefile b/src/Ezfio_files/Makefile index d3b4e2eb..ad986c3d 100644 --- a/src/Ezfio_files/Makefile +++ b/src/Ezfio_files/Makefile @@ -1,7 +1,7 @@ default: all # Define here all other modules on which the current module depends -INCLUDE_DIRS = +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -13,7 +13,7 @@ include $(QPACKAGE_ROOT)/src/Makefile.config include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) Makefile.depend: Makefile diff --git a/src/Ezfio_files/NEEDED_MODULES b/src/Ezfio_files/NEEDED_MODULES new file mode 100644 index 00000000..e69de29b diff --git a/src/Ezfio_files/get_unit_and_open.irp.f b/src/Ezfio_files/get_unit_and_open.irp.f index 259b2eec..9829021a 100644 --- a/src/Ezfio_files/get_unit_and_open.irp.f +++ b/src/Ezfio_files/get_unit_and_open.irp.f @@ -1,5 +1,20 @@ integer function getUnitAndOpen(f,mode) implicit none + + BEGIN_DOC +! :f: +! file name +! +! :mode: +! 'R' : READ, UNFORMATTED +! 'W' : WRITE, UNFORMATTED +! 'r' : READ, FORMATTED +! 'w' : WRITE, FORMATTED +! 'a' : APPEND, FORMATTED +! 'x' : READ/WRITE, FORMATTED +! + END_DOC + character*(*) :: f character*(128) :: new_f integer :: iunit diff --git a/src/MOs/Makefile b/src/MOs/Makefile index 0db39043..ad986c3d 100644 --- a/src/MOs/Makefile +++ b/src/MOs/Makefile @@ -1,7 +1,7 @@ default: all # Define here all other modules on which the current module depends -INCLUDE_DIRS = AOs Ezfio_files Nuclei Utils +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -13,7 +13,7 @@ include $(QPACKAGE_ROOT)/src/Makefile.config include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) Makefile.depend: Makefile diff --git a/src/MOs/NEEDED_MODULES b/src/MOs/NEEDED_MODULES new file mode 100644 index 00000000..2132a408 --- /dev/null +++ b/src/MOs/NEEDED_MODULES @@ -0,0 +1 @@ +AOs Ezfio_files Nuclei Utils diff --git a/src/MOs/README.rst b/src/MOs/README.rst new file mode 100644 index 00000000..7ef0c3e0 --- /dev/null +++ b/src/MOs/README.rst @@ -0,0 +1,12 @@ +Modifying MOs +============= + +When modifying MOs, the label of the current MOs should change accordingly by changing the mo_label. For example: + +.. code-block:: fortran + + mo_coef = new_mo_coef + mo_label = "MyNewLabel" + TOUCH mo_coef mo_label + + diff --git a/src/Makefile b/src/Makefile index 7f964127..d5d26784 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,23 +1,29 @@ default: all -INCLUDE_DIRS = Ezfio_files Nuclei Utils AOs Electrons MonoInts BiInts MOs Output Bitmask +NEEDED_MODULES=$(shell cat NEEDED_MODULES) -include Makefile.common -include Makefile.config - -LIB+=$(MKL) - -SRC=BiInts/map_module.f90 Bitmask/bitmasks_module.f90 -OBJ=IRPF90_temp/BiInts/map_module.o IRPF90_temp/Bitmask/bitmasks_module.o -PYTHON_SCRIPTS= +SRC= +OBJ= +include Makefile.depend +include $(QPACKAGE_ROOT)/src/Makefile.config +include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -all:$(ALL) $(PYTHON_SCRIPTS) -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +all:$(ALL) + +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) -all_clean: - for i in */ ; do unset INCLUDE_DIRS ; $(MAKE) -C $$i veryclean && $(MAKE) -C $$i clean_links ; done +Makefile.depend: Makefile NEEDED_MODULES + $(QPACKAGE_ROOT)/scripts/create_Makefile_depend.sh + +all_clean: + @for i in $(NEEDED_MODULES) ; do cd $$i ; make veryclean ; make clean_links ; cd .. ; done + +all_modules: $(NEEDED_MODULES) + +FORCE: + +$(NEEDED_MODULES): FORCE + @cd $@ ; unset NEEDED_MODULES INCLUDE_DIRS ; make -all_modules: - for i in */ ; do unset INCLUDE_DIRS ; $(MAKE) -C $$i || exit 1 ; done diff --git a/src/Makefile.common b/src/Makefile.common index 6258e38e..f3608a4c 100644 --- a/src/Makefile.common +++ b/src/Makefile.common @@ -2,11 +2,11 @@ ifndef QPACKAGE_ROOT $(error QPACKAGE_ROOT undefined. Run the setup_environment.sh script) endif -INCLUDE_DIRS_OK=$(shell X=`$(QPACKAGE_ROOT)/scripts/check_dependencies.sh $(INCLUDE_DIRS)` && echo OK || echo $$X) -ifneq ($(INCLUDE_DIRS_OK),OK) +NEEDED_MODULES_OK=$(shell X=`$(QPACKAGE_ROOT)/scripts/check_dependencies.sh $(NEEDED_MODULES)` && echo OK || echo $$X) +ifneq ($(NEEDED_MODULES_OK),OK) $(info ---------------------) - $(info Your INCLUDE_DIRS variable is inconsistent. It should be:) - $(info INCLUDE_DIRS = $(INCLUDE_DIRS_OK)) + $(info Your NEEDED_MODULES file is inconsistent. It should be:) + $(info $(NEEDED_MODULES)) $(info ---------------------) $(error ) endif @@ -31,13 +31,13 @@ $(EZFIO): $(wildcard $(QPACKAGE_ROOT)/src/*.ezfio_config) $(wildcard $(QPACKAGE_ @cp $(wildcard $(QPACKAGE_ROOT)/src/*.ezfio_config) $(wildcard $(QPACKAGE_ROOT)/src/*/*.ezfio_config) $(EZFIO_DIR)/config @cd $(EZFIO_DIR) ; export FC="$(FC)" ; export FCFLAGS="$(FCFLAGS)" ; export IRPF90="$(IRPF90)" ; $(MAKE) ; $(MAKE) Python -INCLUDE_DIRS+=include +INCLUDE_DIRS=$(NEEDED_MODULES) include ifneq ($(PWD),$(QPACKAGE_ROOT)/src) $(shell $(QPACKAGE_ROOT)/scripts/prepare_module.sh $(INCLUDE_DIRS)) clean_links: - rm $(INCLUDE_DIRS) $$(basename $$PWD) + rm -f $(INCLUDE_DIRS) $$(basename $$PWD) else clean_links: endif diff --git a/src/NEEDED_MODULES b/src/NEEDED_MODULES new file mode 100644 index 00000000..77c2ba5e --- /dev/null +++ b/src/NEEDED_MODULES @@ -0,0 +1 @@ +AOs Bitmask Electrons Ezfio_files MOs Nuclei Output Utils diff --git a/src/Nuclei/Makefile b/src/Nuclei/Makefile index 788beabb..802b4ffb 100644 --- a/src/Nuclei/Makefile +++ b/src/Nuclei/Makefile @@ -1,7 +1,7 @@ default: all # Define here all other modules on which the current module depends -INCLUDE_DIRS = Ezfio_files Utils +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -13,7 +13,7 @@ include $(QPACKAGE_ROOT)/src/Makefile.config include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) Makefile.depend: Makefile diff --git a/src/Nuclei/NEEDED_MODULES b/src/Nuclei/NEEDED_MODULES new file mode 100644 index 00000000..dcdb5f86 --- /dev/null +++ b/src/Nuclei/NEEDED_MODULES @@ -0,0 +1 @@ +Ezfio_files Utils diff --git a/src/Output/Makefile b/src/Output/Makefile index d3b4e2eb..ad986c3d 100644 --- a/src/Output/Makefile +++ b/src/Output/Makefile @@ -1,7 +1,7 @@ default: all # Define here all other modules on which the current module depends -INCLUDE_DIRS = +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -13,7 +13,7 @@ include $(QPACKAGE_ROOT)/src/Makefile.config include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) Makefile.depend: Makefile diff --git a/src/Output/NEEDED_MODULES b/src/Output/NEEDED_MODULES new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/src/Output/NEEDED_MODULES @@ -0,0 +1 @@ + diff --git a/src/README.rst b/src/README.rst new file mode 100644 index 00000000..18773ac6 --- /dev/null +++ b/src/README.rst @@ -0,0 +1,105 @@ +====================== +Programming guidelines +====================== + +Each module (directory) contains the following: + +* A ``README.rst`` file to document the current module. +* An ``ASSUMPTIONS.rst`` file. This file should document all the implicit + assumptions used in the module. For example, if the atomic orbitals are + assumed to be normalized, this should be mentioned in the + ``AOs/ASSUMPTIONS.rst`` file. +* A ``NEEDED_MODULES`` file which contains the list of modules on which the + current module depends +* A set of ``.irp.f`` files containing provider, subroutines and functions +* A ``tests`` directory that should contain the test programs of the module + (see testing section) +* A ``Makefile`` that should compile +* Optionally some ``*.ezfio_config`` configuration files for the EZFIO + library + +A new module may be created by invoking the ``create_module.sh`` script. + +Every subroutine, function or provider should be documented using the +BEGIN_DOC ... END_DOC block. The documentation should be written in +ReStructured Text format to enable the automatic generation of the Sphinx +documentation. + +When the current module depends on other modules, the list of modules should +be added in the Makefile in the ``INCLUDE_DIRS`` variable. + + +Creating a new module +===================== + +Every new module should be created using the interactive ``create_module.sh`` +script located in the ``${QPACKAGE_ROOT}/scripts`` directory. This will create +all the required files with correct templates. + + +Makefiles +========= + +Use the structure of Makefiles provided by the ``create_module.sh`` script. If +you need to re-create the Makefile, you can use the ``create_Makefile.sh`` +script in the current module directory. + +If you need to add some Fortran or C files that should not be tracked by IRPF90, +you have to add them manually to the Makefile in the ``SRC`` variable. +You also need to add the corresponding ``*.o`` file prefixed by ``IRPF90_temp/``. +For example + +.. code-block:: Makefile + + SRC=map_module.f90 + OBJ=IRPF90_temp/map_module.o + + + +Testing +======= + +Each module contains a ``tests/`` directory which contains the test script. +Each module should be tested by running:: + + make test + +Before merging into the master branch, the module should pass **all** the tests. +This enables the possibility to use ``git bisect`` to quickly find bugs. + + +Input data +========== + +Every program is supposed to use an EZFIO database containing all the +persistent data. This database can be modified in using the generated Fortran +functions or the generated Python module. + +The definition of the data needed by the module should be put in the +``*.ezfio_config`` file. + +Input data can also be read from the standard input to enable the use of +a program with a pipe, but the read statements should be present **only** in +the main program. + + +Output data +=========== + +Print to stdout statements should only appear in programs, not in providers, +subroutines or functions. This enables the possibility easily use the programs +with pipes. + +To print, you should write in an output file provided by the ``Output`` +module. + + +Creating a shell script +======================= + +Shell scripts should be located in the ``${QPACKAGE_ROOT}/scripts`` directory. +Relative paths should be avoided as much as possible, and the result of commands +should be always checked. For example, when creating a directory the existence +of the directory has to be checked. + + diff --git a/src/Utils/Makefile b/src/Utils/Makefile index d3b4e2eb..ad986c3d 100644 --- a/src/Utils/Makefile +++ b/src/Utils/Makefile @@ -1,7 +1,7 @@ default: all # Define here all other modules on which the current module depends -INCLUDE_DIRS = +NEEDED_MODULES=$(shell cat NEEDED_MODULES) # Define here all new external source files and objects.Don't forget to prefix the # object files with IRPF90_temp/ @@ -13,7 +13,7 @@ include $(QPACKAGE_ROOT)/src/Makefile.config include $(QPACKAGE_ROOT)/src/Makefile.common include irpf90.make -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile $(EZFIO) NEEDED_MODULES $(IRPF90) Makefile.depend: Makefile diff --git a/src/Utils/NEEDED_MODULES b/src/Utils/NEEDED_MODULES new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/src/Utils/NEEDED_MODULES @@ -0,0 +1 @@ + diff --git a/src/coding_rules.rst b/src/coding_rules.rst deleted file mode 100644 index 2d7f8d57..00000000 --- a/src/coding_rules.rst +++ /dev/null @@ -1,77 +0,0 @@ -====================== -Programming guidelines -====================== - -Each module (directory) contains the following: - -* A :file:`README.rst` file to document the current module. -* An :file:`ASSUMPTIONS.rst` file. This file should document all the implicit - assumptions used in the module. For example, if the atomic orbitals are - assumed to be normalized, this should be mentioned in the - :file:`AOs/ASSUMPTIONS.rst` file. -* A set of :file:`.irp.f` files containing provider, subroutines and functions -* A :file:`tests` directory that should contain the test programs of the module - (see testing section) -* A :file:`Makefile` that should compile -* Optionally some :file:`*.ezfio_config` configuration files for the EZFIO - library - -A new module may be created by invoking the :file:`create_module.sh` script. - -Every subroutine, function or provider should be documented using the -BEGIN_DOC ... END_DOC block. The documentation should be written in -ReStructured Text format to enable the automatic generation of the Sphinx -documentation. - - -Testing -======= - -Each module contains a :file:`tests` directory which contains the test script. -Each module should be tested by running:: - - make test - -Before merging into the master branch, the module should pass **all** the tests. -This enables the possibility tu use :command:`git bisect` to quickly find bugs. - - -Input data -========== - -Every program is supposed to use an EZFIO database containing all the -persistent data. This database can be modified in using the generated Fortran -functions or the generated Python module. - -The definition of the data needed by the module should be put in the -:file:`*.ezfio_config` file. - -Input data can also be read from the standard input to enable the use of -a program with a pipe, but the read statements should be present **only** in -the main program. - - -Output data -=========== - - Print to stdout statements should only appear in programs, not in providers, -subroutines or functions. This enables the possibility easily use the programs -with pipes. - -To print, you should write in an output file provided by the :file:`Output` -module. - - - -Modifying MOs -============= - -When modifying MOs, the label of the current MOs should change accordingly by changing the mo_label. For example: - -.. code-block:: fortran - - mo_coef = new_mo_coef - mo_label = "MyNewLabel" - TOUCH mo_coef mo_label - -