Skip to content

Commit

Permalink
New pyft version
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienRietteMTO committed Sep 18, 2024
1 parent de1ca4b commit fef003b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
65 changes: 42 additions & 23 deletions build/with_fcm/arch/arch-pgi_CPU_preGPU_MFflavour.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,60 @@ specificTransfos="^progs/:=:
descTree=${TMPDIR:-/tmp}/descTree_$$
trap "\rm -f $descTree" EXIT

#Transformation to apply systematically (IAL, Méso-NH and testprogs)
#We cannot suppress non column calls for Méso-NH, stack transformation is replaced by allocatables
#source this file, then: "export PYFT_OPTS_MNH; check_commit_mesonh.sh --prep_code-opts '--pyft_opts_env PYFT_OPTS_MNH' ...."
#The --wrapH is automatically set by prep_code
#The --mnhExpand is controlled by the different check_commit_* scripts
#--addIncludes must be before --descTree because --addIncludes removes a wrong "file" node
common_opts="--tree . --addIncludes --descTree $descTree --simplify --enableCache" #General options
common_opts="$common_opts --inlineContainedSubroutinesPHYEX" #Inlining
common_opts="$common_opts --deleteDrHook --deleteBudgetDDH" #Not available on GPU
common_opts="$common_opts --addACC_routine_seq" #add 'acc routine' directive
common_opts="$common_opts --stopScopes sub:SHALLOW_MF#sub:ICE_ADJUST#sub:RAIN_ICE#sub:RAIN_ICE_OLD#sub:TURB#sub:LIMA_ADJUST_SPLIT#sub:LIMA"
common_opts="$common_opts --setFalseIfStmt TURBN%LTURB_DIAG --setFalseIfStmt TURBN%LTURB_FLX" #remove diagnostic output
common_opts="$common_opts --buildACCTypeHelpers"

#We cannot suppress non column calls for Méso-NH, stack transformation is replaced by allocatables
#source this file, then: "export PYFT_OPTS_MNH; check_commit_mesonh.sh --prep_code-opts '--pyft_opts_env PYFT_OPTS_MNH' ...."
common_opts_MNH="$common_opts --addArrayParentheses --expandAllArraysPHYEX --attachArraySpecToEntity --applyCPPifdef %REPRO48 --replaceAutomaticWithAllocatable"
PYFT_OPTS_MNH="$common_opts_MNH
PYFT_OPTS_MNH="--tree . --addIncludes --descTree $descTree --simplify --enableCache" #General options
PYFT_OPTS_MNH="$PYFT_OPTS_MNH --inlineContainedSubroutinesPHYEX" #Inlining
PYFT_OPTS_MNH="$PYFT_OPTS_MNH --deleteDrHook --deleteBudgetDDH" #Not available on GPU
PYFT_OPTS_MNH="$PYFT_OPTS_MNH --addACC_routine_seq" #add 'acc routine' directive
PYFT_OPTS_MNH="$PYFT_OPTS_MNH --stopScopes sub:SHALLOW_MF#sub:ICE_ADJUST#sub:RAIN_ICE#sub:RAIN_ICE_OLD#sub:TURB#sub:LIMA_ADJUST_SPLIT#sub:LIMA"
PYFT_OPTS_MNH="$PYFT_OPTS_MNH --setFalseIfStmt TURBN%LTURB_DIAG --setFalseIfStmt TURBN%LTURB_FLX" #remove diagnostic output
PYFT_OPTS_MNH="$PYFT_OPTS_MNH --buildACCTypeHelpers"
PYFT_OPTS_MNH="$PYFT_OPTS_MNH --addArrayParentheses --expandAllArraysPHYEX --attachArraySpecToEntity --applyCPPifdef %REPRO48 --replaceAutomaticWithAllocatable"
PYFT_OPTS_MNH="$PYFT_OPTS_MNH
$specificTransfos
^turb/mode_bl_depth_diag.F90:=:--removeCall module:MODE_BL_DEPTH_DIAG/sub:BL_DEPTH_DIAG_1D BL_DEPTH_DIAG_3D $common_opts_MNH
^micro/rain_ice.F90:=:--removeCall sub:RAIN_ICE ELEC_TENDENCIES $common_opts_MNH"
^turb/mode_bl_depth_diag.F90:=:--removeCall module:MODE_BL_DEPTH_DIAG/sub:BL_DEPTH_DIAG_1D BL_DEPTH_DIAG_3D $PYFT_OPTS_MNH
^micro/rain_ice.F90:=:--removeCall sub:RAIN_ICE ELEC_TENDENCIES $PYFT_OPTS_MNH"

