Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sfx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
inmcm-mirror
sfx
Commits
6fc11e10
Commit
6fc11e10
authored
10 months ago
by
Evgeny Mortikov
Browse files
Options
Downloads
Patches
Plain Diff
major update to sfx main
parent
c637635a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+6
-6
6 additions, 6 deletions
CMakeLists.txt
srcF/sfx_config.f90
+41
-33
41 additions, 33 deletions
srcF/sfx_config.f90
srcF/sfx_main.f90
+112
-79
112 additions, 79 deletions
srcF/sfx_main.f90
with
159 additions
and
118 deletions
CMakeLists.txt
+
6
−
6
View file @
6fc11e10
...
...
@@ -4,7 +4,7 @@ option(INCLUDE_CUDA "GPU build in mode" OFF)
option
(
INCLUDE_CXX
"CXX build in mode"
OFF
)
option
(
BUILD_DOC
"Build documentation"
OFF
)
option
(
SFX_CHECK_NAN
"Build documentation"
OFF
)
option
(
USE_CONFIG_PARSER
"Build config parser"
O
N
)
option
(
USE_CONFIG_PARSER
"Build config parser"
O
FF
)
project
(
INMCM_sfx
)
enable_language
(
Fortran
)
...
...
@@ -142,19 +142,19 @@ if(INCLUDE_CXX OR INCLUDE_CUDA)
set
(
CMAKE_CUDA_FLAGS
" -g "
)
endif
(
INCLUDE_CXX OR INCLUDE_CUDA
)
add_executable
(
drag
${
SOURCES
}
)
add_executable
(
sfx
${
SOURCES
}
)
add_definitions
(
${
RUN_MACRO
}
)
set_property
(
TARGET
drag
PROPERTY LINKER_LANGUAGE Fortran
)
target_include_directories
(
drag
PUBLIC
${
CMAKE_BINARY_DIR
}
/modules/
)
set_property
(
TARGET
sfx
PROPERTY LINKER_LANGUAGE Fortran
)
target_include_directories
(
sfx
PUBLIC
${
CMAKE_BINARY_DIR
}
/modules/
)
if
(
USE_CONFIG_PARSER
)
target_link_libraries
(
drag
parser_F parser_CXX
)
target_link_libraries
(
sfx
parser_F parser_CXX
)
endif
(
USE_CONFIG_PARSER
)
#copy data on post build
add_custom_command
(
TARGET
drag
POST_BUILD
TARGET
sfx
POST_BUILD
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CMAKE_SOURCE_DIR
}
/data
${
CMAKE_CURRENT_BINARY_DIR
}
/data
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
srcF/sfx_config.f90
+
41
−
33
View file @
6fc11e10
...
...
@@ -51,17 +51,6 @@ module sfx_config
real
::
h
,
z0_m
,
z0_h
end
type
type
::
sfxDriverType
integer
::
model_id
integer
::
dataset_id
integer
::
nmax
character
(
len
=
256
)
::
filename_in_common
character
(
len
=
256
)
::
filename_in
character
(
len
=
256
)
::
filename_out
end
type
contains
...
...
@@ -149,46 +138,65 @@ contains
end
function
function
get_dataset_filename
(
id
)
result
(
filename
)
subroutine
set_dataset
(
dataset
,
id
)
implicit
none
integer
::
id
character
(
len
=
:),
allocatable
::
filename
type
(
sfxDatasetType
),
intent
(
out
)
::
dataset
integer
,
intent
(
in
)
::
id
integer
::
id_check
id_check
=
get_dataset_id
(
get_dataset_tag
(
id
))
if
(
id_check
==
-1
)
return
dataset
%
id
=
id
dataset
%
filename
=
get_dataset_filename
(
id
)
dataset
%
nmax
=
0
! *: temporary surface type & z0(h) def.
dataset
%
surface_type
=
1
dataset
%
z0_h
=
-1.0
filename
=
''
if
(
id
==
dataset_mosaic
)
then
filename
=
DATASET_DIR
//
'MOSAiC.txt'
dataset
%
h
=
3.8
dataset
%
z0_m
=
0.01
else
if
(
id
==
dataset_irgason
)
then
filename
=
DATASET_DIR
//
'Irgason1.txt'
dataset
%
h
=
9.2
dataset
%
z0_m
=
0.01
else
if
(
id
==
dataset_sheba
)
then
filename
=
DATASET_DIR
//
'Sheba1.txt'
dataset
%
h
=
3.19
dataset
%
z0_m
=
0.001
else
if
(
id
==
dataset_lake
)
then
filename
=
DATASET_DIR
//
'Kuivajarvi.txt'
! *: check & fix values
dataset
%
h
=
10.0
dataset
%
z0_m
=
-1.0
else
if
(
id
==
dataset_papa
)
then
filename
=
DATASET_DIR
//
'Papa.txt'
dataset
%
h
=
10.0
dataset
%
z0_m
=
-1.0
else
if
(
id
==
dataset_toga
)
then
filename
=
DATASET_DIR
//
'Toga.txt'
! *: check & fix values
dataset
%
h
=
15.0
dataset
%
z0_m
=
-1.0
end
if
end
function
end
subroutine
function
get_dataset_
param_
filename
(
id
)
result
(
filename
)
function
get_dataset_filename
(
id
)
result
(
filename
)
implicit
none
integer
::
id
character
(
len
=
:),
allocatable
::
filename
filename
=
""
filename
=
''
if
(
id
==
dataset_mosaic
)
then
filename
=
DATASET_DIR
//
'MOSAiC
_zh
.txt'
filename
=
DATASET_DIR
//
'MOSAiC.txt'
else
if
(
id
==
dataset_irgason
)
then
filename
=
DATASET_DIR
//
'I
RGASON_zh
.txt'
filename
=
DATASET_DIR
//
'I
rgason1
.txt'
else
if
(
id
==
dataset_sheba
)
then
filename
=
DATASET_DIR
//
'Sheba1
_zh
.txt'
filename
=
DATASET_DIR
//
'Sheba1.txt'
else
if
(
id
==
dataset_lake
)
then
filename
=
DATASET_DIR
//
'Kuivajarvi
_zh
.txt'
filename
=
DATASET_DIR
//
'Kuivajarvi.txt'
else
if
(
id
==
dataset_papa
)
then
filename
=
DATASET_DIR
//
'Papa
_zh
.txt'
filename
=
DATASET_DIR
//
'Papa.txt'
else
if
(
id
==
dataset_toga
)
then
filename
=
DATASET_DIR
//
'Toga
_zh
.txt'
filename
=
DATASET_DIR
//
'Toga.txt'
end
if
end
function
...
...
This diff is collapsed.
Click to expand it.
srcF/sfx_main.f90
+
112
−
79
View file @
6fc11e10
...
...
@@ -55,6 +55,15 @@ 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
)
...
...
@@ -83,9 +92,9 @@ subroutine run_dataset(filename_out, dataset, model)
close
(
32
)
! --- print number of elements in dataset
write
(
*
,
*
)
' size = '
,
num
write
(
*
,
'(a, g0)'
)
'
size = '
,
num
if
(
dataset
%
nmax
>
0
)
then
write
(
*
,
*
)
' nmax = '
,
dataset
%
nmax
write
(
*
,
'(a, g0)'
)
'
nmax = '
,
dataset
%
nmax
num
=
min
(
num
,
dataset
%
nmax
)
end
if
...
...
@@ -166,8 +175,10 @@ program sfx_main
! --------------------------------------------------------------------------------
type
(
sfxDriverType
)
::
sfx_args
type
(
sfxDatasetType
)
::
dataset
integer
::
model
character
(
len
=
256
)
::
filename_out
! command line arguments
! --------------------------------------------------------------------------------
...
...
@@ -187,6 +198,7 @@ program sfx_main
! --------------------------------------------------------------------------------
integer
::
i
integer
::
status
integer
::
id
! --------------------------------------------------------------------------------
#ifdef USE_CONFIG_PARSER
...
...
@@ -195,12 +207,11 @@ program sfx_main
!< @brief define default model & dataset
sfx_args
%
model_id
=
model_esm
!< default = ESM
sfx_args
%
dataset_id
=
dataset_mosaic
!< default = MOSAiC
sfx_args
%
nmax
=
0
is_output_set
=
0
model
=
model_esm
!< default = ESM
call
set_dataset
(
dataset
,
dataset_mosaic
)
!< default = MOSAiC
is_output_set
=
0
!< default = auto define output filename
!< @brief command line arguments processing
num_args
=
command_argument_count
()
do
i
=
1
,
num_args
call
get_command_argument
(
i
,
arg
)
...
...
@@ -212,9 +223,9 @@ program sfx_main
write
(
*
,
*
)
' key = esm (default) || log || most || sheba'
write
(
*
,
*
)
' --dataset [key]'
write
(
*
,
*
)
' key = mosaic (default) || irgason || sheba'
write
(
*
,
*
)
' = lake || papa || toga || user [file
s
]'
write
(
*
,
*
)
'
files = in-common-file in-file
'
write
(
*
,
*
)
' --output [file]'
write
(
*
,
*
)
' = lake || papa || toga || user [file
name] [param
]'
write
(
*
,
*
)
'
param = [h] [z0(m)] [z0(h)]
'
write
(
*
,
*
)
' --output [file
name
]'
write
(
*
,
*
)
' set output filename '
write
(
*
,
*
)
' --nmax [value]'
write
(
*
,
*
)
' max number of data points > 0 '
...
...
@@ -227,54 +238,83 @@ program sfx_main
end
if
call
get_command_argument
(
i
+
1
,
arg
)
sfx_args
%
model
_id
=
get_model_id
(
arg
)
if
(
sfx_args
%
model
_id
==
-1
)
then
model
=
get_model_id
(
arg
)
if
(
model
==
-1
)
then
write
(
*
,
*
)
' FAILURE! > unknown model [key]: '
,
trim
(
arg
)
stop
end
if
end
if
if
(
trim
(
arg
)
==
trim
(
arg_key_dataset
))
then
else
if
(
trim
(
arg
)
==
trim
(
arg_key_dataset
))
then
if
(
i
==
num_args
)
then
write
(
*
,
*
)
' FAILURE! > missing dataset [key] argument'
stop
end
if
call
get_command_argument
(
i
+
1
,
arg
)
sfx_args
%
dataset_
id
=
get_dataset_id
(
arg
)
if
(
sfx_args
%
dataset_
id
==
-1
)
then
id
=
get_dataset_id
(
arg
)
if
(
id
==
-1
)
then
write
(
*
,
*
)
' FAILURE! > unknown dataset [key]: '
,
trim
(
arg
)
stop
end
if
call
set_dataset
(
dataset
,
id
)
if
(
sfx_args
%
dataset_id
==
dataset_user
)
then
if
(
i
+
3
>
num_args
)
then
if
(
dataset
%
id
==
dataset_user
)
then
!< @brief user-defined dataset
if
(
i
+
5
>
num_args
)
then
write
(
*
,
*
)
' FAILURE! > incorrect arguments for [user] dataset'
stop
end
if
call
get_command_argument
(
i
+
2
,
sfx_args
%
filename_in_common
)
call
get_command_argument
(
i
+
3
,
sfx_args
%
filename_in
)
!< @brief filename
call
get_command_argument
(
i
+
2
,
dataset
%
filename
)
!< @brief reading 'h'
call
get_command_argument
(
i
+
3
,
arg
)
call
str2real
(
dataset
%
h
,
arg
,
status
)
if
(
status
/
=
0
)
then
write
(
*
,
*
)
' FAILURE! > expecting real h [value]'
stop
end
if
if
(
dataset
%
h
<=
0
)
then
write
(
*
,
*
)
' FAILURE! > h [value] should be positive'
stop
end
if
!< @brief reading 'z0(m)'
call
get_command_argument
(
i
+
4
,
arg
)
call
str2real
(
dataset
%
z0_m
,
arg
,
status
)
if
(
status
/
=
0
)
then
write
(
*
,
*
)
' FAILURE! > expecting real z0(m) [value]'
stop
end
if
!< @brief reading 'z0(h)'
call
get_command_argument
(
i
+
5
,
arg
)
call
str2real
(
dataset
%
z0_h
,
arg
,
status
)
if
(
status
/
=
0
)
then
write
(
*
,
*
)
' FAILURE! > expecting real z0(h) [value]'
stop
end
if
end
if
if
(
trim
(
arg
)
==
trim
(
arg_key_output
))
then
else
if
(
trim
(
arg
)
==
trim
(
arg_key_output
))
then
if
(
i
==
num_args
)
then
write
(
*
,
*
)
' FAILURE! > missing output [key] argument'
stop
end
if
call
get_command_argument
(
i
+
1
,
sfx_args
%
filename_out
)
call
get_command_argument
(
i
+
1
,
filename_out
)
is_output_set
=
1
end
if
if
(
trim
(
arg
)
==
trim
(
arg_key_nmax
))
then
else
if
(
trim
(
arg
)
==
trim
(
arg_key_nmax
))
then
if
(
i
==
num_args
)
then
write
(
*
,
*
)
' FAILURE! > missing nmax [key] argument'
stop
end
if
call
get_command_argument
(
i
+
1
,
arg
)
call
str2int
(
sfx_args
%
nmax
,
arg
,
status
)
call
str2int
(
dataset
%
nmax
,
arg
,
status
)
if
(
status
/
=
0
)
then
write
(
*
,
*
)
' FAILURE! > expecting int nmax [value]'
stop
end
if
if
(
sfx_args
%
nmax
<=
0
)
then
if
(
dataset
%
nmax
<=
0
)
then
write
(
*
,
*
)
' FAILURE! > nmax [value] should be positive'
stop
end
if
...
...
@@ -284,36 +324,45 @@ program sfx_main
#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
)
sfx_args
%
model
_id
=
get_model_id
(
char_array2str
(
config_field
))
if
(
sfx_args
%
model
_id
==
-1
)
then
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
)
sfx_args
%
dataset_
id
=
get_dataset_id
(
char_array2str
(
config_field
))
if
(
sfx_args
%
dataset_
id
==
-1
)
then
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
if
(
sfx_args
%
dataset_id
==
dataset_user
)
then
call
set_dataset
(
dataset
,
id
)
if
(
dataset
%
id
==
dataset_user
)
then
call
get_charf
(
"dataset.filename"
//
C_NULL_CHAR
,
config_field
)
sfx_args
%
filename
_in
=
char_array2str
(
config_field
)
dataset
%
filename
=
char_array2str
(
config_field
)
call
get_charf
(
"dataset.filename_param"
//
C_NULL_CHAR
,
config_field
)
sfx_args
%
filename_in_common
=
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
is_varname
(
"dataset.nmax"
//
C_NULL_CHAR
,
status
)
if
(
status
/
=
0
)
then
call
get_int
(
"dataset.nmax"
//
C_NULL_CHAR
,
sfx_args
%
nmax
)
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
)
sfx_args
%
filename_out
=
char_array2str
(
config_field
)
filename_out
=
char_array2str
(
config_field
)
is_output_set
=
1
end
if
...
...
@@ -321,36 +370,20 @@ program sfx_main
deallocate
(
config_field
)
#endif
!< @brief set input (& output) filenames for specific dataset
if
(
sfx_args
%
dataset_id
/
=
dataset_user
)
then
sfx_args
%
filename_in_common
=
get_dataset_param_filename
(
sfx_args
%
dataset_id
)
sfx_args
%
filename_in
=
get_dataset_filename
(
sfx_args
%
dataset_id
)
end
if
!< @bried set auto-defined output filename
if
(
is_output_set
==
0
)
then
sfx_args
%
filename_out
=
'output-'
//
trim
(
get_dataset_tag
(
sfx_args
%
dataset
_
id
))
//
'.txt'
filename_out
=
'output-'
//
trim
(
get_dataset_tag
(
dataset
%
id
))
//
'.txt'
end
if
!< @brief running main driver
dataset
%
id
=
sfx_args
%
dataset_id
dataset
%
filename
=
sfx_args
%
filename_in
dataset
%
surface_type
=
1
dataset
%
h
=
10.0
dataset
%
z0_m
=
-1.0
dataset
%
z0_h
=
-1.0
dataset
%
nmax
=
sfx_args
%
nmax
!< @brief read input data common parameters
open
(
32
,
file
=
sfx_args
%
filename_in_common
,
iostat
=
status
,
status
=
'old'
)
open
(
32
,
file
=
"data/MOSAiC_zh.txt"
,
iostat
=
status
,
status
=
'old'
)
if
(
status
/
=
0
)
then
write
(
*
,
*
)
' FAILURE! > unable to open file: '
,
trim
(
sfx_args
%
filename_in_common
)
return
stop
end
if
read
(
32
,
*
)
dataset
%
h
,
dataset
%
z0_m
close
(
32
)
!< @brief running main driver
call
run_dataset
(
sfx_args
%
filename_out
,
dataset
,
sfx_args
%
model_id
)
call
run_dataset
(
filename_out
,
dataset
,
model
)
stop
end
program
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment