280 likes | 423 Views
Introduction to the Standard Compile Environment (SCE) of the Integrated Model & Data Infrastructure (IMDI) Stephanie Legutke, MPI-M M&D. Background. PRISM (Dec 2001-Nov 2004): Develop for the European Earth System (ES) modelling community a software infrastructure to set up compile run
E N D
Introduction • to theStandard Compile Environment (SCE) • of the • Integrated Model & Data Infrastructure (IMDI) • Stephanie Legutke, MPI-M M&D 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Background • PRISM(Dec 2001-Nov 2004):Develop for the European Earth System (ES) modelling community a software infrastructure to • set up • compile • run • analyse coupled ES model experiments and thereby establish a European ES research network M&D: Make the SCE and SRE developed in PRISM become part of the IMDI 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Requirements ... • … to the SCE infrastructure software • Integrate any ES climate research model … • … on any platform • Allow for easy replacement of components in coupled models (CplM) • Interface to a GUI 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Requirements … … from the model developers and users • Minimum impact on component source code • Give a common look&feel with all models and experiments • Automate but allow for easy customizing • Keep it simple • [Low maintenance] 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Components of the SCE • Coupled models, component main & sub models, and libraries • Standards • High level design of the compile system • Compile time configuration of coupled/component models • Component model compile scripts generation • (g)make (file) 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
OASIS3 Coupled Earth System Models OCEAN Sea Ice ATMOSPHERE LandSurface MarineBiogeo- chemistry Atmospheric Chemistry 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Main models AnotherSea Ice Message passing OASIS3 SBR parameter list Sub models Coupled Earth System Models OCEAN ATMOSPHERE LandSurface MarineBiogeo- chemistry Atmospheric Chemistry 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
SCE standards for .... ... coupling • Package rule for main&sub model exchange: No use of other component‘s data blocks ; use message passing or SBR param. lists instead • OASIS3 software if different executables:via OASIS executable or directly using PSMILe(MPI) calls(PSMILe=PRISM System ModelI Interface Library) • Configuration for coupling with partner models by conditional compiling (cpp flag ‘__cpl_partnermodel‘) 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
SCE standards for .... ... component model codes • Components have to be independent from each other (for flexible component exchange) • Avoid unresolved references by cpp flag wraping • Standard directory structure (to enable use of simple tools) ... source code • Single F90 MODULE per file • File name = MODULE name • Suffixes: F90, f90, F, f, c • Single occurence of each basename • Non portable code wraped with cpp flags 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
ok ok for call of SBR if mod2 is submodel of mod1 USE, CALL, INCLUDE SCE: Source code directory 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
before after • SCE:Source code reorganisation 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
COMP_mod1_ID.node User lib*.a call COMP_libs.node ”list1” mod2 / libmod2_ID[.MPIn].a return mod1 / libmod1_mod2_ID [.MPIn].a call COMP_mod2_ID.node return call COMP_libs.node ”list2” return mod1_mod2_ID[.MPIn].x MPIn=MPI or MPI2 Model+submodel compilation 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Build directory (libraries and executables) 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Component model compilation COMP_mod1_ID.node User lib*.a mod2 / libmod2_ID[.MPIn].amod1 / libmod1_mod2_ID [.MPIn].a call COMP_libs.node ”list1” return call COMP_mod2_ID.node return call COMP_libs.node ”list2” return mod1_mod2_ID[.MPIn].x MPIn=MPI or MPI2 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
User COMP_mod1_ID.node all / lib / clean / tar “list” COMP_libs.node “list” create (in-doc.) create (in-doc.) make Top_Makefile make Top_Makefile list of libraries: src directories: make make src / Makefile Makefile lib*.a *.o / *.mod mod1_ID[_MPIn].x Model compilation 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
*_ID.x *.o *.mod *.o *.mod *.a modn *_ID.a Build directory: *.o/*.mod 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Utilities & Tools for compilation • No compile scripts are provided … • … but tools that generate them … • … for the specific platform • … for the specific component model • … configured for the coupled configuration … Example how to do that => 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Create_COMP_models.frm mod1 MPI[1,2] - - nodeID “mod1 mod2mod3” Create_COMP_models.frm mod2 MPI[1,2] - - nodeID “mod1 mod2mod3” Create_COMP_models.frm mod3 MPI[1,2] - - nodeID “mod1 mod2mod3” Create_COMP_models.frm oasis3 MPI[1,2] - - node Create_COMP_libs.frm MPI[1,2] - - node mod1_mod2_ID.MPI[1,2].x mod2_ID.MPI[1,2].a mod3_ID.MPI[1,2].x oasis3.MPI[1,2].x …. , psmile.MPI[1,2].a COMP_mod1_ID.node COMP_mod2_ID.node COMP_mod3_ID.node COMP_oasis3.node COMP_libs.node Creating compile scripts bold: to be typed by user (scripting) additional configuring by editing cplmod = mod1+mod2 & mod3 & OASIS3: Create_COMP_cpl_mod.ksh cplmod[ID [node]] 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
m4 input file • … • include GUIspecific_$model.h • include Sitespecific_$node.h • include Cppflags_$model.h • include Compile_mode_$model_$node.h • include Make_model.h • … m4 COMP_model_ID.node Compile Script Assembly • Create_COMP_models.frm model“” – “” node ID “partner models” *.h 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
User COMP_mod1_ID.node all / lib / clean / tar create (in-doc.) make Top_Makefile make Makefile lib*.a *.o / *.mod mod1_ID[_MPIn].x SCE :Model compilation call with libraries “list” COMP_libs.node “list” create (in-doc.) make Top_Makefile list of libraries: src directories: make src / Makefile 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
SCE: (GNU) Make • All compilation is based on the (g)make software:Make ‘targets’ having ‘prerequisites’ with well defined ‘rules’ while avoiding redundant actions: • Make –f Makefile • Targets, rules & prerequisites are defined in Makefile: … Target: prerequisite1, prerequisite2 …. rule … 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
(GNU) Make targets • Executables: OASIS3.x, ECHAM5.x, *.x • Libraries: *.a • Model libraries: *_ID.a • Binary object code: *.o • FORTRAN90 Modules: *.mod 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
(GNU) Portable Makefiles • All non portable code exported from the compile scripts • 1 Makefile for each source directory with compiler input • All CMs Makefiles have the same look and feel • Exception: prerequisites Tool for generation of *.o prerequisites • All library Makefiles have the same look and feel 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Example Makefile: Def. of variables • SRCS1 = $(shell find ../../../../src/mod/$(MODEL_DIR)/$(strip $(SRC)) –name '*.F90' -print) • OBJS1 = $(patsubst ../../../../src/mod/$(MODEL_DIR)/$(strip $(SRC))/%.F90, %.o, $(SRCS1)) • …. • SRCS5 = $(shell find ../../../../src/mod/$(MODEL_DIR)/$(strip $(SRC)) -name '*.c' -print) • OBJS5 = $(patsubst ../../../../src/mod/$(MODEL_DIR)/$(strip $(SRC))/%.c, %.o, $(SRCS5)) • VPATH = .:../../../../src/mod/$(MODEL_DIR)/$(strip $(SRC)):\ ../../../../src/mod/$(MODEL_DIR)/$(strip $(SRC))/include:\ ../../../../src/mod/$(MODEL_DIR)/include:\ ../../lib/psmile.${CHAN}:\ $(NETCDF_INCLUDE):$(MPI_INCLUDE):$(SYS_INCLUDE):\ ../../../lib/$(MODEL_DIR):\ ../../../lib/$(SUBMOD1):\ ../../../lib:\ ../../../../src/mod/$(MODEL_DIR)/make_dummies • LIBRARY = ../../../lib/$(MODEL_DIR)/lib$(MODLIB).a • PROG = ../../../bin/$(EXEC).x • INCLS = -I../../../../src/mod/$(MODEL_DIR)/include \ -${I4mods}../../lib/clim.${CHAN} • INCLSC = -I../../../../src/mod/$(MODEL_DIR)/include 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Example Makefile: Targets & Rules • clean: rm -f $(LIBRARY) i.* *.o *.mod Top_Makefile_* • all: $(PROG) • lib: $(LIBRARY) • $(PROG): $(DEPLIBS) $(LIBRARY) $(F90) $(LDFLAGS) -o $@ $(MAINPRG).o $(LIBS)$(LIBRARY): $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(AR) $(ARFLAGS) $(LIBRARY) *.o.SUFFIXES:.SUFFIXES: .o .c .f .F .f90 .F90%.o: %.F90 $(F90) $(F90FLAGS) $(INCLS) -c $<…%.o: %.f $(f) $(fFLAGS) $(INCLS) -c $<%.o: %.c $(CC) $(CCFLAGS) $(INCLSC) -c $< 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Generating .o prerequisites mod_unitncdf.o: mod_kinds_oasis.oalloc_src.o: mod_anais.o mod_analysis.o mod_coast.o mod_experiment.o \ mod_extrapol.o mod_kinds_oasis.o mod_memory.o mod_nproc.o \ mod_parallel.o mod_parameter.o mod_pipe.o mod_rainbow.o mod_sipc.o \ mod_string.o mod_timestep.o mod_unitncdf.odealloc_src.o: mod_anais.o mod_analysis.o mod_coast.o mod_experiment.o \ mod_extrapol.o mod_kinds_oasis.o mod_memory.o mod_nproc.o \ mod_parallel.o mod_parameter.o mod_pipe.o mod_rainbow.o mod_sipc.o \ mod_string.o mod_timestep.o mod_unitncdf.oextrap.o: mod_extrapol.o mod_kinds_oasis.o mod_parameter.o mod_printing.o \ mod_unit.ogetfld.o: mod_analysis.o mod_clim.o mod_experiment.o mod_hardware.o \ mod_kinds_oasis.o mod_label.o mod_memory.o mod_parameter.o \ mod_printing.o mod_sipc.o mod_string.o mod_timestep.o mod_unit.o \ mod_unitncdf.o netcdf.inc Append_Dependenciesmodel_namesrc_directory 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
SCE : Util directory Structure 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke
Documentation & URLs • HandbookThe PRISM Standard Compilation EnvironmentStephanie Legutke and Veronika GaylerPRISM Report Series, No. 4, 1. Edition, 15 Jan 2005 http://prism.enes.org/Results/Documents/PRISMReports/Report04.pdf • WP3i (Model Assembly) M&D PRISM web site http://prism.dkrz.de/Workpackages/WP3i/Documentationshttp://prism.dkrz.de/Workpackages/WP3i/Presentations • PRISM project web site http://prism.enes.org • PRISM Portal (under development)http://prism.enes.org/Portal 22-24 Feb 05 Workshop DKRZ / M&D Stephanie Legutke