#For IAL, stack transformation is replaced by allocatables
#source this file, then: "export PYFT_OPTS_IAL; check_commit_ial.sh --prep_code-opts '--pyft_opts_env PYFT_OPTS_IAL' ...."
common_opts_IAL="$common_opts --addArrayParentheses --expandAllArraysPHYEX --attachArraySpecToEntity --applyCPPifdef REPRO48 --deleteNonColumnCallsPHYEX --replaceAutomaticWithAllocatable"
PYFT_OPTS_IAL="$common_opts_IAL
#The --wrapH is automatically set by prep_code
#The --mnhExpand is controlled by the different check_commit_* scripts
#--addIncludes must be before --descTree because --addIncludes removes a wrong "file" node
PYFT_OPTS_IAL="--tree . --addIncludes --descTree $descTree --simplify --enableCache" #General options
PYFT_OPTS_IAL="$PYFT_OPTS_IAL --inlineContainedSubroutinesPHYEX" #Inlining
PYFT_OPTS_IAL="$PYFT_OPTS_IAL --deleteDrHook --deleteBudgetDDH" #Not available on GPU
PYFT_OPTS_IAL="$PYFT_OPTS_IAL --addACC_routine_seq" #add 'acc routine' directive
PYFT_OPTS_IAL="$PYFT_OPTS_IAL --stopScopes sub:SHALLOW_MF#sub:ICE_ADJUST#sub:RAIN_ICE#sub:RAIN_ICE_OLD#sub:TURB#sub:LIMA_ADJUST_SPLIT#sub:LIMA"
PYFT_OPTS_IAL="$PYFT_OPTS_IAL --setFalseIfStmt TURBN%LTURB_DIAG --setFalseIfStmt TURBN%LTURB_FLX" #remove diagnostic output
PYFT_OPTS_IAL="$PYFT_OPTS_IAL --buildACCTypeHelpers"
PYFT_OPTS_IAL="$PYFT_OPTS_IAL --addArrayParentheses --expandAllArraysPHYEX --attachArraySpecToEntity --applyCPPifdef REPRO48 --deleteNonColumnCallsPHYEX --replaceAutomaticWithAllocatable"
PYFT_OPTS_IAL="$PYFT_OPTS_IAL
$specificTransfos
^turb/mode_bl_depth_diag.F90:=:--removeCall module:MODE_BL_DEPTH_DIAG/sub:BL_DEPTH_DIAG_1D BL_DEPTH_DIAG_3D $common_opts_IAL
^micro/rain_ice.F90:=:--removeCall sub:RAIN_ICE ELEC_TENDENCIES $common_opts_IAL"
^turb/mode_bl_depth_diag.F90:=:--removeCall module:MODE_BL_DEPTH_DIAG/sub:BL_DEPTH_DIAG_1D BL_DEPTH_DIAG_3D $PYFT_OPTS_IAL
^micro/rain_ice.F90:=:--removeCall sub:RAIN_ICE ELEC_TENDENCIES $PYFT_OPTS_IAL"

#For testprogs
#check_commit_testprogs.sh -a <this conf>
#For --removeIJDim, the USE_COLCALL compilation key must be set in the *.fcm file
#--removeIJDim internally applies --addArrayParentheses --expandAllArraysPHYEX and, if --simplify is set, attachArraySpecToEntity
common_opts="$common_opts --applyCPPifdef REPRO48 --deleteNonColumnCallsPHYEX --removeIJDim --addStack $stackMode"
PYFT_OPTS="$common_opts
#The --wrapH is automatically set by prep_code
#The --mnhExpand is controlled by the different check_commit_* scripts
#--addIncludes must be before --descTree because --addIncludes removes a wrong "file" node
PYFT_OPTS="--tree . --addIncludes --descTree $descTree --simplify --enableCache" #General options
PYFT_OPTS="$PYFT_OPTS --inlineContainedSubroutinesPHYEX" #Inlining
PYFT_OPTS="$PYFT_OPTS --deleteDrHook --deleteBudgetDDH" #Not available on GPU
#PYFT_OPTS="$PYFT_OPTS --addACC_routine_seq" #add 'acc routine' directive
PYFT_OPTS="$PYFT_OPTS --stopScopes sub:SHALLOW_MF#sub:ICE_ADJUST#sub:RAIN_ICE#sub:RAIN_ICE_OLD#sub:TURB#sub:LIMA_ADJUST_SPLIT#sub:LIMA"
PYFT_OPTS="$PYFT_OPTS --setFalseIfStmt TURBN%LTURB_DIAG --setFalseIfStmt TURBN%LTURB_FLX" #remove diagnostic output
PYFT_OPTS="$PYFT_OPTS --buildACCTypeHelpers"
PYFT_OPTS="$PYFT_OPTS --applyCPPifdef REPRO48 --deleteNonColumnCallsPHYEX --removeIJDim --addStack $stackMode"
PYFT_OPTS="$PYFT_OPTS --removeACC --addACC_routine_seq" #remove pre-existing ACC directives, then add 'acc routine seq' directive
PYFT_OPTS="$PYFT_OPTS
$specificTransfos
^turb/mode_bl_depth_diag.F90:=:--removeCall module:MODE_BL_DEPTH_DIAG/sub:BL_DEPTH_DIAG_1D BL_DEPTH_DIAG_3D $common_opts
^micro/rain_ice.F90:=:--removeCall sub:RAIN_ICE ELEC_TENDENCIES $common_opts"
^turb/mode_bl_depth_diag.F90:=:--removeCall module:MODE_BL_DEPTH_DIAG/sub:BL_DEPTH_DIAG_1D BL_DEPTH_DIAG_3D $PYFT_OPTS
^micro/rain_ice.F90:=:--removeCall sub:RAIN_ICE ELEC_TENDENCIES $PYFT_OPTS"

