Skip to content
Snippets Groups Projects
Commit 8011c479 authored by GUEZ Lionel's avatar GUEZ Lionel
Browse files

Move procedure `get_var` to module `input_ssh_m`

Preparing to allow access to variables of module `input_ssh_m`.
parent db90bb88
No related branches found
No related tags found
No related merge requests found
# inst_eddies:
add_executable(inst_eddies inst_eddies.f90 local_extrema.f90 set_max_speed.f90
get_1_outerm.f90 good_contour.f90 mean_speed.f90 set_contours.f90
nearby_extr.f90 get_var.f90 config.f90 input_ssh.f90 shpc_create.f90
write_snapshot.f90 ccw_orient.f90 write_eddy.f90 set_all_extr.f90
complete_ssh.f90)
nearby_extr.f90 config.f90 input_ssh.f90 shpc_create.f90 write_snapshot.f90
ccw_orient.f90 write_eddy.f90 set_all_extr.f90 complete_ssh.f90)
target_link_libraries(inst_eddies PRIVATE Contour_531::contour_531
Geometry::geometry NetCDF95::netcdf95 Shapelib_03::shapelib_03
Numer_Rec_95::numer_rec_95 Jumble::jumble NetCDF_Fortran::netcdff)
......@@ -19,19 +18,17 @@ configure_file(inst_eddies_Aviso.py . COPYONLY FILE_PERMISSIONS
# Tests:
add_subdirectory(Tests)
target_sources(test_get_1_outerm PRIVATE get_1_outerm.f90 good_contour.f90
config.f90 input_ssh.f90 get_var.f90 shpc_create.f90 write_eddy.f90
ccw_orient.f90)
config.f90 input_ssh.f90 shpc_create.f90 write_eddy.f90 ccw_orient.f90)
target_sources(test_good_contour PRIVATE good_contour.f90)
target_sources(test_mean_speed PRIVATE mean_speed.f90 input_ssh.f90 get_var.f90
config.f90)
target_sources(test_mean_speed PRIVATE mean_speed.f90 input_ssh.f90 config.f90)
target_sources(test_nearby_extr PRIVATE nearby_extr.f90)
target_sources(test_local_extrema PRIVATE local_extrema.f90)
target_sources(test_set_max_speed PRIVATE set_max_speed.f90 good_contour.f90
mean_speed.f90 get_var.f90 config.f90 input_ssh.f90 shpc_create.f90
ccw_orient.f90 write_eddy.f90 complete_ssh.f90)
mean_speed.f90 config.f90 input_ssh.f90 shpc_create.f90 ccw_orient.f90
write_eddy.f90 complete_ssh.f90)
target_sources(test_write_null PRIVATE shpc_create.f90)
target_sources(test_complete_ssh PRIVATE complete_ssh.f90)
target_sources(examine_eddy PRIVATE config.f90 input_ssh.f90 get_var.f90
shpc_create.f90 set_all_extr.f90 local_extrema.f90 write_eddy.f90
set_contours.f90 get_1_outerm.f90 ccw_orient.f90 good_contour.f90
set_max_speed.f90 complete_ssh.f90 mean_speed.f90)
target_sources(examine_eddy PRIVATE config.f90 input_ssh.f90 shpc_create.f90
set_all_extr.f90 local_extrema.f90 write_eddy.f90 set_contours.f90
get_1_outerm.f90 ccw_orient.f90 good_contour.f90 set_max_speed.f90
complete_ssh.f90 mean_speed.f90)
module get_var_m
implicit none
contains
subroutine get_var(periodic, max_rad_lon, values, ncid, nlon, name, &
new_fill_value)
! Read a NetCDF variable, change the missing value and extend it
! in longitude if periodic.
! Libraries:
use netcdf95, only: nf95_inq_varid, nf95_get_var, nf95_get_missing
logical, intent(in):: periodic ! grid is periodic in longitude
integer, intent(in):: max_rad_lon ! maximum radius of an eddy in
! longitude, in number of grid points, used only if periodic
real, intent(out):: values(1 - merge(max_rad_lon, 0, periodic):, :)
! (1 - merge(max_rad_lon, 0, periodic):nlon + merge(max_rad_lon,
! 0, periodic), nlat) ssh, u or v. We cannot place this argument
! first because the declaration references max_rad_lon and
! periodic.
integer, intent(in):: ncid, nlon
character(len = *), intent(in):: name ! of NetCDF variable
real, intent(in):: new_fill_value
! Local:
integer varid
real Fill_Value
!-------------------------------------------------------------------------
call nf95_inq_varid(ncid, name, varid)
call nf95_get_var(ncid, varid, values(1:nlon, :))
call nf95_get_missing(ncid, varid, Fill_Value)
! Change the missing value:
where (values(1:nlon, :) == Fill_Value) values(1:nlon, :) = new_fill_value
if (periodic) then
! Extend in longitude:
values(1 - max_rad_lon:0, :) &
= values(nlon + 1 - max_rad_lon:nlon, :)
values(nlon + 1:nlon + max_rad_lon, :) = values(1:max_rad_lon, :)
end if
end subroutine get_var
end module get_var_m
......@@ -21,7 +21,6 @@ contains
nf95_get_var, nf95_close, nf95_nowrite
use config_m, only: max_radius_deg
use get_var_m, only: get_var
real, intent(out):: step(:) ! (2) longitude and latitude steps, in rad
......@@ -156,4 +155,52 @@ contains
end subroutine input_ssh
!*********************************************************************
subroutine get_var(periodic, max_rad_lon, values, ncid, nlon, name, &
new_fill_value)
! Read a NetCDF variable, change the missing value and extend it
! in longitude if periodic.
! Libraries:
use netcdf95, only: nf95_inq_varid, nf95_get_var, nf95_get_missing
logical, intent(in):: periodic ! grid is periodic in longitude
integer, intent(in):: max_rad_lon ! maximum radius of an eddy in
! longitude, in number of grid points, used only if periodic
real, intent(out):: values(1 - merge(max_rad_lon, 0, periodic):, :)
! (1 - merge(max_rad_lon, 0, periodic):nlon + merge(max_rad_lon,
! 0, periodic), nlat) ssh, u or v. We cannot place this argument
! first because the declaration references max_rad_lon and
! periodic.
integer, intent(in):: ncid, nlon
character(len = *), intent(in):: name ! of NetCDF variable
real, intent(in):: new_fill_value
! Local:
integer varid
real Fill_Value
!-------------------------------------------------------------------------
call nf95_inq_varid(ncid, name, varid)
call nf95_get_var(ncid, varid, values(1:nlon, :))
call nf95_get_missing(ncid, varid, Fill_Value)
! Change the missing value:
where (values(1:nlon, :) == Fill_Value) values(1:nlon, :) = new_fill_value
if (periodic) then
! Extend in longitude:
values(1 - max_rad_lon:0, :) &
= values(nlon + 1 - max_rad_lon:nlon, :)
values(nlon + 1:nlon + max_rad_lon, :) = values(1:max_rad_lon, :)
end if
end subroutine get_var
end module input_ssh_m
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment