SCALE-RM
gtool_file.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
13 !-------------------------------------------------------------------------------
14 ! Warning: This file was generated from gtool_file.f90.erb.
15 ! Do not edit this file.
16 !-------------------------------------------------------------------------------
17 module gtool_file
18  !-----------------------------------------------------------------------------
19  !
20  !++ Used modules
21  !
22  use gtool_file_h
23  use dc_log, only: &
24  log, &
25  log_lmsg
26  use dc_types, only: &
27  dp, &
28  sp
29  !-----------------------------------------------------------------------------
30  implicit none
31  private
32  !-----------------------------------------------------------------------------
33  !
34  !++ Public procedures
35  !
36  public :: fileopen
37  public :: filecreate
38  public :: filesetoption
39  public :: filedefaxis
40  public :: fileputaxis
41  public :: filewriteaxis
43  public :: fileputassociatedcoordinates
44  public :: filewriteassociatedcoordinates
45  public :: fileaddvariable
46  public :: filedefinevariable
47  public :: filesettattr
48  public :: filegetshape
49  public :: filegetdatainfo
50  public :: filegetalldatainfo
51  public :: fileread
52  public :: filewrite
53  public :: filewritevar
54  public :: filegetglobalattribute
55  public :: filesetglobalattribute
56  public :: fileenddef
57  public :: fileclose
58  public :: filecloseall
59  public :: filemakefname
60 
61  interface fileputaxis
62  module procedure fileputaxisrealsp
63  module procedure fileputaxisrealdp
64  end interface fileputaxis
65  interface filewriteaxis
66  module procedure filewriteaxisrealsp
67  module procedure filewriteaxisrealdp
68  end interface filewriteaxis
69  interface fileputassociatedcoordinates
70  module procedure fileput1dassociatedcoordinatesrealsp
71  module procedure fileput1dassociatedcoordinatesrealdp
72  module procedure fileput2dassociatedcoordinatesrealsp
73  module procedure fileput2dassociatedcoordinatesrealdp
74  module procedure fileput3dassociatedcoordinatesrealsp
75  module procedure fileput3dassociatedcoordinatesrealdp
76  module procedure fileput4dassociatedcoordinatesrealsp
77  module procedure fileput4dassociatedcoordinatesrealdp
78  end interface fileputassociatedcoordinates
79  interface filewriteassociatedcoordinates
80  module procedure filewrite1dassociatedcoordinatesrealsp
81  module procedure filewrite1dassociatedcoordinatesrealdp
82  module procedure filewrite2dassociatedcoordinatesrealsp
83  module procedure filewrite2dassociatedcoordinatesrealdp
84  module procedure filewrite3dassociatedcoordinatesrealsp
85  module procedure filewrite3dassociatedcoordinatesrealdp
86  module procedure filewrite4dassociatedcoordinatesrealsp
87  module procedure filewrite4dassociatedcoordinatesrealdp
88  end interface filewriteassociatedcoordinates
89  interface fileaddvariable
90  module procedure fileaddvariablenot
91  module procedure fileaddvariablerealsp
92  module procedure fileaddvariablerealdp
93  end interface fileaddvariable
94  interface fileread
95  module procedure fileread1drealsp
96  module procedure fileread1drealdp
97  module procedure fileread2drealsp
98  module procedure fileread2drealdp
99  module procedure fileread3drealsp
100  module procedure fileread3drealdp
101  module procedure fileread4drealsp
102  module procedure fileread4drealdp
103  end interface fileread
104  interface filewrite
105  module procedure filewrite1drealsp
106  module procedure filewrite1drealdp
107  module procedure filewrite2drealsp
108  module procedure filewrite2drealdp
109  module procedure filewrite3drealsp
110  module procedure filewrite3drealdp
111  module procedure filewrite4drealsp
112  module procedure filewrite4drealdp
113  end interface filewrite
114  interface filewritevar
115  module procedure filewritevar1drealsp
116  module procedure filewritevar1drealdp
117  module procedure filewritevar2drealsp
118  module procedure filewritevar2drealdp
119  module procedure filewritevar3drealsp
120  module procedure filewritevar3drealdp
121  module procedure filewritevar4drealsp
122  module procedure filewritevar4drealdp
123  end interface filewritevar
124  interface filegetglobalattribute
125  module procedure filegetglobalattributetext
126  module procedure filegetglobalattributeint
127  module procedure filegetglobalattributefloat
128  module procedure filegetglobalattributedouble
129  end interface filegetglobalattribute
130  interface filesetglobalattribute
131  module procedure filesetglobalattributetext
132  module procedure filesetglobalattributeint
133  module procedure filesetglobalattributefloat
134  module procedure filesetglobalattributedouble
135  end interface filesetglobalattribute
136 
137  !-----------------------------------------------------------------------------
138  !
139  !++ Public parameters & variables
140  !
141  real(DP), parameter, public :: rmiss = -9.9999e+30
142  !-----------------------------------------------------------------------------
143  !
144  !++ Private procedures
145  !
146  !-----------------------------------------------------------------------------
147  !
148  !++ Private parameters & variables
149  !
150  integer, private, parameter :: file_nfile_max = 512 ! number limit of file
151  ! Keep consistency with "FILE_MAX" in gtool_netcdf.c
152  integer, private, parameter :: file_nvar_max = 40960 ! number limit of variables
153  ! Keep consistency with "VAR_MAX" in gtool_netcdf.c
154 
155  character(LEN=File_HLONG), private, save :: file_fname_list(file_nfile_max)
156  integer, private, save :: file_fid_list (file_nfile_max)
157  integer, private, save :: file_fid_count = 1
158  character(LEN=File_HLONG), private, save :: file_vname_list (file_nvar_max)
159  integer, private, save :: file_vid_fid_list(file_nvar_max)
160  integer, private, save :: file_vid_list (file_nvar_max)
161  integer, private, save :: file_vid_count = 1
162  integer, private, save :: mpi_myrank
163 
164  character(LEN=LOG_LMSG), private :: message
165 
166 contains
167  !-----------------------------------------------------------------------------
168  subroutine filecreate( &
169  fid, & ! (out)
170  existed, & ! (out)
171  basename, & ! (in)
172  title, & ! (in)
173  source, & ! (in)
174  institution, & ! (in)
175  master, & ! (in)
176  myrank, & ! (in)
177  rankidx, & ! (in)
178  single, & ! (in) optional
179  time_units, & ! (in) optional
180  append ) ! (in) optional
181  implicit none
182 
183  integer, intent(out) :: fid
184  logical, intent(out) :: existed
185  character(LEN=*), intent( in) :: basename
186  character(LEN=*), intent( in) :: title
187  character(LEN=*), intent( in) :: source
188  character(LEN=*), intent( in) :: institution
189  integer, intent( in) :: master
190  integer, intent( in) :: myrank
191  integer, intent( in) :: rankidx(:)
192  character(LEN=*), intent( in), optional :: time_units
193  logical, intent( in), optional :: single
194  logical, intent( in), optional :: append
195 
196  character(len=File_HMID) :: time_units_
197  logical :: single_
198  integer :: mode
199  integer :: error
200 
201  intrinsic size
202 
203  if ( present(time_units) ) then
204  time_units_ = time_units
205  else
206  time_units_ = 'seconds'
207  end if
208 
209  mpi_myrank = myrank
210 
211  if ( present(single) ) then
212  if ( single .and. (myrank .ne. master) ) return
213  single_ = single
214  else
215  single_ = .false.
216  endif
217 
218  mode = file_fwrite
219  if ( present(append) ) then
220  if ( append ) mode = file_fappend
221  end if
222 
223  call filegetfid( &
224  fid, & ! (out)
225  existed, & ! (out)
226  basename, & ! (in)
227  mode, & ! (in)
228  single_ & ! (in)
229  )
230 
231  if ( existed ) return
232 
233  !--- append package header to the file
234  call filesetglobalattribute( fid, & ! (in)
235  "title", title ) ! (in)
236  call filesetglobalattribute( fid, & ! (in)
237  "source", source ) ! (in)
238  call filesetglobalattribute( fid, & ! (in)
239  "institution", institution ) ! (in)
240  call filesetglobalattribute( fid, & ! (in)
241  "myrank", (/myrank/) ) ! (in)
242  call filesetglobalattribute( fid, & ! (in)
243  "rankidx", rankidx ) ! (in)
244 
245  call file_set_tunits( fid, & ! (in)
246  time_units_, & ! (in)
247  error ) ! (out)
248  if ( error /= success_code ) then
249  call log('E', 'xxx failed to set time units')
250  end if
251 
252  return
253  end subroutine filecreate
254 
255  !-----------------------------------------------------------------------------
256  subroutine filegetglobalattributetext( &
257  fid, & ! (in)
258  key, & ! (in)
259  val & ! (out)
260  )
261  integer, intent(in) :: fid
262  character(LEN=*), intent(in) :: key
263  character(LEN=*), intent(out) :: val
264 
265  integer error
266 
267  intrinsic size
268 
269  call file_get_global_attribute_text( & ! (in)
270  fid, key, & ! (in)
271  val, error ) ! (out)
272  if ( error /= success_code ) then
273  call log('E', 'xxx failed to get text global attribute: '//trim(key))
274  end if
275 
276  return
277  end subroutine filegetglobalattributetext
278 
279  !-----------------------------------------------------------------------------
280  subroutine filegetglobalattributeint( &
281  fid, & ! (in)
282  key, & ! (in)
283  val & ! (out)
284  )
285  integer, intent(in) :: fid
286  character(LEN=*), intent(in) :: key
287  integer, intent(out) :: val(:)
288 
289  integer error
290 
291  intrinsic size
292 
293  call file_get_global_attribute_int( & ! (in)
294  fid, key, size(val), & ! (in)
295  val, error ) ! (out)
296  if ( error /= success_code ) then
297  call log('E', 'xxx failed to get integer global attribute: '//trim(key))
298  end if
299 
300  return
301  end subroutine filegetglobalattributeint
302 
303  !-----------------------------------------------------------------------------
304  subroutine filegetglobalattributefloat( &
305  fid, & ! (in)
306  key, & ! (in)
307  val & ! (out)
308  )
309  integer, intent(in) :: fid
310  character(LEN=*), intent(in) :: key
311  real(SP), intent(out) :: val(:)
312 
313  integer error
314 
315  intrinsic size
316 
317  call file_get_global_attribute_float( & ! (in)
318  fid, key, size(val), & ! (in)
319  val, error ) ! (out)
320  if ( error /= success_code ) then
321  call log('E', 'xxx failed to get float global attribute: '//trim(key))
322  end if
323 
324  return
325  end subroutine filegetglobalattributefloat
326 
327  !-----------------------------------------------------------------------------
328  subroutine filegetglobalattributedouble( &
329  fid, & ! (in)
330  key, & ! (in)
331  val & ! (out)
332  )
333  integer, intent(in) :: fid
334  character(LEN=*), intent(in) :: key
335  real(DP), intent(out) :: val(:)
336 
337  integer error
338 
339  intrinsic size
340 
341  call file_get_global_attribute_double( & ! (in)
342  fid, key, size(val), & ! (in)
343  val, error ) ! (out)
344  if ( error /= success_code ) then
345  call log('E', 'xxx failed to get double global attribute: '//trim(key))
346  end if
347 
348  return
349  end subroutine filegetglobalattributedouble
350 
351 
352  !-----------------------------------------------------------------------------
353  subroutine filesetglobalattributetext( &
354  fid, & ! (in)
355  key, & ! (in)
356  val & ! (in)
357  )
358  integer, intent(in) :: fid
359  character(LEN=*), intent(in) :: key
360  character(LEN=*), intent(in) :: val
361 
362  integer error
363 
364  call file_set_global_attribute_text( fid, & ! (in)
365  key, val, & ! (in)
366  error ) ! (out)
367  if ( error /= success_code ) then
368  call log('E', 'xxx failed to set text global attribute: '//trim(key))
369  end if
370 
371  return
372  end subroutine filesetglobalattributetext
373 
374  !-----------------------------------------------------------------------------
375  subroutine filesetglobalattributeint( &
376  fid, & ! (in)
377  key, & ! (in)
378  val & ! (in)
379  )
380  integer, intent(in) :: fid
381  character(LEN=*), intent(in) :: key
382  integer, intent(in) :: val(:)
383 
384  integer error
385 
386  intrinsic size
387 
388  call file_set_global_attribute_int( fid, & ! (in)
389  key, val, size(val), & ! (in)
390  error ) ! (out)
391  if ( error /= success_code ) then
392  call log('E', 'xxx failed to set integer global attribute: '//trim(key))
393  end if
394 
395  return
396  end subroutine filesetglobalattributeint
397 
398  !-----------------------------------------------------------------------------
399  subroutine filesetglobalattributefloat( &
400  fid, & ! (in)
401  key, & ! (in)
402  val & ! (in)
403  )
404  integer, intent(in) :: fid
405  character(LEN=*), intent(in) :: key
406  real(SP), intent(in) :: val(:)
407 
408  integer error
409 
410  intrinsic size
411 
412  call file_set_global_attribute_float( fid, & ! (in)
413  key, val, size(val), & ! (in)
414  error ) ! (out)
415  if ( error /= success_code ) then
416  call log('E', 'xxx failed to set float global attribute: '//trim(key))
417  end if
418 
419  return
420  end subroutine filesetglobalattributefloat
421 
422  !-----------------------------------------------------------------------------
423  subroutine filesetglobalattributedouble( &
424  fid, & ! (in)
425  key, & ! (in)
426  val & ! (in)
427  )
428  integer, intent(in) :: fid
429  character(LEN=*), intent(in) :: key
430  real(DP), intent(in) :: val(:)
431 
432  integer error
433 
434  intrinsic size
435 
436  call file_set_global_attribute_double( fid, & ! (in)
437  key, val, size(val), & ! (in)
438  error ) ! (out)
439  if ( error /= success_code ) then
440  call log('E', 'xxx failed to set double global attribute: '//trim(key))
441  end if
442 
443  return
444  end subroutine filesetglobalattributedouble
445 
446  !-----------------------------------------------------------------------------
447  subroutine filesetoption( &
448  fid, & ! (in)
449  filetype, & ! (in)
450  key, & ! (in)
451  val & ! (in)
452  )
453  integer, intent(in) :: fid
454  character(LEN=*), intent(in) :: filetype
455  character(LEN=*), intent(in) :: key
456  character(LEN=*), intent(in) :: val
457 
458  integer error
459 
460  call file_set_option( fid, & ! (in)
461  filetype, key, val, & ! (in)
462  error ) ! (out)
463  if ( error /= success_code ) then
464  call log('E', 'xxx failed to set option')
465  end if
466 
467  return
468  end subroutine filesetoption
469 
470  !-----------------------------------------------------------------------------
471  subroutine fileopen( &
472  fid, & ! (out)
473  basename, & ! (in)
474  mode, & ! (in)
475  single & ! (in) optional
476  )
477  implicit none
478 
479  integer, intent(out) :: fid
480  character(LEN=*), intent( in) :: basename
481  integer, intent( in) :: mode
482  logical, intent( in), optional :: single
483 
484  logical :: existed
485  logical :: single_ = .false.
486 
487  if ( present(single) ) single_ = single
488 
489  call filegetfid( fid, & ! (out)
490  existed, & ! (out)
491  basename, mode, single_ ) ! (in)
492 
493  return
494  end subroutine fileopen
495 
496  !-----------------------------------------------------------------------------
497  ! interface FilePutAxis
498  !-----------------------------------------------------------------------------
499  subroutine fileputaxisrealsp( &
500  fid, & ! (in)
501  name, & ! (in)
502  desc, & ! (in)
503  units, & ! (in)
504  dim_name, & ! (in)
505  dtype, & ! (in)
506  val ) ! (in)
507  integer, intent(in) :: fid
508  character(len=*), intent(in) :: name
509  character(len=*), intent(in) :: desc
510  character(len=*), intent(in) :: units
511  character(len=*), intent(in) :: dim_name
512  integer, intent(in) :: dtype
513  real(SP), intent(in) :: val(:)
514 
515  integer error
516  intrinsic size
517 
518  call file_put_axis( fid, & ! (in)
519  name, desc, units, dim_name, dtype, val, size(val), sp, & ! (in)
520  error ) ! (out)
521  if ( error /= success_code .and. error /= already_existed_code ) then
522  call log('E', 'xxx failed to put axis')
523  end if
524 
525  return
526  end subroutine fileputaxisrealsp
527  subroutine fileputaxisrealdp( &
528  fid, & ! (in)
529  name, & ! (in)
530  desc, & ! (in)
531  units, & ! (in)
532  dim_name, & ! (in)
533  dtype, & ! (in)
534  val ) ! (in)
535  integer, intent(in) :: fid
536  character(len=*), intent(in) :: name
537  character(len=*), intent(in) :: desc
538  character(len=*), intent(in) :: units
539  character(len=*), intent(in) :: dim_name
540  integer, intent(in) :: dtype
541  real(DP), intent(in) :: val(:)
542 
543  integer error
544  intrinsic size
545 
546  call file_put_axis( fid, & ! (in)
547  name, desc, units, dim_name, dtype, val, size(val), dp, & ! (in)
548  error ) ! (out)
549  if ( error /= success_code .and. error /= already_existed_code ) then
550  call log('E', 'xxx failed to put axis')
551  end if
552 
553  return
554  end subroutine fileputaxisrealdp
555 
556  subroutine filedefaxis( &
557  fid, & ! (in)
558  name, & ! (in)
559  desc, & ! (in)
560  units, & ! (in)
561  dim_name, & ! (in)
562  dtype, & ! (in)
563  dim_size ) ! (in)
564  integer, intent(in) :: fid
565  character(len=*), intent(in) :: name
566  character(len=*), intent(in) :: desc
567  character(len=*), intent(in) :: units
568  character(len=*), intent(in) :: dim_name
569  integer, intent(in) :: dtype
570  integer, intent(in) :: dim_size
571 
572  integer error
573  intrinsic size
574 
575  call file_def_axis( fid, name, desc, units, dim_name, dtype, dim_size, & ! (in)
576  error ) ! (out)
577  if ( error /= success_code .and. error /= already_existed_code ) then
578  call log('E', 'xxx failed to define axis')
579  end if
580 
581  return
582  end subroutine filedefaxis
583 
584  !-----------------------------------------------------------------------------
585  ! interface FileWriteAxis
586  !-----------------------------------------------------------------------------
587  subroutine filewriteaxisrealsp( &
588  fid, & ! (in)
589  name, & ! (in)
590  val ) ! (in)
591  integer, intent(in) :: fid
592  character(len=*), intent(in) :: name
593  real(SP), intent(in) :: val(:)
594 
595  integer error
596  intrinsic size
597 
598  call file_write_axis( fid, name, val, sp, & ! (in)
599  error ) ! (out)
600  if ( error /= success_code ) then
601  call log('E', 'xxx failed to write axis')
602  end if
603 
604  return
605  end subroutine filewriteaxisrealsp
606  subroutine filewriteaxisrealdp( &
607  fid, & ! (in)
608  name, & ! (in)
609  val ) ! (in)
610  integer, intent(in) :: fid
611  character(len=*), intent(in) :: name
612  real(DP), intent(in) :: val(:)
613 
614  integer error
615  intrinsic size
616 
617  call file_write_axis( fid, name, val, dp, & ! (in)
618  error ) ! (out)
619  if ( error /= success_code ) then
620  call log('E', 'xxx failed to write axis')
621  end if
622 
623  return
624  end subroutine filewriteaxisrealdp
625 
626  !-----------------------------------------------------------------------------
627  ! interface FilePutAssociatedCoordinates
628  !-----------------------------------------------------------------------------
629  subroutine fileput1dassociatedcoordinatesrealsp( &
630  fid, & ! (in)
631  name, & ! (in)
632  desc, & ! (in)
633  units, & ! (in)
634  dim_names, & ! (in)
635  dtype, & ! (in)
636  val ) ! (in)
637  integer, intent(in) :: fid
638  character(len=*), intent(in) :: name
639  character(len=*), intent(in) :: desc
640  character(len=*), intent(in) :: units
641  character(len=*), intent(in) :: dim_names(:)
642  integer, intent(in) :: dtype
643  real(SP), intent(in) :: val(:)
644 
645  integer error
646  intrinsic size
647 
648  call file_put_associated_coordinates( fid, & ! (in)
649  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
650  val, sp, & ! (in)
651  error ) ! (out)
652  if ( error /= success_code .and. error /= already_existed_code ) then
653  call log('E', 'xxx failed to put associated coordinates')
654  end if
655 
656  return
657  end subroutine fileput1dassociatedcoordinatesrealsp
658  subroutine fileput1dassociatedcoordinatesrealdp( &
659  fid, & ! (in)
660  name, & ! (in)
661  desc, & ! (in)
662  units, & ! (in)
663  dim_names, & ! (in)
664  dtype, & ! (in)
665  val ) ! (in)
666  integer, intent(in) :: fid
667  character(len=*), intent(in) :: name
668  character(len=*), intent(in) :: desc
669  character(len=*), intent(in) :: units
670  character(len=*), intent(in) :: dim_names(:)
671  integer, intent(in) :: dtype
672  real(DP), intent(in) :: val(:)
673 
674  integer error
675  intrinsic size
676 
677  call file_put_associated_coordinates( fid, & ! (in)
678  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
679  val, dp, & ! (in)
680  error ) ! (out)
681  if ( error /= success_code .and. error /= already_existed_code ) then
682  call log('E', 'xxx failed to put associated coordinates')
683  end if
684 
685  return
686  end subroutine fileput1dassociatedcoordinatesrealdp
687  subroutine fileput2dassociatedcoordinatesrealsp( &
688  fid, & ! (in)
689  name, & ! (in)
690  desc, & ! (in)
691  units, & ! (in)
692  dim_names, & ! (in)
693  dtype, & ! (in)
694  val ) ! (in)
695  integer, intent(in) :: fid
696  character(len=*), intent(in) :: name
697  character(len=*), intent(in) :: desc
698  character(len=*), intent(in) :: units
699  character(len=*), intent(in) :: dim_names(:)
700  integer, intent(in) :: dtype
701  real(SP), intent(in) :: val(:,:)
702 
703  integer error
704  intrinsic size
705 
706  call file_put_associated_coordinates( fid, & ! (in)
707  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
708  val, sp, & ! (in)
709  error ) ! (out)
710  if ( error /= success_code .and. error /= already_existed_code ) then
711  call log('E', 'xxx failed to put associated coordinates')
712  end if
713 
714  return
715  end subroutine fileput2dassociatedcoordinatesrealsp
716  subroutine fileput2dassociatedcoordinatesrealdp( &
717  fid, & ! (in)
718  name, & ! (in)
719  desc, & ! (in)
720  units, & ! (in)
721  dim_names, & ! (in)
722  dtype, & ! (in)
723  val ) ! (in)
724  integer, intent(in) :: fid
725  character(len=*), intent(in) :: name
726  character(len=*), intent(in) :: desc
727  character(len=*), intent(in) :: units
728  character(len=*), intent(in) :: dim_names(:)
729  integer, intent(in) :: dtype
730  real(DP), intent(in) :: val(:,:)
731 
732  integer error
733  intrinsic size
734 
735  call file_put_associated_coordinates( fid, & ! (in)
736  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
737  val, dp, & ! (in)
738  error ) ! (out)
739  if ( error /= success_code .and. error /= already_existed_code ) then
740  call log('E', 'xxx failed to put associated coordinates')
741  end if
742 
743  return
744  end subroutine fileput2dassociatedcoordinatesrealdp
745  subroutine fileput3dassociatedcoordinatesrealsp( &
746  fid, & ! (in)
747  name, & ! (in)
748  desc, & ! (in)
749  units, & ! (in)
750  dim_names, & ! (in)
751  dtype, & ! (in)
752  val ) ! (in)
753  integer, intent(in) :: fid
754  character(len=*), intent(in) :: name
755  character(len=*), intent(in) :: desc
756  character(len=*), intent(in) :: units
757  character(len=*), intent(in) :: dim_names(:)
758  integer, intent(in) :: dtype
759  real(SP), intent(in) :: val(:,:,:)
760 
761  integer error
762  intrinsic size
763 
764  call file_put_associated_coordinates( fid, & ! (in)
765  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
766  val, sp, & ! (in)
767  error ) ! (out)
768  if ( error /= success_code .and. error /= already_existed_code ) then
769  call log('E', 'xxx failed to put associated coordinates')
770  end if
771 
772  return
773  end subroutine fileput3dassociatedcoordinatesrealsp
774  subroutine fileput3dassociatedcoordinatesrealdp( &
775  fid, & ! (in)
776  name, & ! (in)
777  desc, & ! (in)
778  units, & ! (in)
779  dim_names, & ! (in)
780  dtype, & ! (in)
781  val ) ! (in)
782  integer, intent(in) :: fid
783  character(len=*), intent(in) :: name
784  character(len=*), intent(in) :: desc
785  character(len=*), intent(in) :: units
786  character(len=*), intent(in) :: dim_names(:)
787  integer, intent(in) :: dtype
788  real(DP), intent(in) :: val(:,:,:)
789 
790  integer error
791  intrinsic size
792 
793  call file_put_associated_coordinates( fid, & ! (in)
794  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
795  val, dp, & ! (in)
796  error ) ! (out)
797  if ( error /= success_code .and. error /= already_existed_code ) then
798  call log('E', 'xxx failed to put associated coordinates')
799  end if
800 
801  return
802  end subroutine fileput3dassociatedcoordinatesrealdp
803  subroutine fileput4dassociatedcoordinatesrealsp( &
804  fid, & ! (in)
805  name, & ! (in)
806  desc, & ! (in)
807  units, & ! (in)
808  dim_names, & ! (in)
809  dtype, & ! (in)
810  val ) ! (in)
811  integer, intent(in) :: fid
812  character(len=*), intent(in) :: name
813  character(len=*), intent(in) :: desc
814  character(len=*), intent(in) :: units
815  character(len=*), intent(in) :: dim_names(:)
816  integer, intent(in) :: dtype
817  real(SP), intent(in) :: val(:,:,:,:)
818 
819  integer error
820  intrinsic size
821 
822  call file_put_associated_coordinates( fid, & ! (in)
823  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
824  val, sp, & ! (in)
825  error ) ! (out)
826  if ( error /= success_code .and. error /= already_existed_code ) then
827  call log('E', 'xxx failed to put associated coordinates')
828  end if
829 
830  return
831  end subroutine fileput4dassociatedcoordinatesrealsp
832  subroutine fileput4dassociatedcoordinatesrealdp( &
833  fid, & ! (in)
834  name, & ! (in)
835  desc, & ! (in)
836  units, & ! (in)
837  dim_names, & ! (in)
838  dtype, & ! (in)
839  val ) ! (in)
840  integer, intent(in) :: fid
841  character(len=*), intent(in) :: name
842  character(len=*), intent(in) :: desc
843  character(len=*), intent(in) :: units
844  character(len=*), intent(in) :: dim_names(:)
845  integer, intent(in) :: dtype
846  real(DP), intent(in) :: val(:,:,:,:)
847 
848  integer error
849  intrinsic size
850 
851  call file_put_associated_coordinates( fid, & ! (in)
852  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
853  val, dp, & ! (in)
854  error ) ! (out)
855  if ( error /= success_code .and. error /= already_existed_code ) then
856  call log('E', 'xxx failed to put associated coordinates')
857  end if
858 
859  return
860  end subroutine fileput4dassociatedcoordinatesrealdp
861 
862  subroutine filedefassociatedcoordinates( &
863  fid, & ! (in)
864  name, & ! (in)
865  desc, & ! (in)
866  units, & ! (in)
867  dim_names, & ! (in)
868  dtype ) ! (in)
869  integer, intent(in) :: fid
870  character(len=*), intent(in) :: name
871  character(len=*), intent(in) :: desc
872  character(len=*), intent(in) :: units
873  character(len=*), intent(in) :: dim_names(:)
874  integer, intent(in) :: dtype
875 
876  integer error
877  intrinsic size
878 
879  call file_def_associated_coordinates( fid, & ! (in)
880  name, desc, units, dim_names, size(dim_names), dtype, & ! (in)
881  error ) ! (out)
882  if ( error /= success_code .and. error /= already_existed_code ) then
883  call log('E', 'xxx failed to put associated coordinates')
884  end if
885 
886  return
887  end subroutine filedefassociatedcoordinates
888 
889  !-----------------------------------------------------------------------------
890  ! interface FileWriteAssociatedCoordinates
891  !-----------------------------------------------------------------------------
892  subroutine filewrite1dassociatedcoordinatesrealsp( &
893  fid, & ! (in)
894  name, & ! (in)
895  val ) ! (in)
896  integer, intent(in) :: fid
897  character(len=*), intent(in) :: name
898  real(SP), intent(in) :: val(:)
899 
900  integer error
901  intrinsic size
902 
903  call file_write_associated_coordinates( fid, name, val, sp, & ! (in)
904  error ) ! (out)
905  if ( error /= success_code .and. error /= already_existed_code ) then
906  call log('E', 'xxx failed to put associated coordinates')
907  end if
908 
909  return
910  end subroutine filewrite1dassociatedcoordinatesrealsp
911  subroutine filewrite1dassociatedcoordinatesrealdp( &
912  fid, & ! (in)
913  name, & ! (in)
914  val ) ! (in)
915  integer, intent(in) :: fid
916  character(len=*), intent(in) :: name
917  real(DP), intent(in) :: val(:)
918 
919  integer error
920  intrinsic size
921 
922  call file_write_associated_coordinates( fid, name, val, dp, & ! (in)
923  error ) ! (out)
924  if ( error /= success_code .and. error /= already_existed_code ) then
925  call log('E', 'xxx failed to put associated coordinates')
926  end if
927 
928  return
929  end subroutine filewrite1dassociatedcoordinatesrealdp
930  subroutine filewrite2dassociatedcoordinatesrealsp( &
931  fid, & ! (in)
932  name, & ! (in)
933  val ) ! (in)
934  integer, intent(in) :: fid
935  character(len=*), intent(in) :: name
936  real(SP), intent(in) :: val(:,:)
937 
938  integer error
939  intrinsic size
940 
941  call file_write_associated_coordinates( fid, name, val, sp, & ! (in)
942  error ) ! (out)
943  if ( error /= success_code .and. error /= already_existed_code ) then
944  call log('E', 'xxx failed to put associated coordinates')
945  end if
946 
947  return
948  end subroutine filewrite2dassociatedcoordinatesrealsp
949  subroutine filewrite2dassociatedcoordinatesrealdp( &
950  fid, & ! (in)
951  name, & ! (in)
952  val ) ! (in)
953  integer, intent(in) :: fid
954  character(len=*), intent(in) :: name
955  real(DP), intent(in) :: val(:,:)
956 
957  integer error
958  intrinsic size
959 
960  call file_write_associated_coordinates( fid, name, val, dp, & ! (in)
961  error ) ! (out)
962  if ( error /= success_code .and. error /= already_existed_code ) then
963  call log('E', 'xxx failed to put associated coordinates')
964  end if
965 
966  return
967  end subroutine filewrite2dassociatedcoordinatesrealdp
968  subroutine filewrite3dassociatedcoordinatesrealsp( &
969  fid, & ! (in)
970  name, & ! (in)
971  val ) ! (in)
972  integer, intent(in) :: fid
973  character(len=*), intent(in) :: name
974  real(SP), intent(in) :: val(:,:,:)
975 
976  integer error
977  intrinsic size
978 
979  call file_write_associated_coordinates( fid, name, val, sp, & ! (in)
980  error ) ! (out)
981  if ( error /= success_code .and. error /= already_existed_code ) then
982  call log('E', 'xxx failed to put associated coordinates')
983  end if
984 
985  return
986  end subroutine filewrite3dassociatedcoordinatesrealsp
987  subroutine filewrite3dassociatedcoordinatesrealdp( &
988  fid, & ! (in)
989  name, & ! (in)
990  val ) ! (in)
991  integer, intent(in) :: fid
992  character(len=*), intent(in) :: name
993  real(DP), intent(in) :: val(:,:,:)
994 
995  integer error
996  intrinsic size
997 
998  call file_write_associated_coordinates( fid, name, val, dp, & ! (in)
999  error ) ! (out)
1000  if ( error /= success_code .and. error /= already_existed_code ) then
1001  call log('E', 'xxx failed to put associated coordinates')
1002  end if
1003 
1004  return
1005  end subroutine filewrite3dassociatedcoordinatesrealdp
1006  subroutine filewrite4dassociatedcoordinatesrealsp( &
1007  fid, & ! (in)
1008  name, & ! (in)
1009  val ) ! (in)
1010  integer, intent(in) :: fid
1011  character(len=*), intent(in) :: name
1012  real(SP), intent(in) :: val(:,:,:,:)
1013 
1014  integer error
1015  intrinsic size
1016 
1017  call file_write_associated_coordinates( fid, name, val, sp, & ! (in)
1018  error ) ! (out)
1019  if ( error /= success_code .and. error /= already_existed_code ) then
1020  call log('E', 'xxx failed to put associated coordinates')
1021  end if
1022 
1023  return
1024  end subroutine filewrite4dassociatedcoordinatesrealsp
1025  subroutine filewrite4dassociatedcoordinatesrealdp( &
1026  fid, & ! (in)
1027  name, & ! (in)
1028  val ) ! (in)
1029  integer, intent(in) :: fid
1030  character(len=*), intent(in) :: name
1031  real(DP), intent(in) :: val(:,:,:,:)
1032 
1033  integer error
1034  intrinsic size
1035 
1036  call file_write_associated_coordinates( fid, name, val, dp, & ! (in)
1037  error ) ! (out)
1038  if ( error /= success_code .and. error /= already_existed_code ) then
1039  call log('E', 'xxx failed to put associated coordinates')
1040  end if
1041 
1042  return
1043  end subroutine filewrite4dassociatedcoordinatesrealdp
1044 
1045  !-----------------------------------------------------------------------------
1046  ! interface FileAddVariable
1047  !-----------------------------------------------------------------------------
1048  subroutine fileaddvariablenot( &
1049  vid, & ! (out)
1050  fid, & ! (in)
1051  varname, & ! (in)
1052  desc, & ! (in)
1053  units, & ! (in)
1054  dims, & ! (in)
1055  dtype, & ! (in)
1056  tavg & ! (in) optional
1057  )
1058  integer, intent(out) :: vid
1059  integer, intent( in) :: fid
1060  character(len=*), intent( in) :: varname
1061  character(len=*), intent( in) :: desc
1062  character(len=*), intent( in) :: units
1063  character(len=*), intent( in) :: dims(:)
1064  integer, intent( in) :: dtype
1065  logical, intent( in), optional :: tavg
1066 
1067  call fileaddvariablerealdp(vid, fid, varname, desc, units, dims, dtype, &
1068  -1.0_dp, tavg )
1069 
1070  return
1071  end subroutine fileaddvariablenot
1072  subroutine fileaddvariablerealsp( &
1073  vid, & ! (out)
1074  fid, & ! (in)
1075  varname, & ! (in)
1076  desc, & ! (in)
1077  units, & ! (in)
1078  dims, & ! (in)
1079  dtype, & ! (in)
1080  tint, & ! (in)
1081  tavg & ! (in) optional
1082  )
1083  integer, intent(out) :: vid
1084  integer, intent( in) :: fid
1085  character(len=*), intent( in) :: varname
1086  character(len=*), intent( in) :: desc
1087  character(len=*), intent( in) :: units
1088  character(len=*), intent( in) :: dims(:)
1089  integer, intent( in) :: dtype
1090  real(SP), intent( in) :: tint
1091  logical, intent( in), optional :: tavg
1092 
1093  real(DP) :: tint8
1094  integer :: itavg
1095  integer :: error
1096  integer :: n
1097 
1098  intrinsic size
1099  !---------------------------------------------------------------------------
1100 
1101  vid = -1
1102  do n = 1, file_vid_count
1103  if ( file_vid_fid_list(n) == fid .and. &
1104  varname == file_vname_list(n) ) then
1105  vid = file_vid_list(n)
1106  end if
1107  enddo
1108 
1109  if ( vid < 0 ) then ! variable registration
1110  !--- register new variable
1111  write(message,*) '*** [File] Var registration'
1112  call log("I", message)
1113  write(message,*) '*** variable name: ', trim(varname)
1114  call log("I", message)
1115 
1116  tint8 = real(tint,dp)
1117 
1118  if ( present(tavg) ) then
1119  if ( tavg ) then
1120  itavg = 1
1121  else
1122  itavg = 0
1123  end if
1124  else
1125  itavg = 0
1126  end if
1127 
1128  call file_add_variable( vid, & ! (out)
1129  fid, varname, desc, units, dims, size(dims), dtype, & ! (in)
1130  tint8, itavg, & ! (in)
1131  error ) ! (out)
1132  if ( error /= success_code ) then
1133  call log('E', 'xxx failed to add variable: '//trim(varname))
1134  end if
1135 
1136  file_vname_list(file_vid_count) = trim(varname)
1137  file_vid_list(file_vid_count) = vid
1138  file_vid_fid_list(file_vid_count) = fid
1139  file_vid_count = file_vid_count + 1
1140  endif
1141 
1142  return
1143  end subroutine fileaddvariablerealsp
1144  subroutine fileaddvariablerealdp( &
1145  vid, & ! (out)
1146  fid, & ! (in)
1147  varname, & ! (in)
1148  desc, & ! (in)
1149  units, & ! (in)
1150  dims, & ! (in)
1151  dtype, & ! (in)
1152  tint, & ! (in)
1153  tavg & ! (in) optional
1154  )
1155  integer, intent(out) :: vid
1156  integer, intent( in) :: fid
1157  character(len=*), intent( in) :: varname
1158  character(len=*), intent( in) :: desc
1159  character(len=*), intent( in) :: units
1160  character(len=*), intent( in) :: dims(:)
1161  integer, intent( in) :: dtype
1162  real(DP), intent( in) :: tint
1163  logical, intent( in), optional :: tavg
1164 
1165  real(DP) :: tint8
1166  integer :: itavg
1167  integer :: error
1168  integer :: n
1169 
1170  intrinsic size
1171  !---------------------------------------------------------------------------
1172 
1173  vid = -1
1174  do n = 1, file_vid_count
1175  if ( file_vid_fid_list(n) == fid .and. &
1176  varname == file_vname_list(n) ) then
1177  vid = file_vid_list(n)
1178  end if
1179  enddo
1180 
1181  if ( vid < 0 ) then ! variable registration
1182  !--- register new variable
1183  write(message,*) '*** [File] Var registration'
1184  call log("I", message)
1185  write(message,*) '*** variable name: ', trim(varname)
1186  call log("I", message)
1187 
1188  tint8 = real(tint,dp)
1189 
1190  if ( present(tavg) ) then
1191  if ( tavg ) then
1192  itavg = 1
1193  else
1194  itavg = 0
1195  end if
1196  else
1197  itavg = 0
1198  end if
1199 
1200  call file_add_variable( vid, & ! (out)
1201  fid, varname, desc, units, dims, size(dims), dtype, & ! (in)
1202  tint8, itavg, & ! (in)
1203  error ) ! (out)
1204  if ( error /= success_code ) then
1205  call log('E', 'xxx failed to add variable: '//trim(varname))
1206  end if
1207 
1208  file_vname_list(file_vid_count) = trim(varname)
1209  file_vid_list(file_vid_count) = vid
1210  file_vid_fid_list(file_vid_count) = fid
1211  file_vid_count = file_vid_count + 1
1212  endif
1213 
1214  return
1215  end subroutine fileaddvariablerealdp
1216 
1217  subroutine filedefinevariable( &
1218  fid, & ! (in)
1219  vid, & ! (out)
1220  varname, & ! (in)
1221  desc, & ! (in)
1222  units, & ! (in)
1223  ndims, & ! (in)
1224  dims, & ! (in)
1225  dtype, & ! (in)
1226  tint, & ! (in) optional
1227  tavg & ! (in) optional
1228  )
1229  integer, intent(out) :: vid
1230  integer, intent( in) :: fid
1231  character(len=*), intent( in) :: varname
1232  character(len=*), intent( in) :: desc
1233  character(len=*), intent( in) :: units
1234  integer, intent( in) :: ndims
1235  character(len=*), intent( in) :: dims(:)
1236  integer, intent( in) :: dtype
1237  real(DP), intent( in), optional :: tint
1238  logical, intent( in), optional :: tavg
1239 
1240  real(DP) :: tint_
1241  integer :: itavg
1242  integer :: error
1243  integer :: n
1244 
1245  intrinsic size
1246  !---------------------------------------------------------------------------
1247 
1248  vid = -1
1249  do n = 1, file_vid_count
1250  if ( file_vid_fid_list(n) == fid .and. &
1251  varname == file_vname_list(n) ) then
1252  vid = file_vid_list(n)
1253  end if
1254  enddo
1255 
1256  if ( vid < 0 ) then ! variable registration
1257  !--- register new variable
1258  write(message,*) '*** [File] Var registration'
1259  call log("I", message)
1260  write(message,*) '*** variable name: ', trim(varname)
1261  call log("I", message)
1262 
1263  if ( .NOT. present(tint) ) then
1264  tint_ = -1.0_dp
1265  endif
1266 
1267  if ( present(tavg) ) then
1268  if ( tavg ) then
1269  itavg = 1
1270  else
1271  itavg = 0
1272  end if
1273  else
1274  itavg = 0
1275  end if
1276 
1277  call file_add_variable( vid, & ! (out)
1278  fid, varname, desc, units, dims, ndims, dtype, & ! (in)
1279  tint_, itavg, & ! (in)
1280  error ) ! (out)
1281  if ( error /= success_code ) then
1282  call log('E', 'xxx failed to add variable: '//trim(varname))
1283  end if
1284 
1285  file_vname_list(file_vid_count) = trim(varname)
1286  file_vid_list(file_vid_count) = vid
1287  file_vid_fid_list(file_vid_count) = fid
1288  file_vid_count = file_vid_count + 1
1289  endif
1290 
1291  return
1292  end subroutine filedefinevariable
1293 
1294  !-----------------------------------------------------------------------------
1295  ! FileSetTAttr
1296  !-----------------------------------------------------------------------------
1297  subroutine filesettattr( &
1298  fid, & ! (in)
1299  vname, & ! (in)
1300  key, & ! (in)
1301  val & ! (in)
1302  )
1303  integer, intent(in) :: fid
1304  character(len=*), intent(in) :: vname
1305  character(len=*), intent(in) :: key
1306  character(len=*), intent(in) :: val
1307 
1308  integer :: error
1309 
1310  call file_set_tattr( &
1311  fid, vname, & ! (in)
1312  key, val, & ! (in)
1313  error ) ! (out)
1314  if ( error /= success_code .and. error /= already_existed_code ) then
1315  call log('E', 'xxx failed to set attr for axis')
1316  end if
1317 
1318  return
1319  end subroutine filesettattr
1320 
1321  !-----------------------------------------------------------------------------
1322  ! FileGetShape
1323  !-----------------------------------------------------------------------------
1324  subroutine filegetshape( &
1325  dims, & ! (out)
1326  basename, & ! (in)
1327  varname, & ! (in)
1328  myrank, & ! (in)
1329  single & ! (in) optional
1330  )
1331  implicit none
1332 
1333  integer, intent(out) :: dims(:)
1334  character(LEN=*), intent( in) :: basename
1335  character(LEN=*), intent( in) :: varname
1336  integer, intent( in) :: myrank
1337  logical, intent( in), optional :: single
1338 
1339  integer :: fid
1340  type(datainfo) :: dinfo
1341  integer :: error
1342  integer :: n
1343 
1344  logical :: single_ = .false.
1345 
1346  intrinsic size
1347  intrinsic shape
1348  !---------------------------------------------------------------------------
1349 
1350  mpi_myrank = myrank
1351 
1352  if ( present(single) ) single_ = single
1353 
1354  !--- search/register file
1355  call fileopen( fid, & ! (out)
1356  basename, file_fread, single_ ) ! (in)
1357 
1358  !--- get data information
1359  call file_get_datainfo( dinfo, & ! (out)
1360  fid, varname, 1, .false., & ! (in)
1361  error ) ! (out)
1362 
1363  !--- verify
1364  if ( error /= success_code ) then
1365  call log('E', 'xxx failed to get data information :'//trim(varname))
1366  end if
1367 
1368  if ( dinfo%rank /= size(dims) ) then
1369  write(message,*) 'xxx rank is different, ', size(dims), dinfo%rank
1370  call log('E', message)
1371  end if
1372  do n = 1, size(dims)
1373  dims(n) = dinfo%dim_size(n)
1374  end do
1375 
1376  return
1377  end subroutine filegetshape
1378 
1379  !-----------------------------------------------------------------------------
1380  ! FileGetData
1381  !-----------------------------------------------------------------------------
1382  subroutine filegetdatainfo( &
1383  basename, &
1384  varname, &
1385  myrank, &
1386  istep, &
1387  single, &
1388  description, &
1389  units, &
1390  datatype, &
1391  dim_rank, &
1392  dim_name, &
1393  dim_size, &
1394  time_start, &
1395  time_end, &
1396  time_units )
1397  implicit none
1398  character(len=*), intent(in) :: basename
1399  character(len=*), intent(in) :: varname
1400  integer, intent(in) :: myrank
1401  integer, intent(in) :: istep
1402  logical, intent(in), optional :: single
1403 
1404  character(len=File_HMID), intent(out), optional :: description
1405  character(len=File_HSHORT), intent(out), optional :: units
1406  integer, intent(out), optional :: datatype
1407  integer, intent(out), optional :: dim_rank
1408  character(len=File_HSHORT), intent(out), optional :: dim_name(:)
1409  integer, intent(out), optional :: dim_size(:)
1410  real(DP), intent(out), optional :: time_start
1411  real(DP), intent(out), optional :: time_end
1412  character(len=File_HMID), intent(out), optional :: time_units
1413 
1414  integer :: fid
1415  type(datainfo) :: dinfo
1416 
1417  integer :: ndim, idim
1418  real(DP):: time(1)
1419 
1420  integer :: error
1421  logical :: single_ = .false.
1422 
1423  intrinsic size
1424  !---------------------------------------------------------------------------
1425 
1426  mpi_myrank = myrank
1427 
1428  if ( present(single) ) single_ = single
1429 
1430  !--- search/register file
1431  call fileopen( fid, & ! [OUT]
1432  basename, & ! [IN]
1433  file_fread, & ! [IN]
1434  single_ ) ! [IN]
1435 
1436  !--- get data information
1437  call file_get_datainfo( dinfo, & ! [OUT]
1438  fid, & ! [IN]
1439  varname, & ! [IN]
1440  istep, & ! [IN]
1441  .false., & ! [IN]
1442  error ) ! [OUT]
1443 
1444  !--- verify and exit
1445  if ( error /= success_code ) then
1446  call log('E', 'xxx data info not found in '//trim(basename))
1447  endif
1448 
1449  if ( present(description) ) description = dinfo%description
1450  if ( present(units) ) units = dinfo%units
1451  if ( present(datatype) ) datatype = dinfo%datatype
1452  if ( present(dim_rank) ) dim_rank = dinfo%rank
1453 
1454  if ( present(dim_name) ) then
1455  ndim = min( dinfo%rank, size(dim_name) ) ! limit dimension rank
1456  do idim = 1, ndim
1457  dim_name(idim) = dinfo%dim_name(idim)
1458  enddo
1459  end if
1460  if ( present(dim_size) ) then
1461  ndim = min( dinfo%rank, size(dim_size) ) ! limit dimension rank
1462  do idim = 1, ndim
1463  dim_size(idim) = dinfo%dim_size(idim)
1464  enddo
1465  end if
1466 
1467  if ( present(time_units) ) then
1468  if ( dinfo%time_units == "" ) then
1469  call filegetglobalattribute( fid, "time_units", time_units )
1470  else
1471  time_units = dinfo%time_units
1472  end if
1473  end if
1474  if ( present(time_start) ) then
1475  if ( dinfo%time_units == "" ) then
1476  call filegetglobalattribute( fid, "time", time )
1477  time_start = time(1)
1478  else
1479  time_start = dinfo%time_start
1480  end if
1481  end if
1482  if ( present(time_end) ) then
1483  if ( dinfo%time_units == "" ) then
1484  call filegetglobalattribute( fid, "time", time )
1485  time_end = time(1)
1486  else
1487  time_end = dinfo%time_end
1488  end if
1489  end if
1490 
1491  return
1492  end subroutine filegetdatainfo
1493 
1494  !-----------------------------------------------------------------------------
1495  ! FileGetData
1496  !-----------------------------------------------------------------------------
1497  subroutine filegetalldatainfo( &
1498  step_limit, &
1499  dim_limit, &
1500  basename, &
1501  varname, &
1502  myrank, &
1503  step_nmax, &
1504  description, &
1505  units, &
1506  datatype, &
1507  dim_rank, &
1508  dim_name, &
1509  dim_size, &
1510  time_start, &
1511  time_end, &
1512  time_units, &
1513  single )
1514  implicit none
1515 
1516  integer, intent(in) :: step_limit
1517  integer, intent(in) :: dim_limit
1518  character(len=*), intent(in) :: basename
1519  character(len=*), intent(in) :: varname
1520  integer, intent(in) :: myrank
1521  integer, intent(out) :: step_nmax
1522  character(len=File_HMID), intent(out) :: description
1523  character(len=File_HSHORT), intent(out) :: units
1524  integer, intent(out) :: datatype
1525  integer, intent(out) :: dim_rank
1526  character(len=File_HSHORT), intent(out) :: dim_name (dim_limit)
1527  integer, intent(out) :: dim_size (dim_limit)
1528  real(DP), intent(out) :: time_start(step_limit)
1529  real(DP), intent(out) :: time_end (step_limit)
1530  character(len=File_HMID), intent(out) :: time_units
1531 
1532  logical, intent(in), optional :: single
1533 
1534  integer :: fid
1535  type(datainfo) :: dinfo
1536 
1537  integer :: ndim
1538  integer :: istep, idim
1539  logical :: flag_first = .true.
1540 
1541  integer :: error
1542  logical :: single_ = .false.
1543  !---------------------------------------------------------------------------
1544 
1545  mpi_myrank = myrank
1546 
1547  if ( present(single) ) single_ = single
1548 
1549  !--- search/register file
1550  call fileopen( fid, & ! [OUT]
1551  basename, & ! [IN]
1552  file_fread, & ! [IN]
1553  single_ ) ! [IN]
1554 
1555  ! initialize
1556  description = ""
1557  units = ""
1558  datatype = -1
1559  dim_rank = -1
1560  dim_name(:) = ""
1561  dim_size(:) = -1
1562  time_start(:) = rmiss
1563  time_end(:) = rmiss
1564 
1565  do istep = 1, step_limit
1566  !--- get data information
1567  call file_get_datainfo( dinfo, & ! [OUT]
1568  fid, & ! [IN]
1569  varname, & ! [IN]
1570  istep, & ! [IN]
1571  .true., & ! [IN]
1572  error ) ! [OUT]
1573 
1574  !--- verify and exit
1575  if ( error /= success_code ) then
1576  step_nmax = istep - 1
1577  exit
1578  endif
1579 
1580  if ( flag_first ) then
1581  flag_first = .false.
1582 
1583  description = dinfo%description
1584  units = dinfo%units
1585  datatype = dinfo%datatype
1586  dim_rank = dinfo%rank
1587 
1588  ndim = min( dinfo%rank, dim_limit ) ! limit dimension rank
1589  do idim = 1, ndim
1590  dim_name(idim) = dinfo%dim_name(idim)
1591  dim_size(idim) = dinfo%dim_size(idim)
1592  enddo
1593 
1594  time_units = dinfo%time_units
1595  endif
1596 
1597  time_start(istep) = dinfo%time_start
1598  time_end(istep) = dinfo%time_end
1599  enddo
1600 
1601  return
1602  end subroutine filegetalldatainfo
1603 
1604  !-----------------------------------------------------------------------------
1605  ! interface File_read
1606  !-----------------------------------------------------------------------------
1607  subroutine fileread1drealsp( &
1608  var, & ! (out)
1609  basename, & ! (in)
1610  varname, & ! (in)
1611  step, & ! (in)
1612  myrank, & ! (in)
1613  allow_missing, & ! (in) optional
1614  single & ! (in) optional
1615  )
1616  implicit none
1617 
1618  real(SP), intent(out) :: var(:)
1619  character(LEN=*), intent( in) :: basename
1620  character(LEN=*), intent( in) :: varname
1621  integer, intent( in) :: step
1622  integer, intent( in) :: myrank
1623  logical, intent( in), optional :: allow_missing !--- if data is missing, set value to zero
1624  logical, intent( in), optional :: single
1625 
1626  integer :: fid
1627  type(datainfo) :: dinfo
1628  integer :: dim_size(1)
1629  integer :: error
1630  integer :: n
1631 
1632  logical :: single_ = .false.
1633 
1634  intrinsic shape
1635  !---------------------------------------------------------------------------
1636 
1637  mpi_myrank = myrank
1638 
1639  if ( present(single) ) single_ = single
1640 
1641  !--- search/register file
1642  call fileopen( fid, & ! (out)
1643  basename, file_fread, single_ ) ! (in)
1644 
1645  !--- get data information
1646  call file_get_datainfo( dinfo, & ! (out)
1647  fid, varname, step, .false., & ! (in)
1648  error ) ! (out)
1649 
1650  !--- verify
1651  if ( error /= success_code ) then
1652  if ( present(allow_missing) ) then
1653  if ( allow_missing ) then
1654  write(message,*) 'xxx [INPUT]/[File] data not found! : ', &
1655  'varname= ',trim(varname),', step=',step
1656  call log('I', message)
1657  call log('I', 'xxx [INPUT]/[File] Value is set to 0.')
1658  var(:) = 0.0_sp
1659  else
1660  call log('E', 'xxx failed to get data information :'//trim(varname))
1661  end if
1662  else
1663  call log('E', 'xxx failed to get data information :'//trim(varname))
1664  end if
1665  end if
1666 
1667  if ( dinfo%rank /= 1 ) then
1668  write(message,*) 'xxx rank is not 1', dinfo%rank
1669  call log('E', message)
1670  end if
1671  dim_size(:) = shape(var)
1672  do n = 1, 1
1673  if ( dinfo%dim_size(n) /= dim_size(n) ) then
1674  write(message,*) 'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1675  call log('E', message)
1676  end if
1677  end do
1678 
1679  call file_read_data( var(:), & ! (out)
1680  dinfo, sp, & ! (in)
1681  error ) ! (out)
1682  if ( error /= success_code ) then
1683  call log('E', 'xxx failed to get data value')
1684  end if
1685 
1686  return
1687  end subroutine fileread1drealsp
1688  subroutine fileread1drealdp( &
1689  var, & ! (out)
1690  basename, & ! (in)
1691  varname, & ! (in)
1692  step, & ! (in)
1693  myrank, & ! (in)
1694  allow_missing, & ! (in) optional
1695  single & ! (in) optional
1696  )
1697  implicit none
1698 
1699  real(DP), intent(out) :: var(:)
1700  character(LEN=*), intent( in) :: basename
1701  character(LEN=*), intent( in) :: varname
1702  integer, intent( in) :: step
1703  integer, intent( in) :: myrank
1704  logical, intent( in), optional :: allow_missing !--- if data is missing, set value to zero
1705  logical, intent( in), optional :: single
1706 
1707  integer :: fid
1708  type(datainfo) :: dinfo
1709  integer :: dim_size(1)
1710  integer :: error
1711  integer :: n
1712 
1713  logical :: single_ = .false.
1714 
1715  intrinsic shape
1716  !---------------------------------------------------------------------------
1717 
1718  mpi_myrank = myrank
1719 
1720  if ( present(single) ) single_ = single
1721 
1722  !--- search/register file
1723  call fileopen( fid, & ! (out)
1724  basename, file_fread, single_ ) ! (in)
1725 
1726  !--- get data information
1727  call file_get_datainfo( dinfo, & ! (out)
1728  fid, varname, step, .false., & ! (in)
1729  error ) ! (out)
1730 
1731  !--- verify
1732  if ( error /= success_code ) then
1733  if ( present(allow_missing) ) then
1734  if ( allow_missing ) then
1735  write(message,*) 'xxx [INPUT]/[File] data not found! : ', &
1736  'varname= ',trim(varname),', step=',step
1737  call log('I', message)
1738  call log('I', 'xxx [INPUT]/[File] Value is set to 0.')
1739  var(:) = 0.0_dp
1740  else
1741  call log('E', 'xxx failed to get data information :'//trim(varname))
1742  end if
1743  else
1744  call log('E', 'xxx failed to get data information :'//trim(varname))
1745  end if
1746  end if
1747 
1748  if ( dinfo%rank /= 1 ) then
1749  write(message,*) 'xxx rank is not 1', dinfo%rank
1750  call log('E', message)
1751  end if
1752  dim_size(:) = shape(var)
1753  do n = 1, 1
1754  if ( dinfo%dim_size(n) /= dim_size(n) ) then
1755  write(message,*) 'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1756  call log('E', message)
1757  end if
1758  end do
1759 
1760  call file_read_data( var(:), & ! (out)
1761  dinfo, dp, & ! (in)
1762  error ) ! (out)
1763  if ( error /= success_code ) then
1764  call log('E', 'xxx failed to get data value')
1765  end if
1766 
1767  return
1768  end subroutine fileread1drealdp
1769  subroutine fileread2drealsp( &
1770  var, & ! (out)
1771  basename, & ! (in)
1772  varname, & ! (in)
1773  step, & ! (in)
1774  myrank, & ! (in)
1775  allow_missing, & ! (in) optional
1776  single & ! (in) optional
1777  )
1778  implicit none
1779 
1780  real(SP), intent(out) :: var(:,:)
1781  character(LEN=*), intent( in) :: basename
1782  character(LEN=*), intent( in) :: varname
1783  integer, intent( in) :: step
1784  integer, intent( in) :: myrank
1785  logical, intent( in), optional :: allow_missing !--- if data is missing, set value to zero
1786  logical, intent( in), optional :: single
1787 
1788  integer :: fid
1789  type(datainfo) :: dinfo
1790  integer :: dim_size(2)
1791  integer :: error
1792  integer :: n
1793 
1794  logical :: single_ = .false.
1795 
1796  intrinsic shape
1797  !---------------------------------------------------------------------------
1798 
1799  mpi_myrank = myrank
1800 
1801  if ( present(single) ) single_ = single
1802 
1803  !--- search/register file
1804  call fileopen( fid, & ! (out)
1805  basename, file_fread, single_ ) ! (in)
1806 
1807  !--- get data information
1808  call file_get_datainfo( dinfo, & ! (out)
1809  fid, varname, step, .false., & ! (in)
1810  error ) ! (out)
1811 
1812  !--- verify
1813  if ( error /= success_code ) then
1814  if ( present(allow_missing) ) then
1815  if ( allow_missing ) then
1816  write(message,*) 'xxx [INPUT]/[File] data not found! : ', &
1817  'varname= ',trim(varname),', step=',step
1818  call log('I', message)
1819  call log('I', 'xxx [INPUT]/[File] Value is set to 0.')
1820  var(:,:) = 0.0_sp
1821  else
1822  call log('E', 'xxx failed to get data information :'//trim(varname))
1823  end if
1824  else
1825  call log('E', 'xxx failed to get data information :'//trim(varname))
1826  end if
1827  end if
1828 
1829  if ( dinfo%rank /= 2 ) then
1830  write(message,*) 'xxx rank is not 2', dinfo%rank
1831  call log('E', message)
1832  end if
1833  dim_size(:) = shape(var)
1834  do n = 1, 2
1835  if ( dinfo%dim_size(n) /= dim_size(n) ) then
1836  write(message,*) 'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1837  call log('E', message)
1838  end if
1839  end do
1840 
1841  call file_read_data( var(:,:), & ! (out)
1842  dinfo, sp, & ! (in)
1843  error ) ! (out)
1844  if ( error /= success_code ) then
1845  call log('E', 'xxx failed to get data value')
1846  end if
1847 
1848  return
1849  end subroutine fileread2drealsp
1850  subroutine fileread2drealdp( &
1851  var, & ! (out)
1852  basename, & ! (in)
1853  varname, & ! (in)
1854  step, & ! (in)
1855  myrank, & ! (in)
1856  allow_missing, & ! (in) optional
1857  single & ! (in) optional
1858  )
1859  implicit none
1860 
1861  real(DP), intent(out) :: var(:,:)
1862  character(LEN=*), intent( in) :: basename
1863  character(LEN=*), intent( in) :: varname
1864  integer, intent( in) :: step
1865  integer, intent( in) :: myrank
1866  logical, intent( in), optional :: allow_missing !--- if data is missing, set value to zero
1867  logical, intent( in), optional :: single
1868 
1869  integer :: fid
1870  type(datainfo) :: dinfo
1871  integer :: dim_size(2)
1872  integer :: error
1873  integer :: n
1874 
1875  logical :: single_ = .false.
1876 
1877  intrinsic shape
1878  !---------------------------------------------------------------------------
1879 
1880  mpi_myrank = myrank
1881 
1882  if ( present(single) ) single_ = single
1883 
1884  !--- search/register file
1885  call fileopen( fid, & ! (out)
1886  basename, file_fread, single_ ) ! (in)
1887 
1888  !--- get data information
1889  call file_get_datainfo( dinfo, & ! (out)
1890  fid, varname, step, .false., & ! (in)
1891  error ) ! (out)
1892 
1893  !--- verify
1894  if ( error /= success_code ) then
1895  if ( present(allow_missing) ) then
1896  if ( allow_missing ) then
1897  write(message,*) 'xxx [INPUT]/[File] data not found! : ', &
1898  'varname= ',trim(varname),', step=',step
1899  call log('I', message)
1900  call log('I', 'xxx [INPUT]/[File] Value is set to 0.')
1901  var(:,:) = 0.0_dp
1902  else
1903  call log('E', 'xxx failed to get data information :'//trim(varname))
1904  end if
1905  else
1906  call log('E', 'xxx failed to get data information :'//trim(varname))
1907  end if
1908  end if
1909 
1910  if ( dinfo%rank /= 2 ) then
1911  write(message,*) 'xxx rank is not 2', dinfo%rank
1912  call log('E', message)
1913  end if
1914  dim_size(:) = shape(var)
1915  do n = 1, 2
1916  if ( dinfo%dim_size(n) /= dim_size(n) ) then
1917  write(message,*) 'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1918  call log('E', message)
1919  end if
1920  end do
1921 
1922  call file_read_data( var(:,:), & ! (out)
1923  dinfo, dp, & ! (in)
1924  error ) ! (out)
1925  if ( error /= success_code ) then
1926  call log('E', 'xxx failed to get data value')
1927  end if
1928 
1929  return
1930  end subroutine fileread2drealdp
1931  subroutine fileread3drealsp( &
1932  var, & ! (out)
1933  basename, & ! (in)
1934  varname, & ! (in)
1935  step, & ! (in)
1936  myrank, & ! (in)
1937  allow_missing, & ! (in) optional
1938  single & ! (in) optional
1939  )
1940  implicit none
1941 
1942  real(SP), intent(out) :: var(:,:,:)
1943  character(LEN=*), intent( in) :: basename
1944  character(LEN=*), intent( in) :: varname
1945  integer, intent( in) :: step
1946  integer, intent( in) :: myrank
1947  logical, intent( in), optional :: allow_missing !--- if data is missing, set value to zero
1948  logical, intent( in), optional :: single
1949 
1950  integer :: fid
1951  type(datainfo) :: dinfo
1952  integer :: dim_size(3)
1953  integer :: error
1954  integer :: n
1955 
1956  logical :: single_ = .false.
1957 
1958  intrinsic shape
1959  !---------------------------------------------------------------------------
1960 
1961  mpi_myrank = myrank
1962 
1963  if ( present(single) ) single_ = single
1964 
1965  !--- search/register file
1966  call fileopen( fid, & ! (out)
1967  basename, file_fread, single_ ) ! (in)
1968 
1969  !--- get data information
1970  call file_get_datainfo( dinfo, & ! (out)
1971  fid, varname, step, .false., & ! (in)
1972  error ) ! (out)
1973 
1974  !--- verify
1975  if ( error /= success_code ) then
1976  if ( present(allow_missing) ) then
1977  if ( allow_missing ) then
1978  write(message,*) 'xxx [INPUT]/[File] data not found! : ', &
1979  'varname= ',trim(varname),', step=',step
1980  call log('I', message)
1981  call log('I', 'xxx [INPUT]/[File] Value is set to 0.')
1982  var(:,:,:) = 0.0_sp
1983  else
1984  call log('E', 'xxx failed to get data information :'//trim(varname))
1985  end if
1986  else
1987  call log('E', 'xxx failed to get data information :'//trim(varname))
1988  end if
1989  end if
1990 
1991  if ( dinfo%rank /= 3 ) then
1992  write(message,*) 'xxx rank is not 3', dinfo%rank
1993  call log('E', message)
1994  end if
1995  dim_size(:) = shape(var)
1996  do n = 1, 3
1997  if ( dinfo%dim_size(n) /= dim_size(n) ) then
1998  write(message,*) 'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
1999  call log('E', message)
2000  end if
2001  end do
2002 
2003  call file_read_data( var(:,:,:), & ! (out)
2004  dinfo, sp, & ! (in)
2005  error ) ! (out)
2006  if ( error /= success_code ) then
2007  call log('E', 'xxx failed to get data value')
2008  end if
2009 
2010  return
2011  end subroutine fileread3drealsp
2012  subroutine fileread3drealdp( &
2013  var, & ! (out)
2014  basename, & ! (in)
2015  varname, & ! (in)
2016  step, & ! (in)
2017  myrank, & ! (in)
2018  allow_missing, & ! (in) optional
2019  single & ! (in) optional
2020  )
2021  implicit none
2022 
2023  real(DP), intent(out) :: var(:,:,:)
2024  character(LEN=*), intent( in) :: basename
2025  character(LEN=*), intent( in) :: varname
2026  integer, intent( in) :: step
2027  integer, intent( in) :: myrank
2028  logical, intent( in), optional :: allow_missing !--- if data is missing, set value to zero
2029  logical, intent( in), optional :: single
2030 
2031  integer :: fid
2032  type(datainfo) :: dinfo
2033  integer :: dim_size(3)
2034  integer :: error
2035  integer :: n
2036 
2037  logical :: single_ = .false.
2038 
2039  intrinsic shape
2040  !---------------------------------------------------------------------------
2041 
2042  mpi_myrank = myrank
2043 
2044  if ( present(single) ) single_ = single
2045 
2046  !--- search/register file
2047  call fileopen( fid, & ! (out)
2048  basename, file_fread, single_ ) ! (in)
2049 
2050  !--- get data information
2051  call file_get_datainfo( dinfo, & ! (out)
2052  fid, varname, step, .false., & ! (in)
2053  error ) ! (out)
2054 
2055  !--- verify
2056  if ( error /= success_code ) then
2057  if ( present(allow_missing) ) then
2058  if ( allow_missing ) then
2059  write(message,*) 'xxx [INPUT]/[File] data not found! : ', &
2060  'varname= ',trim(varname),', step=',step
2061  call log('I', message)
2062  call log('I', 'xxx [INPUT]/[File] Value is set to 0.')
2063  var(:,:,:) = 0.0_dp
2064  else
2065  call log('E', 'xxx failed to get data information :'//trim(varname))
2066  end if
2067  else
2068  call log('E', 'xxx failed to get data information :'//trim(varname))
2069  end if
2070  end if
2071 
2072  if ( dinfo%rank /= 3 ) then
2073  write(message,*) 'xxx rank is not 3', dinfo%rank
2074  call log('E', message)
2075  end if
2076  dim_size(:) = shape(var)
2077  do n = 1, 3
2078  if ( dinfo%dim_size(n) /= dim_size(n) ) then
2079  write(message,*) 'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
2080  call log('E', message)
2081  end if
2082  end do
2083 
2084  call file_read_data( var(:,:,:), & ! (out)
2085  dinfo, dp, & ! (in)
2086  error ) ! (out)
2087  if ( error /= success_code ) then
2088  call log('E', 'xxx failed to get data value')
2089  end if
2090 
2091  return
2092  end subroutine fileread3drealdp
2093  subroutine fileread4drealsp( &
2094  var, & ! (out)
2095  basename, & ! (in)
2096  varname, & ! (in)
2097  step, & ! (in)
2098  myrank, & ! (in)
2099  allow_missing, & ! (in) optional
2100  single & ! (in) optional
2101  )
2102  implicit none
2103 
2104  real(SP), intent(out) :: var(:,:,:,:)
2105  character(LEN=*), intent( in) :: basename
2106  character(LEN=*), intent( in) :: varname
2107  integer, intent( in) :: step
2108  integer, intent( in) :: myrank
2109  logical, intent( in), optional :: allow_missing !--- if data is missing, set value to zero
2110  logical, intent( in), optional :: single
2111 
2112  integer :: fid
2113  type(datainfo) :: dinfo
2114  integer :: dim_size(4)
2115  integer :: error
2116  integer :: n
2117 
2118  logical :: single_ = .false.
2119 
2120  intrinsic shape
2121  !---------------------------------------------------------------------------
2122 
2123  mpi_myrank = myrank
2124 
2125  if ( present(single) ) single_ = single
2126 
2127  !--- search/register file
2128  call fileopen( fid, & ! (out)
2129  basename, file_fread, single_ ) ! (in)
2130 
2131  !--- get data information
2132  call file_get_datainfo( dinfo, & ! (out)
2133  fid, varname, step, .false., & ! (in)
2134  error ) ! (out)
2135 
2136  !--- verify
2137  if ( error /= success_code ) then
2138  if ( present(allow_missing) ) then
2139  if ( allow_missing ) then
2140  write(message,*) 'xxx [INPUT]/[File] data not found! : ', &
2141  'varname= ',trim(varname),', step=',step
2142  call log('I', message)
2143  call log('I', 'xxx [INPUT]/[File] Value is set to 0.')
2144  var(:,:,:,:) = 0.0_sp
2145  else
2146  call log('E', 'xxx failed to get data information :'//trim(varname))
2147  end if
2148  else
2149  call log('E', 'xxx failed to get data information :'//trim(varname))
2150  end if
2151  end if
2152 
2153  if ( dinfo%rank /= 4 ) then
2154  write(message,*) 'xxx rank is not 4', dinfo%rank
2155  call log('E', message)
2156  end if
2157  dim_size(:) = shape(var)
2158  do n = 1, 4
2159  if ( dinfo%dim_size(n) /= dim_size(n) ) then
2160  write(message,*) 'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
2161  call log('E', message)
2162  end if
2163  end do
2164 
2165  call file_read_data( var(:,:,:,:), & ! (out)
2166  dinfo, sp, & ! (in)
2167  error ) ! (out)
2168  if ( error /= success_code ) then
2169  call log('E', 'xxx failed to get data value')
2170  end if
2171 
2172  return
2173  end subroutine fileread4drealsp
2174  subroutine fileread4drealdp( &
2175  var, & ! (out)
2176  basename, & ! (in)
2177  varname, & ! (in)
2178  step, & ! (in)
2179  myrank, & ! (in)
2180  allow_missing, & ! (in) optional
2181  single & ! (in) optional
2182  )
2183  implicit none
2184 
2185  real(DP), intent(out) :: var(:,:,:,:)
2186  character(LEN=*), intent( in) :: basename
2187  character(LEN=*), intent( in) :: varname
2188  integer, intent( in) :: step
2189  integer, intent( in) :: myrank
2190  logical, intent( in), optional :: allow_missing !--- if data is missing, set value to zero
2191  logical, intent( in), optional :: single
2192 
2193  integer :: fid
2194  type(datainfo) :: dinfo
2195  integer :: dim_size(4)
2196  integer :: error
2197  integer :: n
2198 
2199  logical :: single_ = .false.
2200 
2201  intrinsic shape
2202  !---------------------------------------------------------------------------
2203 
2204  mpi_myrank = myrank
2205 
2206  if ( present(single) ) single_ = single
2207 
2208  !--- search/register file
2209  call fileopen( fid, & ! (out)
2210  basename, file_fread, single_ ) ! (in)
2211 
2212  !--- get data information
2213  call file_get_datainfo( dinfo, & ! (out)
2214  fid, varname, step, .false., & ! (in)
2215  error ) ! (out)
2216 
2217  !--- verify
2218  if ( error /= success_code ) then
2219  if ( present(allow_missing) ) then
2220  if ( allow_missing ) then
2221  write(message,*) 'xxx [INPUT]/[File] data not found! : ', &
2222  'varname= ',trim(varname),', step=',step
2223  call log('I', message)
2224  call log('I', 'xxx [INPUT]/[File] Value is set to 0.')
2225  var(:,:,:,:) = 0.0_dp
2226  else
2227  call log('E', 'xxx failed to get data information :'//trim(varname))
2228  end if
2229  else
2230  call log('E', 'xxx failed to get data information :'//trim(varname))
2231  end if
2232  end if
2233 
2234  if ( dinfo%rank /= 4 ) then
2235  write(message,*) 'xxx rank is not 4', dinfo%rank
2236  call log('E', message)
2237  end if
2238  dim_size(:) = shape(var)
2239  do n = 1, 4
2240  if ( dinfo%dim_size(n) /= dim_size(n) ) then
2241  write(message,*) 'xxx shape is different: ', varname, n, dinfo%dim_size(n), dim_size(n)
2242  call log('E', message)
2243  end if
2244  end do
2245 
2246  call file_read_data( var(:,:,:,:), & ! (out)
2247  dinfo, dp, & ! (in)
2248  error ) ! (out)
2249  if ( error /= success_code ) then
2250  call log('E', 'xxx failed to get data value')
2251  end if
2252 
2253  return
2254  end subroutine fileread4drealdp
2255 
2256  !-----------------------------------------------------------------------------
2257  ! interface FileWrite
2258  !-----------------------------------------------------------------------------
2259  subroutine filewrite1drealsp( &
2260  fid, & ! (in)
2261  vid, & ! (in)
2262  var, & ! (in)
2263  t_start, & ! (in)
2264  t_end & ! (in)
2265  )
2266  implicit none
2267 
2268  real(SP), intent(in) :: var(:)
2269  integer, intent(in) :: fid
2270  integer, intent(in) :: vid
2271  real(DP), intent(in) :: t_start
2272  real(DP), intent(in) :: t_end
2273 
2274  real(DP) :: ts, te
2275 
2276  integer :: error, n
2277  character(len=100) :: str
2278  !---------------------------------------------------------------------------
2279 
2280  ts = t_start
2281  te = t_end
2282  call file_write_data( fid, vid, var(:), ts, te, sp, & ! (in)
2283  error ) ! (out)
2284  if ( error /= success_code ) then
2285  do n = 1, file_vid_count
2286  if ( file_vid_list(n) == vid ) then
2287  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2288  exit
2289  end if
2290  enddo
2291  call log('E', trim(str))
2292  end if
2293 
2294  return
2295  end subroutine filewrite1drealsp
2296  subroutine filewrite1drealdp( &
2297  fid, & ! (in)
2298  vid, & ! (in)
2299  var, & ! (in)
2300  t_start, & ! (in)
2301  t_end & ! (in)
2302  )
2303  implicit none
2304 
2305  real(DP), intent(in) :: var(:)
2306  integer, intent(in) :: fid
2307  integer, intent(in) :: vid
2308  real(DP), intent(in) :: t_start
2309  real(DP), intent(in) :: t_end
2310 
2311  real(DP) :: ts, te
2312 
2313  integer :: error, n
2314  character(len=100) :: str
2315  !---------------------------------------------------------------------------
2316 
2317  ts = t_start
2318  te = t_end
2319  call file_write_data( fid, vid, var(:), ts, te, dp, & ! (in)
2320  error ) ! (out)
2321  if ( error /= success_code ) then
2322  do n = 1, file_vid_count
2323  if ( file_vid_list(n) == vid ) then
2324  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2325  exit
2326  end if
2327  enddo
2328  call log('E', trim(str))
2329  end if
2330 
2331  return
2332  end subroutine filewrite1drealdp
2333  subroutine filewrite2drealsp( &
2334  fid, & ! (in)
2335  vid, & ! (in)
2336  var, & ! (in)
2337  t_start, & ! (in)
2338  t_end & ! (in)
2339  )
2340  implicit none
2341 
2342  real(SP), intent(in) :: var(:,:)
2343  integer, intent(in) :: fid
2344  integer, intent(in) :: vid
2345  real(DP), intent(in) :: t_start
2346  real(DP), intent(in) :: t_end
2347 
2348  real(DP) :: ts, te
2349 
2350  integer :: error, n
2351  character(len=100) :: str
2352  !---------------------------------------------------------------------------
2353 
2354  ts = t_start
2355  te = t_end
2356  call file_write_data( fid, vid, var(:,:), ts, te, sp, & ! (in)
2357  error ) ! (out)
2358  if ( error /= success_code ) then
2359  do n = 1, file_vid_count
2360  if ( file_vid_list(n) == vid ) then
2361  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2362  exit
2363  end if
2364  enddo
2365  call log('E', trim(str))
2366  end if
2367 
2368  return
2369  end subroutine filewrite2drealsp
2370  subroutine filewrite2drealdp( &
2371  fid, & ! (in)
2372  vid, & ! (in)
2373  var, & ! (in)
2374  t_start, & ! (in)
2375  t_end & ! (in)
2376  )
2377  implicit none
2378 
2379  real(DP), intent(in) :: var(:,:)
2380  integer, intent(in) :: fid
2381  integer, intent(in) :: vid
2382  real(DP), intent(in) :: t_start
2383  real(DP), intent(in) :: t_end
2384 
2385  real(DP) :: ts, te
2386 
2387  integer :: error, n
2388  character(len=100) :: str
2389  !---------------------------------------------------------------------------
2390 
2391  ts = t_start
2392  te = t_end
2393  call file_write_data( fid, vid, var(:,:), ts, te, dp, & ! (in)
2394  error ) ! (out)
2395  if ( error /= success_code ) then
2396  do n = 1, file_vid_count
2397  if ( file_vid_list(n) == vid ) then
2398  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2399  exit
2400  end if
2401  enddo
2402  call log('E', trim(str))
2403  end if
2404 
2405  return
2406  end subroutine filewrite2drealdp
2407  subroutine filewrite3drealsp( &
2408  fid, & ! (in)
2409  vid, & ! (in)
2410  var, & ! (in)
2411  t_start, & ! (in)
2412  t_end & ! (in)
2413  )
2414  implicit none
2415 
2416  real(SP), intent(in) :: var(:,:,:)
2417  integer, intent(in) :: fid
2418  integer, intent(in) :: vid
2419  real(DP), intent(in) :: t_start
2420  real(DP), intent(in) :: t_end
2421 
2422  real(DP) :: ts, te
2423 
2424  integer :: error, n
2425  character(len=100) :: str
2426  !---------------------------------------------------------------------------
2427 
2428  ts = t_start
2429  te = t_end
2430  call file_write_data( fid, vid, var(:,:,:), ts, te, sp, & ! (in)
2431  error ) ! (out)
2432  if ( error /= success_code ) then
2433  do n = 1, file_vid_count
2434  if ( file_vid_list(n) == vid ) then
2435  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2436  exit
2437  end if
2438  enddo
2439  call log('E', trim(str))
2440  end if
2441 
2442  return
2443  end subroutine filewrite3drealsp
2444  subroutine filewrite3drealdp( &
2445  fid, & ! (in)
2446  vid, & ! (in)
2447  var, & ! (in)
2448  t_start, & ! (in)
2449  t_end & ! (in)
2450  )
2451  implicit none
2452 
2453  real(DP), intent(in) :: var(:,:,:)
2454  integer, intent(in) :: fid
2455  integer, intent(in) :: vid
2456  real(DP), intent(in) :: t_start
2457  real(DP), intent(in) :: t_end
2458 
2459  real(DP) :: ts, te
2460 
2461  integer :: error, n
2462  character(len=100) :: str
2463  !---------------------------------------------------------------------------
2464 
2465  ts = t_start
2466  te = t_end
2467  call file_write_data( fid, vid, var(:,:,:), ts, te, dp, & ! (in)
2468  error ) ! (out)
2469  if ( error /= success_code ) then
2470  do n = 1, file_vid_count
2471  if ( file_vid_list(n) == vid ) then
2472  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2473  exit
2474  end if
2475  enddo
2476  call log('E', trim(str))
2477  end if
2478 
2479  return
2480  end subroutine filewrite3drealdp
2481  subroutine filewrite4drealsp( &
2482  fid, & ! (in)
2483  vid, & ! (in)
2484  var, & ! (in)
2485  t_start, & ! (in)
2486  t_end & ! (in)
2487  )
2488  implicit none
2489 
2490  real(SP), intent(in) :: var(:,:,:,:)
2491  integer, intent(in) :: fid
2492  integer, intent(in) :: vid
2493  real(DP), intent(in) :: t_start
2494  real(DP), intent(in) :: t_end
2495 
2496  real(DP) :: ts, te
2497 
2498  integer :: error, n
2499  character(len=100) :: str
2500  !---------------------------------------------------------------------------
2501 
2502  ts = t_start
2503  te = t_end
2504  call file_write_data( fid, vid, var(:,:,:,:), ts, te, sp, & ! (in)
2505  error ) ! (out)
2506  if ( error /= success_code ) then
2507  do n = 1, file_vid_count
2508  if ( file_vid_list(n) == vid ) then
2509  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2510  exit
2511  end if
2512  enddo
2513  call log('E', trim(str))
2514  end if
2515 
2516  return
2517  end subroutine filewrite4drealsp
2518  subroutine filewrite4drealdp( &
2519  fid, & ! (in)
2520  vid, & ! (in)
2521  var, & ! (in)
2522  t_start, & ! (in)
2523  t_end & ! (in)
2524  )
2525  implicit none
2526 
2527  real(DP), intent(in) :: var(:,:,:,:)
2528  integer, intent(in) :: fid
2529  integer, intent(in) :: vid
2530  real(DP), intent(in) :: t_start
2531  real(DP), intent(in) :: t_end
2532 
2533  real(DP) :: ts, te
2534 
2535  integer :: error, n
2536  character(len=100) :: str
2537  !---------------------------------------------------------------------------
2538 
2539  ts = t_start
2540  te = t_end
2541  call file_write_data( fid, vid, var(:,:,:,:), ts, te, dp, & ! (in)
2542  error ) ! (out)
2543  if ( error /= success_code ) then
2544  do n = 1, file_vid_count
2545  if ( file_vid_list(n) == vid ) then
2546  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2547  exit
2548  end if
2549  enddo
2550  call log('E', trim(str))
2551  end if
2552 
2553  return
2554  end subroutine filewrite4drealdp
2555 
2556  !-----------------------------------------------------------------------------
2557  ! interface FileWriteVar
2558  !-----------------------------------------------------------------------------
2559  subroutine filewritevar1drealsp( &
2560  vid, & ! (in)
2561  var, & ! (in)
2562  t_start, & ! (in)
2563  t_end & ! (in)
2564  )
2565  implicit none
2566 
2567  real(SP), intent(in) :: var(:)
2568  integer, intent(in) :: vid
2569  real(DP), intent(in) :: t_start
2570  real(DP), intent(in) :: t_end
2571 
2572  real(DP) :: ts, te
2573 
2574  integer :: error, n
2575  character(len=100) :: str
2576  !---------------------------------------------------------------------------
2577 
2578  ts = t_start
2579  te = t_end
2580  call file_write_var( vid, var(:), ts, te, sp, & ! (in)
2581  error ) ! (out)
2582  if ( error /= success_code ) then
2583  do n = 1, file_vid_count
2584  if ( file_vid_list(n) == vid ) then
2585  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2586  exit
2587  end if
2588  enddo
2589  call log('E', trim(str))
2590  end if
2591 
2592  return
2593  end subroutine filewritevar1drealsp
2594  subroutine filewritevar1drealdp( &
2595  vid, & ! (in)
2596  var, & ! (in)
2597  t_start, & ! (in)
2598  t_end & ! (in)
2599  )
2600  implicit none
2601 
2602  real(DP), intent(in) :: var(:)
2603  integer, intent(in) :: vid
2604  real(DP), intent(in) :: t_start
2605  real(DP), intent(in) :: t_end
2606 
2607  real(DP) :: ts, te
2608 
2609  integer :: error, n
2610  character(len=100) :: str
2611  !---------------------------------------------------------------------------
2612 
2613  ts = t_start
2614  te = t_end
2615  call file_write_var( vid, var(:), ts, te, dp, & ! (in)
2616  error ) ! (out)
2617  if ( error /= success_code ) then
2618  do n = 1, file_vid_count
2619  if ( file_vid_list(n) == vid ) then
2620  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2621  exit
2622  end if
2623  enddo
2624  call log('E', trim(str))
2625  end if
2626 
2627  return
2628  end subroutine filewritevar1drealdp
2629  subroutine filewritevar2drealsp( &
2630  vid, & ! (in)
2631  var, & ! (in)
2632  t_start, & ! (in)
2633  t_end & ! (in)
2634  )
2635  implicit none
2636 
2637  real(SP), intent(in) :: var(:,:)
2638  integer, intent(in) :: vid
2639  real(DP), intent(in) :: t_start
2640  real(DP), intent(in) :: t_end
2641 
2642  real(DP) :: ts, te
2643 
2644  integer :: error, n
2645  character(len=100) :: str
2646  !---------------------------------------------------------------------------
2647 
2648  ts = t_start
2649  te = t_end
2650  call file_write_var( vid, var(:,:), ts, te, sp, & ! (in)
2651  error ) ! (out)
2652  if ( error /= success_code ) then
2653  do n = 1, file_vid_count
2654  if ( file_vid_list(n) == vid ) then
2655  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2656  exit
2657  end if
2658  enddo
2659  call log('E', trim(str))
2660  end if
2661 
2662  return
2663  end subroutine filewritevar2drealsp
2664  subroutine filewritevar2drealdp( &
2665  vid, & ! (in)
2666  var, & ! (in)
2667  t_start, & ! (in)
2668  t_end & ! (in)
2669  )
2670  implicit none
2671 
2672  real(DP), intent(in) :: var(:,:)
2673  integer, intent(in) :: vid
2674  real(DP), intent(in) :: t_start
2675  real(DP), intent(in) :: t_end
2676 
2677  real(DP) :: ts, te
2678 
2679  integer :: error, n
2680  character(len=100) :: str
2681  !---------------------------------------------------------------------------
2682 
2683  ts = t_start
2684  te = t_end
2685  call file_write_var( vid, var(:,:), ts, te, dp, & ! (in)
2686  error ) ! (out)
2687  if ( error /= success_code ) then
2688  do n = 1, file_vid_count
2689  if ( file_vid_list(n) == vid ) then
2690  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2691  exit
2692  end if
2693  enddo
2694  call log('E', trim(str))
2695  end if
2696 
2697  return
2698  end subroutine filewritevar2drealdp
2699  subroutine filewritevar3drealsp( &
2700  vid, & ! (in)
2701  var, & ! (in)
2702  t_start, & ! (in)
2703  t_end & ! (in)
2704  )
2705  implicit none
2706 
2707  real(SP), intent(in) :: var(:,:,:)
2708  integer, intent(in) :: vid
2709  real(DP), intent(in) :: t_start
2710  real(DP), intent(in) :: t_end
2711 
2712  real(DP) :: ts, te
2713 
2714  integer :: error, n
2715  character(len=100) :: str
2716  !---------------------------------------------------------------------------
2717 
2718  ts = t_start
2719  te = t_end
2720  call file_write_var( vid, var(:,:,:), ts, te, sp, & ! (in)
2721  error ) ! (out)
2722  if ( error /= success_code ) then
2723  do n = 1, file_vid_count
2724  if ( file_vid_list(n) == vid ) then
2725  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2726  exit
2727  end if
2728  enddo
2729  call log('E', trim(str))
2730  end if
2731 
2732  return
2733  end subroutine filewritevar3drealsp
2734  subroutine filewritevar3drealdp( &
2735  vid, & ! (in)
2736  var, & ! (in)
2737  t_start, & ! (in)
2738  t_end & ! (in)
2739  )
2740  implicit none
2741 
2742  real(DP), intent(in) :: var(:,:,:)
2743  integer, intent(in) :: vid
2744  real(DP), intent(in) :: t_start
2745  real(DP), intent(in) :: t_end
2746 
2747  real(DP) :: ts, te
2748 
2749  integer :: error, n
2750  character(len=100) :: str
2751  !---------------------------------------------------------------------------
2752 
2753  ts = t_start
2754  te = t_end
2755  call file_write_var( vid, var(:,:,:), ts, te, dp, & ! (in)
2756  error ) ! (out)
2757  if ( error /= success_code ) then
2758  do n = 1, file_vid_count
2759  if ( file_vid_list(n) == vid ) then
2760  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2761  exit
2762  end if
2763  enddo
2764  call log('E', trim(str))
2765  end if
2766 
2767  return
2768  end subroutine filewritevar3drealdp
2769  subroutine filewritevar4drealsp( &
2770  vid, & ! (in)
2771  var, & ! (in)
2772  t_start, & ! (in)
2773  t_end & ! (in)
2774  )
2775  implicit none
2776 
2777  real(SP), intent(in) :: var(:,:,:,:)
2778  integer, intent(in) :: vid
2779  real(DP), intent(in) :: t_start
2780  real(DP), intent(in) :: t_end
2781 
2782  real(DP) :: ts, te
2783 
2784  integer :: error, n
2785  character(len=100) :: str
2786  !---------------------------------------------------------------------------
2787 
2788  ts = t_start
2789  te = t_end
2790  call file_write_var( vid, var(:,:,:,:), ts, te, sp, & ! (in)
2791  error ) ! (out)
2792  if ( error /= success_code ) then
2793  do n = 1, file_vid_count
2794  if ( file_vid_list(n) == vid ) then
2795  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2796  exit
2797  end if
2798  enddo
2799  call log('E', trim(str))
2800  end if
2801 
2802  return
2803  end subroutine filewritevar4drealsp
2804  subroutine filewritevar4drealdp( &
2805  vid, & ! (in)
2806  var, & ! (in)
2807  t_start, & ! (in)
2808  t_end & ! (in)
2809  )
2810  implicit none
2811 
2812  real(DP), intent(in) :: var(:,:,:,:)
2813  integer, intent(in) :: vid
2814  real(DP), intent(in) :: t_start
2815  real(DP), intent(in) :: t_end
2816 
2817  real(DP) :: ts, te
2818 
2819  integer :: error, n
2820  character(len=100) :: str
2821  !---------------------------------------------------------------------------
2822 
2823  ts = t_start
2824  te = t_end
2825  call file_write_var( vid, var(:,:,:,:), ts, te, dp, & ! (in)
2826  error ) ! (out)
2827  if ( error /= success_code ) then
2828  do n = 1, file_vid_count
2829  if ( file_vid_list(n) == vid ) then
2830  write(str,*) 'xxx failed to write data: ', trim(file_vname_list(n)), mpi_myrank
2831  exit
2832  end if
2833  enddo
2834  call log('E', trim(str))
2835  end if
2836 
2837  return
2838  end subroutine filewritevar4drealdp
2839 
2840  !-----------------------------------------------------------------------------
2841  subroutine fileenddef( &
2842  fid & ! (in)
2843  )
2844  implicit none
2845 
2846  integer, intent(in) :: fid
2847 
2848  integer :: error, n
2849  !---------------------------------------------------------------------------
2850 
2851  if ( fid < 0 ) return
2852 
2853  do n = 1, file_fid_count-1
2854  if ( file_fid_list(n) == fid ) exit
2855  end do
2856  if ( fid .NE. file_fid_list(n) ) then
2857  write(message,*) 'xxx in FileEndDef invalid fid' , fid
2858  call log('E', message)
2859  end if
2860  call file_enddef( fid , & ! (in)
2861  error ) ! (out)
2862  if ( error .EQ. success_code ) then
2863  write(message, '(1x,A,i3)') '*** [File] File enddef : NO.', n
2864  call log('I', message)
2865  call log('I', '*** enddef filename: ' // trim(file_fname_list(n)))
2866  else
2867  call log('E', 'xxx failed to exit define mode')
2868  end if
2869 
2870  return
2871  end subroutine fileenddef
2872 
2873  !-----------------------------------------------------------------------------
2874  subroutine fileclose( &
2875  fid & ! (in)
2876  )
2877  implicit none
2878 
2879  integer, intent(in) :: fid
2880 
2881  character(LEN=File_HLONG) :: fname
2882  integer :: error
2883  integer :: n
2884  !---------------------------------------------------------------------------
2885 
2886  if ( fid < 0 ) return
2887 
2888  do n = 1, file_fid_count-1
2889  if ( file_fid_list(n) == fid ) exit
2890  end do
2891  if ( n .EQ. file_fid_count ) return ! already closed
2892 
2893  if ( fid /= file_fid_list(n) ) then
2894  write(message,*) 'xxx in FileClose invalid fid ', fid
2895  call log('E', message)
2896  end if
2897  call file_close( fid , & ! (in)
2898  error ) ! (out)
2899  if ( error == success_code ) then
2900  write(message, '(1x,A,i3)') '*** [File] File Close : NO.', n
2901  call log('I', message)
2902  call log('I', '*** closed filename: ' // trim(file_fname_list(n)))
2903  else if ( error /= already_closed_code ) then
2904  call log('E', 'xxx failed to close file')
2905  end if
2906 
2907  do n = 1, file_fid_count-1
2908  if ( file_fid_list(n) == fid ) then
2909  file_fid_list(n) = -1
2910  file_fname_list(n) = ''
2911  end if
2912  end do
2913 
2914  return
2915  end subroutine fileclose
2916  !-----------------------------------------------------------------------------
2917  subroutine filecloseall
2918  implicit none
2919 
2920  integer n
2921  !---------------------------------------------------------------------------
2922 
2923  do n = 1, file_fid_count-1
2924  call fileclose( file_fid_list(n) )
2925  enddo
2926 
2927  return
2928  end subroutine filecloseall
2929 
2930  !-----------------------------------------------------------------------------
2931  ! private
2932  !-----------------------------------------------------------------------------
2933  subroutine filemakefname( &
2934  fname, & ! (out)
2935  basename, & ! (in)
2936  prefix, & ! (in)
2937  myrank, & ! (in)
2938  len ) ! (in)
2939  character(len=*), intent(out) :: fname
2940  character(len=*), intent( in) :: basename
2941  character(len=*), intent( in) :: prefix
2942  integer, intent( in) :: myrank
2943  integer, intent( in) :: len
2944 
2945  ! 12345678901234567
2946  character(len=17) :: fmt = "(A, '.', A, I*.*)"
2947  !---------------------------------------------------------------------------
2948 
2949  if ( len < 1 .or. len > 9 ) then
2950  call log('E', 'xxx len is invalid')
2951  end if
2952 
2953  write(fmt(14:14),'(I1)') len
2954  write(fmt(16:16),'(I1)') len
2955  write(fname, fmt) trim(basename), trim(prefix), myrank
2956 
2957  return
2958  end subroutine filemakefname
2959  !-----------------------------------------------------------------------------
2960  subroutine filegetfid( &
2961  fid, &
2962  existed, &
2963  basename, &
2964  mode, &
2965  single )
2966  implicit none
2967 
2968  integer, intent(out) :: fid
2969  logical, intent(out) :: existed
2970  character(LEN=*), intent( in) :: basename
2971  integer, intent( in) :: mode
2972  logical, intent( in) :: single
2973 
2974 
2975  character(LEN=File_HSHORT) :: rwname(0:2)
2976  data rwname / 'READ','WRITE','APPEND' /
2977 
2978  character(LEN=File_HLONG) :: fname
2979  integer :: n
2980 
2981  integer :: error
2982  !---------------------------------------------------------------------------
2983 
2984  !--- register new file and open
2985  if ( single ) then
2986  fname = trim(basename)//'.peall'
2987  else
2988  call filemakefname(fname,trim(basename),'pe',mpi_myrank,6)
2989  endif
2990 
2991  !--- search existing file
2992  fid = -1
2993  do n = 1, file_fid_count-1
2994  if ( fname==file_fname_list(n) ) fid = file_fid_list(n)
2995  enddo
2996 
2997  if ( fid >= 0 ) then
2998  existed = .true.
2999  return
3000  end if
3001 
3002  call file_open( fid, & ! (out)
3003  fname, mode, & ! (in)
3004  error ) ! (out)
3005  if ( error /= success_code ) then
3006  call log('E', 'xxx failed to open file :'//trim(fname)//'.nc')
3007  end if
3008 
3009  write(message,*) '*** [File] File registration : ',trim(rwname(mode)),' -', fid
3010  call log("I", message)
3011  write(message,*) '*** filename: ', trim(fname)
3012  call log("I", message)
3013 
3014  file_fname_list(file_fid_count) = trim(fname)
3015  file_fid_list(file_fid_count) = fid
3016  file_fid_count = file_fid_count + 1
3017 
3018  existed = .false.
3019 
3020  return
3021  end subroutine filegetfid
3022 
3023 end module gtool_file
3024 !-------------------------------------------------------------------------------
3025 
3026 
3027 !--
3028 ! vi:set readonly sw=4 ts=8
3029 !
3030 !Local Variables:
3031 !mode: f90
3032 !buffer-read-only: t
3033 !End:
3034 !
3035 !++
int32_t file_set_tunits(int32_t fid, char *time_units)
Definition: gtool_netcdf.c:455
subroutine, public filecreate(fid, existed, basename, title, source, institution, master, myrank, rankidx, single, time_units, append)
Definition: gtool_file.f90:181
module GTOOL_FILE
Definition: gtool_file.f90:17
integer, parameter, public file_fwrite
module DC_Log
Definition: dc_log.f90:14
real(dp), parameter, public rmiss
Definition: gtool_file.f90:141
int32_t file_set_tattr(int32_t fid, char *vname, char *key, char *val)
Definition: gtool_netcdf.c:463
int32_t file_set_global_attribute_text(int32_t fid, char *key, char *value)
Definition: gtool_netcdf.c:368
subroutine, public filegetalldatainfo(step_limit, dim_limit, basename, varname, myrank, step_nmax, description, units, datatype, dim_rank, dim_name, dim_size, time_start, time_end, time_units, single)
int32_t file_set_global_attribute_double(int32_t fid, char *key, double *value, size_t len)
Definition: gtool_netcdf.c:433
integer, parameter, public log_lmsg
Definition: dc_log.f90:47
integer, parameter, public file_fappend
subroutine, public filedefinevariable(fid, vid, varname, desc, units, ndims, dims, dtype, tint, tavg)
subroutine, public fileenddef(fid)
integer, parameter, public already_existed_code
subroutine, public filegetshape(dims, basename, varname, myrank, single)
int32_t file_set_global_attribute_float(int32_t fid, char *key, float *value, size_t len)
Definition: gtool_netcdf.c:411
int32_t file_get_global_attribute_int(int32_t fid, char *key, int32_t *value, size_t len)
int32_t file_get_global_attribute_float(int32_t fid, char *key, float *value, size_t len)
Definition: gtool_netcdf.c:332
subroutine, public filecloseall
int32_t file_get_datainfo(datainfo_t *dinfo, int32_t fid, char *varname, int32_t step, int32_t suppress)
Definition: gtool_netcdf.c:162
int32_t file_enddef(int32_t fid)
int32_t file_set_global_attribute_int(int32_t fid, char *key, int32_t *value, size_t len)
int32_t file_get_global_attribute_double(int32_t fid, char *key, double *value, size_t len)
Definition: gtool_netcdf.c:350
int32_t file_open(int32_t *fid, char *fname, int32_t mode)
Definition: gtool_netcdf.c:97
integer, parameter, public success_code
subroutine, public fileclose(fid)
int32_t file_put_axis(int32_t fid, char *name, char *desc, char *units, char *dim_name, int32_t dtype, void *val, int32_t size, int32_t precision)
Definition: gtool_netcdf.c:492
subroutine, public filedefassociatedcoordinates(fid, name, desc, units, dim_names, dtype)
Definition: gtool_file.f90:869
integer, parameter, public dp
Definition: dc_types.f90:27
subroutine, public filesettattr(fid, vname, key, val)
subroutine, public filesetoption(fid, filetype, key, val)
Definition: gtool_file.f90:453
int32_t file_def_axis(int32_t fid, char *name, char *desc, char *units, char *dim_name, int32_t dtype, int32_t dim_size)
Definition: gtool_netcdf.c:546
subroutine, public filemakefname(fname, basename, prefix, myrank, len)
int32_t file_write_data(int32_t fid, int32_t vid, void *var, real64_t t_start, real64_t t_end, int32_t precision)
Definition: gtool_netcdf.c:948
integer, parameter, public already_closed_code
integer, parameter, public file_fread
subroutine, public fileopen(fid, basename, mode, single)
Definition: gtool_file.f90:477
subroutine, public log(type, message)
Definition: dc_log.f90:133
subroutine, public filegetdatainfo(basename, varname, myrank, istep, single, description, units, datatype, dim_rank, dim_name, dim_size, time_start, time_end, time_units)
int32_t file_get_global_attribute_text(int32_t fid, char *key, char *value, int32_t len)
Definition: gtool_netcdf.c:294
integer, parameter, public sp
Definition: dc_types.f90:30
int32_t file_def_associated_coordinates(int32_t fid, char *name, char *desc, char *units, char **dim_names, int32_t ndims, int32_t dtype)
Definition: gtool_netcdf.c:673
int32_t file_write_axis(int32_t fid, char *name, void *val, int32_t precision)
Definition: gtool_netcdf.c:581
int32_t file_put_associated_coordinates(int32_t fid, char *name, char *desc, char *units, char **dim_names, int32_t ndims, int32_t dtype, void *val, int32_t precision)
Definition: gtool_netcdf.c:615
module FILE I/O HEADER
int32_t file_write_var(int32_t vid, void *var, real64_t t_start, real64_t t_end, int32_t precision)
int32_t file_write_associated_coordinates(int32_t fid, char *name, void *val, int32_t precision)
Definition: gtool_netcdf.c:712
int32_t file_read_data(void *var, datainfo_t *dinfo, int32_t precision)
Definition: gtool_netcdf.c:245
int32_t file_add_variable(int32_t *vid, int32_t fid, char *varname, char *desc, char *units, char **dims, int32_t ndims, int32_t dtype, real64_t tint, int32_t tavg)
Definition: gtool_netcdf.c:746
int32_t file_close(int32_t fid)
int32_t file_set_option(int32_t fid, char *filetype, char *key, char *val)
Definition: gtool_netcdf.c:146
subroutine, public filedefaxis(fid, name, desc, units, dim_name, dtype, dim_size)
Definition: gtool_file.f90:564