Skip to content
Snippets Groups Projects
Commit ad58b9da authored by Evgeny Mortikov's avatar Evgeny Mortikov
Browse files

model setup and run update

parent 6fc11e10
No related branches found
No related tags found
No related merge requests found
......@@ -55,23 +55,14 @@ subroutine run_dataset(filename_out, dataset, model)
write(*, *) ' Running SFX:'
!write(*, '(a,a)') ' model = ', trim(get_model_tag(model))
!write(*, '(a,a)') ' dataset = ', trim(get_dataset_tag(dataset%id))
!write(*, '(a,a)') ' filename[IN] = ', trim(dataset%filename)
!write(*, '(a,a)') ' filename[OUT] = ', trim(filename_out)
!write(*, '(a, g0)') ' surface type = ', dataset%surface_type
!write(*, '(a, g0)') ' h = ', dataset%h
!write(*, '(a, g0)') ' z0(m) = ', dataset%z0_m
!write(*, '(a, g0)') ' z0(h) = ', dataset%z0_h
write(*, *) ' model = ', trim(get_model_tag(model))
write(*, *) ' dataset = ', trim(get_dataset_tag(dataset%id))
write(*, *) ' filename[IN] = ', trim(dataset%filename)
write(*, *) ' filename[OUT] = ', trim(filename_out)
write(*, *) ' surface type = ', dataset%surface_type
write(*, *) ' h = ', dataset%h
write(*, *) ' z0(m) = ', dataset%z0_m
write(*, *) ' z0(h) = ', dataset%z0_h
write(*, '(a,a)') ' model = ', trim(get_model_tag(model))
write(*, '(a,a)') ' dataset = ', trim(get_dataset_tag(dataset%id))
write(*, '(a,a)') ' filename[IN] = ', trim(dataset%filename)
write(*, '(a,a)') ' filename[OUT] = ', trim(filename_out)
write(*, '(a, g0)') ' surface type = ', dataset%surface_type
write(*, '(a, g0)') ' h = ', dataset%h
write(*, '(a, g0)') ' z0(m) = ', dataset%z0_m
write(*, '(a, g0)') ' z0(h) = ', dataset%z0_h
!< @brief define number of cells
......@@ -190,6 +181,7 @@ program sfx_main
character(len = 128), parameter :: arg_key_output = '--output'
character(len = 128), parameter :: arg_key_nmax = '--nmax'
character(len = 128), parameter :: arg_key_help = '--help'
character(len = 128), parameter :: arg_key_config = "--config"
integer :: is_output_set
! --------------------------------------------------------------------------------
......@@ -198,7 +190,7 @@ program sfx_main
! --------------------------------------------------------------------------------
integer :: i
integer :: status
integer :: id
integer :: id, nmax
! --------------------------------------------------------------------------------
#ifdef USE_CONFIG_PARSER
......@@ -217,8 +209,8 @@ program sfx_main
call get_command_argument(i, arg)
if (trim(arg) == trim(arg_key_help)) then
write(*, *) ' sfx model, usage:'
write(*, *) ' --help '
write(*, *) ' print usage options '
write(*, *) ' --help'
write(*, *) ' print usage options'
write(*, *) ' --model [key]'
write(*, *) ' key = esm (default) || log || most || sheba'
write(*, *) ' --dataset [key]'
......@@ -226,9 +218,11 @@ program sfx_main
write(*, *) ' = lake || papa || toga || user [filename] [param]'
write(*, *) ' param = [h] [z0(m)] [z0(h)]'
write(*, *) ' --output [filename]'
write(*, *) ' set output filename '
write(*, *) ' set output filename'
write(*, *) ' --config [filename]'
write(*, *) ' use configuration file'
write(*, *) ' --nmax [value]'
write(*, *) ' max number of data points > 0 '
write(*, *) ' max number of data points > 0'
stop
end if
if (trim(arg) == trim(arg_key_model)) then
......@@ -255,7 +249,10 @@ program sfx_main
write(*, *) ' FAILURE! > unknown dataset [key]: ', trim(arg)
stop
end if
!< save nmax if previously set
nmax = dataset%nmax
call set_dataset(dataset, id)
dataset%nmax = nmax
if (dataset%id == dataset_user) then
!< @brief user-defined dataset
......@@ -264,10 +261,10 @@ program sfx_main
stop
end if
!< @brief filename
!< filename
call get_command_argument(i + 2, dataset%filename)
!< @brief reading 'h'
!< reading 'h'
call get_command_argument(i + 3, arg)
call str2real(dataset%h, arg, status)
if (status /= 0) then
......@@ -279,7 +276,7 @@ program sfx_main
stop
end if
!< @brief reading 'z0(m)'
!< reading 'z0(m)'
call get_command_argument(i + 4, arg)
call str2real(dataset%z0_m, arg, status)
if (status /= 0) then
......@@ -287,7 +284,7 @@ program sfx_main
stop
end if
!< @brief reading 'z0(h)'
!< reading 'z0(h)'
call get_command_argument(i + 5, arg)
call str2real(dataset%z0_h, arg, status)
if (status /= 0) then
......@@ -318,70 +315,69 @@ program sfx_main
write(*, *) ' FAILURE! > nmax [value] should be positive'
stop
end if
end if
end do
else if (trim(arg) == trim(arg_key_config)) then
if (i == num_args) then
write(*, *) ' FAILURE! > missing configuration file [key] argument'
stop
end if
call get_command_argument(i + 1, arg)
#ifdef USE_CONFIG_PARSER
call run("config.txt"//C_NULL_CHAR)
call is_varname("model.id"//C_NULL_CHAR, status)
if (status /= 0) then
call get_charf("model.id"//C_NULL_CHAR, config_field)
model = get_model_id(char_array2str(config_field))
if (model == -1) then
write(*, *) ' FAILURE! > unknown model [key]: ', trim(char_array2str(config_field))
stop
end if
end if
call is_varname("dataset.id"//C_NULL_CHAR, status)
if (status /= 0) then
call get_charf("dataset.id"//C_NULL_CHAR, config_field)
id = get_dataset_id(char_array2str(config_field))
if (id == -1) then
write(*, *) ' FAILURE! > unknown dataset [key]: ', trim(char_array2str(config_field))
stop
end if
call set_dataset(dataset, id)
if (dataset%id == dataset_user) then
call get_charf("dataset.filename"//C_NULL_CHAR, config_field)
dataset%filename = char_array2str(config_field)
call get_float("dataset.h"//C_NULL_CHAR, dataset%h)
call get_float("dataset.z0_m"//C_NULL_CHAR, dataset%z0_m)
call get_float("dataset.z0_h"//C_NULL_CHAR, dataset%z0_h)
end if
end if
call run(trim(arg)//C_NULL_CHAR)
call is_varname("dataset.nmax"//C_NULL_CHAR, status)
if (status /= 0) then
call get_int("dataset.nmax"//C_NULL_CHAR, dataset%nmax)
end if
call is_varname("model.id"//C_NULL_CHAR, status)
if (status /= 0) then
call get_charf("model.id"//C_NULL_CHAR, config_field)
model = get_model_id(char_array2str(config_field))
if (model == -1) then
write(*, *) ' FAILURE! > unknown model [key]: ', trim(char_array2str(config_field))
stop
end if
end if
call is_varname("output.filename"//C_NULL_CHAR, status)
if (status /= 0) then
call get_charf("output.filename"//C_NULL_CHAR, config_field)
filename_out = char_array2str(config_field)
call is_varname("dataset.id"//C_NULL_CHAR, status)
if (status /= 0) then
call get_charf("dataset.id"//C_NULL_CHAR, config_field)
id = get_dataset_id(char_array2str(config_field))
if (id == -1) then
write(*, *) ' FAILURE! > unknown dataset [key]: ', trim(char_array2str(config_field))
stop
end if
call set_dataset(dataset, id)
if (dataset%id == dataset_user) then
call get_charf("dataset.filename"//C_NULL_CHAR, config_field)
dataset%filename = char_array2str(config_field)
call get_float("dataset.h"//C_NULL_CHAR, dataset%h)
call get_float("dataset.z0_m"//C_NULL_CHAR, dataset%z0_m)
call get_float("dataset.z0_h"//C_NULL_CHAR, dataset%z0_h)
end if
end if
is_output_set = 1
end if
call is_varname("dataset.nmax"//C_NULL_CHAR, status)
if (status /= 0) then
call get_int("dataset.nmax"//C_NULL_CHAR, dataset%nmax)
end if
call is_varname("output.filename"//C_NULL_CHAR, status)
if (status /= 0) then
call get_charf("output.filename"//C_NULL_CHAR, config_field)
filename_out = char_array2str(config_field)
is_output_set = 1
end if
deallocate(config_field)
if (allocated(config_field)) deallocate(config_field)
#endif
end if
end do
!< @bried set auto-defined output filename
if (is_output_set == 0) then
filename_out = 'output-' // trim(get_dataset_tag(dataset%id)) // '.txt'
end if
open(32, file = "data/MOSAiC_zh.txt", iostat = status, status = 'old')
if (status /= 0) then
stop
end if
read(32, *) dataset%h, dataset%z0_m
close(32)
!< @brief running main driver
call run_dataset(filename_out, dataset, model)
stop
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment