Exemplo n.º 1
0
Arquivo: tsc.py Projeto: dabail10/cime
    def _run_with_specified_dtime(self, dtime=2):
        """
        Conduct one multi-instance run with a specified time step size.

        :param dtime (int): Specified time step size in seconds
        """
        coupling_frequency = 86400 // dtime

        self._case.set_value("ATM_NCPL", str(coupling_frequency))
        se_tstep = dtime / 12

        nsteps = SIM_LENGTH // dtime
        self._case.set_value("STOP_N", str(nsteps))
        self._case.set_value("STOP_OPTION", "nsteps")

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

        nstep_output = OUT_FREQ // dtime
        for iinst in range(1, NINST + 1):
            with open(f"user_nl_{self.atmmod}_" + str(iinst).zfill(4),
                      "w") as atmnlfile, open(
                          f"user_nl_{self.lndmod}_" + str(iinst).zfill(4),
                          "w") as lndnlfile:

                fatm_in = os.path.join(
                    csmdata_atm,
                    INIT_COND_FILE_TEMPLATE.format(self.atmmodIC, "i", iinst),
                )
                flnd_in = os.path.join(
                    csmdata_lnd,
                    INIT_COND_FILE_TEMPLATE.format(self.lndmodIC, "r", iinst),
                )
                atmnlfile.write("ncdata  = '{}' \n".format(fatm_in))
                lndnlfile.write("finidat = '{}' \n".format(flnd_in))

                lndnlfile.write("dtime = {} \n".format(dtime))

                atmnlfile.write("dtime = {} \n".format(dtime))
                atmnlfile.write("se_tstep = {} \n".format(se_tstep))
                atmnlfile.write("iradsw = 2 \n")
                atmnlfile.write("iradlw = 2 \n")

                atmnlfile.write("avgflag_pertape = 'I' \n")
                atmnlfile.write("nhtfrq = {} \n".format(nstep_output))
                atmnlfile.write("mfilt = 1 \n")
                atmnlfile.write("ndens = 1 \n")
                atmnlfile.write("empty_htapes = .true. \n")
                atmnlfile.write("fincl1 = 'PS','U','LANDFRAC',{} \n".format(
                    "".join(["'{}',".format(s) for s in VAR_LIST])[:-1]))

        # Force rebuild namelists
        self._skip_pnl = False

        self.run_indv()

        rename_all_hist_files(self._case, suffix="DT{:04d}".format(dtime))
Exemplo n.º 2
0
    def _run_with_specified_dtime(self,dtime=2):

        # dtime is model time step size in seconds. Default is set to 2.

        # Change the coupling frequency accordingly
        ncpl  = 86400/dtime
        self._case.set_value("ATM_NCPL",ncpl)

        # Simulation length = 10 minutes
        nsteps = 600/dtime
        self._case.set_value("STOP_N",     nsteps)
        self._case.set_value("STOP_OPTION","nsteps")

        # Write output every 10 seconds
        nhtfrq = 10/dtime

        # generate paths/file names for initial conditons
        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/b58d55680/"
        file_pref_atm = "SMS_Ly5.ne4_ne4.FC5AV1C-04P2.eos_intel.ne45y.cam.i.0002-"
        file_pref_lnd = "SMS_Ly5.ne4_ne4.FC5AV1C-04P2.eos_intel.ne45y.clm2.r.0002-"

        file_suf_atm = "-01-00000.nc"
        file_suf_lnd = "-01-00000.nc"

        # user_nl_... files are modified for every instance.
        # The number instances specified here has to be consistent with the
        # value set in build_phase.
        ninst = 12
        for iinst in range(1, ninst+1):

            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

                inst_label_2digits = str(iinst).zfill(2)

                atmnlfile.write("ncdata  = '"+ csmdata_atm + "/" + file_pref_atm + inst_label_2digits + file_suf_atm+"' \n")
                lndnlfile.write("finidat = '"+ csmdata_lnd + "/" + file_pref_lnd + inst_label_2digits + file_suf_lnd+"' \n")

                # for initial testing on constance@pnnl
                #atmnlfile.write("ncdata  = '"+ "/pic/projects/uq_climate/wanh895/acme_input/ne4_v1_init/" + file_pref_atm + inst_label_2digits + file_suf_atm+"' \n")
                #lndnlfile.write("finidat = '"+ "/pic/projects/uq_climate/wanh895/acme_input/ne4_v1_init/" + file_pref_lnd + inst_label_2digits + file_suf_lnd+"' \n")

                # time step sizes

                atmnlfile.write("dtime = "+str(dtime)+" \n")
                atmnlfile.write("iradsw = 2 \n")
                atmnlfile.write("iradlw = 2 \n")

                lndnlfile.write("dtime = "+str(dtime)+" \n")

                # atm model output

                atmnlfile.write("avgflag_pertape = 'I' \n")
                atmnlfile.write("nhtfrq = "+str(nhtfrq)+" \n")
                atmnlfile.write("mfilt  = 1  \n")
                atmnlfile.write("ndens  = 1  \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")

        # Force rebuild namelists
        self._skip_pnl = False

        # Namelist settings done. Now run the model.
        self.run_indv()

        # Append "DT000x" to the history file names
        rename_all_hist_files( self._case, suffix="DT"+str(dtime).zfill(4) )
