SCALE-RM
Data Types | Functions/Subroutines | Variables
scale_external_io Module Reference

module FILE I/O (netcdf) More...

Functions/Subroutines

subroutine, public externalfilegetshape (dims, timelen, mdlid, basename, myrank, single)
 
subroutine externalfilegetglobalattvinteger (var, mdlid, basename, attname, myrank, single)
 
subroutine externalfilegetglobalattvrealsp (var, mdlid, basename, attname, myrank, single)
 
subroutine externalfilegetglobalattvrealdp (var, mdlid, basename, attname, myrank, single)
 
subroutine, public externalfilegetglobalattc (chr, mdlid, basename, attname, myrank, single)
 
subroutine, public externalfilevarexistence (existence, basename, varname, myrank, mdlid, single)
 Check Existence of a Variable. More...
 
subroutine externalfileread2drealsp (var, basename, varname, ts, te, myrank, mdlid, nx, single)
 File Read. More...
 
subroutine externalfileread2drealdp (var, basename, varname, ts, te, myrank, mdlid, nx, single)
 
subroutine externalfileread3drealsp (var, basename, varname, ts, te, myrank, mdlid, single, xstag, ystag, option)
 
subroutine externalfileread3drealdp (var, basename, varname, ts, te, myrank, mdlid, single, xstag, ystag)
 
subroutine externalfileread4drealsp (var, basename, varname, ts, te, myrank, mdlid, single, xstag, ystag, zstag, landgrid, option)
 
subroutine externalfileread4drealdp (var, basename, varname, ts, te, myrank, mdlid, single, xstag, ystag, zstag, landgrid)
 
subroutine externalfilereadoffset3drealsp (var, basename, varname, ts, te, myrank, mdlid, single, xstag, ystag)
 
subroutine externalfilereadoffset3drealdp (var, basename, varname, ts, te, myrank, mdlid, single, xstag, ystag)
 
subroutine externalfilereadoffset4drealsp (var, basename, varname, ts, te, myrank, mdlid, single, xstag, ystag, zstag, landgrid)
 
subroutine externalfilereadoffset4drealdp (var, basename, varname, ts, te, myrank, mdlid, single, xstag, ystag, zstag, landgrid)
 
subroutine convertarrayorderwrf2dsp (var, var_org, tcount, nx)
 

Variables

integer, parameter, public iscale = 1
 
integer, parameter, public iwrfarw = 2
 
integer, parameter, public inicam = 3
 
integer, parameter, public igrads = 4
 

Detailed Description

module FILE I/O (netcdf)

Description
general file I/O module frontend interface of netCDF I/O routine
Author
Team SCALE
History
  • 2014-05-01 (R.Yoshida) [new]

Function/Subroutine Documentation

◆ externalfilegetshape()

subroutine, public scale_external_io::externalfilegetshape ( integer, dimension(:), intent(out)  dims,
integer, intent(out)  timelen,
integer, intent(in)  mdlid,
character(len=*), intent(in)  basename,
integer, intent(in)  myrank,
logical, intent(in), optional  single 
)

Definition at line 110 of file scale_external_io.F90.

References scale_stdio::io_fid_log, scale_stdio::io_l, iwrfarw, and scale_process::prc_mpistop().

Referenced by mod_realinput_wrfarw::parentatomsetupwrfarw(), mod_realinput_wrfarw::parentlandsetupwrfarw(), and mod_realinput_wrfarw::parentoceansetupwrfarw().

110  use netcdf ![external lib]
111  implicit none
112 
113  integer, intent(out) :: dims(:)
114  integer, intent(out) :: timelen
115  integer, intent( in) :: mdlid
116  character(len=*), intent( in) :: basename
117  integer, intent( in) :: myrank
118  logical, intent( in), optional :: single
119 
120  integer :: status
121  integer :: ncid, unlimid
122  integer :: dims_org(7)
123  character(len=NF90_MAX_NAME) :: tname
124  character(len=H_LONG) :: fname = ''
125  logical :: single_ = .false.
126 
127  intrinsic size
128  intrinsic shape
129  !---------------------------------------------------------------------------
130 
131  if ( present(single) ) then
132  single_ = single
133  else
134  single_ = .false.
135  endif
136 
137  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
138 
139  status = nf90_open( trim(fname), nf90_nowrite, ncid )
140  if (status /= nf90_noerr) call handle_err(status, __line__)
141 
142  status = nf90_inquire( ncid, unlimiteddimid=unlimid )
143  if (status /= nf90_noerr) call handle_err(status, __line__)
144 
145  status = nf90_inquire_dimension( ncid, unlimid, tname, timelen )
146  if (status /= nf90_noerr) call handle_err(status, __line__)
147 
148  if( trim(tname)=='time' .OR. trim(tname)=='Time' ) then
149  if( io_l ) write(io_fid_log,*) 'Time Dimension Name: '//trim(tname)
150  else
151  write(*,*) 'xxx Not appropriate time dimension is used in the external file. Check!'
152  call prc_mpistop
153  endif
154 
155  call externaltakedimension( dims_org(:),ncid,mdlid )
156 
157  ! convert dimension order for return to scale-system
158  if( mdlid == iwrfarw )then !MODEL ID: WRF-ARW
159  dims(1) = dims_org(3)
160  dims(2) = dims_org(1)
161  dims(3) = dims_org(2)
162  dims(4) = dims_org(6)
163  dims(5) = dims_org(4)
164  dims(6) = dims_org(5)
165  dims(7) = dims_org(7)
166  else
167  dims(:) = dims_org(:)
168  endif
169 
170  status = nf90_close(ncid)
171  if (status /= nf90_noerr) call handle_err(status, __line__)
172 
173  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalfilegetglobalattvinteger()

subroutine scale_external_io::externalfilegetglobalattvinteger ( integer, dimension(:), intent(out)  var,
integer, intent(in)  mdlid,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  attname,
integer, intent(in)  myrank,
logical, intent(in), optional  single 
)

Definition at line 187 of file scale_external_io.F90.

