PyForTool
Python-fortran-tool
|
Public Member Functions | |
splitModuleRoutineFile (self) | |
buildModi (self) | |
deleteNonColumnCallsPHYEX (self, simplify=False) | |
convertTypesInCompute (self) | |
deleteDrHook (self, simplify=False) | |
addDrHook (self) | |
deleteBudgetDDH (self, simplify=False) | |
deleteRoutineCallsMesoNHGPU (self, simplify=True) | |
addMPPDB_CHECKS (self, printsMode=False) | |
addStack (self, model, stopScopes, parser=None, parserOptions=None, wrapH=False) | |
inlineContainedSubroutinesPHYEX (self, simplify=False) | |
removeIJDim (self, stopScopes, parser=None, parserOptions=None, wrapH=False, simplify=False) | |
removePHYEXUnusedLocalVar (self, excludeList=None, simplify=False) | |
expandAllArraysPHYEX (self, concurrent=False) | |
mathFunctoBRFunc (self) | |
shumanFUNCtoCALL (self) | |
buildACCTypeHelpers (self) | |
Methods for high-to-moderate level transformation
Definition at line 59 of file applications.py.
pyfortool.applications.Applications.addDrHook | ( | self | ) |
Add DR_HOOK calls.
Definition at line 262 of file applications.py.
pyfortool.applications.Applications.addMPPDB_CHECKS | ( | self, | |
printsMode = False |
|||
) |
Add MPPDB_CHEKS on all intent REAL arrays on subroutines. ****** Not applied on modd_ routines. ******** Handle optional arguments. Example, for a BL89 routine with 4 arguments, 1 INTENT(IN), 2 INTENT(INOUT), 1 INTENT(OUT), it produces : IF (MPPDB_INITIALIZED) THEN !Check all IN arrays CALL MPPDB_CHECK(PZZ, "BL89 beg:PZZ") !Check all INOUT arrays CALL MPPDB_CHECK(PDZZ, "BL89 beg:PDZZ") CALL MPPDB_CHECK(PTHVREF, "BL89 beg:PTHVREF") END IF ... IF (MPPDB_INITIALIZED) THEN !Check all INOUT arrays CALL MPPDB_CHECK(PDZZ, "BL89 end:PDZZ") CALL MPPDB_CHECK(PTHVREF, "BL89 end:PTHVREF") !Check all OUT arrays CALL MPPDB_CHECK(PLM, "BL89 end:PLM") END IF param printsMode: if True, instead of CALL MPPDB_CHECK, add fortran prints for debugging
Definition at line 315 of file applications.py.
pyfortool.applications.Applications.addStack | ( | self, | |
model, | |||
stopScopes, | |||
parser = None , |
|||
parserOptions = None , |
|||
wrapH = False |
|||
) |
Add specific allocations of local arrays on the fly for GPU :param model : 'MESONH' or 'AROME' for specific objects related to the allocator or stack :param stopScopes: scope paths where we stop to add stack :param parser, parserOptions, wrapH: see the PYFT class Stacks are added to all routines called by the scopes listed in stopScopes
Definition at line 512 of file applications.py.
pyfortool.applications.Applications.buildACCTypeHelpers | ( | self | ) |
build module files containing helpers to copy user type structures
Definition at line 1384 of file applications.py.
pyfortool.applications.Applications.buildModi | ( | self | ) |
Build the modi_ file corresponding to the given scope
Definition at line 79 of file applications.py.
pyfortool.applications.Applications.convertTypesInCompute | ( | self | ) |
Convert STR%VAR into single local variable contained in compute (a-stmt) and in if-then-stmt, else-if-stmt, where-stmt e.g. ZA = 1 + CST%XG ==> ZA = 1 + XCST_G ZA = 1 + PARAM_ICE%XRTMIN(3) ==> ZA = 1 + XPARAM_ICE_XRTMIN3 ZRSMIN(1:KRR) = ICED%XRTMIN(1:KRR) => ZRSMIN(1:KRR) = ICEDXRTMIN1KRR(1:KRR) IF(TURBN%CSUBG_MF_PDF=='NONE')THEN => IF(CTURBNSUBG_MF_PDF=='NONE')THEN RESTRICTION : works only if the r-component variable is contained in 1 parent structure. Allowed for conversion : CST%XG Not converted : TOTO%CST%XG (for now, recursion must be coded) Not converted : TOTO%ARRAY(:) (shape of the array must be determined from E1)
Definition at line 130 of file applications.py.
pyfortool.applications.Applications.deleteBudgetDDH | ( | self, | |
simplify = False |
|||
) |
Remove Budget calls. If Simplify is True, also remove all variables only needed for these calls :param simplify : if True, remove variables that are now unused
Definition at line 287 of file applications.py.
pyfortool.applications.Applications.deleteDrHook | ( | self, | |
simplify = False |
|||
) |
Remove DR_HOOK calls. If Simplify is True, also remove all variables only needed for these calls (ZHOOK_HANDLE, DR_HOOK, LHOOK, YOMHOOK, JPRB, PARKIND1) :param simplify : if True, remove variables that are now unused
Definition at line 252 of file applications.py.
pyfortool.applications.Applications.deleteNonColumnCallsPHYEX | ( | self, | |
simplify = False |
|||
) |
Remove PHYEX routines that compute with different vertical columns not needed for AROME MODE_ROTATE_WIND, UPDATE_ROTATE_WIND If Simplify is True, also remove all variables only needed for these calls :param simplify : if True, remove variables that are now unused
Definition at line 113 of file applications.py.
pyfortool.applications.Applications.deleteRoutineCallsMesoNHGPU | ( | self, | |
simplify = True |
|||
) |
Remove Calls to routines not compatible with Méso-NH on GPU e.g. CALL within a DO loop e.g. OCND2 in condensation uses a CALL ICECLOUD and fonctions within computations If Simplify is True, also remove all variables only needed for these calls :param simplify : if True, remove variables that are now unused
Definition at line 304 of file applications.py.
pyfortool.applications.Applications.expandAllArraysPHYEX | ( | self, | |
concurrent = False |
|||
) |
Transform array syntax into DO loops :param concurrent: use 'DO CONCURRENT' instead of simple 'DO' loops
Definition at line 892 of file applications.py.
pyfortool.applications.Applications.inlineContainedSubroutinesPHYEX | ( | self, | |
simplify = False |
|||
) |
Inline all contained subroutines in the main subroutine Steps : - Identify contained subroutines - Look for all CALL statements, check if it is a containted routines; if yes, inline - Delete the containted routines :param simplify: try to simplify code (construct or variables becoming useless) :param loopVar: None to create new variable for each added DO loop (around ELEMENTAL subroutine calls) or a function that return the name of the variable to use for the loop control. This function returns a string (name of the variable), or True to create a new variable, or False to not transform this statement The functions takes as arguments: - lower and upper bounds as defined in the declaration statement - lower and upper bounds as given in the statement - name of the array - index of the rank
Definition at line 594 of file applications.py.
pyfortool.applications.Applications.mathFunctoBRFunc | ( | self | ) |
Convert intrinsic math functions **, LOG, ATAN, **2, **3, **4, EXP, COS, SIN, ATAN2 into a self defined function BR_ for MesoNH CPU/GPU bit-reproductibility
Definition at line 924 of file applications.py.
pyfortool.applications.Applications.removeIJDim | ( | self, | |
stopScopes, | |||
parser = None , |
|||
parserOptions = None , |
|||
wrapH = False , |
|||
simplify = False |
|||
) |
Transform routines to be called in a loop on columns :param stopScopes: scope paths where we stop to add the D argument (if needed) :param parser, parserOptions, wrapH: see the PYFT class :param simplify: try to simplify code (remove useless dimensions in call) ComputeInSingleColumn : - Remove all Do loops on JI and JJ - Initialize former indexes JI, JJ, JIJ to first array element: JI=D%NIB, JJ=D%NJB, JIJ=D%NIJB - If simplify is True, replace (:,*) on I/J/IJ dimension on argument with explicit (:,*) on CALL statements: e.g. CALL FOO(D, A(:,JK,1), B(:,:)) ==> CALL FOO(D, A(JIJ,JK,1), B(:,:)) only if the target argument is not an array
Definition at line 617 of file applications.py.
pyfortool.applications.Applications.removePHYEXUnusedLocalVar | ( | self, | |
excludeList = None , |
|||
simplify = False |
|||
) |
Remove unused local variables (dummy and module variables are not suppressed) This function is identical to variables.removeUnusedLocalVar except that this one is specific to the PHYEX code and take into account the mnh_expand directives. :param excludeList: list of variable names to exclude from removal (even if unused) :param simplify: try to simplify code (if we delete a declaration statement that used a variable as kind selector, and if this variable is not used else where, we also delete it)
Definition at line 870 of file applications.py.
pyfortool.applications.Applications.shumanFUNCtoCALL | ( | self | ) |
Convert all calling of functions and gradient present in shumansGradients table into the use of subroutines and use mnh_expand_directives to handle intermediate computations
Definition at line 1037 of file applications.py.
pyfortool.applications.Applications.splitModuleRoutineFile | ( | self | ) |
Split all module and subroutine contain in a fortran file Return a fortran file for each module and subroutine
Definition at line 65 of file applications.py.