From 71bba10a712ac7fe3edf6a16abbdaad439166bac Mon Sep 17 00:00:00 2001
From: lkugler <lukas.kugler@gmail.com>
Date: Thu, 18 Jan 2024 18:17:33 +0100
Subject: [PATCH] write the link_to_prior right after assimilate

---
 dartwrf/assimilate.py    | 8 ++++++++
 dartwrf/prep_IC_prior.py | 5 -----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/dartwrf/assimilate.py b/dartwrf/assimilate.py
index 33b3264..cd8d96b 100755
--- a/dartwrf/assimilate.py
+++ b/dartwrf/assimilate.py
@@ -399,6 +399,13 @@ def archive_filter_diagnostics(time, f_out_pattern):
     copy(cluster.dart_rundir + "/obs_seq.final", f_archive)
     print(f_archive, "saved.")
 
+def txtlink_to_prior(time, prior_init_time, prior_path_exp):
+    """For documentation: Which prior was used? -> write into txt file"""
+    os.makedirs(cluster.archivedir + time.strftime('/%Y-%m-%d_%H:%M/'), exist_ok=True)
+    os.system('echo "'+prior_path_exp+'\n'+prior_init_time.strftime('/%Y-%m-%d_%H:%M/')
+                +'\n'+time.strftime('/wrfrst_d01_%Y-%m-%d_%H:%M:%S')+'" > '
+                +cluster.archivedir + time.strftime('/%Y-%m-%d_%H:%M/')+'link_to_prior.txt')
+
 def get_obsseq_out(time):
     """Prepares an obs_seq.out file in the run_DART folder
     If `exp.use_existing_obsseq` points to an existing file, then this is used.
@@ -584,6 +591,7 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
     filter()
     archive_filteroutput(time)
     archive_filter_diagnostics(time, pattern_obs_seq_final)
+    txtlink_to_prior(time, prior_init_time, prior_path_exp)
 
     if prior_inflation_type == '2':
         archive_inflation_2(time)
diff --git a/dartwrf/prep_IC_prior.py b/dartwrf/prep_IC_prior.py
index 8ad84de..95efb7f 100755
--- a/dartwrf/prep_IC_prior.py
+++ b/dartwrf/prep_IC_prior.py
@@ -22,11 +22,6 @@ Ad 2: copies wrfrst to run_WRF directory
 def create_wrfrst_in_WRF_rundir(time, prior_init_time, prior_path_exp):
     """copies wrfrst to run_WRF directory (for next WRF run)
     """
-    # for documentation: Which prior was used? -> write into txt file
-    os.makedirs(cluster.archivedir + time.strftime('/%Y-%m-%d_%H:%M/'), exist_ok=True)
-    os.system('echo "'+prior_path_exp+'\n'+prior_init_time.strftime('/%Y-%m-%d_%H:%M/')
-                +'\n'+time.strftime('/wrfrst_d01_%Y-%m-%d_%H:%M:%S')+'" > '
-                +cluster.archivedir + time.strftime('/%Y-%m-%d_%H:%M/')+'link_to_prior.txt')
 
     for iens in range(1, exp.n_ens+1):
         clean_wrfdir(cluster.wrf_rundir(iens))
-- 
GitLab