Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scm-io
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
scm-io
Commits
bb9ea835
Commit
bb9ea835
authored
9 months ago
by
Ramil Ahtamyanov
Browse files
Options
Downloads
Patches
Plain Diff
Timescan & profile recording functionality
parent
36d84147
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.f90
+14
-1
14 additions, 1 deletion
src/main.f90
src/netcdf_io_module.f90
+52
-4
52 additions, 4 deletions
src/netcdf_io_module.f90
with
66 additions
and
5 deletions
src/main.f90
+
14
−
1
View file @
bb9ea835
...
@@ -4,10 +4,23 @@ program main
...
@@ -4,10 +4,23 @@ program main
type
(
io_struct
)
::
ios
type
(
io_struct
)
::
ios
real
,
dimension
(
10
)
::
time_data
=
(/
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
,
9.0
,
10.0
/)
real
,
dimension
(
10
)
::
time_data
=
(/
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
,
9.0
,
10.0
/)
real
,
dimension
(
10
)
::
series_data
=
(/
10.0
,
9.0
,
8.0
,
7.0
,
6.0
,
5.0
,
4.0
,
3.0
,
2.0
,
1.0
/)
real
,
dimension
(
10
)
::
series_data
=
(/
10.0
,
9.0
,
8.0
,
7.0
,
6.0
,
5.0
,
4.0
,
3.0
,
2.0
,
1.0
/)
real
,
dimension
(
10
,
10
)
::
timescan_data
real
,
dimension
(
10
)
::
profile_data
integer
::
i
,
j
call
open_netcdf
(
'series_data.nc'
,
ios
,
10
)
! Инициализация данных timescan и profile
do
i
=
1
,
10
profile_data
(
i
)
=
real
(
i
)
do
j
=
1
,
10
timescan_data
(
j
,
i
)
=
real
(
j
)
+
real
(
i
)
end
do
end
do
call
open_netcdf
(
'series_data.nc'
,
ios
,
10
,
10
)
if
(
ios
%
is_open
)
then
if
(
ios
%
is_open
)
then
call
write_series
(
ios
,
time_data
,
series_data
)
call
write_series
(
ios
,
time_data
,
series_data
)
call
write_timescan
(
ios
,
timescan_data
)
call
write_profile
(
ios
,
profile_data
)
call
close_netcdf
(
ios
)
call
close_netcdf
(
ios
)
else
else
print
*
,
'Failed to open NetCDF file.'
print
*
,
'Failed to open NetCDF file.'
...
...
This diff is collapsed.
Click to expand it.
src/netcdf_io_module.f90
+
52
−
4
View file @
bb9ea835
...
@@ -4,29 +4,45 @@ module netcdf_io_module
...
@@ -4,29 +4,45 @@ module netcdf_io_module
type
::
io_struct
type
::
io_struct
integer
::
ncid
integer
::
ncid
integer
::
time_dimid
,
varid_time
,
varid_series
integer
::
time_dimid
,
height_dimid
integer
::
varid_time
,
varid_series
,
varid_timescan
,
varid_profile
logical
::
is_open
=
.false.
logical
::
is_open
=
.false.
character
(
len
=
128
)
::
series_name
=
'timeseries of variable'
character
(
len
=
128
)
::
series_name
=
'timeseries of variable'
character
(
len
=
128
)
::
series_long_name
=
'timeseries of some variable'
character
(
len
=
128
)
::
series_long_name
=
'timeseries of some variable'
character
(
len
=
128
)
::
series_units
=
'unit'
character
(
len
=
128
)
::
series_units
=
'unit'
character
(
len
=
128
)
::
timescan_name
=
'vertical timescan of variable'
character
(
len
=
128
)
::
timescan_long_name
=
'vertical timescan of some variable'
character
(
len
=
128
)
::
timescan_units
=
'unit'
character
(
len
=
128
)
::
profile_name
=
'vertical profile of variable'
character
(
len
=
128
)
::
profile_long_name
=
'vertical profile of some variable'
character
(
len
=
128
)
::
profile_units
=
'unit'
end
type
io_struct
end
type
io_struct
contains
contains
subroutine
open_netcdf
(
filename
,
ios
,
time_len
)
subroutine
open_netcdf
(
filename
,
ios
,
time_len
,
height_len
)
character
(
len
=*
),
intent
(
in
)
::
filename
character
(
len
=*
),
intent
(
in
)
::
filename
type
(
io_struct
),
intent
(
out
)
::
ios
type
(
io_struct
),
intent
(
out
)
::
ios
integer
,
intent
(
in
)
::
time_len
integer
,
intent
(
in
)
::
time_len
,
height_len
integer
::
ierr
integer
::
ierr
ierr
=
nf90_create
(
filename
,
nf90_clobber
,
ios
%
ncid
)
ierr
=
nf90_create
(
filename
,
nf90_clobber
,
ios
%
ncid
)
if
(
ierr
==
nf90_noerr
)
then
if
(
ierr
==
nf90_noerr
)
then
ios
%
is_open
=
.true.
ios
%
is_open
=
.true.
ierr
=
nf90_def_dim
(
ios
%
ncid
,
'time'
,
time_len
,
ios
%
time_dimid
)
ierr
=
nf90_def_dim
(
ios
%
ncid
,
'time'
,
time_len
,
ios
%
time_dimid
)
ierr
=
nf90_def_dim
(
ios
%
ncid
,
'height'
,
height_len
,
ios
%
height_dimid
)
ierr
=
nf90_def_var
(
ios
%
ncid
,
'time'
,
nf90_float
,
ios
%
time_dimid
,
ios
%
varid_time
)
ierr
=
nf90_def_var
(
ios
%
ncid
,
'time'
,
nf90_float
,
ios
%
time_dimid
,
ios
%
varid_time
)
ierr
=
nf90_def_var
(
ios
%
ncid
,
'series'
,
nf90_float
,
ios
%
time_dimid
,
ios
%
varid_series
)
ierr
=
nf90_def_var
(
ios
%
ncid
,
'series'
,
nf90_float
,
ios
%
time_dimid
,
ios
%
varid_series
)
ierr
=
nf90_def_var
(
ios
%
ncid
,
'timescan'
,
nf90_float
,
[
ios
%
time_dimid
,
ios
%
height_dimid
],
ios
%
varid_timescan
)
ierr
=
nf90_def_var
(
ios
%
ncid
,
'profile'
,
nf90_float
,
ios
%
height_dimid
,
ios
%
varid_profile
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_series
,
'standard_name'
,
ios
%
series_name
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_series
,
'standard_name'
,
ios
%
series_name
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_series
,
'long_name'
,
ios
%
series_long_name
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_series
,
'long_name'
,
ios
%
series_long_name
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_series
,
'units'
,
ios
%
series_units
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_series
,
'units'
,
ios
%
series_units
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_timescan
,
'standard_name'
,
ios
%
timescan_name
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_timescan
,
'long_name'
,
ios
%
timescan_long_name
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_timescan
,
'units'
,
ios
%
timescan_units
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_profile
,
'standard_name'
,
ios
%
profile_name
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_profile
,
'long_name'
,
ios
%
profile_long_name
)
ierr
=
nf90_put_att
(
ios
%
ncid
,
ios
%
varid_profile
,
'units'
,
ios
%
profile_units
)
ierr
=
nf90_enddef
(
ios
%
ncid
)
ierr
=
nf90_enddef
(
ios
%
ncid
)
else
else
print
*
,
'Error opening file: '
,
ierr
print
*
,
'Error opening file: '
,
ierr
...
@@ -47,10 +63,42 @@ contains
...
@@ -47,10 +63,42 @@ contains
ierr
=
nf90_put_var
(
ios
%
ncid
,
ios
%
varid_time
,
time_data
)
ierr
=
nf90_put_var
(
ios
%
ncid
,
ios
%
varid_time
,
time_data
)
ierr
=
nf90_put_var
(
ios
%
ncid
,
ios
%
varid_series
,
series_data
)
ierr
=
nf90_put_var
(
ios
%
ncid
,
ios
%
varid_series
,
series_data
)
if
(
ierr
/
=
nf90_noerr
)
then
if
(
ierr
/
=
nf90_noerr
)
then
print
*
,
'Error writing data:'
,
ierr
print
*
,
'Error writing
series
data:'
,
ierr
endif
endif
end
subroutine
write_series
end
subroutine
write_series
subroutine
write_timescan
(
ios
,
timescan_data
)
type
(
io_struct
),
intent
(
in
)
::
ios
real
,
dimension
(:,:),
intent
(
in
)
::
timescan_data
integer
::
ierr
if
(
.not.
ios
%
is_open
)
then
print
*
,
"File is not open."
return
endif
ierr
=
nf90_put_var
(
ios
%
ncid
,
ios
%
varid_timescan
,
timescan_data
)
if
(
ierr
/
=
nf90_noerr
)
then
print
*
,
'Error writing timescan data:'
,
ierr
endif
end
subroutine
write_timescan
subroutine
write_profile
(
ios
,
profile_data
)
type
(
io_struct
),
intent
(
in
)
::
ios
real
,
dimension
(:),
intent
(
in
)
::
profile_data
integer
::
ierr
if
(
.not.
ios
%
is_open
)
then
print
*
,
"File is not open."
return
endif
ierr
=
nf90_put_var
(
ios
%
ncid
,
ios
%
varid_profile
,
profile_data
)
if
(
ierr
/
=
nf90_noerr
)
then
print
*
,
'Error writing profile data:'
,
ierr
endif
end
subroutine
write_profile
subroutine
close_netcdf
(
ios
)
subroutine
close_netcdf
(
ios
)
type
(
io_struct
),
intent
(
inout
)
::
ios
type
(
io_struct
),
intent
(
inout
)
::
ios
integer
::
ierr
integer
::
ierr
...
...
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