diff --git a/Python_files/Code/plotscripts/plot_bgc.py b/Python_files/Code/plotscripts/plot_bgc.py index 31c863c7f9559da25e1a3775df20d8dda0923c03..0075afc5961edd6c8a1eea57c7b438c43dc46b59 100644 --- a/Python_files/Code/plotscripts/plot_bgc.py +++ b/Python_files/Code/plotscripts/plot_bgc.py @@ -30,9 +30,15 @@ levelsbrine = ([400,2000]) import numpy import matplotlib.pyplot as plt from matplotlib import rc +import os rc('font', size='10') rc('font', family='serif') +# set wd to the directory of the script +abspath = os.path.abspath(__file__) +dname = os.path.dirname(abspath) +os.chdir(dname) + #Loading data bgc_br = numpy.loadtxt("../../../output/dat_bgc"+tracernumber+".br.dat") bgc_bu = numpy.loadtxt("../../../output/dat_bgc"+tracernumber+".bu.dat") diff --git a/Python_files/Code/plotscripts/plot_profile.py b/Python_files/Code/plotscripts/plot_profile.py index b49e60a4c07271cf9e5d4423941a5c08cd622aa2..e5fb6354153fc9dc1770b36a9583c253cfb1cb2d 100644 --- a/Python_files/Code/plotscripts/plot_profile.py +++ b/Python_files/Code/plotscripts/plot_profile.py @@ -9,14 +9,21 @@ #6. Run the script! (python plot_profile.py) #7. Open the outputfile in the imageviewer of your choice. + + #Loading modules and setting fonts import numpy import matplotlib.pyplot as plt from matplotlib import rc +import os import matplotlib rc('font', size='10') rc('font', family='serif') +# set wd to the directory of the script +abspath = os.path.abspath(__file__) +dname = os.path.dirname(abspath) +os.chdir(dname) #Settings dx = 1.0 diff --git a/Run_specifics/config.json b/Run_specifics/config.json index 959427777198894522f65070003c8a8b71721067..a847c060020a0f82cdd4eeb7cc64f73a2cf76bcd 100644 --- a/Run_specifics/config.json +++ b/Run_specifics/config.json @@ -1,17 +1,17 @@ { - "start_time": "2019-01-01 00:00:00", - "dt": 20, + "start_time": "2022-01-01 00:00:00", + "dt": 60, "time": 0.0, - "time_out": 86400, - "time_total": 55468800, + "time_out": 302400.0, + "time_total": 65318400.0, + "length_input": 1088640.0, "timestep_data": 60, - "length_input": 924481, - "thick_0": 0.02, - "Nlayer": 80, + "thick_0": 0.03, + "Nlayer": 20, "N_active": 1, - "N_top": 20, - "N_bottom": 20, - "N_middle": 40, + "N_top": 5, + "N_bottom": 5, + "N_middle": 10, "boundflux_flag": 2, "albedo_flag": 2, "grav_heat_flag": 1, @@ -25,7 +25,7 @@ "turb_flag": 2, "bottom_flag": 1, "tank_flag": 1, - "precip_flag": 1, + "precip_flag": 0, "freeboard_snow_flag": 0, "snow_flush_flag": 1, "styropor_flag": 0, @@ -33,14 +33,14 @@ "debug_flag": 1, "bgc_flag": 1, "initial_state_flag": 1, - "tank_depth": 0, - "alpha_flux_stable": 0, - "alpha_flux_instable": 0, - "N_bgc": 0, - "bgc_bottom_1": 0, - "bgc_bottom_2": 0, - "thick_1": 0.02, - "m_1": 20.56, - "S_abs_1": 699.04, - "H_abs_1": -69904.0 + "tank_depth": 1, + "alpha_flux_stable": 15, + "alpha_flux_instable": 22, + "N_bgc": 2, + "bgc_bottom_1": 385, + "bgc_bottom_2": 385, + "thick_1": 0.03, + "m_1": 30.84, + "S_abs_1": 1048.56, + "H_abs_1": 0 } \ No newline at end of file diff --git a/Run_specifics/description.txt b/Run_specifics/description.txt index 09826015db88a08a1f0dad820ac8cbf1c14d3a68..7aea20fb332e5989408bb94b1e09d26141927a17 100644 --- a/Run_specifics/description.txt +++ b/Run_specifics/description.txt @@ -1 +1 @@ -Mosaic_run_1 \ No newline at end of file +Testcase_3 \ No newline at end of file diff --git a/documentation/Configuration_Guide.md b/documentation/Configuration_Guide.md index e167635e659e75f1c9c3e745dfc3dbf72b8ab21f..6731551c9397a3f572b6e5720b6ef705f65f62b3 100644 --- a/documentation/Configuration_Guide.md +++ b/documentation/Configuration_Guide.md @@ -2,7 +2,7 @@ How to configure SAMSIM3.0 with config.json files and the respective inputs ## Brief Description -This Guide will show you an example run of SAMSIM3.0 with testcase. We go step-by-step through the python file build_config_1.py which is used to build the config.json file and +This Guide will show you an example run of SAMSIM3.0 with testcase 1. We go step-by-step through the python file build_config_1.py which is used to build the config.json file and the input files needed to run SAMSIM3.0 for testcase 1. For a detailed documentation of the different variables, please look at reference manual and SAMISM3.md. @@ -12,15 +12,21 @@ We use the build_config_1.py file, which is used to create the config.json and t testcase 1 as an example. The first section imports the json lbrary and the functions used to build the input files for the respective testcases. -It also defines two constants used below. +It also defines two constants used below and sets the working directory to the directory of the build_config file. ```python import json -from Python_files.Code.build_config_files.func_bound_values import * +from func_bound_values import * +import os + +# set wd to the directory of the script +abspath = os.path.abspath(__file__) +dname = os.path.dirname(abspath) # set constants rho_l = 1028 c_l = 3400 +os.chdir(dname) ``` The second section initializes the config array which is converted into the config.json file in the end and sets the paths for the storage spaces of the input files and the config file. @@ -43,11 +49,13 @@ file.write(description) file.close() ``` In the fourth section, the time settings of the simulation are defined. Note that 'time_total' -should be a multiple of 'time_out'. +should be a multiple of 'time_out'. 'start_time' sets the beginning of your run, which is important if you +want to have a realistic timeframe. For testcase 1-4 this is arbitrary. ```python # ********************************************************************************************************************** # Initial layer thickness, timestep, output time and simulation time # ********************************************************************************************************************** +config['start_time'] = '2022-01-01 00:00:00' # start time in YYYY-mm-dd HH:MM:SS config['dt'] = 1 # time increment [s]] config['time'] = 0.0 # initial value of time [s] config['time_out'] = 3600 # time between outputs [s] @@ -191,5 +199,45 @@ json_object = json.dumps(config, indent=4) with open(path_config + "config.json", "w") as outfile: outfile.write(json_object) +``` +### Run config script +You can run the build_config_1 file to prepare testcase 1 by simpely typing +````shell +python3 Python_files/Code/build_config_files/build_config_1.py +```` +into your console. Note that the path can be different, depending on what folder you are in. +Running the script will put the needed input in the input folder and the config.json and the description.txt file +in the Run_specifics folder. + +### Run SAMSIM +Now, you can run the model by going to the directory with the makefile in it (home directory of the repository) +and typing +````shell +make +```` +into the console. This will compile the fortran code and produce a .mod and a .o file for every module and an executable file +called samsim.x. + +Having done that, you can now run SAMSIM by typing +````shell +./samsim.x +```` +into the console, which will run the executable file. One good thing about SAMSIM3.0 is that you +don't have to recompile it after you changed the inputs or the config file. You can simpely type the above command again +to rerun it for a different setting. + +Runnig the SAMSIM will produce some output in your console, showing the progress and some other model variables. + +After SAMSIM finishes, you can find the model output in the output foler. + +### Plotting the output +The model output can simpely be plotted by running one of the plotscrips, depending on what you want to investigate. +For a good first overview I suggest using the plot_TPhiS.py script, which plots temperature, liquid fraction and salinity of the +sea ice profile over time. To do so, type +````shell +python3 Python_files/Code/plotscripts/plot_TPhiS.py +```` +The path again depends on which folder you are currently in. This produces a nice plot which you can find in the folder +Python_files/Plots and should look like this for testcase 1: -``` \ No newline at end of file + \ No newline at end of file diff --git a/documentation/Plots/pic_TPhiS.png b/documentation/Plots/pic_TPhiS.png new file mode 100644 index 0000000000000000000000000000000000000000..b86a45796377a88d246f48109d67ce1ac6b6863c Binary files /dev/null and b/documentation/Plots/pic_TPhiS.png differ diff --git a/documentation/SAMSIM3.md b/documentation/SAMSIM3.md index f665be4ba4c495ca1fc24ac133cd00d33fd616a3..366e9c2fa61d8058fdfdc9971bf0b64466074601 100644 --- a/documentation/SAMSIM3.md +++ b/documentation/SAMSIM3.md @@ -22,7 +22,7 @@ This warning have been removed by introducing an additional variable T_in: ```` This improvement of the code caused minor changes in the output of the testcases which have a snow cover (3&4). For testcase 3, the changes look like this: - + There have been a lot of other warnings removed but these were the major ones. @@ -101,13 +101,13 @@ while reading the input data. The exact cause could not be identified but the di If you can find the cause for the errors, contact me (jakob.deutloff@gmail.com) and I invite you for a drink ;). Differences testcase 1 (none): - + Differences testcase 2: - + Differences Testcase 3: - + Differences Testcase 4: - + ## List of New Variables - T2m_input - Input file for T2m - T_top_input - Input file for T_top diff --git a/mo_init.f90 b/mo_init.f90 index 24e78fc4c06972dc0f37f3da19d52961e36740da..d0b48229357e52e0b8cfb26a9555dc79869f74e3 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*, 'n_time_output not found'; STOP; END IF + IF (.not. is_found) THEN; PRINT*, 'lenght_input 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