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

configuration files coupling update

parent f1d27e57
No related branches found
No related tags found
No related merge requests found
/drag.exe
/build/
/srcF/*.mod
.idea
! sfx model macro definitions
!#define SFX_FORCE_DEPRECATED_ESM_CODE
!#define SFX_CHECK_NAN
\ No newline at end of file
!#define SFX_CHECK_NAN
!#define USE_CONFIG_PARSER
......@@ -108,6 +108,9 @@ program sfx_main
! --------------------------------------------------------------------------------
#ifdef USE_CONFIG_PARSER
character, allocatable :: config_model_name(:)
character, allocatable :: config_dataset_name(:)
character, allocatable :: fn_in_common(:), fn_in(:), fn_out(:)
integer :: sfx_type
real :: z0_m
......@@ -216,6 +219,70 @@ program sfx_main
end if
end do
#ifdef USE_CONFIG_PARSER
call run("config.txt"//C_NULL_CHAR)
call get_charf("model.type"//C_NULL_CHAR, config_model_name)
if (compare_char_arrays(config_model_name, trim(arg_key_model_esm), size(config_model_name))) then
model_id = model_esm
else if (compare_char_arrays(config_model_name, trim(arg_key_model_log), size(config_model_name))) then
model_id = model_log
else if (compare_char_arrays(config_model_name, trim(arg_key_model_most), size(config_model_name))) then
model_id = model_most
else if (compare_char_arrays(config_model_name, trim(arg_key_model_sheba), size(config_model_name))) then
model_id = model_sheba
else
write(*, *) ' FAILURE! > unknown model [key]: ', config_model_name
stop
end if
call get_charf("dataset.type"//C_NULL_CHAR, config_dataset_name)
if (compare_char_arrays(config_dataset_name, trim(arg_key_dataset_mosaic), size(config_dataset_name))) then
dataset_id = dataset_MOSAiC
else if (compare_char_arrays(config_dataset_name, trim(arg_key_dataset_irgason), size(config_dataset_name))) then
dataset_id = dataset_IRGASON
else if (compare_char_arrays(config_dataset_name, trim(arg_key_dataset_sheba), size(config_dataset_name))) then
dataset_id = dataset_SHEBA
else if (compare_char_arrays(config_dataset_name, trim(arg_key_dataset_lake), size(config_dataset_name))) then
dataset_id = dataset_LAKE
else if (compare_char_arrays(config_dataset_name, trim(arg_key_dataset_papa), size(config_dataset_name))) then
dataset_id = dataset_PAPA
else if (compare_char_arrays(config_dataset_name, trim(arg_key_dataset_toga), size(config_dataset_name))) then
dataset_id = dataset_TOGA
else if (compare_char_arrays(config_dataset_name, trim(arg_key_dataset_user), size(config_dataset_name))) then
dataset_id = dataset_USER
!call get_charf("dataset.filename"//C_NULL_CHAR, config_dataset_filename)
!call get_charf("dataset.filename_params"//C_NULL_CHAR, config_dataset_filename_params)
write(*, *) ' FAILURE! > user dataset is not supported: ', config_dataset_name
stop
!call get_command_argument(i + 2, filename_in_common)
!call get_command_argument(i + 3, filename_in)
!call get_command_argument(i + 4, filename_out)
else
write(*, *) ' FAILURE! > unknown dataset [key]: ', config_dataset_name
stop
end if
!call get_charf("input_files.filename_in_common"//C_NULL_CHAR, fn_in_common)
!call get_charf("input_files.filename_in"//C_NULL_CHAR, fn_in)
!if (is_output_set == 0) call get_charf("input_files.filename_out"//C_NULL_CHAR, fn_out)
!sfx_type = get_sfx_type("surface.surface_type"//C_NULL_CHAR)
!if ( (sfx_type == surface_ocean) .or. (sfx_type == surface_lake) ) then
! call get_float("surface.z0_m"//C_NULL_CHAR, z0_m)
!end if
!write(*, *) "fn_in_common: ", fn_in_common
!write(*, *) "fn_in: ", fn_in
!if (is_output_set == 0) write(*, *) "fn_out: ", fn_out
!write(*, *) "sfx_type: ", sfx_type
!if ( (sfx_type == surface_ocean) .or. (sfx_type == surface_lake) ) then
! write(*, *) "z0_m: ", z0_m
!end if
#endif
!< @brief set name for specific model
if (model_id == model_esm) then
......@@ -231,27 +298,6 @@ program sfx_main
stop
end if
#ifdef USE_CONFIG_PARSER
call run("config.txt"//C_NULL_CHAR)
call get_charf("input_files.filename_in_common"//C_NULL_CHAR, fn_in_common)
call get_charf("input_files.filename_in"//C_NULL_CHAR, fn_in)
if (is_output_set == 0) call get_charf("input_files.filename_out"//C_NULL_CHAR, fn_out)
sfx_type = get_sfx_type("surface.surface_type"//C_NULL_CHAR)
if ( (sfx_type == surface_ocean) .or. (sfx_type == surface_lake) ) then
call get_float("surface.z0_m"//C_NULL_CHAR, z0_m)
end if
write(*, *) "fn_in_common: ", fn_in_common
write(*, *) "fn_in: ", fn_in
if (is_output_set == 0) write(*, *) "fn_out: ", fn_out
write(*, *) "sfx_type: ", sfx_type
if ( (sfx_type == surface_ocean) .or. (sfx_type == surface_lake) ) then
write(*, *) "z0_m: ", z0_m
end if
#endif
!< @brief set name & filenames for specific dataset
if (dataset_id == dataset_MOSAiC) then
dataset_name = 'MOSAiC'
......@@ -334,10 +380,15 @@ program sfx_main
call allocate_sfx_vec(sfx, num)
#ifdef USE_CONFIG_PARSER
call get_float("dataset.h"//C_NULL_CHAR, meteo_cell%h)
call get_float("dataset.z0_m"//C_NULL_CHAR, meteo_cell%z0_m)
#else
!< @brief read input data common parameters
open(1, file = filename_in_common, status = 'old')
read(1, *) meteo_cell%h, meteo_cell%z0_m
close(1)
#endif
!< @brief read input data
......@@ -380,9 +431,12 @@ program sfx_main
call deallocate_sfx_vec(sfx)
#ifdef USE_CONFIG_PARSER
deallocate( fn_in_common )
deallocate( fn_in )
if (is_output_set == 0) deallocate( fn_out )
deallocate(config_model_name)
deallocate(config_dataset_name)
!deallocate( fn_in_common )
!deallocate( fn_in )
!if (is_output_set == 0) deallocate( fn_out )
#endif
......
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