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
d4866128
Commit
d4866128
authored
9 months ago
by
Debolskiy Andrey
Browse files
Options
Downloads
Patches
Plain Diff
added plt io prototype
parent
fcabb130
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+18
-0
18 additions, 0 deletions
CMakeLists.txt
src/scm_io_plt.f90
+94
-0
94 additions, 0 deletions
src/scm_io_plt.f90
src/test_io_plt.f90
+29
-0
29 additions, 0 deletions
src/test_io_plt.f90
with
141 additions
and
0 deletions
CMakeLists.txt
0 → 100644
+
18
−
0
View file @
d4866128
cmake_minimum_required
(
VERSION 3.15
)
project
(
scm_io
)
set
(
CMAKE_CXX_STANDARD 14
)
include_directories
(
src
)
enable_language
(
Fortran
)
set
(
dialect
" -free -fimplicit-none "
)
set
(
bounds
"-free -fimplicit-none "
)
set
(
CMAKE_Fortran_FLAGS_DEBUG
"
${
CMAKE_Fortran_FLAGS_DEBUG
}
${
bounds
}
-g -fbacktrace -O0 -fcheck=all"
)
set
(
CMAKE_Fortran_FLAGS
"
${
CMAKE_Fortran_FLAGS
}
${
dialect
}
"
)
set
(
plt_io
src/scm_io_plt.f90
src/test_io_plt.f90
)
add_executable
(
test_plt
${
plt_io
}
)
This diff is collapsed.
Click to expand it.
src/scm_io_plt.f90
0 → 100644
+
94
−
0
View file @
d4866128
! Created by Andrey Debolskiy on 21.05.2024.
module
scm_io_plt
implicit
none
!type declaration
type
io_struct
character
(
len
=
160
)
::
fname
integer
::
status
! 0 - closed, 1 - opened
integer
::
unit_id
end
type
io_struct
character
(
len
=
160
)
tmp_str
integer
,
public
::
nunits_max
public
contains
subroutine
set_file
(
f
,
fname
)
implicit
none
type
(
io_struct
),
intent
(
inout
)::
f
character
(
*
),
intent
(
in
)::
fname
if
(
f
%
status
==
0
)
then
f
%
unit_id
=
get_file_unit
()
open
(
f
%
unit_id
,
FILE
=
trim
(
fname
))
f
%
status
=
1
f
%
fname
=
trim
(
fname
)
end
if
end
subroutine
set_file
subroutine
write_series
(
stamp
,
vals
,
nlength
,
f
)
implicit
none
type
(
io_struct
),
intent
(
inout
)::
f
integer
,
intent
(
in
)::
nlength
real
,
intent
(
in
),
dimension
(
nlength
)::
vals
real
,
intent
(
in
)::
stamp
write
(
f
%
unit_id
,
*
)
stamp
,
vals
(:)
end
subroutine
write_series
subroutine
write_profile
(
profs
,
nprof
,
z
,
nz
,
f
)
implicit
none
type
(
io_struct
),
intent
(
inout
)::
f
integer
,
intent
(
in
)::
nprof
,
nz
real
,
intent
(
in
),
dimension
(
nz
,
nprof
)::
profs
real
,
intent
(
in
),
dimension
(
nz
)::
z
integer
k
,
n
if
(
f
%
status
==
1
)
then
do
k
=
1
,
nz
write
(
f
%
unit_id
,
*
)
z
(
k
),
profs
(
k
,:)
end
do
else
write
(
*
,
*
)
"Error in writing file:"
write
(
*
,
*
)
" "
,
f
%
fname
stop
end
if
end
subroutine
write_profile
subroutine
close_file
(
f
)
implicit
none
type
(
io_struct
),
intent
(
inout
)::
f
close
(
f
%
unit_id
)
f
%
status
=
0
end
subroutine
close_file
! get_file_unit returns a unit number that is not in use
integer
function
get_file_unit
()
integer
lu
,
iostat
integer
,
save
::
m
logical
,
save
::
initialized
=
.true.
logical
opened
if
(
initialized
)
then
m
=
nunits_max
initialized
=
.false.
end
if
if
(
m
<
8
)
then
m
=
2
*
nunits_max
end
if
do
lu
=
m
,
7
,
-1
inquire
(
unit
=
lu
,
opened
=
opened
,
iostat
=
iostat
)
if
(
iostat
.ne.
0
)
cycle
if
(
.not.
opened
)
exit
end
do
!
get_file_unit
=
lu
return
end
function
get_file_unit
end
module
scm_io_plt
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/test_io_plt.f90
0 → 100644
+
29
−
0
View file @
d4866128
! Created by Andrey Debolskiy on 21.05.2024.
program
test_io_plt
use
scm_io_plt
implicit
none
integer
,
parameter
::
nvar
=
5
,
nlength
=
10
!io variables
real
,
dimension
(
nvar
)::
series_val
type
(
io_struct
)
::
series_f
!local vars
integer
nt
,
n
real
t
!set output filenames
series_f
%
fname
=
'test_io.plt'
call
set_file
(
series_f
,
series_f
%
fname
)
do
nt
=
1
,
nlength
t
=
nt
/
100.0
do
n
=
1
,
nvar
series_val
(
n
)
=
0.1
*
n
end
do
call
write_series
(
t
,
series_val
,
nvar
,
series_f
)
end
do
call
close_file
(
series_f
)
end
program
test_io_plt
\ No newline at end of file
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