60 likes | 80 Views
Learn effective strategies for porting legacy codes to ESMF, including gradual adoption and customization of ESMF components and data types. Start by splitting your code and create a fake version of ESMF Mod. Then, transition to ESMF-compliant interfaces and gradually adopt ESMF data types and framework services.
E N D
Some Strategies for Porting Legacy Codes to ESMF Arlindo da Silva, NASA/GSFC Data Assimilation Office Data Assimilation Office, NASA/GSFC 2nd ESMF Community Meeting, 15 May 2003
ESMF Components • ESMF Gridded Components need to provide a minimum of 3 subroutines: Module ATM_GridComp Public: ATM_SetServices() Private: ATM_Initialize() ATM_Run() ATM_Finalize() These are saved In function pointer Table by ATM_SetServices() Arlindo da Silva/Shujia Zhou
ESMF Interface Data Types Key high-level ESMF data types: Use ESMF_Mod Type(ESMF_GridComp) :: gcATM Type(ESMF_State):: impATM, expATN Type(ESMF_Clock):: clock call ESMF_Run ( gcATM, impATM, expATM, clock, rc ) Arlindo da Silva/Shujia Zhou
ESMF F90 Application • User code is called via ESMF routines of similar name Type(ESMF_GridComp) :: gcATM gcATM = ESMF_GridCompCreate() Call ESMF_GridCompSetServices(gcATM,…) Call ESMF_GridCompInitialize(gcATM,…) Call ESMF_GridCompRun(gcATM,…) Call ESMF_GridCompFinalize(gcATM,…) • Strategy: gradual adoption Arlindo da Silva/Shujia Zhou
Porting Strategy • Start by splitting your code in 3 main subroutines, using whatever arguments are natural: subroutine ATM_Initialize( arg1, arg2, arg3) subroutine ATM_Run( arg1, array, ier ) subroutine ATM_Finalize() • Create a fake version of ESMF_Mod with the main data types (ESMF_GridComp, ESMF_State) are costumized to represent your data structures, e.g., type ESMF_State integer :: im, jm, km real myArray(im,jm,km), whatever(im,jm) end type ESMF_State Arlindo da Silva/Shujia Zhou
Porting Strategy • Next, use this customized ESMF_Mod write an ESMF compliant interface for your component: subroutine ATM_Run (gcATM, impATM,expATM,clock,rc) • Gradually, adopt the ESMF data types: Use ESMF_Mod, only: clock Use myESMF_Mod, only: ESMF_GridComp, ESMF_State • Adopt ESMF_SetServices, and ESMF framework: ESMF_Initialize, ESMF_Run, ESMF_Finalize • Then, gradually adopt ESMF infrastructure Arlindo da Silva/Shujia Zhou