U $g@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl ZddlZddlZddlZddlZddlZddlZddlmZddl mZmZmZmZmZddlmZmZmZm Z ddl!Tddl m"Z"ddl m#Z#m$Z$m%Z%m&Z&m'Z'e(Z)d d Z*ed d d dddZ+ddZ,ddZ-ddZ.ddZ/Gdddej0j1Z2Gdddej3j4Z5Gdddej3j6Z7Gdddej0j1Z8dS)zbThis module will one day contain the implementation of the HyCOM initialization and forecast jobs.N)NamedDir) make_symlink isnonempty remove_file deliver_filegribver) FileProduct COMPLETEDRUNNINGFAILED)*)jlogger) to_datetimeto_datetime_rel TimeArray to_fraction to_timedeltacCs |rdSdS)NYESNO)xrr8/lfs/h1/ops/prod/packages/hwrf.v13.2.9/ush/hwrf/hycom.pyyesnosril cCsrt|trt|}t|tr.tj|dd}nZ"ed?d@Z#dAdBZ$dCdDZ%Z&S)F HYCOMInitcCs tdSN)selfuncouplerrrr remove_oceanCzHYCOMInit.remove_oceanN~c stt|j|||fd|i|d|_d|_||_||dd|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_dS)NtasknameT spinlengthr)superrI__init__ forecast_exe run_coupledfcstlen make_productsconfintrQicjcidmjdmijgrid Application_HYCOMInit__rtofs_inputs_HYCOMInit__rtofs_inputs_ymd_HYCOMInit__blkdat)rKdstorer1sectionrPrVkwargs __class__rrrSEs&zHYCOMInit.__init__c s|}t|jd|j|dd|_d}|rRttt|j d}|ddd}ntttd }t |j j fd d |D}t |d d |_t |d d |_|D]p}|d|}|jd|d}|d|}|jd|d} t|j||j|d|j|<t|j||j| d|j|<qt|_dD]j} dD]^} | d| } | dkrld| } t|j| |j| d|j| <nd| } t|j| |j|j| <q.q&t|jd|j|_t|jd|j|_t|_ddddddd d!d"d#g }|D]h}dD]\} d$|| f}|d%|}t|j||j|d}||_||j|<|d&||t|fqqt|jd'|j|d(d|_t|jd)|j|d*d|_dS)+zNInitializes all Product objects to make them available to future jobs.hycom_settings!{com}/{out_prefix}.hycom_settings)locationFgK7A9@rNgjt?csg|]}t|dqS))r).0tatimerr lsz+HYCOMInit.make_products..g@zhwrf_basin.{fahr:03d}.az{com}/{out_prefix}.{pn})Zpnzhwrf_basin.{fahr:03d}.bab) restart_out restart_outR.rsz {com}/{out_prefix}.cold_restart.z{com}/{out_prefix}.restart. spin_archv_a spin_archv_bairtmpprecippresurradflxshwflxsurtmptauewdtaunwdvapmixwndspdz forcing.%s.%s{com}/{out_prefix}.z %s => %s (%s)limitsz{com}/{out_prefix}.limits blkdat.inputz*{com}/{out_prefix}.standalone.blkdat.input)logrrbrPr.rglistranger rVrr1cycler init_file2a init_file2btimestrr0rsrvrwforcing_productsridebugreprr blkdat_input)rKloggerZbcflagZfhrsZftimesftimeZ prodnameAZ filepathAZ prodnameBZ filepathBrrwhatlocalZremoteZffilesffilefileZcomfprodrrnrrWXs         zHYCOMInit.make_productscCs|dkr dS|dkrdSdS)Nrr)rKZcychourrrrlast_lead_time_todays zHYCOMInit.last_lead_time_todaycCs||j|d|jgdS)zFills the ocean status files with information. This is called from exhwrf_ocean_init after a successful call to the run() function below. The ocstatus argument is the hwrf.coupling.OceanStatus object that fills the files.zforecast_exe=%sN)setrUrT)rKocstatusrrrr fill_ocstatusszHYCOMInit.fill_ocstatusc Cs4|D]}qq||}|D] }td|}|sJ|d||fq |\}}|}|}|dkr|dkr~d|_q|dkrd|_q|d|t|fn"|d kr||_ n|d ||f|d kr |dkrd|_ n&|dkrd|_ n|d|t|fq |d kr||_ q |d ||fq d S)zReads the ocean status back in during the forecast and check_init job, if 2-way, filling the self.run_coupled, self.forecast_exe variables; if 3-way filling the self.run_3waycoupled, eslf.forecast_exe2 variables. z^ *([^ =]+) *= *(.*?) *$z!%s: unparseable ocstatus line: %sZ RUN_COUPLEDrTrFz.%s: ignoring unrecognized RUN_COUPLED value %srTz%s: ignoring unknown key %sZRUN_WAVE forecast_exe2N) fileiterreadrArBwarningrCstriprUrrTZrun_3waycoupledr) rKrrfilenamelinesrFrGkeyvaluerrrrecall_ocstatussJ         zHYCOMInit.recall_ocstatusc+Csl|}|jj}t|j|j|jd}|d}|j}| dt || d}| d}| d}| d} | dt ||jj}t|j|j|jddd} t d |} t d |} t d } t d }t d }t |jd}| dt | t d | }|j|||dd}| dt |tj|}d}t|rwt)YMDINDIR1INDIR2INDIR3STARTHRENDHRLAST_LEAD_TIME_TODAYZhwrf_get_rtofs)allranksrzget_rtofs.nml.restartrrrOz6FRDa: dir0=%s starthr=%d endhr=%d lastleadtimetoday=%d)rorrrrrrzget_rtofs.nml.0N)(rr1rr!yearmonthdaystrftime rtofs_inputsinforr3rrhourlocateosr7dirnamererrorhwrf exceptions NoOceanDatajoinworkdirnamelistNamelistInserterrcrr.r@writeparsecheckrunmpirunmpigetexerenameZ fcst2stat)+rKrcycZ rtofs_atimeZ rtofs_ymdinputsoceandsrrr oceanatimeprior24Zprior48Zhr6Zhr18Zhr24ZcyctimeZ oceanncsttimeZzerolocZzerodirZzerostatnoBCZfcst1locZ fcst1loc0Z fcst1statmsgZloc0Zloc1Zloc2Zdir0Zdir1Zdir2outdirnidZparminZparmoutZ prior24_ymdinfoutfZlastleadtimetodayZstarthrZendhrrrrfind_rtofs_datas                         ,       zHYCOMInit.find_rtofs_datac Cs|jj}d}|dd}|dd}|dd}|jj}|j}t|d|} ||| |d|||d||dtd d t d d (} | d t t |t t | fW5QRXdS) Nr adjust_river adjust_tempforecast_forcing_intervalrjrkfcstz move limits to limits.standalonerzlimits.standaloner %f %f false false ) r1rrXrVrrtofs_get_forcingrrrr@rrr*) rKrr adjust_windrrinterval startdaterVenddatelimitfrrrmake_forecast_forcings*        zHYCOMInit.make_forecast_forcingc Csp|}d|_d|_zt|_t|j|j |dd}|||j j dd| | ||j }|jd|d|_ttt|jd |d |jD]\}}|j}|j |d|d q|jD]\}}|j}|j |d|d q|jD]N\}}|d ||d \}} |jd|d| |d} |j | |d|dq|jjd} dD].} |jd| |d} |jj | | | d|dqV|||jD]\} }|j d| dq|j j dd|j!j dd|d} t"| d}|#dW5QRXd|_W5QRXt$|_WnVt%k rX}z$|jdt&|fddt'|_W5d}~XYnt'|_YnXdS)ziRuns the hycom initialization. Raises an exception if something goes wrong. Returns on success.NFTrz./hycom_settings)frominfoz{forecast_exe}rDZr)rrrzline 460: what is this time:%sru{})rrrD)rirrrzarchv.%Y_%j_%H.rrz {spin_archv})rrirrz./z./limitsz./blkdat.inputz5{com}/{vit[stnum]:02d}{vit[basin1lc]}.hycom_init.donerzhycom init done for this cycle z%Unhandled exception in ocean init: %s)exc_info)(rrTrUr staterrscrub select_domainrgdeliverr create_bc_icrDicstrrrrrr2prodnamerrsrsplitrr1rrrvrrrrr@rr Exceptionrr )rKrrrDrrfromlocrrrrlocZnotabnamedonerEr9rrrruns~        z HYCOMInit.runc!cs|d}|d}|d}|d}|d}|d}|d}|d}|d } |d } |d } |d d } |} |jj}d}ttt|j dd}|dd}|dkst t | dddD]}|ddd}t |d|}t |d|}||kst t ||||dVt ||||dV| d||d|df~~~q~|dksnt t | ||d|D]}t |d|}|dkr|ddd}t |d|}| d|||dfn|}| d||dft ||||dVt ||||dV| d|||d|dfq~~~~d}|rXd }n ttt|j ddd}t|j|j|j}t d!|}||j}td"}| d#t|t|t|t|t|t|t|ft || ||d$d%Vt || ||d&d%Vt ||dD]}t |d|}||kr:|}n|}||}ttt|dd'}| d(t|t|t|t|tt|dd'ttt|dd't|f|dkr|d kr| d)t|t|t|t|ft ||||d$d%Vt ||||d&d%Vqn\|dkrj| d*t|t|t|t|ft || ||d$d%Vt || ||d&d%Vq|s|} |d+kr|jdkr|} |d+kr|jd,kr|} | d-t|t|t| t|ft || | |d$d%Vt || | |d&d%Vqd.S)/z%!Iterates over all needed input data.atmos1_datasetatmos2_dataset atmos1_flux atmos1_grid atmos2_flux atmos2_gridrrr ocean_rstrrQrirjrgdas1rr@rk)datasetitemrorzMIn hycom inputiter, request GDASVflux and master from %s at atime=%s ftime=%s%Y%m%d%Hgfsrrz"negative h=%d with ahr=%d atime=%szpositive h=%d atime=%szQIn hycom inputiter, request GFS flux and master from %s at h=%d atime=%s ftime=%sTirizIn hycom inputiter (for RTOFS input), todayatime=%s prioratime=%s epsilon=%s hwrf_start=%s hwrf_finish=%s hycom_finish=%s last_fhr_today=%sr)rrrorrrbnegokzTfhr=%s ftime=%s oceanatime=%s oceanftime=%s oceanfhr: to_fraction=%s round=%s int=%sz7For fhr=%s oceanfhr=%s use ocean_past atime=%s ftime=%sz6For fhr=%s oceanfhr=%s use ocean_now atime=%s ftime=%s`rz7For fhr=%s oceanfhr=%s use ocean_fcst atime=%s ftime=%sN)r3rXrr1rr mathceilrrVAssertionErrorrrr0rrr!rrrrrrrround)!rKZatmos1dsZatmos2dsrrr r rrrr rrQr hwrfatimeZ hwrf_startZ hwrf_finishZfcstinthZahrrorrZ hycom_finishZ todayatimeZ prioratimeZlast_fhr_todayepsilonfhrrZ oceanftimeZoceanfhrZ chosen_atimerrr inputiter sR                         zHYCOMInit.inputitercCs|jj}td|jj}|j}|jd}|dd}t|d|jj}d}d} d} d} | dkrl| dkrld} d} |d|||d ||dS) NirkirTrFzCreate subdomain from RTOFS.zSpin up analysis.)r1rrrQrVrrtofs_subset_bdry_init rtofs_spin)rKrZ thiscycleZ prevcycleZspinlenZfsecsrVendZ ocean_statusZboundary_conditions_from_rtofsZ same_domainZforce_coldstartZspinZcreate_subdomainrrrrs"     zHYCOMInit.create_bc_icc% Cs|jdddd}dtt|ddd}|d|jj|d |jj|d |jj|d |jj|d |jj |jj}|d k}|dk}d}|dkrd}n|dkrd}n|r|dkr|dkrd}n|r|dkrd}n|r |dkr |dkr d}n|r,|dkr,|dkr,d}n|rL|dksF|dkrLd}nh|r|dkr|dkrd|t |f}t |t j|n&d|t |f}t |t j|d|_|j}|d } d!} t| d"} | D]v} | } t| d#kr|d$| | fq| \ }}}}}}}}}||kr||jkrd%} ||_||_d%} qW5QRX~ ~ | sd&| t |t |jf}||t j||d'}d!} t|d"}|D]} | } t| d(kr|d$|| fq| \ }}}}}}}} }!}"}#t|}t|}t|}t| } t|!}!t|"}"t|#}#||jkr| |d)krd%} ||||f\|_|_|_|_| |!|"|#f\|_|_ |_!|_"|||_#|_$qW5QRX| sd*|t |jt |f}||t j||j%d+kst&|j'(|j%d,|j|j'(|j%d-|j#|j'(|j%d.|j$|j'(|j%d/|jtd0d1}$|$)d2j*f|j+W5QRX|d3|||| |!|"|#ft d4|j|j#|j|j$fdS)5NdomloncenloconfigrcrkihzDAN select_domain pubbasin2=%szDAN select_domain hwrfbasin2=%szDAN select_domain basin1=%szDAN select_domain basin1lc=%szDAN select_domain basinname=%s)ALEPCPWPIO)SLLSSHSPSIr'Z hat10_basinr)Z hcp70_basiniLZ hep20_basindZ hwp30_basinZ hin40_basinZ hsn50_basiniZ hsp60_basinz[Storm is in South Atlantic basin=%s lon=%s. Ocean coupling with hycom is not supported yet.zANo ocean basin available for basin=%s lon=%s. Something is wrong.Z rtofs_gloz({PARMhycom}/hwrf_rtofs.application_tableFr> z%s: ignore line %sTz/%s: could not find Application=%s RUNmodIDin=%sz!{PARMhycom}/hwrf_rtofs.grid_table rz(%s: could not find grid=%s RUNmodIDin=%s hycominit RUNmodIDin gridlabelin gridlabeloutrDrgraexport idm={idm} export jdm={jdm} export kdm={kdm} export kkdm={kkdm} export ic={ic} export jc={jc} export ijgrid={ijgrid} export gridlabelout={gridlabelout} export gridlabelin={gridlabelin} export RUNmodIDout={RUNmodIDout} export RUNmodIDin={RUNmodIDin} export gridno={gridno} z.linkfrZhwrf_rtofs_subregionrZhwrf_isubregion2avgzInvalid ijgrid value %sz{FIXhycom}/%s.%s.regional.grid regional.gridz{FIXhycom}/%s.%s.regional.depthregional.depthz#{FIXhycom}/hwrf_%s.%s.regional.gridzregional.subgridz${FIXhycom}/hwrf_%s.%s.regional.depthzregional.subdepthrzGet inputs for hours: z, cSsg|] }t|qSrr)rlrrrrrpmsz4HYCOMInit.rtofs_subset_bdry_init..rr-rqr<g @ %Y%m%d_%H%M%Sz%s/rtofs_%s_arch%s.az%s/rtofs_%s_arch%s.bz archv_in.%d.az archv_in.%d.bzsubregion.%d.inzsubregion.%d.outraarchv_in.%d.b hwrf_basin.%03d.b subregion %s %d 'idm ' = longitudinal array size %d 'jdm ' = latitudinal array size %d 'irefi ' = 1st index origin of subgrid or 0 if NOT aligned %d 'jrefi ' = 2nd index origin of subgrid 1 'irefo ' = longitude output reference location 1 'jrefo ' = latitude output reference location 0 'iceflg' = ice in output archive flag (0=none,1=energy loan model) z commands %s r TOTAL_TASKS /bin/truez bigcmd %s r)(rVrrr r]aliasbatchexercriticalrrrDr7rDr8r9linkabr1rrrrQrr3rrr@rr^r[r\rYrZappend mpiserialrenvironrBrr)rKrrr]cmdrr7rDr8r9rZhrrangecommandsrZicountZatypeihrnowfilestringtimeZarchvaZarchvbZ subregion_inZ subregion_outrEbigcmdttttotalirrrrMs~         z HYCOMInit.rtofs_subset_bdry_initc, Cs6|jj}|jdddd}t| d|}t|j d|}tdd(}|dtt|tt|fW5QRXd }|j d ||j d }|d } |d } t | rt | rt | d|dt | d|dn| d} | rd|f} t| nd|f} t| |dd} t|j|j|jddd}td|}|d}d| |f}d| |f}|j|dt|t|t|f|dkrd} t| | stj| |||dd|tdd.}||}t|d }t|}W5QRX|d!t|t|t||tt||d"d#tt t||d"d#t|ft t||d"d#|krv|d$|!d%d&n4|d'|d(|d(f|"||!d)d&|#d&d*d+d+gd,d,gd,d-gd.d.gg}|D]\}}|#d/||q|$d0d}d}|$d1d}|$d2d}d3}|%||d|||d3||$d4d5}t&| d6d7|d"d8t&| d9d:|d"d8t&| d;d<|d"d8t'j(j)d=|d"d>}W5QRXt**d?D]} t| d}|d@|t+dAD]}!|}"q|"}#t|#dB}$dC|"|$f} || |$dDkr8dE| |"f} || tj,| t|$}%| ddFd }&| }'|%dG}(|%dH})t dI|&|(d"|dt dI|'|)d"|dW5QRXq|-d.dJdKD]}|#d/||q|.dL}*|/|*}+t&|+dMd"|dNt&|+dOd"|dNt&|+|*d"|dNt0j12dPr$|!dQdRt3dSd"|dTdS)UNcycling_intervalr r$r%rkrrrzM{oldcom}/{old_out_prefix_nodate}.{aYMDH}.{RUNmodIDout}.spin_restart_warmstart)rorD.a.b restart_in.ar restart_in.bexpect_cold_startzC%s.[ab]: missing or empty (no prior cycle). Will cold start ocean.z2%s.[ab]: missing or empty. Will cold start ocean.rr-rrraz%s/rtofs_%s_restart.az%s/rtofs_%s_restart.bz,prior24=%s filestringtime=%s restart_in_a=%sz(No rtofs restart file found. Giving up.z restart_pre.a restart_pre.br>zjSOME STRING FOR WHICH TO GREP - ryd=%s spinstart=%s ryd-spinstart=%s to_fraction(...)=%s abs=%s epsilon=%sTrz?Restart is at right time. Move restart_pre to restart_forspin. restart_prerestart_forspinzERestart is at wrong time (%s instead of %s). Will use archv2restart.rrs restart_inr^r_z regional.maskz relax.rmuz-{FIXhycom}/hwrf_{RUNmodIDout}.{gridlabelout}.Zparameterized_windsrranalZ hycom_procsZ90zJ{PARMhycom}/hwrf_{RUNmodIDout}.{gridlabelout}.fcst.blkdat.input.standaloner)rrz9{PARMhycom}/hwrf_{RUNmodIDout}.{gridlabelout}.ports.input ports.inputzG{PARMhycom}/hwrf_{RUNmodIDout}.{gridlabelout}.patch.input.{hycom_procs} patch.inputnestrrzhwrf_basin.*.bzhsk--%sr5rjzhsk --- %s: bline= %s zX%s: hycom date before Jan 10, 1901. Probable parser error or corrupted data. Line = %sznest/archv.%Y_%j_%H.aznest/archv.%Y_%j_%H.bz../znest/rmu)z forcing.chlzforcing.offluxforcing.riversz relax.sshZveldf2Zveldf4Ztbaricz iso.sigmahwrf_rtofs_reloc_forecastZocean_executablerrz forecast.exezforcing.surtem.azforcing.surtemzforcing.surtmpokrr)4r1rr:rrQr@rrr*rrDrrconfboolr rrr3r!rrrrrrrOceanRestartMissingrestart2restartreadlinerr'rabsmoveab archv2restartrgrXrrrYcdrglobrOceanDataInvalidcopyabrrrr7existsr),rKrrrtZ prior_cycZ spinstartrrZrestart_for_spinZ restart_aZ restart_bexpectrrrnrroZ restart_in_aZ restart_in_bbfsplatZrydfZrydlinkmeZlfromZltorrrmodeprocsZd1Z basinfilersZblineZbsplitZ hycomdateZ normaldateafilebfileZ nestafileZ nestbfile exec_nameZthe_execrrrr s                                         "     zHYCOMInit.rtofs_spinc Cs*|}td}td}|jj}|} |j} tdddD]} || |kr| j||| |d} | j||| |d} t| rt| r|dt |t |t |t |t | t | f| | fS| d| | fn | d t |t | t |f| |} q6d |||| d f}| |t j|dS) Nrrurrqrorz%s %s %s %s => %s %sz%s %s: do not exist or empty %s<=%s+%sz Cannot find %s %s+%s for time %srrrr1rrrrrrrrrrrrr)rKatmosdsZfluxgridtimersixhrsratime0rorinputitryZflocglocrrrrgetges.s>    zHYCOMInit.getgesc Cs|}td}td}|jj}|}|j} d} tdddD]} |||kr| j||||d} | dkrz| j||||d} d} t| r|dt |t |t |t | f| S| d | n | d t |t |t |f||}q:d | d | f}| |t j|dS) Nrrurrrqrrz%s %s %s => %sz%s : do not exist or emptyrz1Cannot find file for time %s; first file tried %srr)rKrrrrrrrrorZglocsetrrZgloc0rrrrgetges1Hs6   zHYCOMInit.getges1c7Cs|dkr,d}|d}|d}|d}n.d}|d}|d}|d}td d |jj} t|d } td } t||d |d} d tt| g} || }|| }|| }t t | d}t t | d}t t | d}t t | d}t t | d}t t | d}t t | d}t t | d}t t | d}|dkrjd}nd}ddddddddddddd dddd!dddd"d#ddd$d#ddd%d|dd&d|dd'd|dd(d|dd)d|dd*d|dddddd+dddd,dddg}|}|j }||kr.| ||||\}}|d-d.} |d-d/}!t| d0|d1t|!d0|d1t|d2krt|!d3d0|d1t|d4d5||!d3f|d6nt||!d3|d0d7t||!d3|d6}"d8}#|D]x}$|"D]h}%|%|$d9d:kr|%|$d;d:kr|%|$d<d:kr|#|%d=7}#|d>|!d3|%fqq|d?|#t||!d3d@dA|!dBf|#>|d6t|!dB|!d0|dC|dDt|}&|&dEkr|dFt|||d6}'d8}#|'D]4}%|%dGd:kr|dH|%|#|%d=7}#q|#s>dI|f}(||(tj|(|dJ|#t||d@dA| f|#>|d6t|| | dKf|d6n|&d2krJt|||d6}'d8}#|'D]4}%|%dGd:kr|dH|%|#|%d=7}#q|#sdI|f}(||(tj|(|dJ|#t||d@dAdL| f|#>|d6t|| | dKf|d6n dM|f}(||(tj|(t|!|!dNd0|dCt||!|d6})|dO|)t|dP|)dQdR| | dK|!f|d6t||!|!dKft||!dSd0|dCt||!dS|!dTf| dU|d-|!dS| ||f|| 7}qtd dV}*|*d8 | W5QRXtdWdV}+|+dX||fW5QRX|dkrvtdYdZtd[d\td]d^td_d`tdadbtdcddtdedftdgdhtdidjtdkdltdmdntdodptdqdrtdsdttdudvtdwdxtdydztd{d|td}d~tddtddV},|,dW5QRXt t!| d}-t"}.t#d2dD]L}/d|/}0d|/}1t|0dV}2|2d|/W5QRX|.|-|0k|1kq|dt$|.t%|.d:}3ttj&d}4|.d2dD]}5|3t%|57}3q>t'|.}6t#|6|4D]}/|3t%t!d7}3qd|dt$|3tt(|3|d6|)|dS)Nrrjrrrrr r  listflx.datlistflx.dat.standalonerkru%d cnvgribcopygbcopygb2 nco_wgrib2wgribgrbindex grb2index ofs_getkpds ofs_getgds2 hour fcstaveUFLXsurfaceFLUXLEVELTYPEVFLXTMP2 m above groundrSPFHPRATEUGRD10 m above groundVGRDSHTFLLHTFLDLWRFULWRFDSWRFUSWRFPRESLANDrz.pgbges.sfcflxTrr.in2z-g12z-p32rrrXr-rrrr %s: keep(sf): %s KEEP(SF): -i-gribz.out2rzSubset pg file.rzpgfile is GRIB2PRMSLz keep (pg): z#%s: could not find any PRMSL field.z KEEP(PG): .idxz-oz%s: is not GRIB1 nor GRIB2z.before.copygbzofs_getgds2 says gds=z-gz-i0z-az.rawz.raw.idx%s %s %s %s %s r intp_pars.dat &intp_pars avstep = %d., ! averaging fluxes (in hours) mrffreq = %d., ! frequency of MRF fluxes (in hours) = mrffreq for no averaging flxflg = 15, ! Type of HYCOM input (=4 => nhycom=7 and =5 => nhycom=8) dbgn = 0, ! debugging =0 - no dbg; =1,2,3 - add output avg3 = 2, ! if avg3 = 1, then averaged fluxes are converted to instantaneous fields wslocal = 0 ! if wslocal = 1, then wind stress are computed from wind velcoities / forcing.airtmp.aforcing.airtmp.a.standaloneforcing.airtmp.bforcing.airtmp.b.standaloneforcing.precip.aforcing.precip.a.standaloneforcing.precip.bforcing.precip.b.standaloneforcing.presur.aforcing.presur.a.standaloneforcing.presur.bforcing.presur.b.standaloneforcing.radflx.aforcing.radflx.a.standaloneforcing.radflx.bforcing.radflx.b.standaloneforcing.shwflx.aforcing.shwflx.a.standaloneforcing.shwflx.bforcing.shwflx.b.standaloneforcing.surtmp.aforcing.surtmp.a.standaloneforcing.surtmp.bforcing.surtmp.b.standaloneforcing.tauewd.aforcing.tauewd.a.standaloneforcing.tauewd.bforcing.tauewd.b.standaloneforcing.taunwd.aforcing.taunwd.a.standaloneforcing.taunwd.bforcing.taunwd.b.standaloneforcing.vapmix.aforcing.vapmix.a.standaloneforcing.vapmix.bforcing.vapmix.b.standaloneforcing.wndspd.aforcing.wndspd.a.standaloneforcing.wndspd.bforcing.wndspd.b.standalonejpdt_table.dat8 8 0 0 8 0 0 0 0 8 8 8 8 0 0 0 hwrf_gfs2ofsr5 gfs2ofs.%d.ingfs2ofs.%d.out%d COMMANDS %s rbrc BIGCMD %s )*r3rrr1rrrr rrdr/rrrrrrrrrunstr splitlinesrErrrrrrrrhr@rrrerrrrirjrBrofs_timeinterp_forcing)7rKdate1date2rrihoursr atmos_flux atmos_gridrhoursteprnmlistflxrdate1rdate2stopdaterrrwgrib2rrrrrTYPExrLdateirsfZpfZpgfileflxfilesfindexreindexfltrFZpgverZpgindexrZkgdtlistflxfippdfjr rlrs gfs2ofs_in gfs2ofs_outrErprqcrrrrrofs_seasforce3esv                                                                        zHYCOMInit.ofs_seasforce3c*Cs|dkr,d}|d}|d}|d}n.d}|d}|d}|d}tdd|jj} t|d} td } t||d|d} d tt| g} || }|| }|| }t t | d }t t | d }|dkrd }d}nd}dddddddddddddddddddddddddddddd|ddd|ddd|ddd|ddd|dd d|dddddd!dddd"dddd#d$ddg}|}|j }||kr4| |||}|d%d&}t|d'|d(t||d)|d'd*t||d)|d+}d,}|D]x}|D]h}||d-d.kr||d/d.kr||d0d.kr||d17}|d2|d)|fqq|d3|t||d)d4d5|d6f|>|d+t||d6d7d8d9d:d;d<|d=f|d+t|d=|d'|d>t|||d?f| d@|d%|dA|dAf|| 7}qtddB}|d,| W5QRXtdCdB}|dD||fW5QRX|dkr|tdEdFtdGdHtdIdJtdKdLtdMdNtdOdPtdQdRtdSdTtdUdVtdWdXtdYdZtd[d\td]d^td_d`tdadbtdcddtdedftdgdhtdidjtdkdltdmdB}|dnW5QRXt t| do} t}!tdpdqD]L}"dr|"}#ds|"}$t|#dB}%|%dt|"W5QRX|!| |#k|$kq|dut|!t |!d.}&ttj!dv}'|!dpdD]}(|&t |(7}&qDt"|!})t|)|'D]}"|&t tdw7}&qj|dxt|&tt#|&|d+|$|dS)yNrrjrr r rrrkrurrrrrrrrrrrrrrrrrrrrrrrrrrz sea levelrrTrrrrr-rrrrrrrrrz.in3z-new_grid_windsZearthz -new_gridZgaussianz 0:1440:0.25z 89.75:720z.in4rrrnonerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr Z hwrf_gfs2ofs2rr5r r r rrbrcr)%r3rrr1rrrr rrdr/rrrrrrrrrErrrrrhr@rrrerrrrirjrBrr)*rKrrrrrrrrrrrrrrrrrrrrLr rr!r"r#r$r%rFr&r'r(r rlrsr)r*rErprqr+rrrrrofs_seasforce4Fs                                                        zHYCOMInit.ofs_seasforce4c Csd}d}d}t|d}|}|D]*}|dkr$|ddkr$|dd}qPq$|dkrnd|f}tj||||D]}|d7}||r||d7}q|W5QRX|||||fS)Nrr>spanrz(%s: could not find data records in file.r)r@tellrErrrseek) rKr num_timesblinesanamerstartrFrrrrofs_forcing_infos$      zHYCOMInit.ofs_forcing_infoc Cstjjd|ddddD]X}dD]N}d|d|}tj|r d|d|}|d ||ft||q qW5QRXtt t | d }d d d dddggd d ddddggg}|D]\}} d|f} | | \} } } } | D]}d|f}d|f}| |\} }}}|| | ||||g}dd|D}d |d}|d|t|ft|d}||W5QRXt||k|dqqdS)NtempTr) rxryrzr{r|r}r~rrrrrz ../forcing.ruforcing.z Move %s => %sZhwrf_ofs_timeinterp_forcingryrxrzr}rrr~rr{r|ztemp/forcing.%s.bztimeinterp_forcing.%s.incSsg|] }t|qSrr`rlrsrrrrpsz4HYCOMInit.ofs_timeinterp_forcing..rz %s: write %srr)rYrrrr7rrrrdrrrr6rrr@rr)rKrZofieldrrr[r\rZxfieldZifieldZofieldsifile_r2iheadtfileofile num_framesZoheadsnamertfrrrrs8        z HYCOMInit.ofs_timeinterp_forcingc Cs|d\}}}}|d\}}}}||||g}ddd|Dd}tdd}||W5QRX|dd |d } tt| dk|d dS) Nzforcing.surtem.brrcSsg|] }t|qSrr`r9rrrrpsz1HYCOMInit.ofs_correct_forcing..zcorrect_forcing.inrzforcing.airtmpzforcing.airtm1ofs_correct_forcingr)r6rr@rrrrr/) rKrr;r?r<r@r4rZcfifrBrrrrBs    zHYCOMInit.ofs_correct_forcingc! Cs|jj}tddd|dtdd}|dW5QRXt|j d|}|d}|jjd}d }|d \}}} } |d \} } } } |d \} } } } d }d}d\}}}}tdd}|D]}| ddkr| }t |d}|d 8}t |d}|d 7}| ddkr| }t |d}|d 8}t |d}|d 7}qW5QRXdt |j t |j||| ||||||g }ddd|Dd}tdd}||W5QRXtt|d}t|dk|dd}|||g}ddd|Dd}td d}||W5QRXtt|d!}t|d k|dt|d}|}|dd"}W5QRXtd#d }|d$|| | | | |fW5QRXtt|d%} t| d#k|ddS)&N ../tmpvittrackTrrz000 000 000000 00000000 0000 0000 00000 000 000 0000 0000 0000 00 000 0000 0000 0000 0000 0 0000 0000 0000 0000 00 0000 00000 0000 0000 0000 0000 rkrrrrrz STORM.xy.datzfwind4d.STORM.bin)NNNNregional.grid.br>zulat:rrjr|zulon:rcSsg|] }t|qSrr`r9rrrrpBsz-HYCOMInit.ofs_windforcing..zfwind.inrhwrf_ofs_fwindrz frc4hycom.bincSsg|] }t|qSrr`r9rrrrpKsz wind2hycom.inhwrf_ofs_wind2hycomzcorrect_wind.inz frc4hycom.bin forcing.wdspd1.b,forcing.tauew1.b,forcing.taunw1.b forcing.wdspd1.a,forcing.tauew1.a,forcing.taunw1.a forcing.wndspd.b,forcing.tauewd.b,forcing.taunwd.b %d %s,%s,%s %d %s hwrf_ofs_correct_wind)r1rrr@rrrQrr6rErrr r[r\rrdr/rrr)!rKrrrmZfdateZfdate1intvlr3r2ZnrecordsZsname1r;Zsname2Zsname3ZdatfileZbinfileZlatminZlatmaxZlonminZlonmaxrgbfrFrrZfwifrFZbinfnameZwhifrGdfZnrcdsZcwifrIrrrofs_windforcing"sp        (       zHYCOMInit.ofs_windforcingcCs0|j}|tk r||kr|St|j|ddkS)Nrg{Gz?)blkdat NO_DEFAULTr)rKZflagnamedefaultrNrrrblkflages zHYCOMInit.blkflagc  Cs|dd} |dd} |dd} |dd} |dt|t|t|fd} | sl| sl| sl|dnd } |d t|d d d |dt|ddd |dt|ddd |dt|ddd |d||||||r||| d kr|dd|dd } n |d|d krtdd}| }|d}W5QRX|dkrj|dn| ||dkrdd gd!d"gd#d$gd%d&gd'd(gd)d*gd+dgd,d!gd-d#gd.d%gd/d'gd0d)gg }|D](\}}|d1||ft ||q| S)2NpriverFflxflgwndflgatpflgzIANOTHER STRING FOR WHICH TO GREP - mode=%s adjust_temp=%s adjust_wind=%s rqzNo atmospheric forcing createdrzCreate atmospheric forcing.z({FIXhycom}/ofs_atl.ismus_msk1760x880.datzismus_msk1760x880.datTrz){FIXhycom}/ofs_atl.ismus_msk3072x1536.datzismus_msk3072x1536.datz({FIXhycom}/ofs_atl.ismus_msk1440x721.datzismus_msk1440x721.datz({FIXhycom}/ofs_atl.ismus_msk1440x720.datzismus_msk1440x720.datz;{FIXhycom}/hwrf_{RUNmodIDout}.{gridlabelout}.forcing.riversrz"Station River Forcing Files copiedz$River Forcing Files are not employedrCr>rSz0Hurricane too shallow to run parameterized windsrrzforcing.wndspd.a.originalrzforcing.wndspd.b.originalrzforcing.tauewd.a.originalrzforcing.tauewd.b.originalrzforcing.taunwd.a.originalrzforcing.taunwd.b.originalzforcing.wdspd1.azforcing.wdspd1.bzforcing.tauew1.azforcing.tauew1.bzforcing.taunw1.azforcing.taunw1.bzRename %s to %s)rQrrrrr.rBrr@rrrMrr)rKZsrtdaterrJrrrrrrRrSrTrUZforcingfilesmadermrdepthZrenamemeifromZitorrrrlsj                   zHYCOMInit.rtofs_get_forcingcCsN||}tjj|d|dd|dtjj|d|dd|ddS)NrvTrrw)rrYrZrrrKZsfromr\r[rrrrs zHYCOMInit.copyabcCs<t|d|dd|dt|d|dd|ddS)NrvFrrw)rr)rKr[r\rrrrszHYCOMInit.moveabcCsN||}tjj|d|dd|dtjj|d|dd|ddS)NrvTrWrw)rrYrZrrrYrrrrgs zHYCOMInit.linkabc Cs|jdk r|jStt}||_|d}t|D}|D]8}td|}|r8|d\}}t |}|| |q8W5QRX|jS)Nz?{PARMhycom}/hwrf_{RUNmodIDout}.{gridlabelout}.fcst.blkdat.inputz^\s*(\S+)\s*'\s*(\S+)\s*' = r) ra collections defaultdictrrr@rArBrCrrh)rKrrrErFrGvalZkwdrrrrNs     zHYCOMInit.blkdatcCs|jddS)Nbaclinr)rNrKrrrr]szHYCOMInit.baclinc Cs|dd|dd|dd|dd|j}|ddtdrX|dd ntd rl|d d td d |dtdd |dtdd |dtdd |dtd d"}|d|j|j|j|fW5QRXt | dd k}t ||ddS)Nz:{FIXhycom}/hwrf_{RUNmodIDout}.{gridlabelout}.regional.gridr^z;{FIXhycom}/hwrf_{RUNmodIDout}.{gridlabelout}.regional.depthr_zhwrf_basin.000Z archv2r_inzrestart_forspin.br~rr{r}zarchv2restart.inTrzarchv2restart.outz restart_out.bz restart_out.ara=archv2r_in.b restart_in.a restart_out.a 20 'iexpt ' = experiment number x10 (000=from archive file) 3 'yrflag' = days in year flag (0=360J16,1=366J16,2=366J01,3=actual) %d 'idm ' = longitudinal array size %d 'jdm ' = latitudinal array size 2 'kapref' = thermobaric reference state (-1 to 3, optional, default 0) %d 'kdm ' = number of layers 34.0 'thbase' = reference density (sigma units) %f 'baclin' = baroclinic time step (seconds) Zhwrf_archv2restartr) rgr]rrr@rr[r\rFr/rr)rKrr]Zarinrkrrrrs8    zHYCOMInit.archv2restartc Cs|jj}tdd6}|}t|d} |} t| d} W5QRXt|d} d|d|j f} | || | |j |j |j |j | df| dk}t||d t| d|d |d d \}}}t|d }t|d}|d}|d}|d||f~~t| dd}d }|r|}|rt|dkrLq|d}|d}|dd}t|dkrqd|ddt|dt|df}||q&W5QRXW5QRXW5QRXdS)NrEr>rZhwrf_rtofs_restart2restartz restart.%s.%srrvz.b.onerTr)&iUiSrz z%s %s r_z min, max =r-rz%s %16.7E%16.7E r)r1rr@rrr r/rrr9rYrZr[r\rrrrrBreplacer)rKZin_aZin_bZout_aZout_brrrKZidm_moreZ idmglobalZjdm_moreZ jdmglobalexrsrkncZwcbZtwcZroutfZglobalfline1line2ZregionfZgoZglinerlinerZolinerrrrsJ         zHYCOMInit.restart2restart)NrO)'__name__ __module__ __qualname__rMrSrWrrrrrrrrrpropertyrrVrr rrr,r.r6rrBrMrOrQrrrrgrNr]rr __classcell__rrrerrIBsRJ +>](t  c~b( C D  .rIc@sHeZdZddZeddZddZddZd d Zd d Z d dZ dS) HYCOMInitercCs||_||_dSrJ) hycomfcstr)rKrlrrrrrS*szHYCOMIniter.__init__cCs|jjSrJ)rlr6r^rrrr6-szHYCOMIniter.hycominitc Csr|j}|j}||j||js.|ddSt}|jD]\}}| |q>|j D]\}}| |q\d}|D]}d}t j |s|d|fn| ||d||jf|js|d|jfqx|js|d|jfqxt j |js|d|j|jfqx|d|j|jf|d 7}qx|t|kr`|d |t|fd S|d dSd S)zThis subroutine is run by the check_init job and checks to see if the initialization has succeeded. It returns True if the inputs are all present, and False if they're not.(Hycom init says we will not run coupled.Trz?{oldcom}/{oldvit[stormid3lc]}.{RUNmodIDout}.warm_restart.([ab])z%s: product not availablez%s: %s: product is deliveredz%s: no path set in databasez%s: %s: file does not existrz0Have only %d of %d products. Ocean init failed.Fz#Rejoice: we have all coupled inputsN)rlr6rrrUrrrr2rhrrr7isfilerrri availabledidrrB) rKrZhfhiprodsrrcountwarm_rstrrrcheck_coupled_inputs1sP        z HYCOMIniter.check_coupled_inputscCsR|r||S|jj}||j||js8|ddSt}|j D]\}}| |qH|j D]\}}| |qf|st j jd|dt j jd|d|jjj}|D]}|jr|jrtj|jsd|jt|jt|jf}||tj|td|j} | s&t|j|j|ddq| \} } t!| } t"d |} |#d t| t| ftj$"| d | } | %d | }t|j||ddq|&d }t'|}|dkst(dD]}|j&d|d}d}t))|D]F}|d7}|*|}|||d}t+dd|}t||d|dq|#d|||dkst(q|&d}t j,j-#d|f|dkrtj.drd}|d}|d}t j,j-d |t j /|rt j /|rt|d!|dt|d"|dt j,j-#d#|fnt j,j-d$|f|sN|jj0}|dk st(|js$t(|js0t(t1|j}|2||3|dS)%zCalled from the forecast job. If just_check=True, this calls check_coupled_inputs. Otherwise, this links all hycom inputs to the local directory.rmTrrZARCHPz0%s: input not present (location=%s available=%s)zhwrf_basin.0*(\d+).([ab])rrz"Link hour %s relative to cycle %s.rkznest/archv.%Y_%j_%H.z {out_prefix}.rH)rtofsrforcingz{com}/{out_prefix}.{part}*)partrrNz.*\.restart\.([^/]*)z restart_in.\1rWz%s: %d files linked run_wavez wave_flag=%syesz{oldcom}z8{oldcom}/{oldvit[stormid3lc]}.{RUNmodIDout}.warm_restartrvrwzrestart_in: %s is found rxryz%s: warm start for HYCOMzrestart_in: %s is missing )4rurlr6rrrUrrrr2rhrrYrZmakedirsr1rrorirr7rrprrrrOceanInitFailedrArBrrrCr rrnumericsrrrBrrrfindsubrr isdirrrgrHlink_hycom_fixlink_hycom_parm)rK just_checkrrqrrrrrrrGhrrrZ hycomtimermZname1opnoprxglobbynfoundr7Zipref localnameZ finalname wave_flagrtZ warm_rst_aZ warm_rst_bhsprodrDrrrlink_coupled_inputshs                     zHYCOMIniter.link_coupled_inputscCsT|j}ddddd}|D].\}}|jjd||d}tjj|||dd q dS) Nrrr profile.input)zfcst.blkdat.inputzpatch.input.90rrz/{PARMhycom}/hwrf_{RUNmodIDout}.basin.{PARMBASE})rDZPARMBASETr)r6rr2rrYrZr)rKrDrmineZparmbaserparmfilerrrrs zHYCOMIniter.link_hycom_parmc CsH|st|j}|jjd|d}tddddddg}d }d }t|D]}tj|}| d } d } |d 7}| d kr| d } | d krt j j ||| dd|ddd} n4|| dd} | |krt j j |d| |ddd} | s| d||fqH|d 7}qH| d||t|ft j j dd|ddt j j dd|dddS)Nz%{FIXhycom}/hwrf_{RUNmodIDout}.basin.*rzchl.azchl.bzofflux.azofflux.bzrivers.azrivers.brrwFrzbasin.rTrr8z%s: not linking %sz2Linked %d of %d HyCOM fix files for RUNmodIDout=%sz../relax.rmu.az nest/rmu.az../relax.rmu.bz nest/rmu.b)rr6rrrrrr7basenamerErYrZrrr) rKrDrrZ forcewantednZnlinkedr7rfdZlinkedZbdZ forcetyperrrrs@      zHYCOMIniter.link_hycom_fixcCst|ts$tdt|jt|f||ds:t| d}|dkrRd}nd}| |}| |}|szt j dt||S)zReturns an MPIRanksBase to run the executable chosen by the initialization. This function must only be called after link_coupled_inputszDThe ranks argument to make_exe must be an int. You provided a %s %srDryrzhwrf_rtofs_reloc_forecast_way3rzCThe forecast_exe option was not specified in the ocean status file.)rr TypeErrortyperfrread_hycom_init_varstvhaverr3rrrrOceanExeUnspecifiedr)rKr6r/ranksrhyexecrZwantexerrrmake_exes    zHYCOMIniter.make_exeN) rfrgrhrSrir6rurrrrrrrrrk)s 7f  rkcs>eZdZdZd fdd ZddZed d Zd d ZZ S)WRFCoupledHYCOMz7This subclass of CoupledWRF runs the HyCOM-coupled WRF.Tauxhist1Nc  st|ts$tdt|jt|ftt|j||||||f| ||_ t ||} | dddd| | dd} | dd d | | ||d } | d krd } nd} | |_dS)NzcThe hycominit argument to WRFCoupledHYCOM.__init__ must be a HYCOMInit object. You passed a %s %s.coupler hwrf_wm3c wm3c_ranksr ocean_ranksroceanr&Z hycom_ranksryrzrr)rrIrrrfrrRrrS _hycominitrkcouple _add_waverX couplewrfr3Z forecast_exec)rKrbr1rcwrfrkeeprunwrfdiag_streamr6rdZ hycominiterrrrrerrrSs.    zWRFCoupledHYCOM.__init__c Cs,|jj}|j|j}}|}|sDd|jf}||tj ||shd|f}||tj |d}t |dn}|D]b}t d|} | r| d\} } || | |d|| t| f|d7}q||d||fq|W5QRX|dkrd |f}||tj |n|d ||fdS) Nz"%s: no location for hycom_settingsz+%s: not available yet according to databaserr>zexport (\S+)=(\S+)\s*$z%s: set %s = %srz%s: unrecognized line "%s"z%s: no variables found in filez%s: set %d vars)r6rgrorirrprrrr|r@rArBrCtvsetrrr) rKravrrrrKrErFrGvarr\rrrr0s4             z$WRFCoupledHYCOM.read_hycom_init_varscCs|jS)zReturns the HYCOMInit object.)rr^rrrr6MszWRFCoupledHYCOM.hycominitcCsdS)zp!Internal function for adding wave coupling. This must be implemented by a subclass. @protectedNrr^rrrrRszWRFCoupledHYCOM._add_wave)TrN) rfrgrh__doc__rSrrir6rrjrrrerrs rcs0eZdZdZfddZddZddZZS) HYCOMPostzRRuns the ocean post-processor on the HyCOM output, in parallel with the model.c s(tt|j|||f|||_||_dSrJ)rRrrSrVr&)rKdsr1rcrVr&rdrerrrShszHYCOMPost.__init__c4 Cs|}t|_t|j|j |dd}|j}|d}|d}|d}|dd}|d}t |d } | D]} t d | } | rt | d } t d | } | rt | d } t d | } | rt | d }t d| } | r| d }t d| } | rr| d }qrW5QRX|d| | |||fd|||f}tjj|ddd|dtjj|ddd|dd|||f}tjj|ddd|dtjj|ddd|d|jj}|d|dtj|drtd |}|d}d|}|dt|tjd|ds|d }d!d|dg}t||d|d"|d}d!d|dg}t||d|d"||||d }d#}|||krt|d$|}|d}|jd%ks|jd&ks|jd'ks|jd(krd)|}n8|jd ks6|jd*ks6|jd+ks6|jd,kr>d|}d!|d}d }d-}||krtjd|rvqn(|d.}|d/t||ft d0qT||kr|!d1t||ft"d2||f}td|d|d3|dd|d"td|d|d3|dd|d"|d4kr|jd ksX|jd*ksX|jd+ksX|jd,kr|d5t|d!d|dg}d!d|dg}|d6t|tjj|d7d|dtjj|d8d|dt d9d:6}|#d;t |j$t |j%t |j&t |j|fW5QRX|d<d=|} |d>kr<|d krkrNd }dP}||krNd!dQ}tjdQr"dR}1dS|}2td|1d|d3|2dd|d"td|1d|d3|2dd|d"qNn(|d.}|d/t||ft dTqd.}||krt|d$|}|d}d)|}3tjd|3dUrtd|3dU|d3|3dUd|d"|d.7}qR|dVW5QRdWSQRXdXS)Yz5Called from the ocean post job to run the HyCOM post.Trz {FIXhycom}z {PARMhycom}z{out_prefix_nodate}rynorhr>z^export idm=(.*)$rz^export jdm=(.*)$z^export kdm=(.*)$z^export gridlabelout=(.*)$r?z>POSTINFO- idm=%d jdm=%d kdm=%d gridlabelout=%s RUNmodIDout=%s z%s/hwrf_%s.%s.regional.gridrvzregional.grid.arWrwrEz%s/hwrf_%s.%s.regional.depthzregional.depth.azregional.depth.bzfind z{com}/{out_prefix}.spin_archv.bz%Y_%j_%Hzarchv.%szWill move to runwrf %s z ../runwrf/z{com}/{out_prefix}.spin_archv.ar-rg?rkrjr4zarchs.%srrrirzCannot find file %s %d times<z&Cannot find file %s %d times - exitingz hwrf_%s.%sr)Z rtofs_hat10Z rtofs_hep20Z rtofs_hcp70z%Will create ocean 3z products for %s z"Will create ocean products for %s zarchv.azarchv.bZtopzfilerzarchv.b HYCOM %d 'yyyy' = year %d 'month ' = month %d 'day ' = day %d 'hour ' = hour %d 'verfhr' = verification hour zDo Volume HEREz%s/hwrf_rtofs.archv2data_3z.inrzz#%s/hwrf_rtofs.archv2data_3z_way3.inZ tempinfilew)z&idmz&jdmz&kdminfileZhwrf_ofs_archv2data3zZhwrf_ofs_archv2data3z_way3rZpartialbr|r5z$%s.%04d%02d%02d%02d.hwrf_%s_3z.f%03dzfort.51z fort.051az{com}/Frr&z../runwrf/restart_outR.brtz%s.warm_restartrz.txtzfinishing up hererqN)0rr rrrrrVrr3r@rArBr rCrrYrZrr1rrr7rrrrrrrrrrsleepr exceptionrrrrrr2r`rdr/rrrr)4rKrrrVZFIXhycomZ PARMhycomZopnrZhycomsettingsfileZhsfrFrGr[r\rFr9rDr[stimeZarchtimeZarchtimestringZnotabinr\ZnavtimerlogfileZ timessleptsleepmaxZnotaboutrrrr filenamesZifffnameZfilenZ replacementsrsrcZtargZ archv2datarsibpboutfileZoutfileaZoutfilebobZrstRinZrstRoutZarchstxtrrrrmsR                   0 0   && 0 $   &  "    .  &     &&  &  z HYCOMPost.runcCs|}t|_t|_dS)zCalled from the unpost job to delete the HyCOM post output in preparation for a rerun of the entire post-processing for the cycle.N)rr rr )rKrrrrunrunD szHYCOMPost.unrun)rfrgrhrrSrrrjrrrerrXs  Xr)9rrAsysrrr!rr#rZ subprocessprodutil.fileoprY produtil.log hwrf.numericsr hwrf.input hwrf.hwrftask hwrf.couplinghwrf.exceptionsrshutil produtil.cdrrrrrrprodutil.datastorerr r r produtil.runr rrrrrobjectrOrr%r'r*r=rHhwrftaskHWRFTaskrIcouplingComponentIniterrk CoupledWRFrrrrrrsHH    thH