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
a5e04c10
Commit
a5e04c10
authored
8 months ago
by
Debolskiy Andrey
Browse files
Options
Downloads
Patches
Plain Diff
update cmakelists to work with netcdff
parent
30d5f4be
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+35
-13
35 additions, 13 deletions
CMakeLists.txt
src/test_netcdf.f90
+65
-10
65 additions, 10 deletions
src/test_netcdf.f90
with
100 additions
and
23 deletions
CMakeLists.txt
+
35
−
13
View file @
a5e04c10
...
...
@@ -6,17 +6,16 @@ set(CMAKE_CXX_STANDARD 14)
set
(
CMAKE_Fortran_MODULE_DIRECTORY
${
CMAKE_BINARY_DIR
}
/modules
)
enable_language
(
Fortran
)
find_package
(
netCDF-Fortran REQUIRED
HINTS /usr/local/lib/cmake/netCDF/
)
find_package
(
hdf5 REQUIRED
HINTS /usr/local/lib/cmake/hdf5/
)
#
find_package(netCDF-Fortran REQUIRED
#
HINTS /usr/local/lib/cmake/netCDF/)
#set(HDF5_USE_STATIC_LIBRARIES YES)
#find_package(hdf5 REQUIRED
HINTS /usr/local/lib/cmake/hdf5/)
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
}
"
)
include_directories
(
src
)
set
(
src_io
src/scm_io_plt.f90
...
...
@@ -24,11 +23,34 @@ set(src_io
src/io_metadata.f90
)
add_library
(
test_io
${
src_io
}
)
target_include_directories
(
test_io PRIVATE
${
netCDF_INCLUDE_DIR
}
)
target_link_libraries
(
test_io PRIVATE netCDF::netcdff
)
target_link_libraries
(
test_io PRIVATE hdf5
)
add_library
(
lib_scm_io
${
src_io
}
)
#NetCDF handling
execute_process
(
COMMAND bash -c
"nc-config --fflags | grep -Eo '^[^ ]+' | tr -d '
\n
'"
OUTPUT_VARIABLE netcdf_inc
)
cmake_path
(
SET netcfd_inc_dir
"
${
netcdf_inc
}
"
)
message
(
"CMake path is
${
netcdf_inc
}
"
)
target_compile_options
(
lib_scm_io PRIVATE
${
netcdf_inc
}
)
#include_directories(${netcdf_inc})
execute_process
(
COMMAND bash -c
"nc-config --flibs | tr -d '
\n
'"
OUTPUT_VARIABLE temp
)
separate_arguments
(
netcdff_libs UNIX_COMMAND
"
${
temp
}
"
)
execute_process
(
COMMAND bash -c
"nc-config --libs | tr -d '
\n
'"
OUTPUT_VARIABLE temp
)
separate_arguments
(
netcdf_libs UNIX_COMMAND
"
${
temp
}
"
)
#target_include_directories(lib_scm_io PRIVATE ${netCDF_INCLUDE_DIR})
#target_link_libraries(lib_scm_io PRIVATE netCDF::netcdff)
#target_link_libraries(lib_scm_io PRIVATE hdf5)
add_executable
(
test_netcdf_io src/test_netcdf.f90
)
target_link_options
(
test_netcdf_io PRIVATE
${
netcdff_libs
}
)
target_link_options
(
test_netcdf_io PRIVATE
${
netcdf_libs
}
)
target_link_libraries
(
test_netcdf_io lib_scm_io
)
This diff is collapsed.
Click to expand it.
src/test_netcdf.f90
+
65
−
10
View file @
a5e04c10
! Created by Andrey Debolskiy on 14.06.2024.
program
test_netcdf
use
netcdf_io_module
use
io
,
only
:
variable_metadata
,
write_2d_real_nc
,
write_1d_real_nc
implicit
none
integer
,
parameter
::
nt
=
10
,
nx
=
100
real
t
,
x
real
,
dimension
(
nt
)
::
series_t
;
real
,
dimension
(
nx
)
::
profile
;
real
,
dimension
(
nx
,
nt
)
::
time_scan
;
type
(
io_struct
)
::
file_nc
;
character
(
20
)
fname
integer
,
parameter
::
nx
=
100
,
ny
=
100
real
x
(
nx
),
y
(
ny
),
temperature
(
nx
,
ny
)
character
(
20
)
fname_nc
type
(
variable_metadata
)
::
meta_x
=
variable_metadata
(
&
name
=
'X'
,
&
dim_names
=
[
character
(
len
=
32
)
::
'X'
,
''
,
''
,
''
],
&
char_name
=
[
character
(
len
=
32
)
::
&
'long_name'
,
&
'units'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
char_value
=
[
character
(
len
=
32
)
::
&
'X'
,
&
'm'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
real_name
=
[
character
(
len
=
32
)
::
&
'missing_value'
,
&
'scale_factor'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
real_value
=
[&
-9999.9
,
&
1.0
,
&
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
])
type
(
variable_metadata
)
::
meta_y
=
variable_metadata
(
&
name
=
'Y'
,
&
dim_names
=
[
character
(
len
=
32
)
::
'Y'
,
''
,
''
,
''
],
&
char_name
=
[
character
(
len
=
32
)
::
&
'long_name'
,
&
'units'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
char_value
=
[
character
(
len
=
32
)
::
&
'Y'
,
&
'm'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
real_name
=
[
character
(
len
=
32
)
::
&
'missing_value'
,
&
'scale_factor'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
real_value
=
[&
-9999.9
,
&
1.0
,
&
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
])
type
(
variable_metadata
)
::
meta_temperature
=
variable_metadata
(
&
name
=
'T2M'
,
&
dim_names
=
[
character
(
len
=
32
)
::
'X'
,
'Y'
,
''
,
''
],
&
char_name
=
[
character
(
len
=
32
)
::
&
'long_name'
,
&
'units'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
char_value
=
[
character
(
len
=
32
)
::
&
'Air Temperature'
,
&
'C'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
real_name
=
[
character
(
len
=
32
)
::
&
'missing_value'
,
&
'scale_factor'
,
&
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
],
&
real_value
=
[&
-9999.9
,
&
1.0
,
&
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
])
fname
=
'test_io.nc'
call
open_netcdf
(
trim
(
fname
),
file_nc
,
nt
,
nx
,
1
,
1
)
fname_nc
=
'test_io.nc'
call
write_1d_real_nc
(
x
,
fname_nc
,
meta_x
)
call
write_1d_real_nc
(
y
,
fname_nc
,
meta_y
)
call
write_2d_real_nc
(
temperature
,
fname_nc
,
meta_temperature
)
end
program
test_netcdf
\ 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