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

Allow reading from files with multiple time steps

parent 11677eee
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,13 @@ contains
integer unit
integer ncid, dimid, varid
integer:: nc_time = 1
! Index, 1-based, in the NetCDF time coordinate, if any, of the
! time slice to read. If there is no time coordinate, then leave
! nc_time to its default 1 value. If there is a time coordinate
! then we assume that the dimensions of the ssh, u and v NetCDF
! variables are longitude, latitude and time, in Fortran order.
real:: corner_deg(2) = huge(0.)
! longitude and latitude of the corner of the whole grid, in degrees
......@@ -69,7 +76,7 @@ contains
integer copy
namelist /grid_nml/ corner_deg, step_deg, nlon, nlat, periodic, &
uniform_lon_lat
namelist /input_ssh_nml/ periodic, uniform_lon_lat
namelist /input_ssh_nml/ periodic, uniform_lon_lat, nc_time
!----------------------------------------------------------------------
......@@ -121,7 +128,7 @@ contains
! Read ssh, u and v:
call get_var(periodic, ssh, ncid, name = "adt", &
call get_var(periodic, ssh, ncid, nc_time, name = "adt", &
new_fill_value = huge(0.))
! (We cannot keep the original fill value because Contour_531
! works with an upper limit for valid values.)
......@@ -131,7 +138,7 @@ contains
call nf95_open(u_fname, nf95_nowrite, ncid)
end if
call get_var(periodic, u, ncid, name = "ugos", &
call get_var(periodic, u, ncid, nc_time, name = "ugos", &
new_fill_value = ieee_value(0., IEEE_QUIET_NAN))
if (v_fname /= u_fname) then
......@@ -139,7 +146,7 @@ contains
call nf95_open(v_fname, nf95_nowrite, ncid)
end if
call get_var(periodic, v, ncid, name = "vgos", &
call get_var(periodic, v, ncid, nc_time, name = "vgos", &
new_fill_value = ieee_value(0., IEEE_QUIET_NAN))
! (We will need quiet NaNs rather the original fill values for u and
! v when we compute the max-speed contours and when we search the
......@@ -150,7 +157,7 @@ contains
!*********************************************************************
subroutine get_var(periodic, values, ncid, name, new_fill_value)
subroutine get_var(periodic, values, ncid, nc_time, name, new_fill_value)
! Read a NetCDF variable, change the missing value and extend it
! in longitude if periodic.
......@@ -169,6 +176,14 @@ contains
! declaration references periodic.
integer, intent(in):: ncid
integer, intent(in):: nc_time
! Index, 1-based, in the NetCDF time coordinate, if any, of the
! time slice to read. If there is no time coordinate, then nc_time
! should be equal to 1. If there is a time coordinate then we
! assume that the dimension of the NetCDF variable to read are
! longitude, latitude and time, in Fortran order.
character(len = *), intent(in):: name ! of NetCDF variable
real, intent(in):: new_fill_value
......@@ -179,7 +194,14 @@ contains
!-------------------------------------------------------------------------
call nf95_inq_varid(ncid, name, varid)
call nf95_get_var(ncid, varid, values(1:nlon, :))
if (nc_time == 1) then
call nf95_get_var(ncid, varid, values(1:nlon, :))
else
call nf95_get_var(ncid, varid, values(1:nlon, :), &
start = [1, 1, nc_time])
end if
call nf95_get_missing(ncid, varid, Fill_Value)
! Change the missing value:
......
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