Exemplo n.º 3
0
Arquivo: tsc.py Projeto: tjfulle/E3SM
    def _run_with_specified_dtime(self,dtime=2):

        # dtime is model time step size in seconds. Default is set to 2.

        # Change the coupling frequency accordingly
        ncpl  = 86400/dtime
        self._case.set_value("ATM_NCPL",ncpl)

        # Simulation length = 10 minutes
        nsteps = 600/dtime
        self._case.set_value("STOP_N",     nsteps)
        self._case.set_value("STOP_OPTION","nsteps")

        # Write output every 10 seconds
        nhtfrq = 10/dtime
        
        # generate paths/file names for initial conditons
        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/"  
        file_pref_atm = "SMS_Ly5.ne4_ne4.FC5AV1C-04P2.eos_intel.ne45y.cam.i.0002-"
        file_pref_lnd = "SMS_Ly5.ne4_ne4.FC5AV1C-04P2.eos_intel.ne45y.clm2.r.0002-"
        
        file_suf_atm = "-01-00000.nc"
        file_suf_lnd = "-01-00000.nc"

        # user_nl_... files are modified for every instance.
        # The number instances specified here has to be consistent with the 
        # value set in build_phase.
        ninst = 12  
        for iinst in range(1, ninst+1):

            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

                 inst_label_2digits = str(iinst).zfill(2)

                 atmnlfile.write("ncdata  = '"+ csmdata_atm + "/" + file_pref_atm + inst_label_2digits + file_suf_atm+"' \n")
                 lndnlfile.write("finidat = '"+ csmdata_lnd + "/" + file_pref_lnd + inst_label_2digits + file_suf_lnd+"' \n")

                # for initial testing on constance@pnnl
                 #atmnlfile.write("ncdata  = '"+ "/pic/projects/uq_climate/wanh895/acme_input/ne4_v1_init/" + file_pref_atm + inst_label_2digits + file_suf_atm+"' \n")
                 #lndnlfile.write("finidat = '"+ "/pic/projects/uq_climate/wanh895/acme_input/ne4_v1_init/" + file_pref_lnd + inst_label_2digits + file_suf_lnd+"' \n")

                 # time step sizes

                 atmnlfile.write("dtime = "+str(dtime)+" \n")
                 atmnlfile.write("iradsw = 2 \n")
                 atmnlfile.write("iradlw = 2 \n")

                 lndnlfile.write("dtime = "+str(dtime)+" \n")

                 # atm model output

                 atmnlfile.write("avgflag_pertape = 'I' \n")
                 atmnlfile.write("nhtfrq = "+str(nhtfrq)+" \n")
                 atmnlfile.write("mfilt  = 1  \n")
                 atmnlfile.write("ndens  = 1  \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")

        # Force rebuild namelists
        self._skip_pnl = False

        # Namelist settings done. Now run the model.
        self.run_indv()

        # Append "DT000x" to the history file names 
        rename_all_hist_files( self._case, suffix="DT"+str(dtime).zfill(4) )