From efe6b41ff8f3590894c074aae4abd911503605de Mon Sep 17 00:00:00 2001
From: Niels Fuchs <niels.fuchs@uni-hamburg.de>
Date: Mon, 11 Apr 2022 01:07:15 +0200
Subject: [PATCH] add T2m to boundflux 2 if necessary to determine precip phase

---
 mo_functions.f90 | 10 +++++++---
 mo_init.f90      |  4 ++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/mo_functions.f90 b/mo_functions.f90
index 54143fe..e0f958c 100644
--- a/mo_functions.f90
+++ b/mo_functions.f90
@@ -331,8 +331,8 @@ CONTAINS
 
     SUBROUTINE sub_input(length_input, timestep_data, T_top_input, T2m_input, T_bottom_input, S_bu_bottom_input, &
             & fl_q_bottom_input, time_input,fl_sw_input, fl_lw_input, fl_lat_input, fl_sen_input, precip_l_input, &
-            & precip_s_input, boundflux_flag)
-        INTEGER, INTENT(in) :: length_input, boundflux_flag
+            & precip_s_input, boundflux_flag, precip_flag)
+        INTEGER, INTENT(in) :: length_input, boundflux_flag, precip_flag
         REAL(wp), INTENT(in) :: timestep_data
         INTEGER :: k
         REAL(wp), DIMENSION(:), allocatable, INTENT(out) :: T_top_input, T2m_input, T_bottom_input, S_bu_bottom_input, &
@@ -343,7 +343,6 @@ CONTAINS
                 & fl_q_bottom_input(Length_Input), fl_sw_input(Length_Input), fl_lw_input(Length_Input), &
                 & fl_lat_input(Length_Input), fl_sen_input(Length_Input), precip_l_input(Length_Input), &
                 & precip_s_input(Length_Input))
-
         IF (boundflux_flag == 1) THEN
             OPEN(1234, file = 'input/T_top.txt', status = 'old')
             READ(1234, *)T_top_input
@@ -361,6 +360,11 @@ CONTAINS
             OPEN(1234, file = 'input/fl_sen.txt', status = 'old')
             READ(1234, *)fl_sen_input
             CLOSE(1234)
+            IF (precip_flag == 1) THEN
+                OPEN(1234, file = 'input/T2m.txt', status = 'old')
+                READ(1234, *)T2m_input
+                CLOSE(1234)
+            END IF
         ELSE IF (boundflux_flag == 3) THEN
             OPEN(1234, file = 'input/T_top.txt', status = 'old')
             READ(1234, *)T_top_input
diff --git a/mo_init.f90 b/mo_init.f90
index 52ee594..24e78fc 100644
--- a/mo_init.f90
+++ b/mo_init.f90
@@ -98,7 +98,7 @@ CONTAINS
         !Time settings needed when input is given
         !*************************************************************************************************************************
         CALL json%get('length_input', length_input, is_found)
-        IF (.not. is_found) THEN; PRINT*, 'length_input not found'; STOP; END IF
+        IF (.not. is_found) THEN; PRINT*, 'n_time_output not found'; STOP; END IF
         CALL json%get('timestep_data', timestep_data, is_found)
         IF (.not. is_found) THEN; PRINT*, 'timestep_data not found'; STOP; END IF
 
@@ -180,7 +180,7 @@ CONTAINS
         time_counter = 1
         CALL sub_input(length_input, timestep_data, T_top_input, T2m_input, T_bottom_input, S_bu_bottom_input, &
                 & fl_q_bottom_input, time_input,fl_sw_input, fl_lw_input, fl_lat_input, fl_sen_input, precip_l_input, &
-                & precip_s_input, boundflux_flag)
+                & precip_s_input, boundflux_flag, precip_flag)
 
         ! Unpack first values of inputs used for each boundflux_flag. The initial values are used to initialize the sea ice
         ! which is done before they are read in in the first tie step in mo_grotz, which is why we unpack them here.
-- 
GitLab