diff --git a/.gitignore b/.gitignore index 964cb41cb1fd1af8fa22bcd3d3d7a50458c84476..f4a77c2403534a879d05276fd19c475cac703523 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /drag.exe /build/ +/srcF/*.mod .idea diff --git a/includeF/sfx_def.fi b/includeF/sfx_def.fi index 2fc04b6c46c70b7f441cd0a83734b0cb11f3213e..2a1077ca329a4cda062dcff5c49925b23467eb89 100644 --- a/includeF/sfx_def.fi +++ b/includeF/sfx_def.fi @@ -1,4 +1,5 @@ ! 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 diff --git a/srcF/sfx_main.f90 b/srcF/sfx_main.f90 index 08dbd680a2defd5f08ebf13996678a9ee7ac7f3a..8117357aae9c8ddfabe1927702ad77f0bde74fe1 100644 --- a/srcF/sfx_main.f90 +++ b/srcF/sfx_main.f90 @@ -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