5 stdlog, mpp_pe, mpp_root_pe, write_version_number, &
8 use mpp_io_mod,
only: mpp_open, mpp_netcdf, mpp_rdonly,mpp_multi, mpp_single
10 use mpp_io_mod,
only: mpp_get_fields, mpp_get_info, mpp_get_axes, mpp_get_times
27 real(FVPRC),
parameter ::
p0 = 1.e5
33 (/
'lon',
'lat',
'lev' /)
41 (/
'P0 ',
'hyai',
'hybi',
'PHI ',
'PS ',
'T ',
'Q ',
'U ',
'V ' /)
60 integer,
pointer :: length_axes(:)
61 integer :: ndim, nvar, natt, ntim, varid_time
62 integer :: time_offset
63 integer,
dimension(NUM_REQ_FLDS) :: field_index
64 integer,
dimension(NUM_REQ_AXES) :: axis_index
65 type(
axistype),
dimension(NUM_REQ_FLDS) :: axes
76 integer,
intent(out) :: nlon, nlat, nlev, ntime
82 integer :: iunit, ierr, io
83 character(len=128) :: name
84 integer :: istat, i, j, k, n, nd, siz(4), i1, i2
85 type(
axistype),
allocatable :: axes(:)
98 #ifdef INTERNAL_FILE_NML 102 if (file_exist(
'input.nml') )
then 103 iunit = open_namelist_file()
106 read (iunit, nml=read_climate_nudge_data_nml, iostat=io, end=10)
109 10
call close_file (iunit)
116 call write_version_number (
'0.0',
'fv3-jedi-lm' )
117 if (mpp_pe() == mpp_root_pe())
write (iunit, nml=read_climate_nudge_data_nml)
133 call mpp_open(
files(n)%ncid, trim(
filenames(n)), form=mpp_netcdf,action=mpp_rdonly,threading=mpp_multi, &
139 allocate (
files(n)%length_axes(
files(n)%ndim))
140 allocate (axes(
files(n)%ndim))
141 call mpp_get_axes(
files(n)%ncid,axes)
144 do i = 1,
files(n)%ndim
149 files(n)%axes(j) = axes(i)
150 files(n)%axis_index(j) = i
160 allocate(fields(
files(n)%nvar))
161 call mpp_get_fields(
files(n)%ncid,fields)
162 files(n)%field_index = 0
163 do i = 1,
files(n)%nvar
164 call mpp_get_atts(fields(i), name=name, ndim=nd, siz=siz)
167 files(n)%field_index(j) = i
168 files(n)%fields(j) = fields(i)
193 i2 = i2+
files(n)%ntim
211 subroutine read_time ( times, units, calendar )
212 real(FVPRC),
intent(out) :: times(:)
213 character(len=*),
intent(out) :: units, calendar
214 integer :: istat, i1, i2, n
216 character(len=32) :: default_calendar
219 call error_mesg (
'read_climate_nudge_data_nlm_mod/read_time', &
220 'module not initialized', fatal)
223 if (
size(times(:)) <
numtime)
then 224 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'argument times too small in read_time', fatal)
231 i2 = i2+
files(n)%ntim
233 default_calendar = mpp_get_default_calendar()
234 call mpp_get_time_axis(
files(n)%ncid, time_axis)
235 call mpp_get_atts(time_axis, units=units, calendar=calendar)
236 if( trim(calendar) == trim(default_calendar)) calendar =
'gregorian ' 238 call mpp_get_times(
files(n)%ncid, times(i1:i2))
248 subroutine read_grid ( lon, lat, ak, bk )
249 real(FVPRC),
intent(out),
dimension(:) :: lon, lat, ak, bk
255 call error_mesg (
'read_climate_nudge_data_nlm_mod/read_grid', &
256 'module not initialized', fatal)
290 real(FVPRC),
intent(in) :: ylo, yhi, ydat(:)
291 integer,
intent(out) :: js, je
295 call error_mesg (
'read_climate_nudge_data_nlm_mod/read_sub_domain_init', &
296 'module not initialized', fatal)
299 if (ydat(1) < ydat(2))
then 301 do j = 1,
size(ydat(:))-1
302 if (ylo >= ydat(j) .and. ylo <= ydat(j+1))
then 310 print *,
'js,ydat=',js,ydat(js)
311 print *,
'ydat=',ydat(:js+2)
315 do j = js,
size(ydat(:))-1
316 if (yhi >= ydat(j) .and. yhi <= ydat(j+1))
then 324 print *,
'je,ydat=',je,ydat(je)
325 print *,
'ydat=',ydat(je-2:)
330 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'latitude values for observational data decrease with increasing index', note)
332 do j = 1,
size(ydat(:))-1
333 if (ylo >= ydat(j+1) .and. ylo <= ydat(j))
then 341 if (yhi >= ydat(j+1) .and. yhi <= ydat(j))
then 356 integer,
intent(in) :: itime
357 character(len=4),
intent(in) :: field
358 real(FVPRC),
intent(out),
dimension(:,:) :: dat
359 integer,
intent(in),
optional :: is, js
360 integer :: istat, atime, n, this_index
361 integer :: nread(4), start(4)
364 call error_mesg (
'read_climate_nudge_data_nlm_mod', &
365 'module not initialized', fatal)
368 if (itime < 1 .or. itime >
numtime)
then 369 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'itime out of range', fatal)
373 if (
present(js))
then 378 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect 2d array dimensions', fatal)
383 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect 2d array dimensions', fatal)
387 if (field .eq.
'phis')
then 389 else if (field .eq.
'psrf')
then 392 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect field requested in read_climate_nudge_data_2d', fatal)
397 atime = itime -
files(n)%time_offset
400 if (
present(is)) start(1) = is
401 if (
present(js)) start(2) = js
405 nread(1) =
size(dat,1)
406 nread(2) =
size(dat,2)
411 if (field .eq.
'phis')
then 412 if (maxval(dat) > 1000.*
grav)
then 424 integer,
intent(in) :: itime
425 character(len=4),
intent(in) :: field
426 real(FVPRC),
intent(out),
dimension(:,:,:) :: dat
427 integer,
intent(in),
optional :: is, js
428 integer :: istat, atime, n, this_index, start(4), nread(4)
432 call error_mesg (
'read_climate_nudge_data_nlm_mod', &
433 'module not initialized', fatal)
437 if (itime < 1 .or. itime >
numtime)
then 438 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'itime out of range', fatal)
442 if (
present(js))
then 448 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect 3d array dimensions', fatal)
454 call error_mesg (
'read_climate_nudge_mod',
'incorrect 3d array dimensions', fatal)
458 if (field .eq.
'temp')
then 460 else if (field .eq.
'qhum')
then 462 else if (field .eq.
'uwnd')
then 464 else if (field .eq.
'vwnd')
then 467 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect field requested in read_climate_nudge_data_3d', fatal)
473 atime = itime -
files(n)%time_offset
476 if (
present(is)) start(1) = is
477 if (
present(js)) start(2) = js
481 nread(1) =
size(dat,1)
482 nread(2) =
size(dat,2)
483 nread(3) =
size(dat,3)
502 call mpp_close(
files(n)%ncid)
512 integer,
intent(in) :: ind,lendim
528 integer,
intent(in) :: axis_len(:)
530 if (
size(axis_len(:)) .lt. 2)
then 531 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect number of array dimensions', fatal)
534 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect array dimension one', fatal)
537 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect array dimension two', fatal)
539 if (
size(axis_len(:)) .gt. 3)
then 541 call error_mesg (
'read_climate_nudge_data_nlm_mod',
'incorrect array dimension three', fatal)
integer, parameter num_req_flds
character(len=256) filename_head
real(fvprc), parameter p0
integer, parameter index_zs
type(filedata_type), dimension(:), allocatable files
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
integer, parameter index_q
character(len=256), dimension(maxfiles) filenames
real(fvprc), parameter d608
integer function, public check_nml_error(IOSTAT, NML_NAME)
character(len=256), dimension(maxfiles) filename_tails
character(len=input_str_length), dimension(:), allocatable, target, public input_nml_file
integer, parameter index_ak
integer, parameter index_lev
subroutine read_climate_nudge_data_2d(itime, field, dat, is, js)
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
subroutine check_resolution(axis_len)
integer, parameter index_bk
subroutine read_climate_nudge_data_3d(itime, field, dat, is, js)
real, parameter, public grav
Acceleration due to gravity [m/s^2].
integer, parameter index_lon
integer, parameter maxfiles
subroutine check_axis_size(ind, lendim)
logical module_is_initialized
subroutine, public read_grid(lon, lat, ak, bk)
integer, parameter index_v
integer, parameter index_u
integer, parameter index_lat
integer sub_domain_latitude_size
integer, parameter index_t
integer, parameter index_p0
integer, dimension(num_req_axes) global_axis_size
integer, dimension(:), allocatable file_index
character(len=8), dimension(num_req_flds) required_field_names
subroutine, public read_sub_domain_init(ylo, yhi, ydat, js, je)
subroutine, public read_time(times, units, calendar)
character(len=8), dimension(num_req_axes) required_axis_names
subroutine, public error_mesg(routine, message, level)
subroutine, public read_climate_nudge_data_init(nlon, nlat, nlev, ntime)
subroutine, public read_climate_nudge_data_end
integer, parameter index_ps
integer, parameter num_req_axes
real(fp), parameter, public pi