!! The module mo_grotz contains the most important subroutine grotz (Named after GRiewank nOTZ).
!! Mo_grotz is called by SAMSIM.f90.
!! Subroutine grotz contains the time loop, as well as the initialization, and calls all other branches of the model.
!! This model was developed from scratch by Philipp Griewank during and after his PhD at Max Planck Institute of Meteorology from 2010-2014.
!! The code is intended to be understandable and most subroutines, modules, functions, parameters, and global variables have doxygen compatible descriptions.
!! In addition to the doxygen generated description, some python plotscripts are available to plot model output.
!!
!!
!!
!!
!! @author Philipp Griewank
!!
!!
!! COPYRIGHT
!!
!! This file is part of SAMSIM.
!!
!! SAMSIM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
!!
!! SAMSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License along with SAMSIM. If not, see <http://www.gnu.org/licenses/>.
!
!!
!!
!!
!! @par Revision History
!! Started by Philipp Griewank 2012-08-28
!!
MODULEmo_grotz
CONTAINS
!>
!!
!! Main subroutine of SAMSIM, a 1D thermodynamic seaice model.
!! A semi-adaptive grid is used which is managed by mo_layer_dynamics.
!!
!! The basic rundown of the time loop is:
!! 1. Calculate the current ice/snow state and forcing, as well as gravity drainage and flooding
!! 2. Apply all the fluxes, recalculate ice state
!! 3. Flushing and layer dynamics
!!
!! Here is the full rundown of what happens in mo_grotz:
!!
!! - Initialization: all fields are initialized for the given config.json file, and the output is formatted
!! - Input and Forcing read in.
!! TIME LOOP BEGINS:
!! - Calculate the total ice properties, total freshwater, thermal resistivity, energy, bulk salinity
!! - Determine snow and rain rates
!! - Calculate snow thermodynamics
!! - Calculate inner ice thermodynamic fluxes
!! - Calculate brine flux from expulsion
!! - Raw output written out if debug_flag is set to 2
!! - Standard output written
!! - Flooding parametrized
!! - Lowest layer mixing with underlying water
!! - Gravity drainage parametrized
!! - Calcuating and applying the heat fluxes
!! - After heatfluxes are applied new liquidus thermal equilibrium is calculated
!! - Flushing is parametrized
!! - Chemistry advection calculated
!! - Layer Dynamics
!! TIME LOOP ENDS
!! -Final output, files closed, and fields deallocated
!!
!!
!! IMPORTANT:
!! To get the correct freshwater amount make sure the freshwater is calculated using a salinity value to compare against.
!!
!!
!! Common errors leading to termination are: too small timestep, bad programming
!!
!! @par Revision History
!! Basic thermodynamics and layer_dynamics for fixed boundaries seem stable, backup made. by griewank (2010-08-10) \n
!! Add some more outputs, changed routine names and arguments with respect to newly introduces flags by Niels Fuchs, MPIMET (2017-03-01) \n
!! Added a bit of description with the run down of what happends by Philipp Griewank, Uni K (2018-08-08)
SUBROUTINEgrotz()
USEmo_parameters
USEmo_thermo_functions
USEmo_data
USEmo_init
USEmo_layer_dynamics
USEmo_mass
USEmo_grav_drain
USEmo_output
USEmo_flush
USEmo_flood
USEmo_snow
USEmo_functions
USEmo_heat_fluxes
IMPLICITNONE
CHARACTER*12000::description!< String to describes simulation which is output into dat_settings
!Bastard variables, are used for various dirty deeds
INTEGER::jj
REAL(wp)::temp,temp2,temp4,temp5,temp_2017_H,temp_2017_m!when a real is needed !< Niels, 2017 add: temp_2017_m