From b0556c4f98d4e91f2fb0ca34455260cab371db38 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Dec 2009 23:28:19 +0100 Subject: [PATCH] Introduced templates --- configure.ac | 2 +- src/compute.irp.f | 32 ++++++-------- src/gradients.irp.f | 16 +++---- src/grid.irp.f | 18 +++----- src/info.irp.f | 58 +++++++++++++------------ src/{write_cube.irp.f => to_cube.irp.f} | 11 ++++- 6 files changed, 65 insertions(+), 72 deletions(-) rename src/{write_cube.irp.f => to_cube.irp.f} (76%) diff --git a/configure.ac b/configure.ac index 1df849a..0983394 100644 --- a/configure.ac +++ b/configure.ac @@ -82,7 +82,7 @@ case $FC in fi ;; gfortran*) - FCFLAGS="O3 -ffast-math" + FCFLAGS="-O3 -ffast-math" if test $STATIC == 0 ; then FCFLAGS="$FCFLAGS -static-libgcc -static" fi diff --git a/src/compute.irp.f b/src/compute.irp.f index f2e6d86..49a4267 100644 --- a/src/compute.irp.f +++ b/src/compute.irp.f @@ -1,29 +1,23 @@ -BEGIN_SHELL [ /usr/bin/python ] +BEGIN_TEMPLATE -to_compute = [\ - "eplf", - "eplf_grad", - "eplf_lapl", - "elf", - "elf_grad", - "elf_lapl", - "density", - "density_grad", - "density_lapl", -] - -template = """ BEGIN_PROVIDER [ logical, comp_$X ] implicit none BEGIN_DOC -! If true, $X +! If true, compute $X END_DOC comp_$X = .False. call get_compute_$X(comp_$X) END_PROVIDER -""" -for t in to_compute: - print template.replace("$X",t) +SUBST [ X ] + eplf;; + eplf_grad;; + eplf_lapl;; + elf;; + elf_grad;; + elf_lapl;; + density;; + density_grad;; + density_lapl;; -END_SHELL +END_TEMPLATE diff --git a/src/gradients.irp.f b/src/gradients.irp.f index 978fa97..3f01634 100644 --- a/src/gradients.irp.f +++ b/src/gradients.irp.f @@ -1,11 +1,5 @@ -BEGIN_SHELL [ /usr/bin/python ] +BEGIN_TEMPLATE -values = [\ - "eplf", - "elf", - ] - -template = """ BEGIN_PROVIDER [ real, $X_grad_p, (3) ] &BEGIN_PROVIDER [ real, $X_lapl_p ] implicit none @@ -33,9 +27,9 @@ template = """ TOUCH point END_PROVIDER -""" -for value in values: - print template.replace("$X",value) +SUBST [ X ] + eplf;; + elf;; -END_SHELL +END_TEMPLATE diff --git a/src/grid.irp.f b/src/grid.irp.f index 6faaec4..675ca34 100644 --- a/src/grid.irp.f +++ b/src/grid.irp.f @@ -67,15 +67,8 @@ END_PROVIDER -BEGIN_SHELL [ /usr/bin/python ] +BEGIN_TEMPLATE -grids = [ \ - "eplf", - "elf", - "density", -] - -template = """ BEGIN_PROVIDER [ real, grid_$X, (grid_x_num,grid_y_num,grid_z_num) ] implicit none BEGIN_DOC @@ -247,9 +240,10 @@ subroutine set_grid_data_$X_lapl(buffer) call ezfio_set_grid_data_$X_lapl(buffer) endif end -""" -for grid in grids: - print template.replace("$X",grid) +SUBST [ X ] + eplf;; + elf;; + density;; -END_SHELL +END_TEMPLATE diff --git a/src/info.irp.f b/src/info.irp.f index a786e51..058a893 100644 --- a/src/info.irp.f +++ b/src/info.irp.f @@ -1,37 +1,39 @@ -BEGIN_SHELL [ /usr/bin/python ] +BEGIN_TEMPLATE -for i in [('r' ,'real'), \ - ('d','double precision'), \ - ('l','logical'), \ - ('i','integer'), \ - ('c','character*(*)'), \ - ]: - print "subroutine "+i[0]+"info (here,token,value)" - print " implicit none" - print " character*(*) :: here" - print " character*(*) :: token" - print " "+i[1]+" :: value" - print " if (mpi_master) then" - print " print *, trim(here)//':'" - if i[0] == 'l': - print " if (value) then" - print " print *, ' -> ', trim(token), '= True' " - print " else" - print " print *, ' -> ', trim(token), '= False' " - print " endif" - else: - print " print *, ' -> ', trim(token), '=', value" - print " endif" - print "end" + subroutine $Xinfo (here,token,value) + implicit none + character*(*), intent(in) :: here + character*(*), intent(in) :: token + $Y, intent(in) :: value + if (mpi_master) then + print *, trim(here)//':' + $Z + endif + end -END_SHELL +SUBST [ X, Y, Z ] + r; real; + print *, ' -> ', trim(token), '=', value;; + d; double precision; + print *, ' -> ', trim(token), '=', value;; + i; integer; + print *, ' -> ', trim(token), '=', value;; + c; character*(*); + print *, ' -> ', trim(token), '=', value;; + l; logical; + if (value) then + print *, ' -> ', trim(token), '= True' + else + print *, ' -> ', trim(token), '= False' + endif;; +END_TEMPLATE subroutine info(here,message) implicit none - character*(*) :: here, message + character*(*), intent(in) :: here, message if (mpi_master) then - print *, trim(here)//':' - print *, ' -> ', trim(message) + print *, trim(here)//':' + print *, ' -> ', trim(message) endif end diff --git a/src/write_cube.irp.f b/src/to_cube.irp.f similarity index 76% rename from src/write_cube.irp.f rename to src/to_cube.irp.f index 61a9608..83bf51e 100644 --- a/src/write_cube.irp.f +++ b/src/to_cube.irp.f @@ -1,10 +1,19 @@ -program write_cube +program to_cube implicit none integer :: i integer :: l integer :: ix, iy, iz + integer :: iargc + character*(32) :: filename + character*(32) :: grid_type + if (iragc() /= 2) then + print *, 'usage: to_cube ',trim(filename), trim(grid_type) + stop 1 + endif + call getarg(1,filename) + call getarg(2,grid_type) if (.not.mpi_master) then return endif