From 20026586a32c5a3803d7c3213b77343c1b0cd531 Mon Sep 17 00:00:00 2001
From: Victor Stepanenko <vstepanenkomeister@gmail.com>
Date: Sat, 10 Sep 2022 22:56:49 +0300
Subject: [PATCH] Temperature profile calibrated for Alsta

---
 crproj                     |  2 +-
 setup/alsta_driver.dat     |  2 +-
 setup/alsta_setup.dat      | 16 ++++++++--------
 source/model/phys_func.f90 |  4 +++-
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/crproj b/crproj
index b3ba371..454db27 100755
--- a/crproj
+++ b/crproj
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "cygwin" ]]; then
         echo "Operating system: linux"
diff --git a/setup/alsta_driver.dat b/setup/alsta_driver.dat
index 479e75b..67c71f7 100644
--- a/setup/alsta_driver.dat
+++ b/setup/alsta_driver.dat
@@ -120,7 +120,7 @@ call_Flake  0
 # fetch        --- the wind fetch,                                          m
 #----------------------------------------------------------------------------------------
 #
-extwat      3.4 #
+extwat      1.5 #3.4 #
 # 3.
 #select_extwat 9
 #2   0.02
diff --git a/setup/alsta_setup.dat b/setup/alsta_setup.dat
index d90832c..670255b 100644
--- a/setup/alsta_setup.dat
+++ b/setup/alsta_setup.dat
@@ -120,9 +120,9 @@ d_bot  1.E-2
 #----------------------------------------------------------------------------------------
 #
 varalb   1
-PBLpar   1
+PBLpar   3
 waveenh  0
-momflxpart 1
+momflxpart 0
 c_d      -999
 kwe      100.
 relwind  0
@@ -138,7 +138,7 @@ soilswitch  1
 saltice 0 
 nsoilcols 5
 tricemethhydr 0.
-carbon_model 1
+carbon_model 2
 skin     0
 massflux 0
 ifrad    1
@@ -149,8 +149,8 @@ dyn_pgrad 0
 pgrad    0.
 nManning 5.E-2
 horvisc  0.
-backdiff 2
-backdiff0 -999.
+backdiff 3
+backdiff0 5.
 botfric  1
 zero_model 0
 thermokarst_meth_prod 0.
@@ -220,8 +220,8 @@ tribheat       0
 N_tribin 0
 N_triblev 0
 iefflloc 1
-fileinflow 'BolshoiVilui20153_inflows.dat'
-fileoutflow 'BolshoiVilui20153_outflow.dat'
+fileinflow 'alsta_inflows.dat'
+fileoutflow 'alsta_outflow.dat'
 dttribupdate 0.25
 #
 #----------------------------------------------------------------------------------------
@@ -266,7 +266,7 @@ assim       0
 turb_out    0
 monthly     0
 daily       1
-hourly      1
+hourly      0
 everystep   0
 time_series 1
 dt_out      1
diff --git a/source/model/phys_func.f90 b/source/model/phys_func.f90
index 064c33c..68f9cc1 100644
--- a/source/model/phys_func.f90
+++ b/source/model/phys_func.f90
@@ -3,6 +3,7 @@
  use LAKE_DATATYPES, only : ireals, iintegers
  use PHYS_CONSTANTS, only : &
  & row0
+ use NUMERIC_PARAMS, only : small_value
 
 
  implicit none
@@ -518,6 +519,7 @@ END FUNCTION GSW_RHO
   MODULE PHYS_FUNC
 
   use LAKE_DATATYPES, only : ireals, iintegers
+  use NUMERIC_PARAMS, only : small_value
 
   contains
   real(kind=ireals) FUNCTION TURB_DENS_FLUX(tempflux,salflux,Temp,Sal)
@@ -2124,7 +2126,7 @@ END FUNCTION FP_THETA
     !Shear frequency squared
     y = ( (wst%u1(i+1) - wst%u1(i))**2 + (wst%v1(i+1) - wst%v1(i))**2 ) / dz**2
     !Gradient Richardson number
-    Ri = x / y
+    Ri = x / (y + small_value)
     if     (Ri <= 0.) then
       wst%lamw_back(i) = k0
     elseif (Ri < Ri0) then
-- 
GitLab