187  use netcdf ![external lib]
188  implicit none
189 
190  integer, intent(out) :: var(:)
191  integer, intent( in) :: mdlid
192  character(len=*), intent( in) :: basename
193  character(len=*), intent( in) :: attname
194  integer, intent( in) :: myrank
195  logical, intent( in), optional :: single
196 
197  integer, allocatable :: work(:)
198 
199  integer :: status
200  integer :: i, ncid, length
201  character(len=H_LONG) :: fname = ''
202  logical :: single_ = .false.
203 
204  intrinsic size
205  intrinsic shape
206  !---------------------------------------------------------------------------
207 
208  if ( present(single) ) then
209  single_ = single
210  else
211  single_ = .false.
212  endif
213 
214  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
215 
216  status = nf90_open( trim(fname), nf90_nowrite, ncid )
217  if (status /= nf90_noerr) call handle_err(status, __line__)
218 
219  status = nf90_inquire_attribute(ncid, nf90_global, trim(attname), len=length)
220  if (status /= nf90_noerr) call handle_err(status, __line__)
221 
222  allocate( work(length) )
223 
224  status = nf90_get_att(ncid, nf90_global, trim(attname), work)
225  if (status /= nf90_noerr) call handle_err(status, __line__)
226 
227  do i = 1, length
228  var(i) = work(i)
229  enddo
230 
231  status = nf90_close(ncid)
232  if (status /= nf90_noerr) call handle_err(status, __line__)
233  deallocate( work )
234 
235  return

◆ externalfilegetglobalattvrealsp()

subroutine scale_external_io::externalfilegetglobalattvrealsp ( real(sp), dimension(:), intent(out)  var,
integer, intent(in)  mdlid,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  attname,
integer, intent(in)  myrank,
logical, intent(in), optional  single 
)

Definition at line 249 of file scale_external_io.F90.

249  use netcdf ![external lib]
250  implicit none
251 
252  real(SP), intent(out) :: var(:)
253  integer, intent( in) :: mdlid
254  character(len=*), intent( in) :: basename
255  character(len=*), intent( in) :: attname
256  integer, intent( in) :: myrank
257  logical, intent( in), optional :: single
258 
259  real(SP), allocatable :: work(:)
260 
261  integer :: status
262  integer :: i, ncid, length
263  character(len=H_LONG) :: fname = ''
264  logical :: single_ = .false.
265 
266  intrinsic size
267  intrinsic shape
268  !---------------------------------------------------------------------------
269 
270  if ( present(single) ) then
271  single_ = single
272  else
273  single_ = .false.
274  endif
275 
276  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
277 
278  status = nf90_open( trim(fname), nf90_nowrite, ncid )
279  if (status /= nf90_noerr) call handle_err(status, __line__)
280 
281  status = nf90_inquire_attribute(ncid, nf90_global, trim(attname), len=length)
282  if (status /= nf90_noerr) call handle_err(status, __line__)
283 
284  allocate( work(length) )
285 
286  status = nf90_get_att(ncid, nf90_global, trim(attname), work)
287  if (status /= nf90_noerr) call handle_err(status, __line__)
288 
289  do i = 1, length
290  var(i) = work(i)
291  enddo
292 
293  status = nf90_close(ncid)
294  if (status /= nf90_noerr) call handle_err(status, __line__)
295  deallocate( work )
296 
297  return

◆ externalfilegetglobalattvrealdp()

subroutine scale_external_io::externalfilegetglobalattvrealdp ( real(dp), dimension(:), intent(out)  var,
integer, intent(in)  mdlid,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  attname,
integer, intent(in)  myrank,
logical, intent(in), optional  single 
)

Definition at line 311 of file scale_external_io.F90.

311  use netcdf ![external lib]
312  implicit none
313 
314  real(DP), intent(out) :: var(:)
315  integer, intent( in) :: mdlid
316  character(len=*), intent( in) :: basename
317  character(len=*), intent( in) :: attname
318  integer, intent( in) :: myrank
319  logical, intent( in), optional :: single
320 
321  real(DP), allocatable :: work(:)
322 
323  integer :: status
324  integer :: i, ncid, length
325  character(len=H_LONG) :: fname = ''
326  logical :: single_ = .false.
327 
328  intrinsic size
329  intrinsic shape
330  !---------------------------------------------------------------------------
331 
332  if ( present(single) ) then
333  single_ = single
334  else
335  single_ = .false.
336  endif
337 
338  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
339 
340  status = nf90_open( trim(fname), nf90_nowrite, ncid )
341  if (status /= nf90_noerr) call handle_err(status, __line__)
342 
343  status = nf90_inquire_attribute(ncid, nf90_global, trim(attname), len=length)
344  if (status /= nf90_noerr) call handle_err(status, __line__)
345 
346  allocate( work(length) )
347 
348  status = nf90_get_att(ncid, nf90_global, trim(attname), work)
349  if (status /= nf90_noerr) call handle_err(status, __line__)
350 
351  do i = 1, length
352  var(i) = work(i)
353  enddo
354 
355  status = nf90_close(ncid)
356  if (status /= nf90_noerr) call handle_err(status, __line__)
357  deallocate( work )
358 
359  return

◆ externalfilegetglobalattc()

subroutine, public scale_external_io::externalfilegetglobalattc ( character(len=*), dimension(:), intent(out)  chr,
integer, intent(in)  mdlid,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  attname,
integer, intent(in)  myrank,
logical, intent(in), optional  single 
)

Definition at line 373 of file scale_external_io.F90.

References scale_process::prc_mpistop().

373  use netcdf ![external lib]
374  implicit none
375 
376  character(len=*), intent(out) :: chr(:)
377  integer, intent( in) :: mdlid
378  character(len=*), intent( in) :: basename
379  character(len=*), intent( in) :: attname
380  integer, intent( in) :: myrank
381  logical, intent( in), optional :: single
382 
383  integer :: status
384  integer :: ncid, length
385  character(len=H_LONG) :: fname = ''
386  character(len=80) :: work
387  logical :: single_ = .false.
388 
389  intrinsic size
390  intrinsic shape
391  !---------------------------------------------------------------------------
392 
393  if ( present(single) ) then
394  single_ = single
395  else
396  single_ = .false.
397  endif
398 
399  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
400 
401  status = nf90_open( trim(fname), nf90_nowrite, ncid )
402  if (status /= nf90_noerr) call handle_err(status, __line__)
403 
404  status = nf90_inquire_attribute(ncid, nf90_global, trim(attname), len=length)
405  if (status /= nf90_noerr) call handle_err(status, __line__)
406 
407  if( len(work) < length ) then
408  write(*,*) 'xxx Not enough space to put attribute values. [externalio/scalelib]'
409  call prc_mpistop
410  endif
411 
412  status = nf90_get_att(ncid, nf90_global, trim(attname), work)
413  if (status /= nf90_noerr) call handle_err(status, __line__)
414 
415  chr = trim(work)
416 
417  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:

◆ externalfilevarexistence()

subroutine, public scale_external_io::externalfilevarexistence ( logical, intent(out)  existence,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single 
)

Check Existence of a Variable.

Definition at line 431 of file scale_external_io.F90.