2 changes: 1 addition & 1 deletion tools/INSTALL.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -e
set -o pipefail #abort if left command on a pipe fails

pyft_version=3bead4d4b54baafc113f239f72e8bd90b6381dcc
pyft_version=f63de396176e3e91a5cdedae2d098dbbe3497ae2

#This script installs PHYEX
#Call the script with the -h option to get more information.
Expand Down
2 changes: 1 addition & 1 deletion tools/check_commit_ial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ if [ $packupdate -eq 1 -o $packcreation -eq 1 ]; then
cd $HOMEPACK/$name/src/local/phyex

if [ $useexpand == 1 ]; then
expand_options="--mnhExpand"
expand_options="--mnhExpand --removeACC"
else
expand_options=""
fi
Expand Down
4 changes: 3 additions & 1 deletion tools/prep_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function usage {
echo " or a tag with the following syntax: tags/TAG where TAG is the tag name"
echo "-m MODEL merge the code under the common directory with the code specific to MODEL model"
echo "--mnhExpand option passed to the pyft tool"
echo "--removeACC option passed to the pyft tool"
echo "-p push the result as a new branch"
echo "-s SUB subdiretory or file (under src) to consider when merging and applying pyft"
echo "--renameFf rename .F90 into .f90"
Expand All @@ -38,7 +39,7 @@ function usage {
echo "* If the -c option is not provided, DIRECTORY must already contain files and directory as if"
echo " it was the result of a git checkout"
echo "* If the -m option is used, directory tree is modified, only relevant code is kept"
echo "* If --mnhExpand is not used, pyft is not called at all"
echo "* If none of --mnhExpand, --removeACC, --pyft_opts_env or PYFT_OPTIONS is not used, pyft is not called at all"
echo "* -s options are mandatory for -m, -D and -p options"
echo "* -p option is allowed only if -c and -m options are provided"
echo ""
Expand Down Expand Up @@ -101,6 +102,7 @@ while [ -n "$1" ]; do
'-c') checkout_point="$2"; shift;;
'-m') model="$2"; shift;;
'--mnhExpand') pyft_options="$pyft_options $1";;
'--removeACC') pyft_options="$pyft_options $1";;
'-s') subs="$subs $2"; shift;;
'-p') push=1;;
'--renameFf') renameFf=1;;
Expand Down
3 changes: 1 addition & 2 deletions tools/pybinding.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def pybinding(fortran_in, scope, fortran_out, python_out, libso,
'func': 'FUNCTION'}[kind]

#Loop on all the dummy arguments and prepare their use
varList = pftin.getVarList()
argList1 = [] #argument list of the main public interface
argList2 = [] #argument list to the existing FORTRAN routine
moduleList = [] #declarative module to add
Expand All @@ -56,7 +55,7 @@ def pybinding(fortran_in, scope, fortran_out, python_out, libso,
docstringIN = ["Input arguments:"]
docstringOUT = ["Output arguments:"]
for N in scopeNode.findall('.//{*}dummy-arg-LT/{*}arg-N/{*}N'):
var = pftin.findVar(n2name(N), scope, varList=varList, exactScope=True)
var = pftin.varList.findVar(n2name(N), scope, exactScope=True)
vartype = var['t'].replace(' ', '').upper()
if vartype == 'TYPE(DIMPHYEX_T)':
moduleList.append('USE MODD_DIMPHYEX, ONLY: DIMPHYEX_t')
Expand Down

0 comments on commit fef003b

Please sign in to comment.