10
0
mirror of https://gitlab.com/scemama/eplf synced 2024-12-22 12:23:50 +01:00

Introduced templates

This commit is contained in:
Anthony Scemama 2009-12-09 23:28:19 +01:00
parent f0689c031a
commit b0556c4f98
6 changed files with 65 additions and 72 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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