References scale_stdio::io_fid_log, and scale_stdio::io_l.

Referenced by mod_realinput_wrfarw::parentlandinputwrfarw(), and mod_realinput_wrfarw::parentoceaninputwrfarw().

431  use netcdf ![external lib]
432  implicit none
433 
434  logical, intent(out) :: existence
435  character(len=*), intent( in) :: basename
436  character(len=*), intent( in) :: varname
437  integer, intent( in) :: myrank
438  integer, intent( in) :: mdlid
439  logical, intent( in), optional :: single
440 
441  integer :: ncid, varid
442  integer :: status
443 
444  character(len=H_LONG) :: fname = ''
445  logical :: single_ = .false.
446 
447  intrinsic size
448  intrinsic shape
449  !---------------------------------------------------------------------------
450 
451  if ( present(single) ) then
452  single_ = single
453  else
454  single_ = .false.
455  endif
456 
457  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
458 
459  status = nf90_open( trim(fname), nf90_nowrite, ncid )
460  if (status /= nf90_noerr) call handle_err(status, __line__)
461 
462  status = nf90_inq_varid( ncid, trim(varname), varid )
463  if (status == nf90_noerr) then
464  existence = .true.
465  else
466  existence = .false.
467  if( io_l ) write(io_fid_log,*) '+++ not exist variable: ', trim(varname)
468  endif
469 
470  status = nf90_close(ncid)
471  if (status /= nf90_noerr) call handle_err(status, __line__)
472 
473  return
Here is the caller graph for this function:

◆ externalfileread2drealsp()

