def build_phase(self, sharedlib_only=False, model_only=False): ninst = 12 #BSINGH: For debugging only - Building the model can take #significant amount of time. Setting fake_bld to True can save #that time fake_bld = False # Build exectuable with multiple instances # (in the development phase we use 3) # Lay all of the components out concurrently # Only want this to happen once. It will impact the sharedlib build # so it has to happen there. if not model_only: logging.warning("Starting to build multi-instance exe") for comp in ['ATM','OCN','WAV','GLC','ICE','ROF','LND']: ntasks = self._case.get_value("NTASKS_%s"%comp) self._case.set_value("ROOTPE_%s"%comp, 0) self._case.set_value("NINST_%s"%comp, ninst) self._case.set_value("NTASKS_%s"%comp, ntasks*ninst) self._case.set_value("ROOTPE_CPL",0) self._case.set_value("NTASKS_CPL",ntasks*ninst) self._case.flush() case_setup(self._case, test_mode=False, reset=True) #BSINGH: Faking a bld can save the time code spend in building the model components if fake_bld: if (not sharedlib_only): post_build(self._case, []) else: self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
def build_phase(self, sharedlib_only=False, model_only=False): if not sharedlib_only: # Build HOMME srcroot = self._case.get_value("SRCROOT") mach = self._case.get_value("MACH") procs = self._case.get_value("TOTALPES") exeroot = self._case.get_value("EXEROOT") baseline = self._case.get_value("BASELINE_ROOT") basegen = self._case.get_value("BASEGEN_CASE") basecmp = self._case.get_value("BASECMP_CASE") generate = self._case.get_value("GENERATE_BASELINE") gmake = self._case.get_value("GMAKE") cprnc = self._case.get_value("CCSM_CPRNC") basename = basegen if generate else basecmp cmake_cmd = "cmake -C {}/components/homme/cmake/machineFiles/{}.cmake -DUSE_NUM_PROCS={} {}/components/homme -DHOMME_BASELINE_DIR={}/{} -DCPRNC_DIR={}/..".format( srcroot, mach, procs, srcroot, baseline, basename, cprnc) run_cmd_no_fail(cmake_cmd, arg_stdout="homme.bldlog", combine_output=True, from_dir=exeroot) run_cmd_no_fail("{} -j8".format(gmake), arg_stdout="homme.bldlog", combine_output=True, from_dir=exeroot) post_build(self._case, [os.path.join(exeroot, "homme.bldlog")])
def build_phase(self, sharedlib_only=False, model_only=False): if not sharedlib_only: # Build HOMME srcroot = self._case.get_value("SRCROOT") mach = self._case.get_value("MACH") procs = self._case.get_value("TOTALPES") exeroot = self._case.get_value("EXEROOT") baseline = self._case.get_value("BASELINE_ROOT") basecmp = self._case.get_value("BASECMP_CASE") compare = self._case.get_value("COMPARE_BASELINE") gmake = self._case.get_value("GMAKE") cprnc = self._case.get_value("CCSM_CPRNC") if compare: basename = basecmp baselinedir = baseline else: basename = "" baselinedir = exeroot cmake_cmd = "cmake -C {0}/components/homme/cmake/machineFiles/{1}.cmake -DUSE_NUM_PROCS={2} {0}/components/homme -DHOMME_BASELINE_DIR={3}/{4} -DCPRNC_DIR={5}/..".format(srcroot, mach, procs, baselinedir, basename, cprnc) run_cmd_no_fail(cmake_cmd, arg_stdout="homme.bldlog", combine_output=True, from_dir=exeroot) run_cmd_no_fail("{} -j8".format(gmake), arg_stdout="homme.bldlog", combine_output=True, from_dir=exeroot) post_build(self._case, [os.path.join(exeroot, "homme.bldlog")], build_complete=True)
def build_phase(self, sharedlib_only=False, model_only=False): ninst = 12 #BSINGH: For debugging only - Building the model can take #significant amount of time. Setting fake_bld to True can save #that time fake_bld = False # Build exectuable with multiple instances # (in the development phase we use 3) # Lay all of the components out concurrently # Only want this to happen once. It will impact the sharedlib build # so it has to happen there. if not model_only: logging.warn("Starting to build multi-instance exe") for comp in ['ATM','OCN','WAV','GLC','ICE','ROF','LND']: ntasks = self._case.get_value("NTASKS_%s"%comp) self._case.set_value("ROOTPE_%s"%comp, 0) self._case.set_value("NINST_%s"%comp, ninst) self._case.set_value("NTASKS_%s"%comp, ntasks*ninst) self._case.set_value("ROOTPE_CPL",0) self._case.set_value("NTASKS_CPL",ntasks*ninst) self._case.flush() case_setup(self._case, test_mode=False, reset=True) #BSINGH: Faking a bld can save the time code spend in building the model components if fake_bld: if (not sharedlib_only): post_build(self._case, []) else: self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
def build_phase(self, sharedlib_only=False, model_only=False): if not sharedlib_only: exeroot = self._case.get_value("EXEROOT") logfile = os.path.join(exeroot, "funit.bldlog") with open(logfile, "w") as fd: fd.write("No-op\n") post_build(self._case, [logfile], build_complete=True)
def build_phase(self, sharedlib_only=False, model_only=False): if not sharedlib_only: caseroot = self._case.get_value('CASEROOT') lndroot = self._case.get_value('COMP_ROOT_DIR_LND') exeroot = self._case.get_value('EXEROOT') build_dir = os.path.join(caseroot, 'lilac_build') script_path = os.path.abspath(os.path.join(lndroot, 'lilac', 'build_ctsm')) # We only run the initial build command if the build_dir doesn't exist # yet. This is to support rebuilding the test case. (The first time through, # the build_dir won't exist yet; subsequent times, it will already exist, so # we skip to the rebuild command.) if not os.path.isdir(build_dir): machine = self._case.get_value('MACH') compiler = self._case.get_value('COMPILER') debug = self._case.get_value('DEBUG') # It would be possible to do this testing via the python interface rather # than through a separate subprocess. However, we do it through a # subprocess in order to test the full build_ctsm script, including # command-line parsing. cmd = '{script_path} {build_dir} --machine {machine} --compiler {compiler}'.format( script_path=script_path, build_dir=build_dir, machine=machine, compiler=compiler) # It isn't straightforward to determine if pnetcdf is available on a # machine. To keep things simple, always run without pnetcdf. cmd += ' --no-pnetcdf' if debug: cmd += ' --build-debug' self._run_build_cmd(cmd, exeroot, 'build_ctsm.bldlog') # We call the build script with --rebuild even for an initial build. This is # so we make sure to test the code path for --rebuild. (This is also needed if # the user rebuilds the test case, in which case this will be the only command # run, since the build_dir will already exist.) cmd = '{script_path} {build_dir} --rebuild'.format( script_path=script_path, build_dir=build_dir) self._run_build_cmd(cmd, exeroot, 'rebuild_ctsm.bldlog') self._build_atm_driver() self._create_link_to_atm_driver() self._create_runtime_inputs() self._setup_atm_driver_rundir() self._cmpgen_namelists() # Setting logs=[] implies that we don't bother gzipping any of the build log # files; that seems fine for these purposes (and it keeps the above code # simpler). post_build(self._case, logs=[], build_complete=True)
def build_phase(self, sharedlib_only=False, model_only=False): if (not sharedlib_only): exeroot = self._case.get_value("EXEROOT") cime_model = self._case.get_value("MODEL") modelexe = os.path.join(exeroot, "{}.exe".format(cime_model)) with open(modelexe, 'w') as f: f.write("#!/bin/bash\n") f.write(self._script) os.chmod(modelexe, 0o755) build.post_build(self._case, [], build_complete=True)
def build_phase(self, sharedlib_only=False, model_only=False): if not sharedlib_only: # Build HOMME srcroot = self._case.get_value("SRCROOT") mach = self._case.get_value("MACH") procs = self._case.get_value("TOTALPES") exeroot = self._case.get_value("EXEROOT") baseline = self._case.get_value("CCSM_BASELINE") basegen = self._case.get_value("BASEGEN_CASE") basecmp = self._case.get_value("BASECMP_CASE") generate = self._case.get_value("GENERATE_BASELINE") basename = basegen if generate else basecmp cmake_cmd = "cmake -C %s/components/homme/cmake/machineFiles/%s.cmake -DUSE_NUM_PROCS=%s %s/components/homme -DHOMME_BASELINE_DIR=%s/%s >& homme.bldlog" % (srcroot, mach, procs, srcroot, baseline, basename) run_cmd_no_fail(cmake_cmd, from_dir=exeroot) run_cmd_no_fail("make -j8 >> homme.bldlog 2>&1", from_dir=exeroot) post_build(self._case, [os.path.join(exeroot, "homme.bldlog")])
def build_phase(self, sharedlib_only=False, model_only=False): if not sharedlib_only: # Build HOMME srcroot = self._case.get_value("SRCROOT") mach = self._case.get_value("MACH") procs = self._case.get_value("TOTALPES") exeroot = self._case.get_value("EXEROOT") baseline = self._case.get_value("BASELINE_ROOT") basegen = self._case.get_value("BASEGEN_CASE") basecmp = self._case.get_value("BASECMP_CASE") generate = self._case.get_value("GENERATE_BASELINE") gmake = self._case.get_value("GMAKE") basename = basegen if generate else basecmp cmake_cmd = "cmake -C {}/components/homme/cmake/machineFiles/{}.cmake -DUSE_NUM_PROCS={} {}/components/homme -DHOMME_BASELINE_DIR={}/{}".format(srcroot, mach, procs, srcroot, baseline, basename) run_cmd_no_fail(cmake_cmd, arg_stdout="homme.bldlog", combine_output=True, from_dir=exeroot) run_cmd_no_fail("{} -j8".format(gmake), arg_stdout="homme.bldlog", combine_output=True, from_dir=exeroot) post_build(self._case, [os.path.join(exeroot, "homme.bldlog")])
def build_phase(self, sharedlib_only=False, model_only=False): #------------------------------------------------------ #Compute number of instances: #------------------------------------------------------ #------------------------------------------------------ #Number of instances: #~~~~~~~~~~~~~~~~~~~ #Comput it from number of initial conditions to use and #number of perturbation ensemble members to use #------------------------------------------------------ nprt = len(prt) ninst = ninit_cond * nprt if (debug): print('PGN_INFO: number of instance: ' + str(ninst)) #------------------------------------------------------ #Fake Build: #~~~~~~~~~~ #(for debugging only) Building the model can take #significant amount of time. Setting fake_bld to True #can savethat time #------------------------------------------------------ fake_bld = False #Find number of instance in the default setup default_ninst = self._case.get_value("NINST_ATM") #Sanity check: see if NINST is same for all model components, otherwise exit with error for comp in ['OCN', 'WAV', 'GLC', 'ICE', 'ROF', 'LND']: iinst = self._case.get_value("NINST_%s" % comp) expect( default_ninst == iinst, "ERROR: component " + str(comp) + " NINST(" + str(iinst) + ")" " is different from component ATM NINST(" + str(default_ninst) + ")") #------------------------------------------------------ #Setup multi-instances for model components: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #Set the model for multi-instance ONLY if NINST == 1 #for all model components. This is because, for #NINST > 1 (e.g. rebuilding an old case) the following #loop will increase the ntasks to a multiple of ninst #(requiring a clean build again). We hit this issue if #we launch ./case.build in the case directory of PGN #test #------------------------------------------------------ if (default_ninst == 1): #if multi-instance is not already set # Only want this to happen once. It will impact the sharedlib build # so it has to happen here. if not model_only: # Lay all of the components out concurrently if (debug): print( "PGN_INFO: Updating NINST for multi-instance in env_mach_pes.xml" ) for comp in ['ATM', 'OCN', 'WAV', 'GLC', 'ICE', 'ROF', 'LND']: ntasks = self._case.get_value("NTASKS_%s" % comp) self._case.set_value("ROOTPE_%s" % comp, 0) self._case.set_value("NINST_%s" % comp, ninst) self._case.set_value("NTASKS_%s" % comp, ntasks * ninst) self._case.set_value("ROOTPE_CPL", 0) self._case.set_value("NTASKS_CPL", ntasks * ninst) self._case.flush() case_setup(self._case, test_mode=False, reset=True) #Faking a bld can save the time code spend in building the model components if fake_bld: if (debug): print("PGN_INFO: FAKE Build") if (not sharedlib_only): post_build(self._case, []) else: # Build exectuable with multiple instances self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only) #---------------------------------------------------------------- # Namelist settings: #~~~~~~~~~~~~~~~~~~ # Do this already in build_phase so that we can check the xml and # namelist files before job starts running. #---------------------------------------------------------------- if (debug): print("PGN_INFO: Updating user_nl_* files") csmdata_root = self._case.get_value("DIN_LOC_ROOT") csmdata_atm = csmdata_root + "/atm/cam/inic/homme/ne4_v1_init/" csmdata_lnd = csmdata_root + "/lnd/clm2/initdata/ne4_v1_init/" iinst = 1 for icond in range(ninit_cond): icond_label_2digits = str(icond + 1).zfill(2) fatm_in = file_pref_atm + icond_label_2digits + file_suf_atm flnd_in = file_pref_lnd + icond_label_2digits + file_suf_lnd for iprt in prt: with open('user_nl_cam_'+str(iinst).zfill(4), 'w') as atmnlfile, \ open('user_nl_clm_'+str(iinst).zfill(4), 'w') as lndnlfile: #atm/lnd intitial conditions #initial condition files to use for atm and land #atmnlfile.write("ncdata = '"+ "/pic/projects/uq_climate/wanh895/acme_input/ne4_v1_init/" + fatm_in+"' \n") #lndnlfile.write("finidat = '"+ "/pic/projects/uq_climate/wanh895/acme_input/ne4_v1_init/" + flnd_in+"' \n") #uncomment the following when there files are on SVN server atmnlfile.write("ncdata = '" + csmdata_atm + "/" + fatm_in + "' \n") lndnlfile.write("finidat = '" + csmdata_lnd + "/" + flnd_in + "' \n") #atm model output atmnlfile.write("avgflag_pertape = 'I' \n") atmnlfile.write("nhtfrq = 1 \n") atmnlfile.write("mfilt = 2 \n") atmnlfile.write("ndens = 1 \n") atmnlfile.write("pergro_mods = .true. \n") atmnlfile.write("pergro_test_active = .true. \n") #atmnlfile.write("empty_htapes = .true. \n") #atmnlfile.write("fincl1 = 'PS','U','V','T','Q','CLDLIQ','CLDICE','NUMLIQ','NUMICE','num_a1','num_a2','num_a3','LANDFRAC' \n") #atmnlfile.write("phys_debug_lat = 41.3495891345") #atmnlfile.write("phys_debug_lon = 45.0" ) if (iprt != 0.0): atmnlfile.write("pertlim = " + str(iprt) + " \n") iinst += 1 #-------------------------------- #Settings common to all instances #-------------------------------- #Coupler settings which are applicable to ALL the instances (as there is only one coupler for all instances) self._case.set_value("STOP_N", "1") self._case.set_value("STOP_OPTION", "nsteps")
def build_phase(self, sharedlib_only=False, model_only=False): #------------------------------------------------------ #Compute number of instances: #------------------------------------------------------ #------------------------------------------------------ #Number of instances: #~~~~~~~~~~~~~~~~~~~ #Comput it from number of initial conditions to use and #number of perturbation ensemble members to use #------------------------------------------------------ nprt = len(prt) ninst = ninit_cond * nprt if(debug): print('PGN_INFO: number of instance: '+str(ninst)) #------------------------------------------------------ #Fake Build: #~~~~~~~~~~ #(for debugging only) Building the model can take #significant amount of time. Setting fake_bld to True #can savethat time #------------------------------------------------------ fake_bld = False #Find number of instance in the default setup default_ninst = self._case.get_value("NINST_ATM") #Sanity check: see if NINST is same for all model components, otherwise exit with error for comp in ['OCN','WAV','GLC','ICE','ROF','LND']: iinst = self._case.get_value("NINST_%s"%comp) expect(default_ninst == iinst, "ERROR: component "+str(comp)+" NINST("+str(iinst)+")" " is different from component ATM NINST("+str(default_ninst)+")") #------------------------------------------------------ #Setup multi-instances for model components: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #Set the model for multi-instance ONLY if NINST == 1 #for all model components. This is because, for #NINST > 1 (e.g. rebuilding an old case) the following #loop will increase the ntasks to a multiple of ninst #(requiring a clean build again). We hit this issue if #we launch ./case.build in the case directory of PGN #test #------------------------------------------------------ if(default_ninst == 1): #if multi-instance is not already set # Only want this to happen once. It will impact the sharedlib build # so it has to happen here. if not model_only: # Lay all of the components out concurrently if(debug): print("PGN_INFO: Updating NINST for multi-instance in env_mach_pes.xml") for comp in ['ATM','OCN','WAV','GLC','ICE','ROF','LND']: ntasks = self._case.get_value("NTASKS_%s"%comp) self._case.set_value("ROOTPE_%s"%comp, 0) self._case.set_value("NINST_%s"%comp, ninst) self._case.set_value("NTASKS_%s"%comp, ntasks*ninst) self._case.set_value("ROOTPE_CPL",0) self._case.set_value("NTASKS_CPL",ntasks*ninst) self._case.flush() case_setup(self._case, test_mode=False, reset=True) #Faking a bld can save the time code spend in building the model components if fake_bld: if(debug): print("PGN_INFO: FAKE Build") if (not sharedlib_only): post_build(self._case, []) else: # Build exectuable with multiple instances self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only) #---------------------------------------------------------------- # Namelist settings: #~~~~~~~~~~~~~~~~~~ # Do this already in build_phase so that we can check the xml and # namelist files before job starts running. #---------------------------------------------------------------- if(debug): print("PGN_INFO: Updating user_nl_* files") csmdata_root = self._case.get_value("DIN_LOC_ROOT") csmdata_atm = csmdata_root+"/atm/cam/inic/homme/ne4_v1_init/" csmdata_lnd = csmdata_root+"/lnd/clm2/initdata/ne4_v1_init/" iinst = 1 for icond in range(ninit_cond): icond_label_2digits = str(icond+1).zfill(2) fatm_in = file_pref_atm + icond_label_2digits + file_suf_atm flnd_in = file_pref_lnd + icond_label_2digits + file_suf_lnd for iprt in prt: with open('user_nl_cam_'+str(iinst).zfill(4), 'w') as atmnlfile, \ open('user_nl_clm_'+str(iinst).zfill(4), 'w') as lndnlfile: #atm/lnd intitial conditions #initial condition files to use for atm and land #atmnlfile.write("ncdata = '"+ "/pic/projects/uq_climate/wanh895/acme_input/ne4_v1_init/" + fatm_in+"' \n") #lndnlfile.write("finidat = '"+ "/pic/projects/uq_climate/wanh895/acme_input/ne4_v1_init/" + flnd_in+"' \n") #uncomment the following when there files are on SVN server atmnlfile.write("ncdata = '"+ csmdata_atm + "/" + fatm_in+"' \n") lndnlfile.write("finidat = '"+ csmdata_lnd + "/" + flnd_in+"' \n") #atm model output atmnlfile.write("avgflag_pertape = 'I' \n") atmnlfile.write("nhtfrq = 1 \n") atmnlfile.write("mfilt = 2 \n") atmnlfile.write("ndens = 1 \n") atmnlfile.write("pergro_mods = .true. \n") atmnlfile.write("pergro_test_active = .true. \n") #atmnlfile.write("empty_htapes = .true. \n") #atmnlfile.write("fincl1 = 'PS','U','V','T','Q','CLDLIQ','CLDICE','NUMLIQ','NUMICE','num_a1','num_a2','num_a3','LANDFRAC' \n") #atmnlfile.write("phys_debug_lat = 41.3495891345") #atmnlfile.write("phys_debug_lon = 45.0" ) if(iprt != 0.0): atmnlfile.write("pertlim = "+str(iprt)+" \n") iinst += 1 #-------------------------------- #Settings common to all instances #-------------------------------- #Coupler settings which are applicable to ALL the instances (as there is only one coupler for all instances) self._case.set_value("STOP_N", "1") self._case.set_value("STOP_OPTION","nsteps")