Esempio n. 1
0
    def build_phase(self, sharedlib_only=False, model_only=False):
        # 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 self._case.get_values("COMP_CLASSES"):
                self._case.set_value("NTHRDS_{}".format(comp), 1)

                ntasks = self._case.get_value("NTASKS_{}".format(comp))

                self._case.set_value("NTASKS_{}".format(comp), ntasks * NINST)
                if comp != "CPL":
                    self._case.set_value("NINST_{}".format(comp), NINST)

            self._case.flush()

            case_setup(self._case, test_mode=False, reset=True)

        for iinst in range(1, NINST + 1):
            with open(
                "user_nl_{}_{:04d}".format(self.component, iinst), "w"
            ) as nl_atm_file:
                nl_atm_file.write("new_random = .true.\n")
                nl_atm_file.write("pertlim = 1.0e-10\n")
                nl_atm_file.write("seed_custom = {}\n".format(iinst))
                nl_atm_file.write("seed_clock = .true.\n")

        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
Esempio n. 2
0
    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)
Esempio n. 3
0
    def build_phase(self, sharedlib_only=False, model_only=False):
        # 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 self._case.get_values("COMP_CLASSES"):
                self._case.set_value('NTHRDS_{}'.format(comp), 1)

                ntasks = self._case.get_value("NTASKS_{}".format(comp))

                self._case.set_value('NTASKS_{}'.format(comp), ntasks * ninst)
                if comp != 'CPL':
                    self._case.set_value('NINST_{}'.format(comp), ninst)

            self._case.set_value('ATM_NCPL', 18)

            self._case.flush()

            case_setup(self._case, test_mode=False, reset=True)

        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)

        # =================================================================
        # Run-time settings.
        # Do this already in build_phase so that we can check the xml and
        # namelist files before job starts running.
        # =================================================================

        # namelist specifications for each instance
        for iinst in range(1, ninst + 1):
            with open('user_nl_cam_{:04d}'.format(iinst), 'w') as nl_atm_file:
                nl_atm_file.write('new_random = .true.\n')
                nl_atm_file.write('pertlim = 1.0e-10\n')
                nl_atm_file.write('seed_custom = {}\n'.format(iinst))
Esempio n. 4
0
File: tsc.py Progetto: tjfulle/E3SM
    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)
Esempio n. 5
0
    def build_phase(self, sharedlib_only=False, model_only=False):
        # 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 self._case.get_values("COMP_CLASSES"):
                self._case.set_value('NTHRDS_{}'.format(comp), 1)

                ntasks = self._case.get_value("NTASKS_{}".format(comp))

                self._case.set_value('NTASKS_{}'.format(comp), ntasks * NINST)
                if comp != 'CPL':
                    self._case.set_value('NINST_{}'.format(comp), NINST)

            self._case.set_value('ATM_NCPL', 18)

            self._case.flush()

            case_setup(self._case, test_mode=False, reset=True)

        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)

        for iinst in range(1, NINST + 1):
            with open('user_nl_cam_{:04d}'.format(iinst), 'w') as nl_atm_file:
                nl_atm_file.write('new_random = .true.\n')
                nl_atm_file.write('pertlim = 1.0e-10\n')
                nl_atm_file.write('seed_custom = {}\n'.format(iinst))
Esempio n. 6
0
File: mvk.py Progetto: bertinia/cime
    def build_phase(self, sharedlib_only=False, model_only=False):
        # 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 self._case.get_values("COMP_CLASSES"):
                self._case.set_value('NTHRDS_{}'.format(comp), 1)

                ntasks = self._case.get_value("NTASKS_{}".format(comp))

                self._case.set_value('NTASKS_{}'.format(comp), ntasks*ninst)
                if comp != 'CPL':
                    self._case.set_value('NINST_{}'.format(comp), ninst)

            self._case.set_value('ATM_NCPL', 18)

            self._case.flush()

            case_setup(self._case, test_mode=False, reset=True)

        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)

        # =================================================================
        # Run-time settings.
        # Do this already in build_phase so that we can check the xml and
        # namelist files before job starts running.
        # =================================================================

        # namelist specifications for each instance
        for iinst in range(1, ninst+1):
            with open('user_nl_cam_{:04d}'.format(iinst), 'w') as nl_atm_file:
                nl_atm_file.write('new_random = .true.\n')
                nl_atm_file.write('pertlim = 1.0e-10\n')
                nl_atm_file.write('seed_custom = {}\n'.format(iinst))
Esempio n. 7
0
    def build_phase(self, sharedlib_only=False, model_only=False):
        ninst = NUMBER_INITIAL_CONDITIONS * len(PERTURBATIONS)
        logger.debug('PGN_INFO: number of instance: '+str(ninst))

        default_ninst = self._case.get_value("NINST_ATM")

        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
                logger.debug("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_{}".format(comp))
                    self._case.set_value("ROOTPE_{}".format(comp), 0)
                    self._case.set_value("NINST_{}".format(comp),  ninst)
                    self._case.set_value("NTASKS_{}".format(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)

        logger.debug("PGN_INFO: Updating user_nl_* files")

        csmdata_root = self._case.get_value("DIN_LOC_ROOT")
        csmdata_atm = os.path.join(csmdata_root, "atm/cam/inic/homme/ne4_v2_init")
        csmdata_lnd = os.path.join(csmdata_root, "lnd/clm2/initdata/ne4_oQU240_v2_init")

        iinst = 1
        for icond in range(1, NUMBER_INITIAL_CONDITIONS + 1):
            fatm_in = os.path.join(csmdata_atm, INIT_COND_FILE_TEMPLATE.format(self.atmmodIC, 'i', icond))
            flnd_in = os.path.join(csmdata_lnd, INIT_COND_FILE_TEMPLATE.format(self.lndmodIC, 'r', icond))
            for iprt in PERTURBATIONS.values():
                with open('user_nl_{}_{:04d}'.format(self.atmmod, iinst), 'w') as atmnlfile, \
                        open('user_nl_{}_{:04d}'.format(self.lndmod, iinst), 'w') as lndnlfile:

                    atmnlfile.write("ncdata  = '{}' \n".format(fatm_in))
                    lndnlfile.write("finidat = '{}' \n".format(flnd_in))

                    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")

                    if iprt != 0.0:
                        atmnlfile.write("pertlim = {} \n".format(iprt))

                    iinst += 1

        self._case.set_value("STOP_N", "1")
        self._case.set_value("STOP_OPTION", "nsteps")
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
Esempio n. 8
0
    def build_phase(self, sharedlib_only=False, model_only=False):
        # 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_{}".format(comp))
                self._case.set_value("ROOTPE_{}".format(comp), 0)
                self._case.set_value("NINST_{}".format(comp), NINST)
                self._case.set_value("NTASKS_{}".format(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)

        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
Esempio n. 9
0
File: pgn.py Progetto: tjfulle/E3SM
    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")
Esempio n. 10
0
File: pgn.py Progetto: srinathv/cime
    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")