subroutine scale_external_io::externalfileread2drealsp ( real(sp), dimension(:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
integer, intent(in)  nx,
logical, intent(in), optional  single 
)

File Read.

Definition at line 490 of file scale_external_io.F90.

References scale_process::prc_mpistop().

490  use netcdf ![external lib]
491  implicit none
492 
493  real(SP), intent(out) :: var(:,:)
494  character(len=*), intent( in) :: basename
495  character(len=*), intent( in) :: varname
496  integer, intent( in) :: ts
497  integer, intent( in) :: te
498  integer, intent( in) :: myrank
499  integer, intent( in) :: mdlid
500  integer, intent( in) :: nx
501  logical, intent( in), optional :: single
502 
503  real(SP), allocatable :: var_org(:,:)
504  integer :: ncid, varid
505  integer :: status
506  integer :: precis
507 
508  integer :: tcount
509  character(len=H_LONG) :: fname = ''
510  logical :: single_ = .false.
511 
512  intrinsic size
513  intrinsic shape
514  !---------------------------------------------------------------------------
515 
516  tcount = te - ts + 1
517 
518  if ( present(single) ) then
519  single_ = single
520  else
521  single_ = .false.
522  endif
523 
524  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
525 
526  status = nf90_open( trim(fname), nf90_nowrite, ncid )
527  if (status /= nf90_noerr) call handle_err(status, __line__)
528 
529  ! based on specified dimension size
530  allocate( var_org(nx,tcount) )
531 
532  status = nf90_inq_varid( ncid, trim(varname), varid )
533  if (status /= nf90_noerr) call handle_err(status, __line__)
534 
535  status = nf90_inquire_variable( ncid, varid, xtype=precis )
536  if(status /= nf90_noerr) call handle_err(status, __line__)
537  if(precis /= nf90_float) then
538  write(*,*) 'xxx Internal Error: [scale_external_io]/[ExternalFileRead2DSP]'
539  call prc_mpistop
540  endif
541 
542  status = nf90_get_var( ncid, varid, var_org(:,:), start = (/ 1,ts /), &
543  count = (/ nx,tcount /) )
544  if (status /= nf90_noerr) call handle_err(status, __line__)
545 
546  status = nf90_close(ncid)
547  if (status /= nf90_noerr) call handle_err(status, __line__)
548 
549  call convertarrayorder( var,var_org,tcount,nx )
550 
551  deallocate( var_org )
552 
553  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:

◆ externalfileread2drealdp()

subroutine scale_external_io::externalfileread2drealdp ( real(dp), dimension(:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
integer, intent(in)  nx,
logical, intent(in), optional  single 
)

Definition at line 566 of file scale_external_io.F90.

References scale_process::prc_mpistop().

566  use netcdf ![external lib]
567  implicit none
568 
569  real(DP), intent(out) :: var(:,:)
570  character(len=*), intent( in) :: basename
571  character(len=*), intent( in) :: varname
572  integer, intent( in) :: ts
573  integer, intent( in) :: te
574  integer, intent( in) :: myrank
575  integer, intent( in) :: mdlid
576  integer, intent( in) :: nx
577  logical, intent( in), optional :: single
578 
579  real(DP), allocatable :: var_org(:,:)
580  integer :: ncid, varid
581  integer :: status
582  integer :: precis
583 
584  integer :: tcount
585  character(len=H_LONG) :: fname = ''
586  logical :: single_ = .false.
587 
588  intrinsic size
589  intrinsic shape
590  !---------------------------------------------------------------------------
591 
592  tcount = te - ts + 1
593 
594  if ( present(single) ) then
595  single_ = single
596  else
597  single_ = .false.
598  endif
599 
600  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
601 
602  status = nf90_open( trim(fname), nf90_nowrite, ncid )
603  if (status /= nf90_noerr) call handle_err(status, __line__)
604 
605  ! based on specified dimension size
606  allocate( var_org(nx,tcount) )
607 
608  status = nf90_inq_varid( ncid, trim(varname), varid )
609  if (status /= nf90_noerr) call handle_err(status, __line__)
610 
611  status = nf90_inquire_variable( ncid, varid, xtype=precis )
612  if(status /= nf90_noerr) call handle_err(status, __line__)
613  if(precis /= nf90_double) then
614  write(*,*) 'xxx Internal Error: [scale_external_io]/[ExternalFileRead2DDP]'
615  call prc_mpistop
616  endif
617 
618  status = nf90_get_var( ncid, varid, var_org(:,:), start = (/ 1,ts /), &
619  count = (/ nx,tcount /) )
620  if (status /= nf90_noerr) call handle_err(status, __line__)
621 
622  status = nf90_close(ncid)
623  if (status /= nf90_noerr) call handle_err(status, __line__)
624 
625  call convertarrayorder( var,var_org,tcount,nx )
626 
627  deallocate( var_org )
628 
629  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:

◆ externalfileread3drealsp()

subroutine scale_external_io::externalfileread3drealsp ( real(sp), dimension(:,:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single,
logical, intent(in), optional  xstag,
logical, intent(in), optional  ystag,
logical, intent(in), optional  option 
)

Definition at line 644 of file scale_external_io.F90.

References scale_process::prc_mpistop().

644  use netcdf ![external lib]
645  implicit none
646 
647  real(SP), intent(out) :: var(:,:,:)
648  character(len=*), intent( in) :: basename
649  character(len=*), intent( in) :: varname
650  integer, intent( in) :: ts
651  integer, intent( in) :: te
652  integer, intent( in) :: myrank
653  integer, intent( in) :: mdlid
654  logical, intent( in), optional :: single
655  logical, intent( in), optional :: xstag
656  logical, intent( in), optional :: ystag
657  logical, intent( in), optional :: option
658 
659  real(SP), allocatable :: var_org(:,:,:)
660  integer :: ncid, varid
661  integer :: status
662  integer :: precis
663  integer :: nx, ny
664  integer :: dims(7)
665 
666  integer :: tcount
667  character(len=H_LONG) :: fname = ''
668  logical :: single_ = .false.
669  logical :: option_ = .false.
670 
671  intrinsic size
672  intrinsic shape
673  !---------------------------------------------------------------------------
674 
675  tcount = te - ts + 1
676 
677  if ( present(single) ) then
678  single_ = single
679  endif
680 
681  if ( present(option) ) then
682  option_ = option
683  end if
684 
685  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
686 
687  status = nf90_open( trim(fname), nf90_nowrite, ncid )
688  if (status /= nf90_noerr) then
689  if ( option_ ) then
690  return
691  else
692  call handle_err(status, __line__)
693  end if
694  end if
695 
696  ! retrieve dimension size in data original order
697  call externaltakedimension( dims(:),ncid,mdlid )
698  nx = dims(1)
699  if ( present(xstag) ) then
700  if ( xstag ) then
701  nx = dims(4)
702  endif
703  endif
704  ny = dims(2)
705  if ( present(ystag) ) then
706  if ( ystag ) then
707  ny = dims(5)
708  endif
709  endif
710  allocate( var_org(nx,ny,tcount) )
711 
712  status = nf90_inq_varid( ncid, trim(varname), varid )
713  if (status /= nf90_noerr) call handle_err(status, __line__)
714 
715  status = nf90_inquire_variable( ncid, varid, xtype=precis )
716  if(status /= nf90_noerr) call handle_err(status, __line__)
717  if(precis /= nf90_float) then
718  write(*,*) 'xxx Internal Error: [scale_external_io]/[ExternalFileRead3DSP]'
719  call prc_mpistop
720  endif
721 
722  status = nf90_get_var( ncid, varid, var_org(:,:,:), start = (/ 1,1,ts /), &
723  count = (/ nx,ny,tcount /) )
724  if (status /= nf90_noerr) call handle_err(status, __line__)
725 
726  status = nf90_close(ncid)
727  if (status /= nf90_noerr) call handle_err(status, __line__)
728 
729  call convertarrayorder( var,var_org,tcount,nx,ny )
730 
731  deallocate( var_org )
732 
733  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:

◆ externalfileread3drealdp()

subroutine scale_external_io::externalfileread3drealdp ( real(dp), dimension(:,:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single,
logical, intent(in), optional  xstag,
logical, intent(in), optional  ystag 
)

Definition at line 747 of file scale_external_io.F90.

References scale_process::prc_mpistop().

747  use netcdf ![external lib]
748  implicit none
749 
750  real(DP), intent(out) :: var(:,:,:)
751  character(len=*), intent( in) :: basename
752  character(len=*), intent( in) :: varname
753  integer, intent( in) :: ts
754  integer, intent( in) :: te
755  integer, intent( in) :: myrank
756  integer, intent( in) :: mdlid
757  logical, intent( in), optional :: single
758  logical, intent( in), optional :: xstag
759  logical, intent( in), optional :: ystag
760 
761  real(DP), allocatable :: var_org(:,:,:)
762  integer :: ncid, varid
763  integer :: status
764  integer :: precis
765  integer :: nx, ny
766  integer :: dims(7)
767 
768  integer :: tcount
769  character(len=H_LONG) :: fname = ''
770  logical :: single_ = .false.
771 
772  intrinsic size
773  intrinsic shape
774  !---------------------------------------------------------------------------
775 
776  tcount = te - ts + 1
777 
778  if ( present(single) ) then
779  single_ = single
780  else
781  single_ = .false.
782  endif
783 
784  call externalfilemakefname( fname,mdlid,basename,myrank,single )
785 
786  status = nf90_open( trim(fname), nf90_nowrite, ncid )
787  if (status /= nf90_noerr) call handle_err(status, __line__)
788 
789  ! retrieve dimension size in data original order
790  call externaltakedimension( dims(:),ncid,mdlid )
791  nx = dims(1)
792  if ( present(xstag) ) then
793  if ( xstag ) then
794  nx = dims(4)
795  endif
796  endif
797  ny = dims(2)
798  if ( present(ystag) ) then
799  if ( ystag ) then
800  ny = dims(5)
801  endif
802  endif
803  allocate( var_org(nx,ny,tcount) )
804 
805  status = nf90_inq_varid( ncid, trim(varname), varid )
806  if (status /= nf90_noerr) call handle_err(status, __line__)
807 
808  status = nf90_inquire_variable( ncid, varid, xtype=precis )
809  if(status /= nf90_noerr) call handle_err(status, __line__)
810  if(precis /= nf90_double) then
811  write(*,*) 'xxx Internal Error: [scale_external_io]/[ExternalFileRead3DDP]'
812  call prc_mpistop
813  endif
814 
815  status = nf90_get_var( ncid, varid, var_org(:,:,:), start = (/ 1,1,ts /), &
816  count = (/ nx,ny,tcount /) )
817  if (status /= nf90_noerr) call handle_err(status, __line__)
818 
819  status = nf90_close(ncid)
820  if (status /= nf90_noerr) call handle_err(status, __line__)
821 
822  call convertarrayorder( var,var_org,tcount,nx,ny )
823 
824  deallocate( var_org )
825 
826  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:

◆ externalfileread4drealsp()

subroutine scale_external_io::externalfileread4drealsp ( real(sp), dimension(:,:,:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single,
logical, intent(in), optional  xstag,
logical, intent(in), optional  ystag,
logical, intent(in), optional  zstag,
logical, intent(in), optional  landgrid,
logical, intent(in), optional  option 
)

Definition at line 843 of file scale_external_io.F90.

References scale_process::prc_mpistop().

843  use netcdf ![external lib]
844  implicit none
845 
846  real(SP), intent(out) :: var(:,:,:,:)
847  character(len=*), intent( in) :: basename
848  character(len=*), intent( in) :: varname
849  integer, intent( in) :: ts
850  integer, intent( in) :: te
851  integer, intent( in) :: myrank
852  integer, intent( in) :: mdlid
853  logical, intent( in), optional :: single
854  logical, intent( in), optional :: xstag
855  logical, intent( in), optional :: ystag
856  logical, intent( in), optional :: zstag
857  logical, intent( in), optional :: landgrid
858  logical, intent( in), optional :: option
859 
860  real(SP), allocatable :: var_org(:,:,:,:)
861  integer :: ncid, varid
862  integer :: status
863  integer :: precis
864  integer :: nx, ny, nz
865  integer :: dims(7)
866 
867  integer :: tcount
868  character(len=H_LONG) :: fname = ''
869  logical :: single_ = .false.
870  logical :: option_ = .false.
871 
872  intrinsic size
873  intrinsic shape
874  !---------------------------------------------------------------------------
875 
876  tcount = te - ts + 1
877 
878  if ( present(single) ) then
879  single_ = single
880  endif
881 
882  if ( present(option) ) then
883  option_ = option
884  endif
885 
886  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
887 
888  status = nf90_open( trim(fname), nf90_nowrite, ncid )
889  if (status /= nf90_noerr) then
890  if ( option_ ) then
891  return
892  else
893  write(*,*) trim(fname)
894  call handle_err(status, __line__)
895  end if
896  end if
897 
898  ! retrieve dimension size in data original order
899  call externaltakedimension( dims(:),ncid,mdlid )
900  nx = dims(1)
901  if ( present(xstag) ) then
902  if ( xstag ) then
903  nx = dims(4)
904  endif
905  endif
906  ny = dims(2)
907  if ( present(ystag) ) then
908  if ( ystag ) then
909  ny = dims(5)
910  endif
911  endif
912  nz = dims(3)
913  if ( present(zstag) ) then
914  if ( zstag ) then
915  nz = dims(6)
916  endif
917  endif
918  if ( present(landgrid) ) then
919  if ( landgrid ) then
920  nz = dims(7)
921  endif
922  endif
923  allocate( var_org(nx,ny,nz,tcount) )
924 
925  status = nf90_inq_varid( ncid, trim(varname), varid )
926  if (status /= nf90_noerr) call handle_err(status, __line__)
927 
928  status = nf90_inquire_variable( ncid, varid, xtype=precis )
929  if(status /= nf90_noerr) call handle_err(status, __line__)
930  if(precis /= nf90_float) then
931  write(*,*) 'xxx Internal Error: [scale_external_io]/[ExternalFileRead4DSP]'
932  call prc_mpistop
933  endif
934 
935  status = nf90_get_var( ncid, varid, var_org(:,:,:,:), start = (/ 1,1,1,ts /), &
936  count = (/ nx,ny,nz,tcount /) )
937  if (status /= nf90_noerr) call handle_err(status, __line__)
938 
939  status = nf90_close(ncid)
940  if (status /= nf90_noerr) call handle_err(status, __line__)
941 
942  call convertarrayorder( var,var_org,tcount,nz,nx,ny )
943 
944  deallocate( var_org )
945 
946  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:

◆ externalfileread4drealdp()

subroutine scale_external_io::externalfileread4drealdp ( real(dp), dimension(:,:,:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single,
logical, intent(in), optional  xstag,
logical, intent(in), optional  ystag,
logical, intent(in), optional  zstag,
logical, intent(in), optional  landgrid 
)

Definition at line 962 of file scale_external_io.F90.

References scale_process::prc_mpistop().

962  use netcdf ![external lib]
963  implicit none
964 
965  real(DP), intent(out) :: var(:,:,:,:)
966  character(len=*), intent( in) :: basename
967  character(len=*), intent( in) :: varname
968  integer, intent( in) :: ts
969  integer, intent( in) :: te
970  integer, intent( in) :: myrank
971  integer, intent( in) :: mdlid
972  logical, intent( in), optional :: single
973  logical, intent( in), optional :: xstag
974  logical, intent( in), optional :: ystag
975  logical, intent( in), optional :: zstag
976  logical, intent( in), optional :: landgrid
977 
978  real(DP), allocatable :: var_org(:,:,:,:)
979  integer :: ncid, varid
980  integer :: status
981  integer :: precis
982  integer :: nx, ny, nz
983  integer :: dims(7)
984 
985  integer :: tcount
986  character(len=H_LONG) :: fname = ''
987  logical :: single_ = .false.
988 
989  intrinsic size
990  intrinsic shape
991  !---------------------------------------------------------------------------
992 
993  tcount = te - ts + 1
994 
995  if ( present(single) ) then
996  single_ = single
997  else
998  single_ = .false.
999  endif
1000 
1001  call externalfilemakefname( fname,mdlid,basename,myrank,single )
1002 
1003  status = nf90_open( trim(fname), nf90_nowrite, ncid )
1004  if (status /= nf90_noerr) call handle_err(status, __line__)
1005 
1006  ! retrieve dimension size in data original order
1007  call externaltakedimension( dims(:),ncid,mdlid )
1008  nx = dims(1)
1009  if ( present(xstag) ) then
1010  if ( xstag ) then
1011  nx = dims(4)
1012  endif
1013  endif
1014  ny = dims(2)
1015  if ( present(ystag) ) then
1016  if ( ystag ) then
1017  ny = dims(5)
1018  endif
1019  endif
1020  nz = dims(3)
1021  if ( present(zstag) ) then
1022  if ( zstag ) then
1023  nz = dims(6)
1024  endif
1025  endif
1026  if ( present(landgrid) ) then
1027  if ( landgrid ) then
1028  nz = dims(7)
1029  endif
1030  endif
1031  allocate( var_org(nx,ny,nz,tcount) )
1032 
1033  status = nf90_inq_varid( ncid, trim(varname), varid )
1034  if (status /= nf90_noerr) call handle_err(status, __line__)
1035 
1036  status = nf90_inquire_variable( ncid, varid, xtype=precis )
1037  if(status /= nf90_noerr) call handle_err(status, __line__)
1038  if(precis /= nf90_double) then
1039  write(*,*) 'xxx Internal Error: [scale_external_io]/[ExternalFileRead4DDP]'
1040  call prc_mpistop
1041  endif
1042 
1043  status = nf90_get_var( ncid, varid, var_org(:,:,:,:), start = (/ 1,1,1,ts /), &
1044  count = (/ nx,ny,nz,tcount /) )
1045  if (status /= nf90_noerr) call handle_err(status, __line__)
1046 
1047  status = nf90_close(ncid)
1048  if (status /= nf90_noerr) call handle_err(status, __line__)
1049 
1050  call convertarrayorder( var,var_org,tcount,nz,nx,ny )
1051 
1052  deallocate( var_org )
1053 
1054  return
subroutine, public prc_mpistop
Abort MPI.
Here is the call graph for this function:

◆ externalfilereadoffset3drealsp()

subroutine scale_external_io::externalfilereadoffset3drealsp ( real(sp), dimension(:,:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single,
logical, intent(in), optional  xstag,
logical, intent(in), optional  ystag 
)

Definition at line 1069 of file scale_external_io.F90.

1069  use netcdf ![external lib]
1070  implicit none
1071 
1072  real(SP), intent(out) :: var(:,:,:)
1073  character(len=*), intent( in) :: basename
1074  character(len=*), intent( in) :: varname
1075  integer, intent( in) :: ts
1076  integer, intent( in) :: te
1077  integer, intent( in) :: myrank
1078  integer, intent( in) :: mdlid
1079  logical, intent( in), optional :: single
1080  logical, intent( in), optional :: xstag
1081  logical, intent( in), optional :: ystag
1082 
1083  real(SP), allocatable :: var_org(:,:,:)
1084  integer(2), allocatable :: short(:,:,:)
1085 
1086  real(4) :: scale_factor, add_offset
1087 
1088  integer :: ncid, varid
1089  integer :: status
1090  integer :: precis
1091  integer :: nx, ny
1092  integer :: dims(7)
1093 
1094  integer :: tcount
1095  character(len=H_LONG) :: fname = ''
1096  logical :: single_ = .false.
1097 
1098  intrinsic size
1099  intrinsic shape
1100  !---------------------------------------------------------------------------
1101 
1102  tcount = te - ts + 1
1103 
1104  if ( present(single) ) then
1105  single_ = single
1106  else
1107  single_ = .false.
1108  endif
1109 
1110  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
1111 
1112  status = nf90_open( trim(fname), nf90_nowrite, ncid )
1113  if (status /= nf90_noerr) call handle_err(status, __line__)
1114 
1115  ! retrieve dimension size in data original order
1116  call externaltakedimension( dims(:),ncid,mdlid )
1117  nx = dims(1)
1118  if ( present(xstag) ) then
1119  if ( xstag ) then
1120  nx = dims(4)
1121  endif
1122  endif
1123  ny = dims(2)
1124  if ( present(ystag) ) then
1125  if ( ystag ) then
1126  ny = dims(5)
1127  endif
1128  endif
1129  allocate( var_org(nx,ny,tcount) )
1130  allocate( short(nx,ny,tcount) )
1131 
1132  status = nf90_inq_varid( ncid, trim(varname), varid )
1133  if (status /= nf90_noerr) call handle_err(status, __line__)
1134 
1135  status = nf90_inquire_variable( ncid, varid, xtype=precis )
1136  if(status /= nf90_noerr) call handle_err(status, __line__)
1137 
1138  if(precis /= nf90_short) then
1139  status = nf90_get_var( ncid, varid, var_org(:,:,:), start = (/ 1,1,ts /), &
1140  count = (/ nx,ny,tcount /) )
1141  if (status /= nf90_noerr) call handle_err(status, __line__)
1142  else
1143  status = nf90_get_att(ncid, varid, "scale_factor", scale_factor)
1144  if (status /= nf90_noerr) call handle_err(status, __line__)
1145 
1146  status = nf90_get_att(ncid, varid, "add_offset", add_offset)
1147  if (status /= nf90_noerr) call handle_err(status, __line__)
1148 
1149  status = nf90_get_var( ncid, varid, short(:,:,:), start = (/ 1,1,ts /), &
1150  count = (/ nx,ny,tcount /) )
1151  if (status /= nf90_noerr) call handle_err(status, __line__)
1152 
1153  var_org(:,:,:) = real( short(:,:,:),kind=sp )*scale_factor + add_offset
1154  end if
1155 
1156  status = nf90_close(ncid)
1157  if (status /= nf90_noerr) call handle_err(status, __line__)
1158 
1159  call convertarrayorder( var,var_org,tcount,nx,ny )
1160 
1161  deallocate( var_org )
1162  deallocate( short )
1163 
1164  return
integer, parameter, public sp

◆ externalfilereadoffset3drealdp()

subroutine scale_external_io::externalfilereadoffset3drealdp ( real(dp), dimension(:,:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single,
logical, intent(in), optional  xstag,
logical, intent(in), optional  ystag 
)

Definition at line 1178 of file scale_external_io.F90.

References dc_types::dp.

1178  use netcdf ![external lib]
1179  implicit none
1180 
1181  real(DP), intent(out) :: var(:,:,:)
1182  character(len=*), intent( in) :: basename
1183  character(len=*), intent( in) :: varname
1184  integer, intent( in) :: ts
1185  integer, intent( in) :: te
1186  integer, intent( in) :: myrank
1187  integer, intent( in) :: mdlid
1188  logical, intent( in), optional :: single
1189  logical, intent( in), optional :: xstag
1190  logical, intent( in), optional :: ystag
1191 
1192  real(DP), allocatable :: var_org(:,:,:)
1193  integer(2), allocatable :: short(:,:,:)
1194 
1195  real(4) :: scale_factor, add_offset
1196 
1197  integer :: ncid, varid
1198  integer :: status
1199  integer :: precis
1200  integer :: nx, ny
1201  integer :: dims(7)
1202 
1203  integer :: tcount
1204  character(len=H_LONG) :: fname = ''
1205  logical :: single_ = .false.
1206 
1207  intrinsic size
1208  intrinsic shape
1209  !---------------------------------------------------------------------------
1210 
1211  tcount = te - ts + 1
1212 
1213  if ( present(single) ) then
1214  single_ = single
1215  else
1216  single_ = .false.
1217  endif
1218 
1219  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
1220 
1221  status = nf90_open( trim(fname), nf90_nowrite, ncid )
1222  if (status /= nf90_noerr) call handle_err(status, __line__)
1223 
1224  ! retrieve dimension size in data original order
1225  call externaltakedimension( dims(:),ncid,mdlid )
1226  nx = dims(1)
1227  if ( present(xstag) ) then
1228  if ( xstag ) then
1229  nx = dims(4)
1230  endif
1231  endif
1232  ny = dims(2)
1233  if ( present(ystag) ) then
1234  if ( ystag ) then
1235  ny = dims(5)
1236  endif
1237  endif
1238  allocate( var_org(nx,ny,tcount) )
1239  allocate( short(nx,ny,tcount) )
1240 
1241  status = nf90_inq_varid( ncid, trim(varname), varid )
1242  if (status /= nf90_noerr) call handle_err(status, __line__)
1243 
1244  status = nf90_inquire_variable( ncid, varid, xtype=precis )
1245  if(status /= nf90_noerr) call handle_err(status, __line__)
1246 
1247  if(precis /= nf90_short) then
1248  status = nf90_get_var( ncid, varid, var_org(:,:,:), start = (/ 1,1,ts /), &
1249  count = (/ nx,ny,tcount /) )
1250  if (status /= nf90_noerr) call handle_err(status, __line__)
1251  else
1252  status = nf90_get_att(ncid, varid, "scale_factor", scale_factor)
1253  if (status /= nf90_noerr) call handle_err(status, __line__)
1254 
1255  status = nf90_get_att(ncid, varid, "add_offset", add_offset)
1256  if (status /= nf90_noerr) call handle_err(status, __line__)
1257 
1258  status = nf90_get_var( ncid, varid, short(:,:,:), start = (/ 1,1,ts /), &
1259  count = (/ nx,ny,tcount /) )
1260  if (status /= nf90_noerr) call handle_err(status, __line__)
1261 
1262  var_org(:,:,:) = real( real(short(:,:,:),kind=sp)*scale_factor + add_offset, kind=dp )
1263  endif
1264 
1265  status = nf90_close(ncid)
1266  if (status /= nf90_noerr) call handle_err(status, __line__)
1267 
1268  call convertarrayorder( var,var_org,tcount,nx,ny )
1269 
1270  deallocate( var_org )
1271  deallocate( short )
1272 
1273  return
integer, parameter, public sp
integer, parameter, public dp

◆ externalfilereadoffset4drealsp()

subroutine scale_external_io::externalfilereadoffset4drealsp ( real(sp), dimension(:,:,:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single,
logical, intent(in), optional  xstag,
logical, intent(in), optional  ystag,
logical, intent(in), optional  zstag,
logical, intent(in), optional  landgrid 
)

Definition at line 1289 of file scale_external_io.F90.

1289  use netcdf ![external lib]
1290  implicit none
1291 
1292  real(SP), intent(out) :: var(:,:,:,:)
1293  character(len=*), intent( in) :: basename
1294  character(len=*), intent( in) :: varname
1295  integer, intent( in) :: ts
1296  integer, intent( in) :: te
1297  integer, intent( in) :: myrank
1298  integer, intent( in) :: mdlid
1299  logical, intent( in), optional :: single
1300  logical, intent( in), optional :: xstag
1301  logical, intent( in), optional :: ystag
1302  logical, intent( in), optional :: zstag
1303  logical, intent( in), optional :: landgrid
1304 
1305  real(SP), allocatable :: var_org(:,:,:,:)
1306  integer(2), allocatable :: short(:,:,:,:)
1307 
1308  real(4) :: scale_factor, add_offset
1309 
1310  integer :: ncid, varid
1311  integer :: status
1312  integer :: precis
1313  integer :: nx, ny, nz
1314  integer :: dims(7)
1315 
1316  integer :: tcount
1317  character(len=H_LONG) :: fname = ''
1318  logical :: single_ = .false.
1319 
1320  intrinsic size
1321  intrinsic shape
1322  !---------------------------------------------------------------------------
1323 
1324  tcount = te - ts + 1
1325 
1326  if ( present(single) ) then
1327  single_ = single
1328  else
1329  single_ = .false.
1330  endif
1331 
1332  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
1333 
1334  status = nf90_open( trim(fname), nf90_nowrite, ncid )
1335  if (status /= nf90_noerr) call handle_err(status, __line__)
1336 
1337  ! retrieve dimension size in data original order
1338  call externaltakedimension( dims(:),ncid,mdlid )
1339  nx = dims(1)
1340  if ( present(xstag) ) then
1341  if ( xstag ) then
1342  nx = dims(4)
1343  endif
1344  endif
1345  ny = dims(2)
1346  if ( present(ystag) ) then
1347  if ( ystag ) then
1348  ny = dims(5)
1349  endif
1350  endif
1351  nz = dims(3)
1352  if ( present(zstag) ) then
1353  if ( zstag ) then
1354  nz = dims(6)
1355  endif
1356  endif
1357  if ( present(landgrid) ) then
1358  if ( landgrid ) then
1359  nz = dims(7)
1360  endif
1361  endif
1362  allocate( var_org(nx,ny,nz,tcount) )
1363  allocate( short(nx,ny,nz,tcount) )
1364 
1365  status = nf90_inq_varid( ncid, trim(varname), varid )
1366  if (status /= nf90_noerr) call handle_err(status, __line__)
1367 
1368  status = nf90_inquire_variable( ncid, varid, xtype=precis )
1369  if (status /= nf90_noerr) call handle_err(status, __line__)
1370 
1371  if(precis /= nf90_short) then
1372  status = nf90_get_var( ncid, varid, var_org(:,:,:,:), start = (/ 1,1,1,ts /), &
1373  count = (/ nx,ny,nz,tcount /) )
1374  if (status /= nf90_noerr) call handle_err(status, __line__)
1375  else
1376  status = nf90_get_att(ncid, varid, "scale_factor", scale_factor)
1377  if (status /= nf90_noerr) call handle_err(status, __line__)
1378 
1379  status = nf90_get_att(ncid, varid, "add_offset", add_offset)
1380  if (status /= nf90_noerr) call handle_err(status, __line__)
1381 
1382  status = nf90_get_var( ncid, varid, short(:,:,:,:), start = (/ 1,1,1,ts /), &
1383  count = (/ nx,ny,nz,tcount /) )
1384  if (status /= nf90_noerr) call handle_err(status, __line__)
1385 
1386  var_org(:,:,:,:) = real( short(:,:,:,:),kind=sp )*scale_factor + add_offset
1387  end if
1388 
1389  status = nf90_close(ncid)
1390  if (status /= nf90_noerr) call handle_err(status, __line__)
1391 
1392  call convertarrayorder( var,var_org,tcount,nz,nx,ny )
1393 
1394  deallocate( var_org )
1395  deallocate( short )
1396 
1397  return
integer, parameter, public sp

◆ externalfilereadoffset4drealdp()

subroutine scale_external_io::externalfilereadoffset4drealdp ( real(dp), dimension(:,:,:,:), intent(out)  var,
character(len=*), intent(in)  basename,
character(len=*), intent(in)  varname,
integer, intent(in)  ts,
integer, intent(in)  te,
integer, intent(in)  myrank,
integer, intent(in)  mdlid,
logical, intent(in), optional  single,
logical, intent(in), optional  xstag,
logical, intent(in), optional  ystag,
logical, intent(in), optional  zstag,
logical, intent(in), optional  landgrid 
)

Definition at line 1413 of file scale_external_io.F90.

References dc_types::dp, gtool_file::filemakefname(), inicam, iwrfarw, and scale_process::prc_mpistop().

1413  use netcdf ![external lib]
1414  implicit none
1415 
1416  real(DP), intent(out) :: var(:,:,:,:)
1417  character(len=*), intent( in) :: basename
1418  character(len=*), intent( in) :: varname
1419  integer, intent( in) :: ts
1420  integer, intent( in) :: te
1421  integer, intent( in) :: myrank
1422  integer, intent( in) :: mdlid
1423  logical, intent( in), optional :: single
1424  logical, intent( in), optional :: xstag
1425  logical, intent( in), optional :: ystag
1426  logical, intent( in), optional :: zstag
1427  logical, intent( in), optional :: landgrid
1428 
1429  real(DP), allocatable :: var_org(:,:,:,:)
1430  integer(2), allocatable :: short(:,:,:,:)
1431 
1432  real(4) :: scale_factor, add_offset
1433 
1434  integer :: ncid, varid
1435  integer :: status
1436  integer :: precis
1437  integer :: nx, ny, nz
1438  integer :: dims(7)
1439 
1440  integer :: tcount
1441  character(len=H_LONG) :: fname = ''
1442  logical :: single_ = .false.
1443 
1444  intrinsic size
1445  intrinsic shape
1446  !---------------------------------------------------------------------------
1447 
1448  tcount = te - ts + 1
1449 
1450  if ( present(single) ) then
1451  single_ = single
1452  else
1453  single_ = .false.
1454  endif
1455 
1456  call externalfilemakefname( fname,mdlid,basename,myrank,single_ )
1457 
1458  status = nf90_open( trim(fname), nf90_nowrite, ncid )
1459  if (status /= nf90_noerr) call handle_err(status, __line__)
1460 
1461  ! retrieve dimension size in data original order
1462  call externaltakedimension( dims(:),ncid,mdlid )
1463  nx = dims(1)
1464  if ( present(xstag) ) then
1465  if ( xstag ) then
1466  nx = dims(4)
1467  endif
1468  endif
1469  ny = dims(2)
1470  if ( present(ystag) ) then
1471  if ( ystag ) then
1472  ny = dims(5)
1473  endif
1474  endif
1475  nz = dims(3)
1476  if ( present(zstag) ) then
1477  if ( zstag ) then
1478  nz = dims(6)
1479  endif
1480  endif
1481  if ( present(landgrid) ) then
1482  if ( landgrid ) then
1483  nz = dims(7)
1484  endif
1485  endif
1486  allocate( var_org(nx,ny,nz,tcount) )
1487  allocate( short(nx,ny,nz,tcount) )
1488 
1489  status = nf90_inq_varid( ncid, trim(varname), varid )
1490  if (status /= nf90_noerr) call handle_err(status, __line__)
1491 
1492  status = nf90_inquire_variable( ncid, varid, xtype=precis )
1493  if(status /= nf90_noerr) call handle_err(status, __line__)
1494 
1495  if(precis /= nf90_short) then
1496  status = nf90_get_var( ncid, varid, var_org(:,:,:,:), start = (/ 1,1,1,ts /), &
1497  count = (/ nx,ny,nz,tcount /) )
1498  if (status /= nf90_noerr) call handle_err(status, __line__)
1499  else
1500  status = nf90_get_att(ncid, varid, "scale_factor", scale_factor)
1501  if (status /= nf90_noerr) call handle_err(status, __line__)
1502 
1503  status = nf90_get_att(ncid, varid, "add_offset", add_offset)
1504  if (status /= nf90_noerr) call handle_err(status, __line__)
1505 
1506  status = nf90_get_var( ncid, varid, short(:,:,:,:), start = (/ 1,1,1,ts /), &
1507  count = (/ nx,ny,nz,tcount /) )
1508  if (status /= nf90_noerr) call handle_err(status, __line__)
1509 
1510  var_org(:,:,:,:) = real( real(short(:,:,:,:),kind=sp)*scale_factor + add_offset, kind=dp )
1511  end if
1512 
1513  status = nf90_close(ncid)
1514  if (status /= nf90_noerr) call handle_err(status, __line__)
1515 
1516  call convertarrayorder( var,var_org,tcount,nz,nx,ny )
1517 
1518  deallocate( var_org )
1519  deallocate( short )
1520 
1521  return
integer, parameter, public sp
integer, parameter, public dp
Here is the call graph for this function:

◆ convertarrayorderwrf2dsp()

subroutine scale_external_io::convertarrayorderwrf2dsp ( real(sp), dimension(:,:), intent(out)  var,
real(sp), dimension(:,:), intent(in)  var_org,
integer, intent(in)  tcount,
integer, intent(in)  nx 
)

Definition at line 1633 of file scale_external_io.F90.

References scale_process::prc_mpistop().

1633  implicit none
1634 
1635  real(SP), intent(out) :: var(:,:)
1636  real(SP), intent( in) :: var_org(:,:)
1637  integer, intent( in) :: tcount
1638  integer, intent( in) :: nx
1639  integer :: n, i
1640  intrinsic shape
1641 
1642  do n = 1, tcount
1643  do i = 1, nx
1644  var(i,n) = var_org(i,n)
1645  end do
1646  end do
1647 
1648  return
Here is the call graph for this function:

Variable Documentation

◆ iscale

integer, parameter, public scale_external_io::iscale = 1

Definition at line 68 of file scale_external_io.F90.

Referenced by mod_realinput::parentatomsetup().

68  integer, public, parameter :: iscale = 1 ! use gtool, coz it's not external

◆ iwrfarw

integer, parameter, public scale_external_io::iwrfarw = 2

◆ inicam

integer, parameter, public scale_external_io::inicam = 3

Definition at line 70 of file scale_external_io.F90.

Referenced by externalfilereadoffset4drealdp(), and mod_realinput::parentatomsetup().

70  integer, public, parameter :: inicam = 3

◆ igrads

integer, parameter, public scale_external_io::igrads = 4

Definition at line 71 of file scale_external_io.F90.

Referenced by mod_realinput::parentatomsetup(), and mod_realinput::realinput_surface().

71  integer, public, parameter :: igrads = 4