21 #include <fms_platform.h> 109 use mpp_io_mod,
only: mpp_get_axes, mpp_get_axis_data, mpp_get_att_char, mpp_get_att_name
110 use mpp_io_mod,
only: mpp_get_att_real_scalar, mpp_attribute_exist, mpp_is_dist_ioroot
112 use mpp_io_mod,
only: mpp_netcdf, mpp_ascii, mpp_multi, mpp_single, mpp_overwr, mpp_rdonly
113 use mpp_io_mod,
only: mpp_ieee32, mpp_native, mpp_delete, mpp_append, mpp_sequential, mpp_direct
115 use mpp_io_mod,
only: mpp_get_dimension_length
120 use mpp_domains_mod,
only: mpp_get_ntile_count, mpp_get_current_ntile, mpp_get_tile_id
123 use mpp_mod,
only:
mpp_error, fatal, note, warning, mpp_pe, mpp_root_pe, mpp_npes, stdlog, stdout
127 use mpp_mod,
only: mpp_fill_double,mpp_fill_int
163 integer(INT_KIND),
parameter,
public ::
xidx = 1
164 integer(INT_KIND),
parameter,
public ::
yidx = 2
165 integer(INT_KIND),
parameter,
public ::
cidx = 3
166 integer(INT_KIND),
parameter,
public ::
zidx = 4
167 integer(INT_KIND),
parameter,
public ::
hidx = 5
168 integer(INT_KIND),
parameter,
public ::
tidx = 6
169 integer(INT_KIND),
parameter,
public ::
uidx = 7
170 integer(INT_KIND),
parameter,
public ::
ccidx = 8
173 integer,
parameter,
private ::
nidx=8
179 character(len=256) :: name
180 real,
allocatable :: rval(:)
181 integer,
allocatable :: ival(:)
184 character(len=256) :: cval
189 character(len=128) :: name =
'' 190 character(len=128) :: units =
'' 191 character(len=128) :: longname =
'' 192 character(len=8) :: cartesian =
'' 193 character(len=256) :: compressed =
'' 194 character(len=128) :: dimlen_name =
'' 195 character(len=128) :: dimlen_lname =
'' 196 character(len=128) :: calendar =
'' 201 integer,
allocatable :: idx(:)
202 integer,
allocatable :: nelems(:)
203 real,
pointer :: data(:) =>null()
209 integer(INT_KIND) :: nelems_for_current_rank
216 character(len=128) :: name =
'' 217 character(len=128) :: longname =
'' 218 character(len=128) :: units =
'' 219 real,
dimension(:,:,:,:), _allocatable :: buffer _null
220 logical :: domain_present = .false.
221 integer :: domain_idx = -1
222 logical :: is_dimvar = .false.
223 logical :: read_only = .false.
224 logical :: owns_data = .false.
232 integer :: id_axes(4)
233 logical :: initialized
237 character(len=8) :: compressed_axis
238 integer,
dimension(:),
allocatable :: pelist
239 integer :: ishift, jshift
240 integer :: x_halo, y_halo
245 integer(INT_KIND),
dimension(5) :: field_dimension_order
246 integer(INT_KIND),
dimension(NIDX) :: field_dimension_sizes
252 real,
pointer :: p => null()
256 real,
dimension(:),
pointer :: p => null()
260 real,
dimension(:,:),
pointer :: p => null()
264 real,
dimension(:,:,:),
pointer :: p => null()
268 real(DOUBLE_KIND),
dimension(:,:),
pointer :: p => null()
272 real(DOUBLE_KIND),
dimension(:,:,:),
pointer :: p => null()
276 real,
dimension(:,:,:,:),
pointer :: p => null()
280 integer,
pointer :: p => null()
284 integer,
dimension(:),
pointer :: p => null()
288 integer,
dimension(:,:),
pointer :: p => null()
292 integer,
dimension(:,:,:),
pointer :: p => null()
298 character(len=128) :: name =
'' 299 integer :: register_id = 0
302 integer :: max_ntime = 0
303 logical :: is_root_pe = .false.
304 logical :: is_compressed = .false.
305 logical :: unlimited_axis = .false.
306 integer :: tile_count = 1
309 type(
var_type),
dimension(:),
pointer :: var => null()
310 type(
ptr0dr),
dimension(:,:),
pointer :: p0dr => null()
311 type(
ptr1dr),
dimension(:,:),
pointer :: p1dr => null()
312 type(
ptr2dr),
dimension(:,:),
pointer :: p2dr => null()
313 type(
ptr3dr),
dimension(:,:),
pointer :: p3dr => null()
314 type(
ptr2dr8),
dimension(:,:),
pointer :: p2dr8 => null()
315 type(
ptr3dr8),
dimension(:,:),
pointer :: p3dr8 => null()
316 type(
ptr4dr),
dimension(:,:),
pointer :: p4dr => null()
317 type(
ptr0di),
dimension(:,:),
pointer :: p0di => null()
318 type(
ptr1di),
dimension(:,:),
pointer :: p1di => null()
319 type(
ptr2di),
dimension(:,:),
pointer :: p2di => null()
320 type(
ptr3di),
dimension(:,:),
pointer :: p3di => null()
337 module procedure read_cdata_2d,read_cdata_3d,read_cdata_4d
343 module procedure read_data_2d_region_r8
344 module procedure read_data_3d_region_r8
380 module procedure write_cdata_2d,write_cdata_3d,write_cdata_4d
390 module procedure register_restart_field_r2d8
391 module procedure register_restart_field_r3d8
392 module procedure register_restart_field_r2d8_2level
393 module procedure register_restart_field_r3d8_2level
555 #include<file_version.h> 561 public :: fms_io_unstructured_save_restart
563 public :: fms_io_unstructured_get_field_size
564 public :: fms_io_unstructured_file_unit
565 public :: fms_io_unstructured_field_exist
568 module procedure fms_io_unstructured_register_restart_axis_r1d
569 module procedure fms_io_unstructured_register_restart_axis_i1d
570 module procedure fms_io_unstructured_register_restart_axis_u
574 module procedure fms_io_unstructured_register_restart_field_r_0d
575 module procedure fms_io_unstructured_register_restart_field_r_1d
576 module procedure fms_io_unstructured_register_restart_field_r_2d
577 module procedure fms_io_unstructured_register_restart_field_r_3d
579 module procedure fms_io_unstructured_register_restart_field_r8_2d
580 module procedure fms_io_unstructured_register_restart_field_r8_3d
582 module procedure fms_io_unstructured_register_restart_field_i_0d
583 module procedure fms_io_unstructured_register_restart_field_i_1d
584 module procedure fms_io_unstructured_register_restart_field_i_2d
588 module procedure fms_io_unstructured_read_r_scalar
589 module procedure fms_io_unstructured_read_r_1d
590 module procedure fms_io_unstructured_read_r_2d
591 module procedure fms_io_unstructured_read_r_3d
592 module procedure fms_io_unstructured_read_i_scalar
593 module procedure fms_io_unstructured_read_i_1d
594 module procedure fms_io_unstructured_read_i_2d
624 logical,
intent(inout) :: do_netcdf_restart
639 integer :: i, unit, io_status, logunit
640 integer,
allocatable,
dimension(:) :: pelist
641 real(DOUBLE_KIND) :: doubledata = 0
643 character(len=256) :: grd_file, filename
644 logical :: is_mosaic_grid
645 character(len=4096) :: attvalue
650 #ifdef INTERNAL_FILE_NML 651 read (input_nml_file, fms_io_nml, iostat=io_status)
652 if (io_status > 0)
then 653 call mpp_error(fatal,
'=>fms_io_init: Error reading input.nml')
656 call mpp_open(unit,
'input.nml',
form=mpp_ascii,action=mpp_rdonly)
657 read(unit,fms_io_nml,iostat=io_status)
658 if (io_status > 0)
then 659 call mpp_error(fatal,
'=>fms_io_init: Error reading input.nml')
661 call mpp_close (unit)
667 pack_size =
size(transfer(doubledata, realarray))
684 call mpp_error(fatal,
'fms_io_init: only NetCDF format currently supported in fms_io')
707 grd_file =
"INPUT/grid_spec.nc" 709 is_mosaic_grid = .false.
712 is_mosaic_grid = .true.
714 call read_data(grd_file,
"gridfiles", filename, level=1)
715 grd_file =
'INPUT/'//trim(filename)
716 is_mosaic_grid = .true.
720 if(is_mosaic_grid)
then 722 if(trim(attvalue) ==
"TRUE")
then 724 else if(trim(attvalue) ==
"FALSE")
then 727 call mpp_error(fatal,
"fms_io(fms_io_init: value of global attribute great_circle_algorithm in file"// &
728 trim(grd_file)//
" should be TRUE of FALSE")
734 call mpp_error(note,
"fms_io_mod: great_circle algorithm will be used in the model run")
750 integer :: num_x_axes, num_y_axes, num_z_axes
752 real,
dimension(max_axis_size) :: axisdata
754 integer,
dimension(max_axes) :: id_x_axes, siz_x_axes
755 integer,
dimension(max_axes) :: id_y_axes, siz_y_axes
756 integer,
dimension(max_axes) :: id_z_axes, siz_z_axes
757 type(
axistype),
dimension(max_axes) :: x_axes, y_axes, z_axes
759 type(
var_type),
pointer,
save :: cur_var=>null()
760 integer :: i, j, k, kk
761 character(len=256) :: filename
762 character(len=10) :: axisname
763 logical :: domain_present
764 logical :: write_on_this_pe
765 type(
domain2d),
pointer :: io_domain =>null()
782 domain_present = .false.
785 domain_present = .true.
795 if( domain_present )
then 796 call mpp_open(unit,trim(filename),action=mpp_overwr,
form=
form, &
799 call mpp_open(unit,trim(filename),action=mpp_overwr,
form=
form,threading=mpp_single,&
800 fileset=mpp_single, is_root_pe=
files_write(i)%is_root_pe)
803 write_on_this_pe = .false.
804 if(domain_present)
then 806 if(
associated(io_domain))
then 807 if(mpp_domain_is_tile_root_pe(io_domain)) write_on_this_pe = .true.
811 if(
files_write(i)%is_root_pe ) write_on_this_pe = .true.
815 write(axisname,
'(a,i1)')
'xaxis_',j
817 write(axisname,
'(a,i2)')
'xaxis_',j
819 if(id_x_axes(j) > 0)
then 821 data=axisdata(1:siz_x_axes(j)),domain=
domain_x(id_x_axes(j)),cartesian=
'X')
824 data=axisdata(1:siz_x_axes(j)),cartesian=
'X')
830 write(axisname,
'(a,i1)')
'yaxis_',j
832 write(axisname,
'(a,i2)')
'yaxis_',j
834 if(id_y_axes(j) > 0)
then 836 data=axisdata(1:siz_y_axes(j)),domain=
domain_y(id_y_axes(j)),cartesian=
'Y')
839 data=axisdata(1:siz_y_axes(j)),cartesian=
'Y')
845 write(axisname,
'(a,i1)')
'zaxis_',j
847 write(axisname,
'(a,i2)')
'zaxis_',j
850 data=axisdata(1:siz_z_axes(j)),cartesian=
'Z')
856 'Time',
'time level',
'Time',cartesian=
'T')
861 call mpp_write_meta(unit,cur_var%field, (/x_axes(cur_var%id_axes(1)), &
862 y_axes(cur_var%id_axes(2)), z_axes(cur_var%id_axes(3)), t_axes/), cur_var%name, &
885 if(k > cur_var%siz(4))
then 886 cur_var%buffer(:,:,:,1) = 0.0
891 if(cur_var%domain_present)
then 892 call mpp_write(unit, cur_var%field,
array_domain(cur_var%domain_idx), cur_var%buffer(:,:,:,kk), tlev, &
893 default_data=cur_var%default_data)
894 else if (write_on_this_pe)
then 895 call mpp_write(unit, cur_var%field, cur_var%buffer(:,:,:,kk), tlev)
943 no_domain, position, tile_count, data_default)
945 character(len=*),
intent(in) :: filename, fieldname
946 integer,
dimension(:,:,:),
intent(in) :: data
947 type(domain2d),
intent(in),
optional :: domain
948 logical,
intent(in),
optional :: no_domain
949 integer,
intent(in),
optional :: position, tile_count, data_default
952 default_data = transfer(mpp_fill_int,default_data)
953 if(
present(data_default)) default_data =
real(data_default)
956 no_domain, .false., position, tile_count, data_default=default_data)
960 no_domain, position, tile_count, data_default)
962 character(len=*),
intent(in) :: filename, fieldname
963 integer,
dimension(:,:),
intent(in) :: data
964 type(domain2d),
intent(in),
optional :: domain
965 logical,
intent(in),
optional :: no_domain
966 integer,
intent(in),
optional :: position, tile_count, data_default
969 default_data = transfer(mpp_fill_int,default_data)
970 if(
present(data_default)) default_data =
real(data_default)
972 no_domain, position, tile_count, data_default=default_data)
977 no_domain, tile_count, data_default)
978 type(domain2d),
intent(in),
optional :: domain
979 character(len=*),
intent(in) :: filename, fieldname
980 integer,
dimension(:),
intent(in) :: data
981 logical,
intent(in),
optional :: no_domain
982 integer,
intent(in),
optional :: tile_count, data_default
985 default_data = transfer(mpp_fill_int,default_data)
986 if(
present(data_default)) default_data =
real(data_default)
988 no_domain, tile_count, data_default=default_data)
992 no_domain, tile_count, data_default)
993 type(domain2d),
intent(in),
optional :: domain
994 character(len=*),
intent(in) :: filename, fieldname
995 integer,
intent(in) :: data
996 logical,
intent(in),
optional :: no_domain
997 integer,
intent(in),
optional :: tile_count, data_default
1000 default_data = transfer(mpp_fill_int,default_data)
1001 if(
present(data_default)) default_data =
real(data_default)
1003 no_domain, tile_count, data_default=default_data)
1007 subroutine write_data_3d_new(filename, fieldname, data, domain, no_domain, scalar_or_1d, &
1008 position, tile_count, data_default)
1010 character(len=*),
intent(in) :: filename, fieldname
1011 real,
dimension(:,:,:),
intent(in) :: data
1012 type(domain2d),
optional,
intent(in),
target :: domain
1013 real,
optional,
intent(in) :: data_default
1014 logical,
optional,
intent(in) :: no_domain
1015 logical,
optional,
intent(in) :: scalar_or_1d
1016 integer,
optional,
intent(in) :: position, tile_count
1019 real,
allocatable :: tmp_buffer(:,:,:,:)
1020 integer :: index_field
1021 integer :: index_file
1022 logical :: append_pelist, is_no_domain, is_scalar_or_1d
1023 character(len=256) :: fname, filename2,append_string
1024 real :: default_data
1025 integer :: length, i, domain_idx
1026 integer :: ishift, jshift
1027 integer :: gxsize, gysize
1028 integer :: cxsize, cysize
1029 integer :: dxsize, dysize
1030 type(domain2d),
pointer,
save :: d_ptr =>null()
1031 type(var_type),
pointer,
save :: cur_var =>null()
1032 type(restart_file_type),
pointer,
save :: cur_file =>null()
1038 if(
PRESENT(data_default))
then 1039 default_data=data_default
1041 default_data=mpp_fill_double
1044 if(
present(tile_count) .AND. .not.
present(domain))
call mpp_error(fatal, &
1045 'fms_io write_data: when tile_count is present, domain must be present')
1047 is_scalar_or_1d = .false.
1048 if(
PRESENT(scalar_or_1d)) is_scalar_or_1d = scalar_or_1d
1050 is_no_domain = .false.
1051 if (
PRESENT(no_domain))
THEN 1052 is_no_domain = no_domain
1055 if(is_no_domain)
then 1056 if(
PRESENT(domain)) &
1057 call mpp_error(fatal,
'fms_io(write_data_3d_new): no_domain cannot be .true. when optional argument domain is present.')
1058 else if(
PRESENT(domain))
then 1065 length = len_trim(filename)
1066 if(filename(length-2:length) ==
'.nc')
then 1067 filename2 = filename(1:length-3)
1069 filename2 = filename(1:length)
1073 append_pelist = .false.
1079 append_pelist = .true.
1083 if(append_pelist) filename2 = trim(filename2)//
'.'//trim(append_string)
1093 if (trim(
files_write(i)%name) == trim(fname))
then 1100 if (index_file < 0)
then 1102 call mpp_error(fatal,
'fms_io(write_data_3d_new): max_files_w exceeded, increase it via fms_io_nml')
1107 cur_file%name = trim(fname)
1108 cur_file%tile_count=1
1109 if(
present(tile_count)) cur_file%tile_count = tile_count
1110 if(
ASSOCIATED(d_ptr))
then 1111 cur_file%is_root_pe = mpp_domain_is_tile_root_pe(d_ptr)
1113 cur_file%is_root_pe = mpp_pe() == mpp_root_pe()
1115 cur_file%max_ntime = 1
1120 cur_file%var(i)%name =
'none' 1121 cur_file%var(i)%domain_present = .false.
1122 cur_file%var(i)%read_only = .false.
1123 cur_file%var(i)%domain_idx = -1
1124 cur_file%var(i)%is_dimvar = .false.
1125 cur_file%var(i)%position = center
1126 cur_file%var(i)%siz(:) = 0
1127 cur_file%var(i)%gsiz(:) = 0
1128 cur_file%var(i)%id_axes(:) = -1
1134 do i = 1, cur_file%nvar
1135 if(trim(cur_file%var(i)%name) == trim(fieldname))
then 1141 if(index_field > 0)
then 1142 cur_var => cur_file%var(index_field)
1143 cur_var%siz(4) = cur_var%siz(4) + 1
1144 if(cur_file%max_ntime < cur_var%siz(4) ) cur_file%max_ntime = cur_var%siz(4)
1147 'the time level of field '//trim(cur_var%name)//
' in file '//trim(cur_file%name)// &
1148 ' is greater than MAX_TIME_LEVEL_WRITE(=20), increase MAX_TIME_LEVEL_WRITE or check your code')
1150 cur_file%nvar = cur_file%nvar +1
1153 call mpp_error(fatal,
'fms_io(write_data_3d_new): max_fields exceeded, needs increasing, nvar/max_fields=' &
1156 index_field = cur_file%nvar
1157 cur_var => cur_file%var(index_field)
1158 cur_var%siz(1) =
size(
data,1)
1159 cur_var%siz(2) =
size(
data,2)
1160 cur_var%siz(3) =
size(
data,3)
1162 cur_var%gsiz(3) = cur_var%siz(3)
1163 cur_var%name = fieldname
1164 cur_var%default_data = default_data
1166 if(
present(position)) cur_var%position = position
1168 if(
ASSOCIATED(d_ptr) .AND. .NOT. is_scalar_or_1d)
then 1169 cur_var%domain_present = .true.
1171 if(domain_idx == -1)
then 1174 //
' needs increasing')
1178 tile_count=tile_count)
1180 cur_var%domain_idx = domain_idx
1181 call mpp_get_domain_shift (
array_domain(domain_idx), ishift, jshift, position)
1185 if (ishift .NE. 0)
then 1186 cxsize = cxsize+ishift; dxsize = dxsize+ishift; gxsize = gxsize + ishift
1188 if (jshift .NE. 0)
then 1189 cysize = cysize+jshift; dysize = dysize+jshift; gysize = gysize + jshift
1191 if( (cur_var%siz(1) .NE. cxsize .AND. cur_var%siz(1) .NE. dxsize ) .OR. &
1192 (cur_var%siz(2) .NE. cysize .AND. cur_var%siz(2) .NE. dysize ) )
then 1193 call mpp_error(fatal,
'fms_io(write_data_3d_new): data should be on either compute domain '//&
1194 'or data domain when domain is present for field '//trim(fieldname)//
' of file '//trim(filename) )
1196 cur_var%gsiz(1) = gxsize
1197 cur_var%gsiz(2) = gysize
1199 cur_var%domain_present=.false.
1200 cur_var%gsiz(1) =
size(
data,1)
1201 cur_var%gsiz(2) =
size(
data,2)
1209 if(cur_var%siz(4) == 1)
then 1210 allocate(cur_var%buffer(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3), cur_var%siz(4)) )
1212 allocate(tmp_buffer(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3),
size(cur_var%buffer,4)) )
1213 tmp_buffer = cur_var%buffer
1214 deallocate(cur_var%buffer)
1215 allocate(cur_var%buffer(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3), cur_var%siz(4)) )
1216 cur_var%buffer(:,:,:,1:
size(tmp_buffer,4)) = tmp_buffer
1217 deallocate(tmp_buffer)
1220 cur_var%buffer(:,:,:,cur_var%siz(4)) =
data 1235 type(restart_file_type),
intent(inout) :: fileObj
1236 character(len=*),
intent(in) :: filename, fieldname
1237 real,
intent(in),
target :: data(:)
1238 character(len=*),
intent(in) :: cartesian
1239 character(len=*),
optional,
intent(in) :: units, longname
1240 integer,
optional,
intent(in) :: sense
1241 real,
optional,
intent(in) :: min
1242 character(len=*),
optional,
intent(in) :: calendar
1249 select case(trim(cartesian))
1261 call mpp_error(fatal,
'fms_io(register_restart_axis_r1d): Axis must be one of X,Y,Z,T or CC ' // &
1262 'but has value '//trim(cartesian))
1264 if(.not.
ALLOCATED(fileobj%axes))
allocate(fileobj%axes(
nidx))
1265 if(
ASSOCIATED(fileobj%axes(idx)%data)) &
1266 call mpp_error(fatal,
'fms_io(register_restart_axis_r1d): '//trim(cartesian)//
' axis has already been defined')
1271 fileobj%axes(idx)%name = fieldname
1272 fileobj%axes(idx)%data =>
data 1273 fileobj%axes(idx)%cartesian = cartesian
1274 fileobj%axes(idx)%dimlen = -1
1275 if(
PRESENT(units)) fileobj%axes(idx)%units = units
1276 if(
PRESENT(longname)) fileobj%axes(idx)%longname = longname
1277 if(
PRESENT(min)) fileobj%axes(idx)%min = min
1278 if(idx ==
tidx)
then 1279 if(
PRESENT(calendar)) fileobj%axes(idx)%calendar = trim(calendar)
1281 if(
PRESENT(sense))
then 1282 if(idx /=
zidx)
call mpp_error(fatal,
'fms_io(register_restart_axis_r1d): Only the Z axis may define sense; ' // &
1283 'Axis = '//trim(cartesian))
1284 if(abs(sense) /= 1)
call mpp_error(fatal,
'fms_io(register_restart_axis_r1d): Value of sense must be +/- 1')
1285 fileobj%axes(idx)%sense = sense
1295 compressed_axis,dimlen,dimlen_name,dimlen_lname,units,longname,imin)
1296 type(restart_file_type),
intent(inout) :: fileObj
1297 character(len=*),
intent(in) :: filename, fieldname
1298 integer,
intent(in) :: data(:)
1299 character(len=*),
intent(in) :: compressed
1300 character(len=*),
intent(in) :: compressed_axis
1301 integer,
intent(in) :: dimlen
1302 character(len=*),
optional,
intent(in) :: dimlen_name, dimlen_lname
1303 character(len=*),
optional,
intent(in) :: units, longname
1304 integer,
optional,
intent(in) :: imin
1306 integer :: ssize,rsize,npes
1308 integer,
allocatable :: pelist(:)
1309 type(domain2d),
pointer :: io_domain=>null()
1314 select case(trim(compressed_axis))
1320 call mpp_error(fatal,
'fms_io(register_restart_axis_r1d): Axis must be one of C or H ' // &
1321 'but has value '//trim(compressed_axis))
1324 if(.not.
ALLOCATED(fileobj%axes))
allocate(fileobj%axes(
nidx))
1325 if(
ALLOCATED(fileobj%axes(idx)%idx)) &
1326 call mpp_error(fatal,
'fms_io(register_restart_axis_i1d): Compressed axis ' //&
1327 trim(compressed_axis) //
' has already been defined')
1332 fileobj%is_compressed = .true.
1333 fileobj%unlimited_axis = .false.
1334 fileobj%axes(idx)%name = fieldname
1338 if(.not.
ASSOCIATED(io_domain)) &
1339 call mpp_error(fatal,
'fms_io(register_restart_axis_i1d): The io domain must be defined')
1340 npes = mpp_get_domain_npes(io_domain)
1341 allocate(fileobj%axes(idx)%nelems(npes)); fileobj%axes(idx)%nelems = 0
1342 allocate(pelist(npes))
1345 call mpp_gather((/ssize/),fileobj%axes(idx)%nelems,pelist)
1346 rsize = sum(fileobj%axes(idx)%nelems)
1347 allocate( fileobj%axes(idx)%idx(rsize) )
1349 call mpp_gather(
data,ssize,fileobj%axes(idx)%idx,fileobj%axes(idx)%nelems,pelist)
1350 deallocate(pelist); io_domain=>null()
1352 call mpp_error(fatal,
'fms_io(register_restart_axis_i1d): The domain must be defined through set_domain')
1354 fileobj%axes(idx)%compressed = compressed
1355 fileobj%axes(idx)%dimlen = dimlen
1356 if(
PRESENT(dimlen_name)) fileobj%axes(idx)%dimlen_name = dimlen_name
1357 if(
PRESENT(dimlen_lname)) fileobj%axes(idx)%dimlen_lname = dimlen_lname
1358 if(
PRESENT(units)) fileobj%axes(idx)%units = units
1359 if(
PRESENT(longname)) fileobj%axes(idx)%longname = longname
1360 if(
PRESENT(imin)) fileobj%axes(idx)%imin = imin
1366 type(restart_file_type),
intent(inout) :: fileObj
1367 character(len=*),
intent(in) :: filename, fieldname
1369 character(len=*),
optional,
intent(in) :: units, longname
1372 integer,
allocatable :: pelist(:)
1373 type(domain2d),
pointer :: io_domain=>null()
1377 call mpp_error(fatal,
'fms_io(register_restart_axis_unlimited): need to call fms_io_init')
1380 if(.not.
ALLOCATED(fileobj%axes))
allocate(fileobj%axes(
nidx))
1381 if(
ALLOCATED(fileobj%axes(idx)%idx)) &
1382 call mpp_error(fatal,
'fms_io(register_restart_axis_unlimited): Unlimited axis has already been defined')
1387 fileobj%is_compressed = .false.
1388 fileobj%unlimited_axis = .true.
1389 fileobj%axes(idx)%name = fieldname
1393 if(.not.
ASSOCIATED(io_domain)) &
1394 call mpp_error(fatal,
'fms_io(register_restart_axis_i1d): The io domain must be defined')
1395 npes = mpp_get_domain_npes(io_domain)
1396 allocate(fileobj%axes(idx)%nelems(npes)); fileobj%axes(idx)%nelems = 0
1397 allocate(pelist(npes))
1399 call mpp_gather((/nelem/),fileobj%axes(idx)%nelems,pelist)
1400 deallocate(pelist); io_domain=>null()
1402 call mpp_error(fatal,
'fms_io(register_restart_axis_unlimited): The domain must be defined through set_domain')
1404 if(
PRESENT(units)) fileobj%axes(idx)%units = units
1405 if(
PRESENT(longname)) fileobj%axes(idx)%longname = longname
1416 integer :: id, n, j, k
1427 call mpp_error(fatal,
'fms_io(free_restart_type): fileObj%name is not found in registered_files')
1434 fileobj%register_id = 0
1439 fileobj%max_ntime = -1
1440 fileobj%tile_count = -1
1441 if(
ALLOCATED(fileobj%axes))
deallocate(fileobj%axes)
1443 do k = 1,
size(fileobj%var)
1444 if (fileobj%var(k)%owns_data)
then 1445 do j = 1,
size(fileobj%p0dr,1)
1446 if(
ASSOCIATED(fileobj%p0dr(j,k)%p))
deallocate(fileobj%p0dr(j,k)%p)
1447 if(
ASSOCIATED(fileobj%p1dr(j,k)%p))
deallocate(fileobj%p1dr(j,k)%p)
1448 if(
ASSOCIATED(fileobj%p2dr(j,k)%p))
deallocate(fileobj%p2dr(j,k)%p)
1449 if(
ASSOCIATED(fileobj%p3dr(j,k)%p))
deallocate(fileobj%p3dr(j,k)%p)
1450 if(
ASSOCIATED(fileobj%p2dr8(j,k)%p))
deallocate(fileobj%p2dr8(j,k)%p)
1451 if(
ASSOCIATED(fileobj%p3dr8(j,k)%p))
deallocate(fileobj%p3dr8(j,k)%p)
1452 if(
ASSOCIATED(fileobj%p0di(j,k)%p))
deallocate(fileobj%p0di(j,k)%p)
1453 if(
ASSOCIATED(fileobj%p1di(j,k)%p))
deallocate(fileobj%p1di(j,k)%p)
1454 if(
ASSOCIATED(fileobj%p2di(j,k)%p))
deallocate(fileobj%p2di(j,k)%p)
1455 if(
ASSOCIATED(fileobj%p3di(j,k)%p))
deallocate(fileobj%p3di(j,k)%p)
1459 if(
ASSOCIATED(fileobj%var))
deallocate(fileobj%var)
1460 if(
ASSOCIATED(fileobj%p0dr))
deallocate(fileobj%p0dr)
1461 if(
ASSOCIATED(fileobj%p1dr))
deallocate(fileobj%p1dr)
1462 if(
ASSOCIATED(fileobj%p2dr))
deallocate(fileobj%p2dr)
1463 if(
ASSOCIATED(fileobj%p3dr))
deallocate(fileobj%p3dr)
1464 if(
ASSOCIATED(fileobj%p2dr8))
deallocate(fileobj%p2dr8)
1465 if(
ASSOCIATED(fileobj%p3dr8))
deallocate(fileobj%p3dr8)
1466 if(
ASSOCIATED(fileobj%p0di))
deallocate(fileobj%p0di)
1467 if(
ASSOCIATED(fileobj%p1di))
deallocate(fileobj%p1di)
1468 if(
ASSOCIATED(fileobj%p2di))
deallocate(fileobj%p2di)
1469 if(
ASSOCIATED(fileobj%p3di))
deallocate(fileobj%p3di)
1470 if(
ASSOCIATED(fileobj%first))
then 1471 this =>fileobj%first
1472 do while(
associated(this%next))
1475 do while(
associated(this))
1480 if(
allocated(this%rval))
deallocate(this%rval)
1481 if(
allocated(this%ival))
deallocate(this%ival)
1488 fileobj%first =>null()
1499 character(len=*),
intent(in) :: name
1500 real,
intent(in),
optional :: rval(:)
1501 integer,
intent(in),
optional :: ival(:)
1502 character(len=*),
intent(in),
optional :: cval
1506 this =>fileobj%first
1507 if(
associated(this))
then 1508 do while(
associated(this%next))
1511 allocate(this_n); this%next =>this_n; this_n%prev =>this; this =>this_n
1514 fileobj%first =>this
1521 if(
present(rval))
then 1522 allocate(this%rval(
size(rval))); this%rval=rval
1523 elseif(
present(ival))
then 1524 allocate(this%ival(
size(ival))); this%ival=ival
1525 elseif(
present(cval))
then 1539 integer,
intent(in) :: unit
1540 type(restart_file_type),
intent(in) :: fileObj
1541 type(meta_type),
pointer :: this
1543 this =>fileobj%first
1544 do while(
associated(this))
1545 if(
allocated(this%rval))
then 1547 elseif(
allocated(this%ival))
then 1551 elseif(len_trim(this%cval).GT.0)
then 1566 no_domain, position, tile_count, data_default, &
1567 longname, units, read_only, restart_owns_data)
1569 character(len=*),
intent(in) :: filename, fieldname
1570 real,
intent(in),
target :: data
1571 type(
domain2d),
optional,
intent(in),
target :: domain
1572 logical,
optional,
intent(in) :: no_domain
1573 real,
optional,
intent(in) :: data_default
1574 logical,
optional,
intent(in) :: mandatory
1575 integer,
optional,
intent(in) :: position, tile_count
1576 character(len=*),
optional,
intent(in) :: longname, units
1577 logical,
optional,
intent(in) :: read_only
1578 logical,
optional,
intent(in) :: restart_owns_data
1579 integer :: index_field
1583 call setup_one_field(fileobj, filename, fieldname, (/1, 1, 1, 1/), index_field, domain, mandatory, &
1584 no_domain, scalar_or_1d=.true., position=position, tile_count=tile_count, &
1585 data_default=data_default, longname=longname, units=units, read_only=read_only,&
1586 owns_data=restart_owns_data)
1587 fileobj%p0dr(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1588 fileobj%var(index_field)%ndim = 0
1599 no_domain, position, tile_count, data_default, longname, units, &
1600 compressed_axis, read_only, restart_owns_data)
1602 character(len=*),
intent(in) :: filename, fieldname
1603 real,
dimension(:),
intent(in),
target :: data
1604 type(
domain2d),
optional,
intent(in),
target :: domain
1605 logical,
optional,
intent(in) :: no_domain
1606 real,
optional,
intent(in) :: data_default
1607 integer,
optional,
intent(in) :: position, tile_count
1608 logical,
optional,
intent(in) :: mandatory
1609 character(len=*),
optional,
intent(in) :: longname, units, compressed_axis
1610 logical,
optional,
intent(in) :: read_only
1611 logical,
optional,
intent(in) :: restart_owns_data
1612 integer :: index_field
1616 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1), 1, 1, 1/), index_field, domain, mandatory, &
1617 no_domain, scalar_or_1d=.true., position=position, tile_count=tile_count, &
1618 data_default=data_default, longname=longname, units=units, compressed_axis=compressed_axis, &
1619 read_only=read_only, owns_data=restart_owns_data)
1621 fileobj%p1dr(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1622 fileobj%var(index_field)%ndim = 1
1633 compressed, position, tile_count, data_default, longname, units, &
1634 compressed_axis, read_only, restart_owns_data)
1636 character(len=*),
intent(in) :: filename, fieldname
1637 real,
dimension(:,:),
intent(in),
target :: data
1638 type(
domain2d),
optional,
intent(in),
target :: domain
1639 real,
optional,
intent(in) :: data_default
1640 logical,
optional,
intent(in) :: no_domain
1641 logical,
optional,
intent(in) :: compressed
1642 integer,
optional,
intent(in) :: position, tile_count
1643 logical,
optional,
intent(in) :: mandatory
1644 character(len=*),
optional,
intent(in) :: longname, units, compressed_axis
1645 logical,
optional,
intent(in) :: read_only
1646 logical,
optional,
intent(in) :: restart_owns_data
1647 logical :: is_compressed
1648 integer :: index_field
1652 is_compressed = .false.
1653 if(
present(compressed)) is_compressed=compressed
1654 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2), 1, 1/), &
1655 index_field, domain, mandatory, no_domain, is_compressed, &
1656 position, tile_count, data_default, longname, units, compressed_axis, &
1657 read_only=read_only, owns_data=restart_owns_data)
1658 fileobj%p2dr(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1659 fileobj%var(index_field)%ndim = 2
1671 no_domain, position, tile_count, data_default, longname, units, read_only, &
1672 compressed, compressed_axis, restart_owns_data)
1674 character(len=*),
intent(in) :: filename, fieldname
1675 real,
dimension(:,:,:),
intent(in),
target :: data
1676 type(
domain2d),
optional,
intent(in),
target :: domain
1677 real,
optional,
intent(in) :: data_default
1678 logical,
optional,
intent(in) :: no_domain
1679 integer,
optional,
intent(in) :: position, tile_count
1680 logical,
optional,
intent(in) :: mandatory
1681 character(len=*),
optional,
intent(in) :: longname, units, compressed_axis
1682 logical,
optional,
intent(in) :: read_only
1683 logical,
optional,
intent(in) :: compressed
1684 logical,
optional,
intent(in) :: restart_owns_data
1685 logical :: is_compressed
1686 integer :: index_field
1690 if(
present(compressed))
then 1691 is_compressed=compressed
1693 is_compressed = .false.
1695 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2),
size(
data,3), 1/), &
1696 index_field, domain, mandatory, no_domain, is_compressed, &
1697 position, tile_count, data_default, longname, units, compressed_axis, &
1698 read_only=read_only, owns_data=restart_owns_data)
1699 fileobj%p3dr(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1700 fileobj%var(index_field)%ndim = 3
1712 function register_restart_field_r2d8(fileObj, filename, fieldname, data, domain, mandatory, no_domain, &
1713 compressed, position, tile_count, data_default, longname, units, &
1714 compressed_axis, read_only, restart_owns_data)
1716 character(len=*),
intent(in) :: filename, fieldname
1717 real(DOUBLE_KIND),
dimension(:,:),
intent(in),
target :: data
1718 type(
domain2d),
optional,
intent(in),
target :: domain
1719 real(DOUBLE_KIND),
optional,
intent(in) :: data_default
1720 logical,
optional,
intent(in) :: no_domain
1721 logical,
optional,
intent(in) :: compressed
1722 integer,
optional,
intent(in) :: position, tile_count
1723 logical,
optional,
intent(in) :: mandatory
1724 character(len=*),
optional,
intent(in) :: longname, units, compressed_axis
1725 logical,
optional,
intent(in) :: read_only
1726 logical,
optional,
intent(in) :: restart_owns_data
1727 logical :: is_compressed
1728 integer :: index_field
1729 integer :: register_restart_field_r2d8
1730 real(FLOAT_KIND) :: data_default_r4
1733 is_compressed = .false.
1734 if(
present(compressed)) is_compressed=compressed
1735 if(
present(data_default)) data_default_r4=data_default
1736 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2), 1, 1/), &
1737 index_field, domain, mandatory, no_domain, is_compressed, &
1738 position, tile_count, data_default_r4, longname, units, compressed_axis, &
1739 read_only=read_only, owns_data=restart_owns_data)
1740 fileobj%p2dr8(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1741 fileobj%var(index_field)%ndim = 2
1742 register_restart_field_r2d8 = index_field
1744 end function register_restart_field_r2d8
1752 function register_restart_field_r3d8(fileObj, filename, fieldname, data, domain, mandatory, &
1753 no_domain, position, tile_count, data_default, longname, units, read_only, &
1754 compressed, compressed_axis, restart_owns_data)
1756 character(len=*),
intent(in) :: filename, fieldname
1757 real(DOUBLE_KIND),
dimension(:,:,:),
intent(in),
target :: data
1758 type(
domain2d),
optional,
intent(in),
target :: domain
1759 real(DOUBLE_KIND),
optional,
intent(in) :: data_default
1760 logical,
optional,
intent(in) :: no_domain
1761 integer,
optional,
intent(in) :: position, tile_count
1762 logical,
optional,
intent(in) :: mandatory
1763 character(len=*),
optional,
intent(in) :: longname, units, compressed_axis
1764 logical,
optional,
intent(in) :: read_only
1765 logical,
optional,
intent(in) :: compressed
1766 logical,
optional,
intent(in) :: restart_owns_data
1767 logical :: is_compressed
1768 integer :: index_field
1769 integer :: register_restart_field_r3d8
1770 real(FLOAT_KIND) :: data_default_r4
1773 is_compressed = .false.
1774 if(
present(compressed)) is_compressed=compressed
1775 if(
present(data_default)) data_default_r4=data_default
1776 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2),
size(
data,3), 1/), &
1777 index_field, domain, mandatory, no_domain, is_compressed, &
1778 position, tile_count, data_default_r4, longname, units, compressed_axis, &
1779 read_only=read_only, owns_data=restart_owns_data)
1780 fileobj%p3dr8(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1781 fileobj%var(index_field)%ndim = 3
1782 register_restart_field_r3d8 = index_field
1784 end function register_restart_field_r3d8
1792 no_domain, position, tile_count, data_default, longname, units, &
1793 read_only, restart_owns_data)
1795 character(len=*),
intent(in) :: filename, fieldname
1796 real,
dimension(:,:,:,:),
intent(in),
target :: data
1797 type(
domain2d),
optional,
intent(in),
target :: domain
1798 real,
optional,
intent(in) :: data_default
1799 logical,
optional,
intent(in) :: no_domain
1800 integer,
optional,
intent(in) :: position, tile_count
1801 logical,
optional,
intent(in) :: mandatory
1802 character(len=*),
optional,
intent(in) :: longname, units
1803 logical,
optional,
intent(in) :: read_only
1804 logical,
optional,
intent(in) :: restart_owns_data
1805 integer :: index_field
1809 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2),
size(
data,3), 1,
size(
data,4)/), &
1810 index_field, domain, mandatory, no_domain, .false., &
1811 position, tile_count, data_default, longname, units, &
1812 read_only=read_only, owns_data=restart_owns_data)
1813 fileobj%p4dr(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1814 fileobj%var(index_field)%ndim = 4
1826 no_domain, position, tile_count, data_default, longname, units, &
1827 read_only, restart_owns_data)
1829 character(len=*),
intent(in) :: filename, fieldname
1830 integer,
intent(in),
target :: data
1831 type(
domain2d),
optional,
intent(in),
target :: domain
1832 integer,
optional,
intent(in) :: data_default
1833 integer,
optional,
intent(in) :: position, tile_count
1834 logical,
optional,
intent(in) :: mandatory
1835 logical,
optional,
intent(in) :: no_domain
1836 character(len=*),
optional,
intent(in) :: longname, units
1837 logical,
optional,
intent(in) :: read_only
1838 logical,
optional,
intent(in) :: restart_owns_data
1839 integer :: index_field
1841 real :: data_default_r
1845 if (kind(data_default)/=kind(data))
call mpp_error(fatal,
'fms_io(register_restart_field_i0d): data_default and data different KIND()')
1846 data_default_r = transfer(mpp_fill_int,data_default_r)
1847 if (
present(data_default)) data_default_r = transfer(data_default ,data_default_r)
1849 call setup_one_field(fileobj, filename, fieldname, (/1, 1, 1, 1/), index_field, domain, &
1850 mandatory, no_domain=no_domain, scalar_or_1d=.true., position=position, tile_count=tile_count, &
1851 data_default=data_default_r, longname=longname, units=units, &
1852 read_only=read_only, owns_data=restart_owns_data)
1854 fileobj%p0di(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1855 fileobj%var(index_field)%ndim = 0
1866 no_domain, position, tile_count, data_default, longname, units, &
1867 compressed_axis, read_only, restart_owns_data)
1869 character(len=*),
intent(in) :: filename, fieldname
1870 integer,
dimension(:),
intent(in),
target :: data
1871 type(
domain2d),
optional,
intent(in),
target :: domain
1872 integer,
optional,
intent(in) :: data_default
1873 integer,
optional,
intent(in) :: position, tile_count
1874 logical,
optional,
intent(in) :: mandatory
1875 logical,
optional,
intent(in) :: no_domain
1876 character(len=*),
optional,
intent(in) :: longname, units, compressed_axis
1877 logical,
optional,
intent(in) :: read_only
1878 logical,
optional,
intent(in) :: restart_owns_data
1879 integer :: index_field
1881 real :: data_default_r
1885 if (kind(data_default)/=kind(data))
call mpp_error(fatal,
'fms_io(register_restart_field_i1d): data_default and data different KIND()')
1886 data_default_r = transfer(mpp_fill_int,data_default_r)
1887 if (
present(data_default)) data_default_r = transfer(data_default ,data_default_r)
1889 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1), 1, 1, 1/), index_field, domain, &
1890 mandatory, no_domain=no_domain, scalar_or_1d=.true., position=position, tile_count=tile_count, &
1891 data_default=data_default_r, longname=longname, units=units, compressed_axis=compressed_axis, &
1892 read_only=read_only, owns_data=restart_owns_data)
1893 fileobj%p1di(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1894 fileobj%var(index_field)%ndim = 1
1906 compressed, position, tile_count, data_default, longname, units, &
1907 compressed_axis, read_only, restart_owns_data)
1909 character(len=*),
intent(in) :: filename, fieldname
1910 integer,
dimension(:,:),
intent(in),
target :: data
1911 type(
domain2d),
optional,
intent(in),
target :: domain
1912 integer,
optional,
intent(in) :: data_default
1913 logical,
optional,
intent(in) :: no_domain
1914 logical,
optional,
intent(in) :: compressed
1915 integer,
optional,
intent(in) :: position, tile_count
1916 logical,
optional,
intent(in) :: mandatory
1917 character(len=*),
optional,
intent(in) :: longname, units, compressed_axis
1918 logical,
optional,
intent(in) :: read_only
1919 logical,
optional,
intent(in) :: restart_owns_data
1920 logical :: is_compressed
1921 integer :: index_field
1923 real :: data_default_r
1926 is_compressed = .false.
1927 if(
present(compressed)) is_compressed=compressed
1929 if (kind(data_default)/=kind(data))
call mpp_error(fatal,
'fms_io(register_restart_field_i2d): data_default and data different KIND()')
1930 data_default_r = transfer(mpp_fill_int,data_default_r)
1931 if (
present(data_default)) data_default_r = transfer(data_default ,data_default_r)
1933 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2), 1, 1/), &
1934 index_field, domain, mandatory, no_domain, is_compressed, &
1935 position, tile_count, data_default_r, longname, units, compressed_axis, &
1936 read_only=read_only, owns_data=restart_owns_data)
1937 fileobj%p2di(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1938 fileobj%var(index_field)%ndim = 2
1949 no_domain, position, tile_count, data_default, longname, units, &
1950 read_only, restart_owns_data)
1952 character(len=*),
intent(in) :: filename, fieldname
1953 integer,
dimension(:,:,:),
intent(in),
target :: data
1954 type(
domain2d),
optional,
intent(in),
target :: domain
1955 integer,
optional,
intent(in) :: data_default
1956 logical,
optional,
intent(in) :: no_domain
1957 integer,
optional,
intent(in) :: position, tile_count
1958 logical,
optional,
intent(in) :: mandatory
1959 character(len=*),
optional,
intent(in) :: longname, units
1960 logical,
optional,
intent(in) :: read_only
1961 logical,
optional,
intent(in) :: restart_owns_data
1962 integer :: index_field
1964 real :: data_default_r
1968 if (kind(data_default)/=kind(data))
call mpp_error(fatal,
'fms_io(register_restart_field_i3d): data_default and data different KIND()')
1969 data_default_r = transfer(mpp_fill_int,data_default_r)
1970 if (
present(data_default)) data_default_r = transfer(data_default ,data_default_r)
1972 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2),
size(
data,3), 1/), &
1973 index_field, domain, mandatory, no_domain, .false., &
1974 position, tile_count, data_default_r, longname, units, &
1975 read_only=read_only, owns_data=restart_owns_data)
1976 fileobj%p3di(fileobj%var(index_field)%siz(4), index_field)%p =>
data 1977 fileobj%var(index_field)%ndim = 3
1988 no_domain, position, tile_count, data_default, longname, units, read_only)
1990 character(len=*),
intent(in) :: filename, fieldname
1991 real,
intent(in),
target :: data1, data2
1992 type(
domain2d),
optional,
intent(in),
target :: domain
1993 real,
optional,
intent(in) :: data_default
1994 integer,
optional,
intent(in) :: position, tile_count
1995 logical,
optional,
intent(in) :: mandatory
1996 logical,
optional,
intent(in) :: no_domain
1997 character(len=*),
optional,
intent(in) :: longname, units
1998 logical,
optional,
intent(in) :: read_only
1999 integer :: index_field
2003 'fms_io(register_restart_field_r0d_2level): need to call fms_io_init')
2004 call setup_one_field(fileobj, filename, fieldname, (/1, 1, 1, 2/), index_field, domain, &
2005 mandatory, no_domain=no_domain, scalar_or_1d=.true., position=position, tile_count=tile_count, &
2006 data_default=data_default, longname=longname, units=units, read_only=read_only)
2007 fileobj%p0dr(1, index_field)%p => data1
2008 fileobj%p0dr(2, index_field)%p => data2
2009 fileobj%var(index_field)%ndim = 0
2020 no_domain, position, tile_count, data_default, longname, units, read_only)
2022 character(len=*),
intent(in) :: filename, fieldname
2023 real,
dimension(:),
intent(in),
target :: data1, data2
2024 type(
domain2d),
optional,
intent(in),
target :: domain
2025 real,
optional,
intent(in) :: data_default
2026 integer,
optional,
intent(in) :: position, tile_count
2027 logical,
optional,
intent(in) :: mandatory
2028 logical,
optional,
intent(in) :: no_domain
2029 character(len=*),
optional,
intent(in) :: longname, units
2030 logical,
optional,
intent(in) :: read_only
2031 integer :: index_field
2035 'fms_io(register_restart_field_r1d_2level): need to call fms_io_init')
2036 call setup_one_field(fileobj, filename, fieldname, (/
size(data1,1), 1, 1, 2/), index_field, domain, &
2037 mandatory, no_domain=no_domain, scalar_or_1d=.true., position=position, tile_count=tile_count, &
2038 data_default=data_default, longname=longname, units=units, read_only=read_only)
2039 fileobj%p1dr(1, index_field)%p => data1
2040 fileobj%p1dr(2, index_field)%p => data2
2041 fileobj%var(index_field)%ndim = 1
2054 no_domain, position, tile_count, data_default, longname, units, read_only)
2056 character(len=*),
intent(in) :: filename, fieldname
2057 real,
dimension(:,:),
intent(in),
target :: data1, data2
2058 type(
domain2d),
optional,
intent(in),
target :: domain
2059 real,
optional,
intent(in) :: data_default
2060 logical,
optional,
intent(in) :: no_domain
2061 integer,
optional,
intent(in) :: position, tile_count
2062 logical,
optional,
intent(in) :: mandatory
2063 character(len=*),
optional,
intent(in) :: longname, units
2064 logical,
optional,
intent(in) :: read_only
2065 integer :: index_field
2069 'fms_io(register_restart_field_r2d_2level): need to call fms_io_init')
2070 call setup_one_field(fileobj, filename, fieldname, (/
size(data1,1),
size(data1,2), 1, 2/), &
2071 index_field, domain, mandatory, no_domain, .false., &
2072 position, tile_count, data_default, longname, units, read_only=read_only)
2073 fileobj%p2dr(1, index_field)%p => data1
2074 fileobj%p2dr(2, index_field)%p => data2
2075 fileobj%var(index_field)%ndim = 2
2088 no_domain, position, tile_count, data_default, longname, units, read_only)
2090 character(len=*),
intent(in) :: filename, fieldname
2091 real,
dimension(:,:,:),
intent(in),
target :: data1, data2
2092 type(
domain2d),
optional,
intent(in),
target :: domain
2093 real,
optional,
intent(in) :: data_default
2094 logical,
optional,
intent(in) :: no_domain
2095 integer,
optional,
intent(in) :: position, tile_count
2096 logical,
optional,
intent(in) :: mandatory
2097 character(len=*),
optional,
intent(in) :: longname, units
2098 logical,
optional,
intent(in) :: read_only
2099 integer :: index_field
2103 'fms_io(register_restart_field_r3d_2level): need to call fms_io_init')
2104 call setup_one_field(fileobj, filename, fieldname, (/
size(data1,1),
size(data1,2),
size(data1,3), 2/), &
2105 index_field, domain, mandatory, no_domain, .false., &
2106 position, tile_count, data_default, longname, units, read_only=read_only)
2107 fileobj%p3dr(1, index_field)%p => data1
2108 fileobj%p3dr(2, index_field)%p => data2
2109 fileobj%var(index_field)%ndim = 3
2122 function register_restart_field_r2d8_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, &
2123 no_domain, position, tile_count, data_default, longname, units, read_only)
2125 character(len=*),
intent(in) :: filename, fieldname
2126 real(DOUBLE_KIND),
dimension(:,:),
intent(in),
target :: data1, data2
2127 type(
domain2d),
optional,
intent(in),
target :: domain
2128 real,
optional,
intent(in) :: data_default
2129 logical,
optional,
intent(in) :: no_domain
2130 integer,
optional,
intent(in) :: position, tile_count
2131 logical,
optional,
intent(in) :: mandatory
2132 character(len=*),
optional,
intent(in) :: longname, units
2133 logical,
optional,
intent(in) :: read_only
2134 integer :: index_field
2135 integer :: register_restart_field_r2d8_2level
2138 'fms_io(register_restart_field_r2d_2level): need to call fms_io_init')
2139 call setup_one_field(fileobj, filename, fieldname, (/
size(data1,1),
size(data1,2), 1, 2/), &
2140 index_field, domain, mandatory, no_domain, .false., &
2141 position, tile_count, data_default, longname, units, read_only=read_only)
2142 fileobj%p2dr8(1, index_field)%p => data1
2143 fileobj%p2dr8(2, index_field)%p => data2
2144 fileobj%var(index_field)%ndim = 2
2145 register_restart_field_r2d8_2level = index_field
2149 end function register_restart_field_r2d8_2level
2156 function register_restart_field_r3d8_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, &
2157 no_domain, position, tile_count, data_default, longname, units, read_only)
2159 character(len=*),
intent(in) :: filename, fieldname
2160 real(DOUBLE_KIND),
dimension(:,:,:),
intent(in),
target :: data1, data2
2161 type(
domain2d),
optional,
intent(in),
target :: domain
2162 real,
optional,
intent(in) :: data_default
2163 logical,
optional,
intent(in) :: no_domain
2164 integer,
optional,
intent(in) :: position, tile_count
2165 logical,
optional,
intent(in) :: mandatory
2166 character(len=*),
optional,
intent(in) :: longname, units
2167 logical,
optional,
intent(in) :: read_only
2168 integer :: index_field
2169 integer :: register_restart_field_r3d8_2level
2172 'fms_io(register_restart_field_r3d_2level): need to call fms_io_init')
2173 call setup_one_field(fileobj, filename, fieldname, (/
size(data1,1),
size(data1,2),
size(data1,3), 2/), &
2174 index_field, domain, mandatory, no_domain, .false., &
2175 position, tile_count, data_default, longname, units, read_only=read_only)
2176 fileobj%p3dr8(1, index_field)%p => data1
2177 fileobj%p3dr8(2, index_field)%p => data2
2178 fileobj%var(index_field)%ndim = 3
2179 register_restart_field_r3d8_2level = index_field
2183 end function register_restart_field_r3d8_2level
2192 no_domain, position, tile_count, data_default, longname, units, read_only)
2194 character(len=*),
intent(in) :: filename, fieldname
2195 integer,
intent(in),
target :: data1, data2
2196 type(
domain2d),
optional,
intent(in),
target :: domain
2197 integer,
optional,
intent(in) :: data_default
2198 integer,
optional,
intent(in) :: position, tile_count
2199 logical,
optional,
intent(in) :: mandatory
2200 logical,
optional,
intent(in) :: no_domain
2201 character(len=*),
optional,
intent(in) :: longname, units
2202 logical,
optional,
intent(in) :: read_only
2203 integer :: index_field
2205 real :: data_default_r
2208 'fms_io(register_restart_field_i0d_2level): need to call fms_io_init')
2210 if (kind(data_default)/=kind(data1))
call mpp_error(fatal,
'fms_io(register_restart_field_i0d_2level): data_default and data1 different KIND()')
2211 if (kind(data_default)/=kind(data2))
call mpp_error(fatal,
'fms_io(register_restart_field_i0d_2level): data_default and data2 different KIND()')
2212 data_default_r = transfer(mpp_fill_int,data_default_r)
2213 if (
present(data_default)) data_default_r = transfer(data_default ,data_default_r)
2215 call setup_one_field(fileobj, filename, fieldname, (/1, 1, 1, 2/), index_field, domain, &
2216 mandatory, no_domain=no_domain, scalar_or_1d=.true., position=position, tile_count=tile_count, &
2217 data_default=data_default_r, longname=longname, units=units, read_only=read_only)
2218 fileobj%p0di(1, index_field)%p => data1
2219 fileobj%p0di(2, index_field)%p => data2
2220 fileobj%var(index_field)%ndim = 0
2233 no_domain, position, tile_count, data_default, longname, units, read_only)
2235 character(len=*),
intent(in) :: filename, fieldname
2236 integer,
dimension(:),
intent(in),
target :: data1, data2
2237 type(
domain2d),
optional,
intent(in),
target :: domain
2238 integer,
optional,
intent(in) :: data_default
2239 integer,
optional,
intent(in) :: position, tile_count
2240 logical,
optional,
intent(in) :: mandatory
2241 logical,
optional,
intent(in) :: no_domain
2242 character(len=*),
optional,
intent(in) :: longname, units
2243 logical,
optional,
intent(in) :: read_only
2244 integer :: index_field
2246 real :: data_default_r
2249 'fms_io(register_restart_field_i1d_2level): need to call fms_io_init')
2251 if (kind(data_default)/=kind(data1))
call mpp_error(fatal,
'fms_io(register_restart_field_i1d_2level): data_default and data1 different KIND()')
2252 if (kind(data_default)/=kind(data2))
call mpp_error(fatal,
'fms_io(register_restart_field_i1d_2level): data_default and data2 different KIND()')
2253 data_default_r = transfer(mpp_fill_int,data_default_r)
2254 if (
present(data_default)) data_default_r = transfer(data_default ,data_default_r)
2256 call setup_one_field(fileobj, filename, fieldname, (/
size(data1,1), 1, 1, 2/), index_field, domain, &
2257 mandatory, no_domain=no_domain, scalar_or_1d=.true., position=position, tile_count=tile_count, &
2258 data_default=data_default_r, longname=longname, units=units, read_only=read_only)
2259 fileobj%p1di(1, index_field)%p => data1
2260 fileobj%p1di(2, index_field)%p => data2
2261 fileobj%var(index_field)%ndim = 1
2274 no_domain, position, tile_count, data_default, longname, units, read_only)
2276 character(len=*),
intent(in) :: filename, fieldname
2277 integer,
dimension(:,:),
intent(in),
target :: data1, data2
2278 type(
domain2d),
optional,
intent(in),
target :: domain
2279 integer,
optional,
intent(in) :: data_default
2280 logical,
optional,
intent(in) :: no_domain
2281 integer,
optional,
intent(in) :: position, tile_count
2282 logical,
optional,
intent(in) :: mandatory
2283 character(len=*),
optional,
intent(in) :: longname, units
2284 logical,
optional,
intent(in) :: read_only
2285 integer :: index_field
2287 real :: data_default_r
2290 'fms_io(register_restart_field_i2d_2level): need to call fms_io_init')
2292 if (kind(data_default)/=kind(data1))
call mpp_error(fatal,
'fms_io(register_restart_field_i2d_2level): data_default and data1 different KIND()')
2293 if (kind(data_default)/=kind(data2))
call mpp_error(fatal,
'fms_io(register_restart_field_i2d_2level): data_default and data2 different KIND()')
2294 data_default_r = transfer(mpp_fill_int,data_default_r)
2295 if (
present(data_default)) data_default_r = transfer(data_default ,data_default_r)
2297 call setup_one_field(fileobj, filename, fieldname, (/
size(data1,1),
size(data1,2), 1, 2/), &
2298 index_field, domain, mandatory, no_domain, .false., &
2299 position, tile_count, data_default_r, longname, units, read_only=read_only)
2300 fileobj%p2di(1, index_field)%p => data1
2301 fileobj%p2di(2, index_field)%p => data2
2302 fileobj%var(index_field)%ndim = 2
2315 no_domain, position, tile_count, data_default, longname, units, read_only)
2317 character(len=*),
intent(in) :: filename, fieldname
2318 integer,
dimension(:,:,:),
intent(in),
target :: data1, data2
2319 type(
domain2d),
optional,
intent(in),
target :: domain
2320 integer,
optional,
intent(in) :: data_default
2321 logical,
optional,
intent(in) :: no_domain
2322 integer,
optional,
intent(in) :: position, tile_count
2323 logical,
optional,
intent(in) :: mandatory
2324 character(len=*),
optional,
intent(in) :: longname, units
2325 logical,
optional,
intent(in) :: read_only
2326 integer :: index_field
2328 real :: data_default_r
2331 'fms_io(register_restart_field_i3d_2level): need to call fms_io_init')
2333 if (kind(data_default)/=kind(data1))
call mpp_error(fatal,
'fms_io(register_restart_field_i3d_2level): data_default and data1 different KIND()')
2334 if (kind(data_default)/=kind(data2))
call mpp_error(fatal,
'fms_io(register_restart_field_i3d_2level): data_default and data2 different KIND()')
2335 data_default_r = transfer(mpp_fill_int,data_default_r)
2336 if (
present(data_default)) data_default_r = transfer(data_default ,data_default_r)
2338 call setup_one_field(fileobj, filename, fieldname, (/
size(data1,1),
size(data1,2),
size(data1,3), 2/), &
2339 index_field, domain, mandatory, no_domain, .false., &
2340 position, tile_count, data_default_r, longname, units, read_only=read_only)
2341 fileobj%p3di(1, index_field)%p => data1
2342 fileobj%p3di(2, index_field)%p => data2
2343 fileobj%var(index_field)%ndim = 3
2357 pelist, is_root_pe, longname, units, position, &
2358 x_halo, y_halo, ishift, jshift, read_only, mandatory)
2360 character(len=*),
intent(in) :: filename, fieldname
2361 real,
dimension(:,:),
intent(in),
target :: data
2362 integer,
dimension(:),
intent(in) :: indices, global_size, pelist
2363 logical,
intent(in) :: is_root_pe
2364 character(len=*),
optional,
intent(in) :: longname, units
2365 integer,
optional,
intent(in) :: position, x_halo, y_halo, ishift, jshift
2366 logical,
optional,
intent(in) :: read_only
2367 logical,
optional,
intent(in) :: mandatory
2368 integer :: index_field, l_position
2372 if ((is_root_pe) .and. (.not.any(mpp_pe().eq.pelist)))
call mpp_error(fatal, &
2373 'fms_io(register_restart_region_r2d) designated root_pe is not a member of pelist')
2375 if (
present(position)) l_position = position
2376 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2), 1, 1/), &
2377 index_field, no_domain=.true., position=l_position, longname=longname, units=units, &
2378 read_only=read_only, mandatory=mandatory)
2379 fileobj%p2dr(fileobj%var(index_field)%siz(4), index_field)%p =>
data 2380 fileobj%var(index_field)%ndim = 2
2381 fileobj%var(index_field)%is = indices(1)
2382 fileobj%var(index_field)%ie = indices(2)
2383 fileobj%var(index_field)%js = indices(3)
2384 fileobj%var(index_field)%je = indices(4)
2385 fileobj%var(index_field)%gsiz(1) = global_size(1)
2386 fileobj%var(index_field)%gsiz(2) = global_size(2)
2387 fileobj%is_root_pe = is_root_pe
2388 fileobj%var(index_field)%x_halo = 0
2389 fileobj%var(index_field)%y_halo = 0
2390 fileobj%var(index_field)%ishift = 0
2391 fileobj%var(index_field)%jshift = 0
2392 if (
present(x_halo)) fileobj%var(index_field)%x_halo = x_halo
2393 if (
present(y_halo)) fileobj%var(index_field)%y_halo = y_halo
2394 if (
present(ishift)) fileobj%var(index_field)%ishift = ishift
2395 if (
present(jshift)) fileobj%var(index_field)%jshift = jshift
2396 if (
allocated(fileobj%var(index_field)%pelist))
deallocate(fileobj%var(index_field)%pelist)
2397 if (
allocated(fileobj%var(index_field)%pelist))
deallocate(fileobj%var(index_field)%pelist)
2398 allocate(fileobj%var(index_field)%pelist(
size(pelist)))
2399 fileobj%var(index_field)%pelist = pelist
2412 pelist, is_root_pe, longname, units, position, &
2413 x_halo, y_halo, ishift, jshift, read_only, mandatory)
2415 character(len=*),
intent(in) :: filename, fieldname
2416 real,
dimension(:,:,:),
intent(in),
target :: data
2417 integer,
dimension(:),
intent(in) :: indices, global_size, pelist
2418 logical,
intent(in) :: is_root_pe
2419 character(len=*),
optional,
intent(in) :: longname, units
2420 logical,
optional,
intent(in) :: read_only
2421 integer,
optional,
intent(in) :: position, x_halo, y_halo, ishift, jshift
2422 logical,
optional,
intent(in) :: mandatory
2423 integer :: index_field, l_position
2427 if ((is_root_pe) .and. (.not.any(mpp_pe().eq.pelist)))
call mpp_error(fatal, &
2428 'fms_io(register_restart_region_r3d) designated root_pe is not a member of pelist')
2430 if (
present(position)) l_position = position
2431 call setup_one_field(fileobj, filename, fieldname, (/
size(
data,1),
size(
data,2),
size(
data,3), 1/), &
2432 index_field, no_domain=.true., position=l_position, longname=longname, units=units, &
2433 read_only=read_only, mandatory=mandatory)
2434 fileobj%p3dr(fileobj%var(index_field)%siz(4), index_field)%p =>
data 2435 fileobj%var(index_field)%ndim = 3
2436 fileobj%var(index_field)%is = indices(1)
2437 fileobj%var(index_field)%ie = indices(2)
2438 fileobj%var(index_field)%js = indices(3)
2439 fileobj%var(index_field)%je = indices(4)
2440 fileobj%var(index_field)%gsiz(1) = global_size(1)
2441 fileobj%var(index_field)%gsiz(2) = global_size(2)
2442 fileobj%var(index_field)%gsiz(3) = global_size(3)
2443 fileobj%is_root_pe = is_root_pe
2444 fileobj%var(index_field)%x_halo = 0
2445 fileobj%var(index_field)%y_halo = 0
2446 fileobj%var(index_field)%ishift = 0
2447 fileobj%var(index_field)%jshift = 0
2448 if (
present(x_halo)) fileobj%var(index_field)%x_halo = x_halo
2449 if (
present(y_halo)) fileobj%var(index_field)%y_halo = y_halo
2450 if (
present(ishift)) fileobj%var(index_field)%ishift = ishift
2451 if (
present(jshift)) fileobj%var(index_field)%jshift = jshift
2452 if (
allocated(fileobj%var(index_field)%pelist))
deallocate(fileobj%var(index_field)%pelist)
2453 allocate(fileobj%var(index_field)%pelist(
size(pelist)))
2454 fileobj%var(index_field)%pelist = pelist
2466 subroutine save_restart(fileObj, time_stamp, directory, append, time_level)
2468 character(len=*),
intent(in),
optional :: directory
2469 character(len=*),
intent(in),
optional :: time_stamp
2473 logical,
intent(in),
optional :: append
2474 real,
intent(in),
optional :: time_level
2475 character(len=256) :: dir
2476 character(len=80) :: restartname
2477 character(len=336) :: restartpath
2482 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(save_restart): " // &
2483 "restart_file_type data must be initialized by calling register_restart_field before using it")
2486 if(
present(directory)) dir = directory
2488 restartname = fileobj%name
2490 if (
PRESENT(time_stamp))
then 2491 if(len_trim(restartname)+len_trim(time_stamp) > 79)
call mpp_error(fatal,
"fms_io(save_restart): " // &
2492 "Length of restart file name + time_stamp is greater than allowed character length of 79")
2493 restartname = trim(time_stamp)//
"."//trim(restartname)
2496 if(len_trim(dir) > 0)
then 2497 if(len_trim(dir)+len_trim(restartname) > 335)
call mpp_error(fatal,
"fms_io(save_restart): " // &
2498 "Length of full restart path + file name is greater than allowed character length of 355")
2499 restartpath = trim(dir)//
"/"// trim(restartname)
2501 restartpath = trim(restartname)
2504 if(fileobj%is_compressed .AND.
ALLOCATED(fileobj%axes))
then 2508 elseif(fileobj%unlimited_axis .AND.
ALLOCATED(fileobj%axes))
then 2524 do j = 1, fileobj%nvar
2525 if( .not. fileobj%var(j)%read_only)
then 2543 type(restart_file_type),
intent(inout),
target :: fileObj
2544 character(len=336) :: restartpath
2564 logical,
intent(in),
optional :: append
2565 real,
intent(in),
optional :: time_level
2568 type(axistype) :: x_axis, y_axis, z_axis, CC_axis, other_axis
2569 type(axistype) :: t_axis, c_axis, h_axis
2570 type(axistype) :: comp_axis
2571 logical :: naxis_z=.false.
2572 type(axistype),
dimension(4) :: var_axes
2573 type(var_type),
pointer,
save :: cur_var=>null()
2574 integer :: i, j, k, l, num_var_axes, cpack, idx, mpp_action
2576 real,
allocatable,
dimension(:,:) :: r2d
2577 real,
allocatable,
dimension(:) :: r1d
2579 integer(LONG_KIND),
allocatable,
dimension(:) :: check_val
2580 character(len=256) :: checksum_char
2581 logical :: domain_present, write_meta_data, write_field_data
2582 logical :: c_axis_defined, h_axis_defined, CC_axis_defined
2583 type(domain2d),
pointer :: domain =>null()
2584 type(ax_type),
pointer :: axis =>null()
2589 if (.not.
ALLOCATED(fileobj%axes(
cidx)%idx) .and. .not.
ALLOCATED(fileobj%axes(
hidx)%idx) )
then 2590 call mpp_error(fatal,
"fms_io(save_compressed_restart): A compressed axis has "// &
2591 "not been defined for file "//trim(fileobj%name))
2592 else if (
ALLOCATED(fileobj%axes(
cidx)%idx))
then 2593 domain =>fileobj%axes(
cidx)%domain
2595 domain =>fileobj%axes(
hidx)%domain
2598 if(
present(append))
then 2599 if(append .and. .not.
present(time_level))
then 2600 call mpp_error(fatal,
'fms_io(save_compressed_restart): time_level must be present when append=.true.'// &
2601 ' for file '//trim(fileobj%name))
2605 mpp_action = mpp_overwr
2606 write_meta_data = .true.
2607 if(
present(append))
then 2609 mpp_action = mpp_append
2610 write_meta_data = .false.
2611 if(time_level < 0.0)
then 2612 call mpp_error(fatal,
'fms_io(save_compressed_restart): time_level cannot be negative when append is .true.'// &
2613 ' for file '//trim(fileobj%name))
2618 write_field_data = .true.
2619 if(
present(time_level))
then 2620 write_field_data = time_level >= 0.0
2623 call mpp_open(unit,trim(restartpath),action=mpp_action,
form=
form, &
2624 is_root_pe=fileobj%is_root_pe, domain=domain)
2626 if(write_meta_data)
then 2633 axis => fileobj%axes(
xidx)
2634 if(.not.
ASSOCIATED(axis))
call mpp_error(fatal,
"fms_io(save_compressed_restart): "// &
2635 " The X axis has not been defined for "// &
2636 " file "//trim(fileobj%name) )
2637 call mpp_write_meta(unit,x_axis,axis%name,axis%units,axis%longname,data=axis%data,cartesian=
'X')
2639 axis => fileobj%axes(
yidx)
2640 if(.not.
ASSOCIATED(axis))
call mpp_error(fatal,
"fms_io(save_compressed_restart): "// &
2641 " The Y axis has not been defined for "// &
2642 " file "//trim(fileobj%name) )
2643 call mpp_write_meta(unit,y_axis,axis%name,axis%units,axis%longname,data=axis%data,cartesian=
'Y')
2645 axis => fileobj%axes(
zidx)
2647 if(
ASSOCIATED(axis%data))
then 2648 call mpp_write_meta(unit,z_axis,axis%name,axis%units,axis%longname, &
2649 data=axis%data,cartesian=
'Z')
2653 axis => fileobj%axes(
ccidx)
2654 if(
ASSOCIATED(axis%data))
then 2655 call mpp_write_meta(unit,cc_axis,axis%name,axis%units,axis%longname,data=axis%data,cartesian=
'CC')
2656 cc_axis_defined = .true.
2658 cc_axis_defined = .false.
2662 axis => fileobj%axes(
cidx)
2663 if(
ALLOCATED(axis%idx))
then 2664 call mpp_def_dim(unit,trim(axis%dimlen_name),axis%dimlen,trim(axis%dimlen_lname), (/(i,i=1,axis%dimlen)/))
2665 call mpp_write_meta(unit,c_axis,axis%name,axis%units,axis%longname, &
2666 data=axis%idx,compressed=axis%compressed,
min=axis%imin)
2667 c_axis_defined = .true.
2669 c_axis_defined = .false.
2672 axis => fileobj%axes(
hidx)
2673 if (
ALLOCATED(axis%idx))
then 2674 call mpp_def_dim(unit,trim(axis%dimlen_name),axis%dimlen,trim(axis%dimlen_lname), (/(i,i=1,axis%dimlen)/))
2675 call mpp_write_meta(unit,h_axis,axis%name,axis%units,axis%longname, &
2676 data=axis%idx,compressed=axis%compressed,
min=axis%imin)
2677 h_axis_defined = .true.
2679 h_axis_defined = .false.
2683 axis => fileobj%axes(
tidx)
2684 if(
ASSOCIATED(axis%data))
then 2685 call mpp_write_meta(unit,t_axis, axis%name, units=axis%units, longname=axis%longname, cartesian=
'T', calendar=axis%calendar)
2687 call mpp_write_meta(unit,t_axis,
'Time',
'time level',
'Time',cartesian=
'T')
2691 do j = 1,fileobj%nvar
2692 cur_var => fileobj%var(j)
2693 if(cur_var%read_only) cycle
2694 if(cur_var%siz(4) > 1 .AND. cur_var%siz(4) .NE. fileobj%max_ntime )
call mpp_error(fatal, &
2695 "fms_io(save_restart): "//trim(cur_var%name)//
" in file "//trim(fileobj%name)// &
2696 " has more than one time level, but number of time level is not equal to max_ntime")
2698 select case (trim(cur_var%compressed_axis))
2704 other_axis = cc_axis
2708 if (
ALLOCATED(fileobj%axes(
cidx)%idx))
then 2716 if(cur_var%ndim == 0)
then 2718 var_axes(1) = t_axis
2719 elseif(cur_var%ndim == 1)
then 2721 var_axes(1) = comp_axis
2722 if(cur_var%siz(4) == fileobj%max_ntime)
then 2724 var_axes(2) = t_axis
2726 elseif(cur_var%ndim == 2)
then 2728 var_axes(1) = comp_axis
2729 var_axes(2) = other_axis
2730 if(cur_var%siz(4) == fileobj%max_ntime)
then 2732 var_axes(3) = t_axis
2734 elseif(cur_var%ndim == 3)
then 2736 var_axes(1) = comp_axis
2737 var_axes(2) = z_axis
2738 var_axes(3) = cc_axis
2739 if(cur_var%siz(4) == fileobj%max_ntime)
then 2741 var_axes(4) = t_axis
2744 call mpp_error(fatal,
"fms_io(save_compressed_restart): "//trim(cur_var%name)//
" in file "// &
2745 trim(fileobj%name)//
" has more than three dimensions (not including time level)")
2749 allocate(check_val(
max(1,cur_var%siz(4))))
2750 do k = 1, cur_var%siz(4)
2751 if (
Associated(fileobj%p0dr(k,j)%p) )
then 2752 check_val(k) =
mpp_chksum(fileobj%p0dr(k,j)%p, (/mpp_pe()/), mask_val=cur_var%default_data)
2753 else if (
Associated(fileobj%p1dr(k,j)%p) )
then 2754 check_val(k) =
mpp_chksum(fileobj%p1dr(k,j)%p(:), mask_val=cur_var%default_data)
2755 else if (
Associated(fileobj%p2dr(k,j)%p) )
then 2756 check_val(k) =
mpp_chksum(fileobj%p2dr(k,j)%p(:,:), mask_val=cur_var%default_data)
2757 else if (
Associated(fileobj%p3dr(k,j)%p) )
then 2758 check_val(k) =
mpp_chksum(fileobj%p3dr(k,j)%p(:,:,:))
2759 else if (
Associated(fileobj%p0di(k,j)%p) )
then 2760 check_val(k) = fileobj%p0di(k,j)%p
2762 else if (
Associated(fileobj%p1di(k,j)%p) )
then 2763 check_val(k) =
mpp_chksum(fileobj%p1di(k,j)%p(:), mask_val=cur_var%default_data)
2765 else if (
Associated(fileobj%p2di(k,j)%p) )
then 2766 check_val(k) =
mpp_chksum(fileobj%p2di(k,j)%p(:,:), mask_val=cur_var%default_data)
2768 else if (
Associated(fileobj%p3di(k,j)%p) )
then 2769 call mpp_error(fatal,
"fms_io(save_compressed_restart): integer 3D restart fields are not currently supported"// &
2770 trim(cur_var%name)//
" of file "//trim(fileobj%name) )
2772 call mpp_error(fatal,
"fms_io(save_restart): There is no pointer associated with the data of field "// &
2773 trim(cur_var%name)//
" of file "//trim(fileobj%name) )
2778 if(write_field_data)
then 2779 call mpp_write_meta(unit,cur_var%field, var_axes(1:num_var_axes), cur_var%name, &
2780 cur_var%units,cur_var%longname,pack=cpack,checksum=check_val,fill=cur_var%default_data)
2782 call mpp_write_meta(unit,cur_var%field, var_axes(1:num_var_axes), cur_var%name, &
2783 cur_var%units,cur_var%longname,pack=cpack,fill=cur_var%default_data)
2785 deallocate(check_val)
2791 if (c_axis_defined)
call mpp_write(unit,c_axis)
2792 if (h_axis_defined)
call mpp_write(unit,h_axis)
2793 if (cc_axis_defined)
call mpp_write(unit,cc_axis)
2798 if(write_field_data)
then 2800 do k = 1, fileobj%max_ntime
2801 if(
present(time_level))
then 2807 cur_var => fileobj%var(j)
2808 if(cur_var%read_only) cycle
2810 select case (trim(cur_var%compressed_axis))
2816 if (
ALLOCATED(fileobj%axes(
cidx)%idx))
then 2825 if(k <= cur_var%siz(4))
then 2826 if (
Associated(fileobj%p0dr(k,j)%p) )
then 2827 call mpp_write(unit, cur_var%field, fileobj%p0dr(k,j)%p, tlev)
2828 elseif (
Associated(fileobj%p1dr(k,j)%p) )
then 2830 fileobj%axes(idx)%nelems(:), tstamp=tlev, default_data=cur_var%default_data)
2831 elseif (
Associated(fileobj%p2dr(k,j)%p) )
then 2833 fileobj%axes(idx)%nelems(:), tstamp=tlev, default_data=cur_var%default_data)
2834 elseif (
Associated(fileobj%p3dr(k,j)%p) )
then 2836 fileobj%axes(idx)%nelems(:), tstamp=tlev, default_data=cur_var%default_data)
2837 elseif (
Associated(fileobj%p0di(k,j)%p) )
then 2838 r0d = fileobj%p0di(k,j)%p
2839 call mpp_write(unit, cur_var%field, r0d, tlev)
2840 elseif (
Associated(fileobj%p1di(k,j)%p) )
then 2841 allocate(r1d(cur_var%siz(1)) )
2842 r1d = fileobj%p1di(k,j)%p
2844 fileobj%axes(idx)%nelems(:), tstamp=tlev, default_data=cur_var%default_data)
2846 elseif (
Associated(fileobj%p2di(k,j)%p) )
then 2847 allocate(r2d(cur_var%siz(1), cur_var%siz(2)) )
2848 r2d = fileobj%p2di(k,j)%p
2850 fileobj%axes(idx)%nelems(:), tstamp=tlev, default_data=cur_var%default_data)
2853 call mpp_error(fatal,
"fms_io(save_restart): There is no pointer associated with the data of field "// &
2854 trim(cur_var%name)//
" of file "//trim(fileobj%name) )
2861 call mpp_close(unit)
2872 type(restart_file_type),
intent(inout),
target :: fileObj
2873 character(len=336) :: restartpath
2876 type(axistype) :: u_axis
2877 type(axistype),
dimension(4) :: var_axes
2878 type(var_type),
pointer,
save :: cur_var=>null()
2879 integer :: i, j, k, l, num_var_axes, cpack, idx
2880 real,
allocatable,
dimension(:) :: r1d
2881 integer(LONG_KIND) :: check_val
2882 character(len=256) :: checksum_char
2883 type(domain2d),
pointer :: domain =>null()
2884 type(ax_type),
pointer :: axis =>null()
2887 if ( .NOT.fileobj%unlimited_axis )
then 2888 call mpp_error(fatal,
"fms_io(save_unlimited_axis_restart): An unlimited axis has "// &
2889 "not been defined for file "//trim(fileobj%name))
2891 domain =>fileobj%axes(
uidx)%domain
2893 call mpp_open(unit,trim(restartpath),action=mpp_overwr,
form=
form, &
2894 is_root_pe=fileobj%is_root_pe, domain=domain)
2897 axis => fileobj%axes(
uidx)
2898 call mpp_write_meta(unit,u_axis,axis%name,data=sum(axis%nelems(:)),unlimited=.true.)
2903 do j = 1,fileobj%nvar
2904 cur_var => fileobj%var(j)
2905 if(cur_var%siz(4) > 1)
call mpp_error(fatal, &
2906 "fms_io(save_restart): "//trim(cur_var%name)//
" in file "//trim(fileobj%name)// &
2907 " has more than one time level. Only single time level is currrently supported")
2909 if(cur_var%ndim == 1)
then 2911 var_axes(1) = u_axis
2913 call mpp_error(fatal,
'fms_io(save_unlimited_axis_restart): Only vectors are currently supported')
2917 if (
Associated(fileobj%p1dr(1,j)%p) )
then 2918 check_val =
mpp_chksum(fileobj%p1dr(1,j)%p(:))
2919 else if (
Associated(fileobj%p1di(1,j)%p) )
then 2921 check_val =
mpp_chksum(int(fileobj%p1di(1,j)%p(:),8))
2924 call mpp_error(fatal,
"fms_io(save_unlimited_axis_restart): There is no pointer associated with the record data of field "// &
2925 trim(cur_var%name)//
" of file "//trim(fileobj%name) )
2927 call mpp_write_meta(unit,cur_var%field, var_axes(1:num_var_axes), cur_var%name, &
2928 cur_var%units,cur_var%longname,pack=cpack,checksum=(/check_val/))
2933 cur_var => fileobj%var(j)
2934 if (
Associated(fileobj%p1dr(1,j)%p) )
then 2936 elseif (
Associated(fileobj%p1di(1,j)%p) )
then 2937 allocate(r1d(cur_var%siz(1)) )
2938 r1d = fileobj%p1di(1,j)%p
2942 call mpp_error(fatal,
"fms_io(save_restart): There is no pointer associated with the data of field "// &
2943 trim(cur_var%name)//
" of file "//trim(fileobj%name) )
2946 call mpp_close(unit)
2958 type(restart_file_type),
intent(inout) :: fileObj
2959 character(len=336) :: restartpath
2961 character(len=8) :: suffix
2962 integer :: var_sz, size_in_file
2964 real,
dimension(max_axis_size) :: axisdata
2965 integer,
dimension(max_axes) :: id_x_axes, siz_x_axes
2966 integer,
dimension(max_axes) :: id_y_axes, siz_y_axes
2967 integer,
dimension(max_axes) :: id_z_axes, siz_z_axes
2968 integer,
dimension(max_axes) :: id_a_axes, siz_a_axes
2969 integer,
dimension(max_axes) :: x_axes_indx, y_axes_indx, z_axes_indx, a_axes_indx
2970 type(axistype),
dimension(max_axes) :: x_axes, y_axes, z_axes, a_axes
2971 type(axistype) :: t_axes
2972 integer :: num_var_axes
2973 type(axistype),
dimension(5) :: var_axes
2974 type(var_type),
pointer,
save :: cur_var=>null()
2975 integer :: num_x_axes, num_y_axes, num_z_axes, num_a_axes
2976 integer :: naxes_x, naxes_y, naxes_z, naxes_a
2977 integer :: i, j, k, l, siz, ind_dom
2978 logical :: domain_present
2980 real(DOUBLE_KIND) :: tlev_r8
2981 character(len=10) :: axisname
2982 integer :: meta_size
2983 type(domain2d) :: domain
2985 real,
allocatable,
dimension(:,:,:) :: r3d
2986 real,
allocatable,
dimension(:,:) :: r2d
2987 real,
allocatable,
dimension(:) :: r1d
2989 integer(LONG_KIND),
allocatable,
dimension(:) :: check_val
2990 character(len=256) :: checksum_char
2991 integer :: isc, iec, jsc, jec
2992 integer :: isg, ieg, jsg, jeg
2993 integer :: ishift, jshift, iadd, jadd, cpack_size
2994 logical :: write_on_this_pe
2995 type(domain2d),
pointer :: io_domain =>null()
2997 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(save_restart): " // &
2998 "restart_file_type data must be initialized by calling register_restart_field before using it")
3008 domain_present = .false.
3009 do j = 1, fileobj%nvar
3010 if (fileobj%var(j)%domain_present)
then 3011 domain_present = .true.
3018 num_z_axes =
unique_axes(fileobj, 3, id_z_axes, siz_z_axes )
3019 num_a_axes =
unique_axes(fileobj, 4, id_a_axes, siz_a_axes )
3021 write_on_this_pe = .false.
3022 if(domain_present)
then 3023 io_domain => mpp_get_io_domain(
array_domain(fileobj%var(ind_dom)%domain_idx))
3024 if(
associated(io_domain))
then 3025 if(mpp_domain_is_tile_root_pe(io_domain)) write_on_this_pe = .true.
3029 if( fileobj%is_root_pe ) write_on_this_pe = .true.
3031 if( domain_present )
then 3032 call mpp_open(unit,trim(restartpath),action=mpp_overwr,
form=
form,&
3033 is_root_pe=fileobj%is_root_pe, domain=
array_domain(fileobj%var(ind_dom)%domain_idx) )
3035 call mpp_open(unit,trim(restartpath),action=mpp_overwr,
form=
form,threading=mpp_single,&
3036 fileset=mpp_single, is_root_pe=fileobj%is_root_pe)
3046 do j = 1, num_x_axes
3049 if(fileobj%var(l)%read_only) cycle
3050 if( fileobj%var(l)%id_axes(1) == j )
exit 3052 if( l > fileobj%nvar ) cycle
3053 naxes_x = naxes_x + 1
3054 x_axes_indx(naxes_x) = j
3055 if (naxes_x < 10)
then 3056 write(axisname,
'(a,i1)')
'xaxis_',naxes_x
3058 write(axisname,
'(a,i2)')
'xaxis_',naxes_x
3060 if(id_x_axes(j) > 0)
then 3062 data=axisdata(1:siz_x_axes(j)),domain=
domain_x(id_x_axes(j)),cartesian=
'X')
3065 data=axisdata(1:siz_x_axes(j)),cartesian=
'X')
3071 do j = 1, num_y_axes
3074 if(fileobj%var(l)%read_only) cycle
3075 if( fileobj%var(l)%id_axes(2) == j )
exit 3077 if( l > fileobj%nvar ) cycle
3078 naxes_y = naxes_y + 1
3079 y_axes_indx(naxes_y) = j
3080 if (naxes_y < 10)
then 3081 write(axisname,
'(a,i1)')
'yaxis_',naxes_y
3083 write(axisname,
'(a,i2)')
'yaxis_',naxes_y
3085 if(id_y_axes(j) > 0)
then 3087 data=axisdata(1:siz_y_axes(j)),domain=
domain_y(id_y_axes(j)),cartesian=
'Y')
3090 data=axisdata(1:siz_y_axes(j)),cartesian=
'Y')
3096 do j = 1, num_z_axes
3099 if(fileobj%var(l)%read_only) cycle
3100 if( fileobj%var(l)%id_axes(3) == j )
exit 3102 if( l > fileobj%nvar ) cycle
3103 naxes_z = naxes_z + 1
3104 z_axes_indx(naxes_z) = j
3105 if (naxes_z < 10)
then 3106 write(axisname,
'(a,i1)')
'zaxis_',naxes_z
3108 write(axisname,
'(a,i2)')
'zaxis_',naxes_z
3111 data=axisdata(1:siz_z_axes(j)),cartesian=
'Z')
3116 do j = 1, num_a_axes
3119 if(fileobj%var(l)%read_only) cycle
3120 if( fileobj%var(l)%id_axes(4) == j )
exit 3122 if( l > fileobj%nvar ) cycle
3123 naxes_a = naxes_a + 1
3124 a_axes_indx(naxes_a) = j
3125 if (naxes_a < 10)
then 3126 write(axisname,
'(a,i1)')
'aaxis_',naxes_a
3128 write(axisname,
'(a,i2)')
'aaxis_',naxes_a
3131 data=axisdata(1:siz_a_axes(j)),cartesian=
'N')
3136 'Time',
'time level',
'Time',cartesian=
'T')
3138 do j = 1,fileobj%nvar
3139 cur_var => fileobj%var(j)
3140 if(cur_var%read_only) cycle
3141 if(cur_var%siz(4) > 1 .AND. cur_var%siz(4) .NE. fileobj%max_ntime )
call mpp_error(fatal, &
3142 "fms_io(save_restart): "//trim(cur_var%name)//
" in file "//trim(fileobj%name)// &
3143 " has more than one time level, but number of time level is not equal to max_ntime")
3145 if(cur_var%ndim == 0)
then 3147 var_axes(1) = t_axes
3148 else if(cur_var%ndim == 1)
then 3150 var_axes(1) = x_axes(cur_var%id_axes(1))
3151 if(cur_var%siz(4) == fileobj%max_ntime)
then 3153 var_axes(2) = t_axes
3155 else if(cur_var%ndim == 2)
then 3157 var_axes(1) = x_axes(cur_var%id_axes(1))
3158 var_axes(2) = y_axes(cur_var%id_axes(2))
3159 if(cur_var%siz(4) == fileobj%max_ntime)
then 3161 var_axes(3) = t_axes
3163 else if(cur_var%ndim == 3)
then 3165 var_axes(1) = x_axes(cur_var%id_axes(1))
3166 var_axes(2) = y_axes(cur_var%id_axes(2))
3167 var_axes(3) = z_axes(cur_var%id_axes(3))
3168 if(cur_var%siz(4) == fileobj%max_ntime)
then 3170 var_axes(4) = t_axes
3172 else if(cur_var%ndim == 4)
then 3174 var_axes(1) = x_axes(cur_var%id_axes(1))
3175 var_axes(2) = y_axes(cur_var%id_axes(2))
3176 var_axes(3) = z_axes(cur_var%id_axes(3))
3177 var_axes(4) = a_axes(cur_var%id_axes(4))
3178 if(cur_var%siz(4) == fileobj%max_ntime)
then 3180 var_axes(5) = t_axes
3184 if ( cur_var%domain_idx > 0)
then 3187 call mpp_get_domain_shift(
array_domain(cur_var%domain_idx), ishift, jshift, cur_var%position)
3191 call mpp_get_domain_shift(
current_domain, ishift, jshift, cur_var%position)
3205 if(iec == ieg) iadd = iadd + ishift
3206 if(jec == jeg) jadd = jadd + jshift
3208 allocate(check_val(
max(1,cur_var%siz(4))))
3210 do k = 1, cur_var%siz(4)
3211 if (
Associated(fileobj%p0dr(k,j)%p) )
then 3212 check_val(k) =
mpp_chksum(fileobj%p0dr(k,j)%p, (/mpp_pe()/) )
3213 else if (
Associated(fileobj%p1dr(k,j)%p) )
then 3214 check_val(k) =
mpp_chksum(fileobj%p1dr(k,j)%p, (/mpp_pe()/) )
3215 else if (
Associated(fileobj%p2dr(k,j)%p) )
then 3216 check_val(k) =
mpp_chksum(fileobj%p2dr(k,j)%p(cur_var%is:cur_var%is+iadd, cur_var%js:cur_var%js+jadd) )
3217 else if (
Associated(fileobj%p3dr(k,j)%p) )
then 3218 check_val(k) =
mpp_chksum(fileobj%p3dr(k,j)%p(cur_var%is:cur_var%is+iadd, cur_var%js:cur_var%js+jadd, :) )
3219 else if (
Associated(fileobj%p2dr8(k,j)%p) )
then 3221 check_val(k) =
mpp_chksum(fileobj%p2dr8(k,j)%p(cur_var%is:cur_var%is+iadd, cur_var%js:cur_var%js+jadd) )
3222 else if (
Associated(fileobj%p3dr8(k,j)%p) )
then 3224 check_val(k) =
mpp_chksum(fileobj%p3dr8(k,j)%p(cur_var%is:cur_var%is+iadd, cur_var%js:cur_var%js+jadd, :) )
3225 else if (
Associated(fileobj%p4dr(k,j)%p) )
then 3226 check_val(k) =
mpp_chksum(fileobj%p4dr(k,j)%p(cur_var%is:cur_var%is+iadd, cur_var%js:cur_var%js+jadd, :, :) )
3227 else if (
Associated(fileobj%p0di(k,j)%p) )
then 3228 check_val(k) = fileobj%p0di(k,j)%p
3229 else if (
Associated(fileobj%p1di(k,j)%p) )
then 3230 check_val(k) =
mpp_chksum(fileobj%p1di(k,j)%p, (/mpp_pe()/) )
3231 else if (
Associated(fileobj%p2di(k,j)%p) )
then 3232 check_val(k) =
mpp_chksum(fileobj%p2di(k,j)%p(cur_var%is:cur_var%is+iadd, cur_var%js:cur_var%js+jadd) )
3233 else if (
Associated(fileobj%p3di(k,j)%p) )
then 3234 check_val(k) =
mpp_chksum(fileobj%p3di(k,j)%p(cur_var%is:cur_var%is+iadd, cur_var%js:cur_var%js+jadd, :))
3236 call mpp_error(fatal,
"fms_io(save_restart): There is no pointer associated with the data of field "// &
3237 trim(cur_var%name)//
" of file "//trim(fileobj%name) )
3240 call mpp_write_meta(unit,cur_var%field, var_axes(1:num_var_axes), cur_var%name, &
3241 cur_var%units,cur_var%longname,pack=cpack_size,checksum=check_val)
3242 deallocate(check_val)
3247 call mpp_write(unit,x_axes(x_axes_indx(j)))
3250 call mpp_write(unit,y_axes(y_axes_indx(j)))
3253 call mpp_write(unit,z_axes(z_axes_indx(j)))
3257 call mpp_write(unit,a_axes(a_axes_indx(j)))
3261 do k = 1, fileobj%max_ntime
3263 cur_var => fileobj%var(j)
3264 if(cur_var%read_only) cycle
3269 if(k <= cur_var%siz(4))
then 3270 if(cur_var%domain_present)
then 3271 if(
Associated(fileobj%p2dr(k,j)%p) )
then 3273 default_data=cur_var%default_data)
3274 else if(
Associated(fileobj%p3dr(k,j)%p) )
then 3276 default_data=cur_var%default_data)
3277 else if(
Associated(fileobj%p2dr8(k,j)%p) )
then 3278 call mpp_write(unit, cur_var%field,
array_domain(cur_var%domain_idx), fileobj%p2dr8(k,j)%p, tlev_r8, &
3279 default_data=
real(cur_var%default_data,kind=double_kind))
3280 else if(
Associated(fileobj%p3dr8(k,j)%p) )
then 3281 call mpp_write(unit, cur_var%field,
array_domain(cur_var%domain_idx), fileobj%p3dr8(k,j)%p, tlev_r8, &
3282 default_data=
real(cur_var%default_data,kind=double_kind))
3283 else if(
Associated(fileobj%p4dr(k,j)%p) )
then 3285 default_data=cur_var%default_data)
3286 else if(
Associated(fileobj%p2di(k,j)%p) )
then 3287 allocate(r2d(cur_var%siz(1), cur_var%siz(2)) )
3288 r2d = fileobj%p2di(k,j)%p
3290 default_data=cur_var%default_data)
3292 else if(
Associated(fileobj%p3di(k,j)%p) )
then 3293 allocate(r3d(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3)) )
3294 r3d = fileobj%p3di(k,j)%p
3296 default_data=cur_var%default_data)
3299 call mpp_error(fatal,
"fms_io(save_restart): domain is present, "// &
3300 "field "//trim(cur_var%name)//
" of file "//trim(fileobj%name)// &
3301 ", but none of p2dr, p3dr, p2di and p3di is associated")
3303 else if (write_on_this_pe)
then 3304 if (
Associated(fileobj%p0dr(k,j)%p) )
then 3305 call mpp_write(unit, cur_var%field, fileobj%p0dr(k,j)%p, tlev)
3306 else if (
Associated(fileobj%p1dr(k,j)%p) )
then 3307 call mpp_write(unit, cur_var%field, fileobj%p1dr(k,j)%p, tlev)
3308 else if (
Associated(fileobj%p2dr(k,j)%p) )
then 3309 call mpp_write(unit, cur_var%field, fileobj%p2dr(k,j)%p, tlev)
3310 else if (
Associated(fileobj%p3dr(k,j)%p) )
then 3311 call mpp_write(unit, cur_var%field, fileobj%p3dr(k,j)%p, tlev)
3316 else if (
Associated(fileobj%p4dr(k,j)%p) )
then 3317 call mpp_write(unit, cur_var%field, fileobj%p4dr(k,j)%p, tlev)
3318 else if (
Associated(fileobj%p0di(k,j)%p) )
then 3319 r0d = fileobj%p0di(k,j)%p
3320 call mpp_write(unit, cur_var%field, r0d, tlev)
3321 else if (
Associated(fileobj%p1di(k,j)%p) )
then 3322 allocate(r1d(cur_var%siz(1)) )
3323 r1d = fileobj%p1di(k,j)%p
3324 call mpp_write(unit, cur_var%field, r1d, tlev)
3326 else if (
Associated(fileobj%p2di(k,j)%p) )
then 3327 allocate(r2d(cur_var%siz(1), cur_var%siz(2)) )
3328 r2d = fileobj%p2di(k,j)%p
3329 call mpp_write(unit, cur_var%field, r2d, tlev)
3331 else if (
Associated(fileobj%p3di(k,j)%p) )
then 3332 allocate(r3d(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3)) )
3333 r3d = fileobj%p3di(k,j)%p
3334 call mpp_write(unit, cur_var%field, r3d, tlev)
3337 call mpp_error(fatal,
"fms_io(save_restart): There is no pointer associated with the data of field "// &
3338 trim(cur_var%name)//
" of file "//trim(fileobj%name) )
3344 call mpp_close(unit)
3355 character(len=*),
intent(in),
optional :: directory
3356 character(len=*),
intent(in),
optional :: time_stamp
3358 character(len=256) :: dir
3359 character(len=256) :: restartpath
3360 character(len=80) :: restartname
3363 real,
dimension(max_axis_size) :: axisdata
3364 integer,
dimension(max_axes) :: id_x_axes, siz_x_axes
3365 integer,
dimension(max_axes) :: id_y_axes, siz_y_axes
3366 integer,
dimension(max_axes) :: id_z_axes, siz_z_axes
3367 integer,
dimension(max_axes) :: x_axes_indx, y_axes_indx, z_axes_indx
3368 type(
axistype),
dimension(max_axes) :: x_axes, y_axes, z_axes
3370 integer :: num_var_axes
3371 type(
axistype),
dimension(4) :: var_axes
3372 type(
var_type),
pointer,
save :: cur_var=>null()
3373 integer :: num_x_axes, num_y_axes, num_z_axes
3374 integer :: naxes_x, naxes_y, naxes_z
3375 integer :: i, j, k, l
3376 integer :: isc, iec, jsc, jec
3378 integer :: i_add, i1, i2
3379 integer :: j_add, j1, j2
3380 integer :: i_glob, j_glob, k_glob
3382 character(len=10) :: axisname
3384 real,
allocatable,
dimension(:,:) :: r2d
3385 real,
allocatable,
dimension(:,:,:) :: r3d
3386 integer(LONG_KIND),
allocatable,
dimension(:) :: check_val
3396 if(
present(directory)) dir = directory
3398 restartname = fileobj%name
3400 if (
PRESENT(time_stamp))
then 3401 restartname = trim(time_stamp)//
"."//trim(restartname)
3404 if (len_trim(dir) > 0)
then 3405 restartpath = trim(dir)//
"/"// trim(restartname)
3407 restartpath = trim(restartname)
3410 num_x_axes =
unique_axes(fileobj, 1, id_x_axes, siz_x_axes)
3411 num_y_axes =
unique_axes(fileobj, 2, id_y_axes, siz_y_axes)
3412 num_z_axes =
unique_axes(fileobj, 3, id_z_axes, siz_z_axes)
3414 call mpp_open(unit,trim(restartpath),action=mpp_overwr,
form=mpp_netcdf,threading=mpp_single,&
3415 fileset=mpp_single, is_root_pe=fileobj%is_root_pe)
3424 do j = 1, num_x_axes
3426 do l=1, fileobj%nvar
3427 if(fileobj%var(l)%read_only) cycle
3428 if (fileobj%var(l)%id_axes(1) == j)
exit 3430 if( l > fileobj%nvar ) cycle
3431 naxes_x = naxes_x + 1
3432 x_axes_indx(naxes_x) = j
3433 if (naxes_x < 10)
then 3434 write(axisname,
'(a,i1)')
'xaxis_',naxes_x
3436 write(axisname,
'(a,i2)')
'xaxis_',naxes_x
3439 data=axisdata(1:siz_x_axes(j)),cartesian=
'X')
3444 do j = 1, num_y_axes
3446 do l=1, fileobj%nvar
3447 if(fileobj%var(l)%read_only) cycle
3448 if (fileobj%var(l)%id_axes(2) == j)
exit 3450 if( l > fileobj%nvar ) cycle
3451 naxes_y = naxes_y + 1
3452 y_axes_indx(naxes_y) = j
3453 if (naxes_y < 10)
then 3454 write(axisname,
'(a,i1)')
'yaxis_',naxes_y
3456 write(axisname,
'(a,i2)')
'yaxis_',naxes_y
3459 data=axisdata(1:siz_y_axes(j)),cartesian=
'Y')
3464 do j = 1, num_z_axes
3466 do l=1, fileobj%nvar
3467 if(fileobj%var(l)%read_only) cycle
3468 if (fileobj%var(l)%id_axes(3) == j)
exit 3470 if( l > fileobj%nvar ) cycle
3471 naxes_z = naxes_z + 1
3472 z_axes_indx(naxes_z) = j
3473 if (naxes_z < 10)
then 3474 write(axisname,
'(a,i1)')
'zaxis_',naxes_z
3476 write(axisname,
'(a,i2)')
'zaxis_',naxes_z
3479 data=axisdata(1:siz_z_axes(j)),cartesian=
'Z')
3484 'Time',cartesian=
'T')
3487 do j = 1, fileobj%nvar
3488 cur_var => fileobj%var(j)
3489 if(cur_var%read_only) cycle
3490 if ((cur_var%siz(4) > 1) .AND. (cur_var%siz(4).NE.fileobj%max_ntime))
call mpp_error(fatal, &
3491 "fms_io(save_restart_border): "//trim(cur_var%name)//
" in file "//trim(fileobj%name)// &
3492 " has more than one time level, but number of time level is not equal to max_ntime")
3494 if (cur_var%ndim == 2)
then 3496 var_axes(1) = x_axes(cur_var%id_axes(1))
3497 var_axes(2) = y_axes(cur_var%id_axes(2))
3498 if(cur_var%siz(4) == fileobj%max_ntime)
then 3500 var_axes(3) = t_axes
3502 else if (cur_var%ndim == 3)
then 3504 var_axes(1) = x_axes(cur_var%id_axes(1))
3505 var_axes(2) = y_axes(cur_var%id_axes(2))
3506 var_axes(3) = z_axes(cur_var%id_axes(3))
3507 if(cur_var%siz(4) == fileobj%max_ntime)
then 3509 var_axes(4) = t_axes
3512 call mpp_error(fatal,
"fms_io(save_restart_border): "//trim(cur_var%name)//
" in file "// &
3513 trim(fileobj%name)//
" has more than three dimension (not including time level)")
3517 if (.not.any(mpp_pe().eq.cur_var%pelist(:))) cycle
3521 allocate(check_val(
max(1,cur_var%siz(4))))
3522 do k = 1, cur_var%siz(4)
3524 if (.not.any(mpp_pe().eq.cur_var%pelist(:))) cycle
3530 i1 = 1 + cur_var%x_halo
3532 j1 = 1 + cur_var%y_halo
3535 i_add = cur_var%ishift
3536 j_add = cur_var%jshift
3539 if(k <= cur_var%siz(4))
then 3540 if (
Associated(fileobj%p2dr(k,j)%p) )
then 3541 i_glob = cur_var%gsiz(1)
3542 j_glob = cur_var%gsiz(2)
3543 if (fileobj%is_root_pe)
allocate(r2d(i_glob, j_glob))
3544 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, cur_var%pelist, &
3545 fileobj%p2dr(k,j)%p(i1:i2,j1:j2), &
3546 r2d, fileobj%is_root_pe)
3548 if (
allocated(r2d))
deallocate(r2d)
3549 else if (
Associated(fileobj%p3dr(k,j)%p) )
then 3550 i_glob = cur_var%gsiz(1)
3551 j_glob = cur_var%gsiz(2)
3552 k_glob = cur_var%gsiz(3)
3553 if (fileobj%is_root_pe)
allocate(r3d(i_glob, j_glob, k_glob))
3554 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, cur_var%pelist, &
3555 fileobj%p3dr(k,j)%p(i1:i2,j1:j2,:), r3d, fileobj%is_root_pe)
3557 if (
allocated(r3d))
deallocate(r3d)
3559 call mpp_error(fatal,
"fms_io(save_restart_border): no pointer associated with data of field "// &
3560 trim(cur_var%name)//
" in file "//trim(fileobj%name) )
3564 call mpp_write_meta(unit,cur_var%field, var_axes(1:num_var_axes), cur_var%name, &
3565 cur_var%units,cur_var%longname,pack=
pack_size,checksum=check_val)
3566 if (
allocated(check_val))
deallocate(check_val)
3571 call mpp_write(unit,x_axes(x_axes_indx(j)))
3574 call mpp_write(unit,y_axes(y_axes_indx(j)))
3577 call mpp_write(unit,z_axes(z_axes_indx(j)))
3581 do k = 1, fileobj%max_ntime
3583 do j=1, fileobj%nvar
3584 cur_var => fileobj%var(j)
3585 if(cur_var%read_only) cycle
3587 if (.not.any(mpp_pe().eq.cur_var%pelist(:))) cycle
3593 i1 = 1 + cur_var%x_halo
3595 j1 = 1 + cur_var%y_halo
3598 i_add = cur_var%ishift
3599 j_add = cur_var%jshift
3602 if(k <= cur_var%siz(4))
then 3603 if (
Associated(fileobj%p2dr(k,j)%p))
then 3604 i_glob = cur_var%gsiz(1)
3605 j_glob = cur_var%gsiz(2)
3606 if (fileobj%is_root_pe)
allocate(r2d(i_glob, j_glob))
3607 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, cur_var%pelist, &
3608 fileobj%p2dr(k,j)%p(i1:i2,j1:j2), r2d, fileobj%is_root_pe)
3609 call mpp_write(unit, cur_var%field, r2d, tlev)
3610 if (
allocated(r2d))
deallocate(r2d)
3611 else if (
Associated(fileobj%p3dr(k,j)%p))
then 3612 i_glob = cur_var%gsiz(1)
3613 j_glob = cur_var%gsiz(2)
3614 k_glob = cur_var%gsiz(3)
3615 if (fileobj%is_root_pe)
allocate(r3d(i_glob, j_glob, k_glob))
3616 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, cur_var%pelist, &
3617 fileobj%p3dr(k,j)%p(i1:i2,j1:j2,:), r3d, fileobj%is_root_pe)
3618 call mpp_write(unit, cur_var%field, r3d, tlev)
3619 if (
allocated(r3d))
deallocate(r3d)
3621 call mpp_error(fatal,
"fms_io(save_restart_border): no pointer associated with data of field "// &
3622 trim(cur_var%name)//
" in file "//trim(fileobj%name) )
3627 call mpp_close(unit)
3646 character(len=*),
optional,
intent(in) :: directory
3647 logical,
optional,
intent(in) :: nonfatal_missing_files
3652 character(len=128) :: dir
3653 character(len=256) :: restartpath
3654 character(len=200) :: filepath
3655 character(len=80) :: varname
3656 character(len=256) :: mesg
3657 type(
var_type),
pointer,
save :: cur_var=>null()
3658 integer :: ndim, nvar, natt, ntime, tlev, siz
3659 type(
fieldtype),
allocatable :: fields(:)
3661 integer :: j, n, l, k, unit
3662 real,
allocatable,
dimension(:,:,:) :: r3d
3663 real,
allocatable,
dimension(:,:) :: r2d
3664 integer :: isc, iec, jsc, jec
3665 logical :: check_exist
3666 integer :: i1, i2, j1, j2
3667 integer :: ishift, jshift, i_add, j_add
3668 integer :: i_glob, j_glob, k_glob
3669 integer(LONG_KIND),
dimension(3) :: checksum_file
3670 integer(LONG_KIND) :: checksum_data
3671 logical :: is_there_a_checksum
3672 logical :: fatal_missing_files
3674 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(restore_state_border): " // &
3675 "restart_file_type data must be initialized by calling register_restart_field before using it")
3678 if(
present(directory)) dir = directory
3680 fatal_missing_files = .true.
3681 if (
present(nonfatal_missing_files)) fatal_missing_files = .not.nonfatal_missing_files
3683 if(len_trim(dir) > 0)
then 3684 restartpath = trim(dir)//
"/"// trim(fileobj%name)
3686 restartpath = trim(fileobj%name)
3692 inquire (file=trim(restartpath), exist=fexist)
3693 if (.not.fexist)
then ;
if (fatal_missing_files)
then 3694 call mpp_error(fatal,
"fms_io(restore_state_border): unable to find any restart files "// &
3695 "specified by "//trim(restartpath))
3696 elseif (mpp_pe() == mpp_root_pe())
then 3697 call mpp_error(warning,
"fms_io(restore_state_border): unable to find any restart files "// &
3698 "specified by "//trim(restartpath))
3702 call mpp_open(unit,trim(restartpath),action=mpp_rdonly,
form=mpp_netcdf,threading=mpp_single,&
3703 fileset=mpp_single, is_root_pe=fileobj%is_root_pe)
3706 call mpp_get_info(unit, ndim, nvar, natt, ntime)
3708 allocate(fields(nvar))
3709 call mpp_get_fields(unit,fields(1:nvar))
3712 cur_var => fileobj%var(j)
3714 if (.not.any(mpp_pe().eq.cur_var%pelist(:))) cycle
3720 i1 = 1 + cur_var%x_halo
3722 j1 = 1 + cur_var%y_halo
3725 i_add = cur_var%ishift
3726 j_add = cur_var%jshift
3729 if (lowercase(trim(varname)) == lowercase(trim(cur_var%name)))
then 3730 cur_var%initialized = .true.
3731 check_exist = mpp_attribute_exist(fields(l),
"checksum")
3733 is_there_a_checksum = .false.
3734 if ( check_exist )
then 3736 is_there_a_checksum = .true.
3740 do k = 1, cur_var%siz(4)
3743 if (
Associated(fileobj%p2dr(k,j)%p))
then 3744 i_glob = cur_var%gsiz(1)
3745 j_glob = cur_var%gsiz(2)
3746 if (fileobj%is_root_pe)
allocate(r2d(i_glob, j_glob))
3747 call mpp_read(unit, fields(l), r2d, tlev)
3748 call mpp_scatter(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, cur_var%pelist, &
3749 fileobj%p2dr(k,j)%p(i1:i2,j1:j2), r2d, fileobj%is_root_pe)
3750 if ((fileobj%is_root_pe) .and. (is_there_a_checksum)) checksum_data =
mpp_chksum(r2d, (/mpp_pe()/) )
3751 if (
allocated(r2d))
deallocate(r2d)
3752 else if (
Associated(fileobj%p3dr(k,j)%p))
then 3753 i_glob = cur_var%gsiz(1)
3754 j_glob = cur_var%gsiz(2)
3755 k_glob = cur_var%gsiz(3)
3756 if (fileobj%is_root_pe)
allocate(r3d(i_glob, j_glob, k_glob))
3757 call mpp_read(unit, fields(l), r3d, tlev)
3758 call mpp_scatter(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, cur_var%pelist, &
3759 fileobj%p3dr(k,j)%p(i1:i2,j1:j2,:), r3d, fileobj%is_root_pe)
3760 if ((fileobj%is_root_pe) .and. (is_there_a_checksum)) checksum_data =
mpp_chksum(r3d, (/mpp_pe()/) )
3761 if (
allocated(r3d))
deallocate(r3d)
3763 call mpp_error(fatal,
"fms_io(retore_state_border): no pointer associated with data of field "// &
3764 trim(cur_var%name)//
" in file "//trim(fileobj%name) )
3766 if ((fileobj%is_root_pe) .and. (is_there_a_checksum) .and. (checksum_file(k)/=checksum_data))
then 3767 write (mesg,
'(a,Z16,a,Z16,a)')
"Checksum of input field "// uppercase(trim(varname))//
" ", checksum_data,&
3768 " does not match value ", checksum_file(k),
" stored in "//uppercase(trim(fileobj%name)//
"." )
3769 call mpp_error(fatal,
"fms_io(restore_state_border): "//trim(mesg) )
3785 do j = 1, fileobj%nvar
3786 if (.not.any(mpp_pe().eq.fileobj%var(j)%pelist(:))) cycle
3787 if (.NOT. fileobj%var(j)%initialized)
then 3788 if (fileobj%var(j)%mandatory)
then 3789 call mpp_error(fatal,
"fms_io(restore_state_border): unable to find mandatory variable "// &
3790 trim(fileobj%var(j)%name)//
" in restart file "//trim(fileobj%name) )
3804 type(restart_file_type),
intent(inout) :: fileObj
3805 integer,
intent(in) :: action
3806 integer(LONG_KIND) :: data_chksum
3807 integer :: j, k, outunit
3808 integer :: isc, iec, jsc, jec
3809 integer :: isg, ieg, jsg, jeg
3810 integer :: ishift, jshift, iadd, jadd
3811 type(var_type),
pointer,
save :: cur_var=>null()
3812 character(len=32) :: routine_name
3814 if(action == mpp_overwr)
then 3815 routine_name =
"save_restart" 3816 else if(action == mpp_rdonly)
then 3817 routine_name =
"restore_state" 3819 call mpp_error(fatal,
"fms_io_mod(write_chksum): action should be MPP_OVERWR or MPP_RDONLY")
3823 cur_var => fileobj%var(j)
3825 if ( cur_var%domain_idx > 0)
then 3828 call mpp_get_domain_shift(
array_domain(cur_var%domain_idx), ishift, jshift, cur_var%position)
3832 call mpp_get_domain_shift(
current_domain, ishift, jshift, cur_var%position)
3845 if(iec == ieg) iadd = iadd + ishift
3846 if(jec == jeg) jadd = jadd + jshift
3848 if(action == mpp_overwr .OR. (action == mpp_rdonly .AND. cur_var%initialized) )
then 3849 do k = 1, cur_var%siz(4)
3850 if (
Associated(fileobj%p0dr(k,j)%p) )
then 3851 data_chksum =
mpp_chksum(fileobj%p0dr(k,j)%p, (/mpp_pe()/) )
3852 else if (
Associated(fileobj%p1dr(k,j)%p) )
then 3853 data_chksum =
mpp_chksum(fileobj%p1dr(k,j)%p, (/mpp_pe()/) )
3854 else if (
Associated(fileobj%p2dr(k,j)%p) )
then 3855 data_chksum =
mpp_chksum(fileobj%p2dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
3856 else if (
Associated(fileobj%p3dr(k,j)%p) )
then 3857 data_chksum =
mpp_chksum(fileobj%p3dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :) )
3858 else if (
Associated(fileobj%p4dr(k,j)%p) )
then 3859 data_chksum =
mpp_chksum(fileobj%p4dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :, :) )
3860 else if (
Associated(fileobj%p0di(k,j)%p) )
then 3861 data_chksum = fileobj%p0di(k,j)%p
3862 else if (
Associated(fileobj%p1di(k,j)%p) )
then 3863 data_chksum =
mpp_chksum(fileobj%p1di(k,j)%p, (/mpp_pe()/) )
3864 else if (
Associated(fileobj%p2di(k,j)%p) )
then 3865 data_chksum =
mpp_chksum(fileobj%p2di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
3866 else if (
Associated(fileobj%p3di(k,j)%p) )
then 3867 data_chksum =
mpp_chksum(fileobj%p3di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :))
3869 call mpp_error(fatal,
"fms_io(write_chksum): There is no pointer associated with the data of field "// &
3870 trim(cur_var%name)//
" of file "//trim(fileobj%name) )
3873 write(outunit,
'(a, I1, a, Z16)')
'fms_io('//trim(routine_name)//
'): At time level = ', k,
', chksum for "'// &
3874 trim(cur_var%name)//
'" of "'// trim(fileobj%name)//
'" = ', data_chksum
3890 type(restart_file_type),
intent(inout) :: fileObj
3892 character(len=*),
optional,
intent(in) :: directory
3893 logical,
optional,
intent(in) :: nonfatal_missing_files
3900 character(len=128) :: dir
3901 character(len=256) :: restartpath
3902 character(len=200) :: filepath
3903 character(len=8) :: suffix
3905 character(len=80) :: varname
3906 character(len=256) :: filename
3907 character(len=256) :: mesg
3908 integer :: num_restart
3912 integer :: unit(max_split_file)
3913 type(var_type),
pointer,
save :: cur_var=>null()
3914 integer :: ndim, nvar, natt, ntime, tlev, siz
3915 type(fieldtype),
allocatable :: fields(:)
3916 logical :: fexist, domain_present
3917 integer :: j, n, l, k, missing_fields, domain_idx
3918 integer :: tile_id(1)
3919 real,
allocatable,
dimension(:,:,:) :: r3d
3920 real,
allocatable,
dimension(:,:) :: r2d
3921 real,
allocatable,
dimension(:) :: r1d
3923 type(domain2d),
pointer,
save :: io_domain=>null()
3924 integer :: isc, iec, jsc, jec
3925 logical :: check_exist
3926 integer :: isg, ieg, jsg, jeg
3927 integer :: ishift, jshift, iadd, jadd
3928 integer(LONG_KIND),
dimension(3) :: checksum_file
3929 integer(LONG_KIND) :: checksum_data
3930 logical :: is_there_a_checksum
3931 logical :: fatal_missing_files
3933 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(restore_state_all): " // &
3934 "restart_file_type data must be initialized by calling register_restart_field before using it")
3937 if(
present(directory)) dir = directory
3939 fatal_missing_files = .true.
3940 if (
present(nonfatal_missing_files)) fatal_missing_files = .not.nonfatal_missing_files
3944 if(len_trim(dir) > 0)
then 3945 restartpath = trim(dir)//
"/"// trim(fileobj%name)
3947 restartpath = trim(fileobj%name)
3950 domain_present = .false.
3951 do j = 1, fileobj%nvar
3952 if (fileobj%var(j)%domain_present)
then 3953 domain_present = .true.
3954 domain_idx = fileobj%var(j)%domain_idx
3962 if(domain_present)
then 3963 io_domain => mpp_get_io_domain(
array_domain(domain_idx))
3964 if(
associated(io_domain))
then 3965 tile_id = mpp_get_tile_id(io_domain)
3966 write(filename,
'(a,i4.4)' ) trim(restartpath)//
'.', tile_id(1)
3967 inquire (file=trim(filename), exist = fexist)
3968 if( .NOT. fexist )
then 3969 write(filename,
'(a,i6.6)' ) trim(restartpath)//
'.', tile_id(1)
3970 inquire (file=trim(filename), exist = fexist)
3978 call mpp_open(unit(nfile), trim(restartpath),
form=
form,action=mpp_rdonly, &
3982 if (num_restart < 10)
then 3983 write(suffix,
'("_",I1)') num_restart
3985 write(suffix,
'("_",I2)') num_restart
3987 if (num_restart > 0)
then 3988 siz = len_trim(restartpath)
3989 if(restartpath(siz-2:siz) ==
".nc")
then 3990 filepath = restartpath(1:siz-3)//trim(suffix)
3992 filepath = trim(restartpath) // trim(suffix)
3995 filepath = trim(restartpath)
3997 inquire (file=trim(filepath), exist=fexist)
3998 if(.not. fexist)
inquire(file=trim(filepath)//
".nc", exist=fexist)
4001 if(nfile > max_split_file)
call mpp_error(fatal, &
4002 "fms_io(restore_state_all): nfile is larger than max_split_file, increase max_split_file")
4003 call mpp_open(unit(nfile), trim(filepath),
form=
form,action=mpp_rdonly,threading=mpp_multi, &
4008 num_restart = num_restart + 1
4011 if (nfile == 0)
then ;
if (fatal_missing_files)
then 4012 call mpp_error(fatal,
"fms_io(restore_state_all): unable to find any restart files "// &
4013 "specified by "//trim(restartpath))
4014 elseif (mpp_pe() == mpp_root_pe())
then 4015 call mpp_error(warning,
"fms_io(restore_state_all): unable to find any restart files "// &
4016 "specified by "//trim(restartpath))
4022 call mpp_get_info(unit(n), ndim, nvar, natt, ntime)
4024 allocate(fields(nvar))
4025 call mpp_get_fields(unit(n),fields(1:nvar))
4030 cur_var => fileobj%var(j)
4031 domain_present = cur_var%domain_present
4032 domain_idx = cur_var%domain_idx
4034 if ( cur_var%domain_idx > 0)
then 4037 call mpp_get_domain_shift(
array_domain(cur_var%domain_idx), ishift, jshift, cur_var%position)
4041 call mpp_get_domain_shift(
current_domain, ishift, jshift, cur_var%position)
4054 if(iec == ieg) iadd = iadd + ishift
4055 if(jec == jeg) jadd = jadd + jshift
4063 if (lowercase(trim(varname)) == lowercase(trim(cur_var%name)))
then 4064 cur_var%initialized = .true.
4065 check_exist = mpp_attribute_exist(fields(l),
"checksum")
4067 is_there_a_checksum = .false.
4068 if ( check_exist )
then 4070 is_there_a_checksum = .true.
4074 do k = 1, cur_var%siz(4)
4076 if(domain_present)
then 4077 if(
Associated(fileobj%p0dr(k,j)%p) )
then 4078 call mpp_read(unit(n), fields(l), fileobj%p0dr(k,j)%p, tlev)
4079 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p0dr(k,j)%p, (/mpp_pe()/) )
4080 else if(
Associated(fileobj%p1dr(k,j)%p) )
then 4081 call mpp_read(unit(n), fields(l), fileobj%p1dr(k,j)%p, tlev)
4082 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p1dr(k,j)%p, (/mpp_pe()/) )
4083 else if(
Associated(fileobj%p2dr(k,j)%p) )
then 4085 if ( is_there_a_checksum ) &
4086 checksum_data =
mpp_chksum(fileobj%p2dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4087 else if(
Associated(fileobj%p3dr(k,j)%p) )
then 4089 if ( is_there_a_checksum ) &
4090 checksum_data =
mpp_chksum(fileobj%p3dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :) )
4091 else if(
Associated(fileobj%p2dr8(k,j)%p) )
then 4093 if ( is_there_a_checksum ) &
4094 checksum_data =
mpp_chksum(fileobj%p2dr8(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4095 else if(
Associated(fileobj%p3dr8(k,j)%p) )
then 4097 if ( is_there_a_checksum ) &
4098 checksum_data =
mpp_chksum(fileobj%p3dr8(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :) )
4099 else if(
Associated(fileobj%p4dr(k,j)%p) )
then 4101 if ( is_there_a_checksum ) &
4102 checksum_data =
mpp_chksum(fileobj%p4dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd,:,:))
4103 else if(
Associated(fileobj%p0di(k,j)%p) )
then 4104 call mpp_read(unit(n), fields(l), r0d, tlev)
4105 fileobj%p0di(k,j)%p = r0d
4106 if ( is_there_a_checksum ) checksum_data = fileobj%p0di(k,j)%p
4107 else if(
Associated(fileobj%p1di(k,j)%p) )
then 4108 allocate(r1d(cur_var%siz(1)))
4109 call mpp_read(unit(n), fields(l), r1d, tlev)
4110 fileobj%p1di(k,j)%p = r1d
4111 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p1di(k,j)%p, (/mpp_pe()/) )
4113 else if(
Associated(fileobj%p2di(k,j)%p) )
then 4114 allocate(r2d(cur_var%siz(1), cur_var%siz(2)) )
4117 fileobj%p2di(k,j)%p(isc:iec,jsc:jec) = r2d(isc:iec,jsc:jec)
4118 if ( is_there_a_checksum ) &
4119 checksum_data =
mpp_chksum(fileobj%p2di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4121 else if(
Associated(fileobj%p3di(k,j)%p) )
then 4122 allocate(r3d(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3)) )
4125 fileobj%p3di(k,j)%p(isc:iec,jsc:jec,:) = r3d(isc:iec,jsc:jec,:)
4126 if ( is_there_a_checksum ) &
4127 checksum_data =
mpp_chksum(fileobj%p3di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :))
4130 call mpp_error(fatal,
"fms_io(restore_state_all): domain is present for the field "//trim(varname)// &
4131 " of file "//trim(fileobj%name)//
", but none of p2dr, p3dr, p2di and p3di is associated")
4134 if(
Associated(fileobj%p0dr(k,j)%p) )
then 4135 call mpp_read(unit(n), fields(l), fileobj%p0dr(k,j)%p, tlev)
4136 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p0dr(k,j)%p, (/mpp_pe()/) )
4137 else if(
Associated(fileobj%p1dr(k,j)%p) )
then 4138 call mpp_read(unit(n), fields(l), fileobj%p1dr(k,j)%p, tlev)
4139 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p1dr(k,j)%p, (/mpp_pe()/) )
4140 else if(
Associated(fileobj%p2dr(k,j)%p) )
then 4141 call mpp_read(unit(n), fields(l), fileobj%p2dr(k,j)%p, tlev)
4142 if ( is_there_a_checksum ) &
4143 checksum_data =
mpp_chksum(fileobj%p2dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4144 else if(
Associated(fileobj%p3dr(k,j)%p) )
then 4145 call mpp_read(unit(n), fields(l), fileobj%p3dr(k,j)%p, tlev)
4146 if ( is_there_a_checksum ) &
4147 checksum_data =
mpp_chksum(fileobj%p3dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :) )
4148 else if(
Associated(fileobj%p4dr(k,j)%p) )
then 4149 call mpp_read(unit(n), fields(l), fileobj%p4dr(k,j)%p, tlev)
4150 if ( is_there_a_checksum ) &
4151 checksum_data =
mpp_chksum(fileobj%p4dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd,:,:))
4152 else if(
Associated(fileobj%p0di(k,j)%p) )
then 4153 call mpp_read(unit(n), fields(l), r0d, tlev)
4154 fileobj%p0di(k,j)%p = r0d
4155 if ( is_there_a_checksum ) checksum_data = fileobj%p0di(k,j)%p
4156 else if(
Associated(fileobj%p1di(k,j)%p) )
then 4157 allocate(r1d(cur_var%siz(1)) )
4158 call mpp_read(unit(n), fields(l), r1d, tlev)
4159 fileobj%p1di(k,j)%p = r1d
4160 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p1di(k,j)%p, (/mpp_pe()/) )
4162 else if(
Associated(fileobj%p2di(k,j)%p) )
then 4163 allocate(r2d(cur_var%siz(1), cur_var%siz(2)) )
4165 call mpp_read(unit(n), fields(l), r2d, tlev)
4166 fileobj%p2di(k,j)%p = r2d
4167 if ( is_there_a_checksum ) &
4168 checksum_data =
mpp_chksum(fileobj%p2di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4170 else if(
Associated(fileobj%p3di(k,j)%p) )
then 4171 allocate(r3d(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3)) )
4173 call mpp_read(unit(n), fields(l), r3d, tlev)
4174 fileobj%p3di(k,j)%p = r3d
4175 if ( is_there_a_checksum ) &
4176 checksum_data =
mpp_chksum(fileobj%p3di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :))
4179 call mpp_error(fatal,
"fms_io(restore_state_all): There is no pointer "//&
4180 "associated with the data of field "// trim(varname)//
" of file "//trim(fileobj%name) )
4183 if ( ( is_there_a_checksum ) .and. (checksum_file(k) /= checksum_data) )
then 4184 write (mesg,
'(a,Z16,a,Z16,a)')
"Checksum of input field "// uppercase(trim(varname))//
" ", checksum_data,&
4185 " does not match value ", checksum_file(k),
" stored in "//uppercase(trim(fileobj%name)//
"." )
4186 call mpp_error(fatal,
"fms_io(restore_state_all): "//trim(mesg) )
4192 if (l>nvar) missing_fields = missing_fields+1
4196 if (missing_fields == 0)
exit 4204 do j = 1, fileobj%nvar
4205 if( .NOT. fileobj%var(j)%initialized )
then 4206 if( fileobj%var(j)%mandatory )
then 4207 call mpp_error(fatal,
"fms_io(restore_state_all): unable to find mandatory variable "// &
4208 trim(fileobj%var(j)%name)//
" in restart file "//trim(fileobj%name) )
4225 type(restart_file_type),
intent(inout) :: fileObj
4227 integer,
intent(in) :: id_field
4229 character(len=*),
optional,
intent(in) :: directory
4230 logical,
optional,
intent(in) :: nonfatal_missing_files
4237 character(len=128) :: dir
4238 character(len=256) :: restartpath
4239 character(len=200) :: filepath
4240 character(len=8) :: suffix
4242 character(len=80) :: varname
4243 character(len=256) :: filename
4244 character(len=256) :: mesg
4245 integer :: num_restart
4249 integer :: unit(max_split_file)
4250 type(var_type),
pointer,
save :: cur_var=>null()
4251 integer :: ndim, nvar, natt, ntime, tlev, siz
4252 integer :: tile_id(1)
4253 type(fieldtype),
allocatable :: fields(:)
4254 logical :: fexist, domain_present
4255 integer :: j, n, l, k, missing_fields, domain_idx
4256 real,
allocatable,
dimension(:,:,:) :: r3d
4257 real,
allocatable,
dimension(:,:) :: r2d
4258 real,
allocatable,
dimension(:) :: r1d
4260 type(domain2d),
pointer,
save :: io_domain=>null()
4261 integer :: isc, iec, jsc, jec
4262 logical :: check_exist
4263 integer :: isg, ieg, jsg, jeg
4264 integer :: ishift, jshift, iadd, jadd
4265 integer(LONG_KIND),
dimension(3) :: checksum_file
4266 integer(LONG_KIND) :: checksum_data
4267 logical :: is_there_a_checksum
4268 logical :: fatal_missing_files
4270 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(restore_state_one_field): " // &
4271 "restart_file_type data must be initialized by calling register_restart_field before using it")
4274 if(
present(directory)) dir = directory
4276 fatal_missing_files = .true.
4277 if (
present(nonfatal_missing_files)) fatal_missing_files = .not.nonfatal_missing_files
4279 cur_var => fileobj%var(id_field)
4280 domain_present = cur_var%domain_present
4281 domain_idx = cur_var%domain_idx
4283 if ( cur_var%domain_idx > 0)
then 4286 call mpp_get_domain_shift(
array_domain(cur_var%domain_idx), ishift, jshift, cur_var%position)
4290 call mpp_get_domain_shift(
current_domain, ishift, jshift, cur_var%position)
4303 if(iec == ieg) iadd = iadd + ishift
4304 if(jec == jeg) jadd = jadd + jshift
4308 if(len_trim(dir) > 0)
then 4309 restartpath = trim(dir)//
"/"// trim(fileobj%name)
4311 restartpath = trim(fileobj%name)
4316 if(domain_present)
then 4317 io_domain => mpp_get_io_domain(
array_domain(domain_idx))
4318 if(
associated(io_domain))
then 4319 tile_id = mpp_get_tile_id(io_domain)
4320 write(filename,
'(a,i4.4)' ) trim(restartpath)//
'.', tile_id(1)
4321 inquire (file=trim(filename), exist = fexist)
4322 if( .NOT. fexist )
then 4323 write(filename,
'(a,i6.6)' ) trim(restartpath)//
'.', tile_id(1)
4324 inquire (file=trim(filename), exist = fexist)
4333 call mpp_open(unit(nfile), trim(restartpath),
form=
form,action=mpp_rdonly, &
4337 if (num_restart < 10)
then 4338 write(suffix,
'("_",I1)') num_restart
4340 write(suffix,
'("_",I2)') num_restart
4342 if (num_restart > 0)
then 4343 siz = len_trim(restartpath)
4344 if(restartpath(siz-2:siz) ==
".nc")
then 4345 filepath = restartpath(1:siz-3)//trim(suffix)
4347 filepath = trim(restartpath) // trim(suffix)
4350 filepath = trim(restartpath)
4352 inquire (file=trim(filepath), exist=fexist)
4353 if(.not. fexist)
inquire(file=trim(filepath)//
".nc", exist=fexist)
4356 if(nfile > max_split_file)
call mpp_error(fatal, &
4357 "fms_io(restore_state_one_field): nfile is larger than max_split_file, increase max_split_file")
4358 call mpp_open(unit(nfile), trim(filepath),
form=
form,action=mpp_rdonly,threading=mpp_multi, &
4363 num_restart = num_restart + 1
4366 if (nfile == 0)
then ;
if (fatal_missing_files)
then 4367 call mpp_error(fatal,
"fms_io(restore_state_all): unable to find any restart files "// &
4368 "specified by "//trim(restartpath))
4369 elseif (mpp_pe() == mpp_root_pe())
then 4370 call mpp_error(warning,
"fms_io(restore_state_all): unable to find any restart files "// &
4371 "specified by "//trim(restartpath))
4377 call mpp_get_info(unit(n), ndim, nvar, natt, ntime)
4379 allocate(fields(nvar))
4380 call mpp_get_fields(unit(n),fields(1:nvar))
4386 if (lowercase(trim(varname)) == lowercase(trim(cur_var%name)))
then 4387 cur_var%initialized = .true.
4388 check_exist = mpp_attribute_exist(fields(l),
"checksum")
4390 is_there_a_checksum = .false.
4391 if ( check_exist )
then 4393 is_there_a_checksum = .true.
4400 do k = 1, cur_var%siz(4)
4402 if(domain_present)
then 4403 if(
Associated(fileobj%p0dr(k,j)%p) )
then 4404 call mpp_read(unit(n), fields(l), fileobj%p0dr(k,j)%p, tlev)
4405 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p0dr(k,j)%p, (/mpp_pe()/) )
4406 else if(
Associated(fileobj%p1dr(k,j)%p) )
then 4407 call mpp_read(unit(n), fields(l), fileobj%p1dr(k,j)%p, tlev)
4408 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p1dr(k,j)%p, (/mpp_pe()/) )
4409 else if(
Associated(fileobj%p2dr(k,j)%p) )
then 4411 if ( is_there_a_checksum ) checksum_data =&
4412 &
mpp_chksum(fileobj%p2dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4413 else if(
Associated(fileobj%p3dr(k,j)%p) )
then 4415 if ( is_there_a_checksum ) checksum_data =&
4416 &
mpp_chksum(fileobj%p3dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :) )
4417 else if(
Associated(fileobj%p4dr(k,j)%p) )
then 4419 if ( is_there_a_checksum ) checksum_data =&
4420 &
mpp_chksum(fileobj%p4dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :,:) )
4421 else if(
Associated(fileobj%p0di(k,j)%p) )
then 4422 call mpp_read(unit(n), fields(l), r0d, tlev)
4423 fileobj%p0di(k,j)%p = r0d
4424 if ( is_there_a_checksum ) checksum_data = fileobj%p0di(k,j)%p
4425 else if(
Associated(fileobj%p1di(k,j)%p) )
then 4426 allocate(r1d(cur_var%siz(1)))
4427 call mpp_read(unit(n), fields(l), r1d, tlev)
4428 fileobj%p1di(k,j)%p = r1d
4429 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p1di(k,j)%p, (/mpp_pe()/) )
4431 else if(
Associated(fileobj%p2di(k,j)%p) )
then 4432 allocate(r2d(cur_var%siz(1), cur_var%siz(2)) )
4435 fileobj%p2di(k,j)%p(isc:iec,jsc:jec) = r2d(isc:iec,jsc:jec)
4436 if ( is_there_a_checksum ) checksum_data =&
4437 &
mpp_chksum(fileobj%p2di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4439 else if(
Associated(fileobj%p3di(k,j)%p) )
then 4440 allocate(r3d(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3)) )
4443 fileobj%p3di(k,j)%p(isc:iec,jsc:jec,:) = r3d(isc:iec,jsc:jec,:)
4444 if ( is_there_a_checksum ) checksum_data =&
4445 &
mpp_chksum(fileobj%p3di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :))
4448 call mpp_error(fatal,
"fms_io(restore_state_one_field): domain is present for the field "//trim(varname)// &
4449 " of file "//trim(fileobj%name)//
", but none of p2dr, p3dr, p2di and p3di is associated")
4452 if(
Associated(fileobj%p0dr(k,j)%p) )
then 4453 call mpp_read(unit(n), fields(l), fileobj%p0dr(k,j)%p, tlev)
4454 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p0dr(k,j)%p, (/mpp_pe()/) )
4455 else if(
Associated(fileobj%p1dr(k,j)%p) )
then 4456 call mpp_read(unit(n), fields(l), fileobj%p1dr(k,j)%p, tlev)
4457 if ( is_there_a_checksum ) checksum_data =
mpp_chksum(fileobj%p1dr(k,j)%p, (/mpp_pe()/) )
4458 else if(
Associated(fileobj%p2dr(k,j)%p) )
then 4459 call mpp_read(unit(n), fields(l), fileobj%p2dr(k,j)%p, tlev)
4460 if ( is_there_a_checksum ) checksum_data =&
4461 &
mpp_chksum(fileobj%p2dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4462 else if(
Associated(fileobj%p3dr(k,j)%p) )
then 4463 call mpp_read(unit(n), fields(l), fileobj%p3dr(k,j)%p, tlev)
4464 if ( is_there_a_checksum ) checksum_data =&
4465 &
mpp_chksum(fileobj%p3dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :) )
4466 else if(
Associated(fileobj%p4dr(k,j)%p) )
then 4467 call mpp_read(unit(n), fields(l), fileobj%p4dr(k,j)%p, tlev)
4468 if ( is_there_a_checksum ) checksum_data =&
4469 &
mpp_chksum(fileobj%p4dr(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :, :) )
4470 else if(
Associated(fileobj%p0di(k,j)%p) )
then 4471 call mpp_read(unit(n), fields(l), r0d, tlev)
4472 fileobj%p0di(k,j)%p = r0d
4473 if ( is_there_a_checksum ) checksum_data = fileobj%p0di(k,j)%p
4474 else if(
Associated(fileobj%p1di(k,j)%p) )
then 4475 allocate(r1d(cur_var%siz(1)) )
4476 call mpp_read(unit(n), fields(l), r1d, tlev)
4477 fileobj%p1di(k,j)%p = r1d
4478 if ( is_there_a_checksum ) checksum_data = fileobj%p0di(k,j)%p
4480 else if(
Associated(fileobj%p2di(k,j)%p) )
then 4481 allocate(r2d(cur_var%siz(1), cur_var%siz(2)) )
4483 call mpp_read(unit(n), fields(l), r2d, tlev)
4484 fileobj%p2di(k,j)%p = r2d
4485 if ( is_there_a_checksum ) checksum_data =&
4486 &
mpp_chksum(fileobj%p2di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd) )
4488 else if(
Associated(fileobj%p3di(k,j)%p) )
then 4489 allocate(r3d(cur_var%siz(1), cur_var%siz(2), cur_var%siz(3)) )
4491 call mpp_read(unit(n), fields(l), r3d, tlev)
4492 fileobj%p3di(k,j)%p = r3d
4493 if ( is_there_a_checksum ) checksum_data =&
4494 &
mpp_chksum(fileobj%p3di(k,j)%p(cur_var%is:cur_var%is+iadd,cur_var%js:cur_var%js+jadd, :))
4497 call mpp_error(fatal,
"fms_io(restore_state_one_field): There is no pointer "// &
4498 "associated with the data of field "//trim(varname)//
" of file "//trim(fileobj%name) )
4501 if ( (is_there_a_checksum ) .and. (checksum_file(k) /= checksum_data) )
then 4502 write (mesg,
'(a,Z16,a,Z16,a)')
"Checksum of input field "// uppercase(trim(varname)), checksum_data,&
4503 " does not match value ", checksum_file(k),
"stored in "//uppercase(trim(fileobj%name)//
"." )
4504 call mpp_error(fatal,
"fms_io(restore_state_one_field): "//trim(mesg) )
4510 if (l>nvar) missing_fields = missing_fields+1
4512 if (missing_fields == 0)
exit 4520 if( .NOT. fileobj%var(id_field)%initialized )
then 4521 if( fileobj%var(id_field)%mandatory )
then 4522 call mpp_error(fatal,
"fms_io(restore_state_one_field): unable to find mandatory variable "// &
4523 trim(fileobj%var(id_field)%name)//
" in restart file "//trim(fileobj%name) )
4535 subroutine setup_one_field(fileObj, filename, fieldname, field_siz, index_field, domain, mandatory, &
4536 no_domain, scalar_or_1d, position, tile_count, data_default, longname, units, &
4537 compressed_axis, read_only, owns_data)
4538 type(restart_file_type),
intent(inout) :: fileObj
4539 character(len=*),
intent(in) :: filename, fieldname
4540 integer,
dimension(:),
intent(in) :: field_siz
4541 integer,
intent(out) :: index_field
4542 type(domain2d),
optional,
intent(in),
target :: domain
4543 real,
optional,
intent(in) :: data_default
4544 logical,
optional,
intent(in) :: no_domain
4545 logical,
optional,
intent(in) :: scalar_or_1d
4546 integer,
optional,
intent(in) :: position, tile_count
4547 logical,
optional,
intent(in) :: mandatory
4548 character(len=*),
optional,
intent(in) :: longname, units, compressed_axis
4549 logical,
optional,
intent(in) :: owns_data
4550 logical,
optional,
intent(in) :: read_only
4553 integer :: i, domain_idx
4554 integer :: ishift, jshift
4555 integer :: gxsize, gysize
4556 integer :: cxsize, cysize
4557 integer :: dxsize, dysize
4558 real :: default_data
4559 logical :: is_no_domain = .false.
4560 logical :: is_scalar_or_1d = .false.
4561 character(len=256) :: fname, filename2, append_string
4562 type(domain2d),
pointer,
save :: d_ptr =>null()
4563 type(var_type),
pointer,
save :: cur_var =>null()
4564 integer :: length, n_field_siz
4566 if(any(field_siz < 0))
then 4567 call mpp_error(fatal,
"fms_io(setup_one_field): each entry of field_size should be a non-negative integer")
4570 if(
PRESENT(data_default))
then 4571 default_data=data_default
4573 default_data = mpp_fill_double
4576 if(
present(tile_count) .AND. .not.
present(domain))
call mpp_error(fatal, &
4577 'fms_io(setup_one_field): when tile_count is present, domain must be present')
4579 is_scalar_or_1d = .false.
4580 if(
PRESENT(scalar_or_1d)) is_scalar_or_1d = scalar_or_1d
4582 is_no_domain = .false.
4583 if (
PRESENT(no_domain))
THEN 4584 is_no_domain = no_domain
4587 if(is_no_domain)
then 4588 if(
PRESENT(domain)) &
4589 call mpp_error(fatal,
'fms_io(setup_one_field): no_domain cannot be .true. when optional argument domain is present.')
4590 else if(
PRESENT(domain))
then 4597 length = len_trim(filename)
4598 if(filename(length-2:length) ==
'.nc')
then 4599 filename2 = filename(1:length-3)
4601 filename2 = filename(1:length)
4609 if(len_trim(append_string) > 0) filename2 = trim(filename2)//
'.'//trim(append_string)
4616 if(
Associated(fileobj%var) )
then 4618 if(trim(fileobj%name) .NE. trim(fname))
call mpp_error(fatal,
'fms_io(setup_one_field): filename = '// &
4619 trim(fname)//
' is not consistent with the filename of the restart object = '//trim(fileobj%name) )
4637 'fms_io(setup_one_field): '//trim(fname)//
' is already registered with other restart_file_type data')
4643 'fms_io(setup_one_field): num_registered_files > max_files_w, increase fms_io_nml max_files_w')
4646 fileobj%name = trim(fname)
4647 fileobj%tile_count=1
4648 if(
present(tile_count)) fileobj%tile_count = tile_count
4649 if(
ASSOCIATED(d_ptr))
then 4650 fileobj%is_root_pe = mpp_domain_is_tile_root_pe(d_ptr)
4652 fileobj%is_root_pe = mpp_pe() == mpp_root_pe()
4654 fileobj%max_ntime = field_siz(4)
4658 fileobj%var(i)%name =
'none' 4659 fileobj%var(i)%domain_present = .false.
4660 fileobj%var(i)%domain_idx = -1
4661 fileobj%var(i)%is_dimvar = .false.
4662 fileobj%var(i)%position = center
4663 fileobj%var(i)%siz(:) = 0
4664 fileobj%var(i)%gsiz(:) = 0
4665 fileobj%var(i)%id_axes(:) = -1
4666 fileobj%var(i)%longname =
'';
4667 fileobj%var(i)%units =
'none';
4668 fileobj%var(i)%mandatory = .true.
4669 fileobj%var(i)%initialized = .false.
4670 fileobj%var(i)%compressed_axis =
'' 4671 fileobj%var(i)%read_only = .false.
4672 fileobj%var(i)%owns_data = .false.
4678 do i = 1, fileobj%nvar
4679 if(trim(fileobj%var(i)%name) == trim(fieldname))
then 4685 if(index_field > 0)
then 4686 cur_var => fileobj%var(index_field)
4687 if(cur_var%siz(1) .NE. field_siz(1) .OR. cur_var%siz(2) .NE. field_siz(2) .OR. cur_var%siz(3) .NE. field_siz(3) ) &
4688 call mpp_error(fatal,
'fms_io(setup_one_field): field size mismatch for field '// &
4689 trim(fieldname)//
' of file '//trim(filename) )
4691 cur_var%siz(4) = cur_var%siz(4) + field_siz(4)
4692 if(fileobj%max_ntime < cur_var%siz(4) ) fileobj%max_ntime = cur_var%siz(4)
4695 'the time level of field '//trim(cur_var%name)//
' in file '//trim(fileobj%name)// &
4696 ' is greater than MAX_TIME_LEVEL_REGISTER(=2), increase MAX_TIME_LEVEL_REGISTER or check your code')
4698 fileobj%nvar = fileobj%nvar +1
4701 call mpp_error(fatal,
'fms_io(setup_one_field): max_fields exceeded, needs increasing, nvar/max_fields=' &
4704 index_field = fileobj%nvar
4705 cur_var => fileobj%var(index_field)
4706 n_field_siz =
size(field_siz(:))
4707 cur_var%siz(1:n_field_siz) = field_siz(1:n_field_siz)
4708 cur_var%gsiz(3) = field_siz(3)
4709 if(n_field_siz == 5) cur_var%gsiz(4) = field_siz(5)
4710 cur_var%name = fieldname
4711 cur_var%default_data = default_data
4712 if(
present(mandatory)) cur_var%mandatory = mandatory
4713 if(
present(read_only)) cur_var%read_only = read_only
4714 if(
present(owns_data)) cur_var%owns_data = owns_data
4715 if(
present(longname))
then 4716 cur_var%longname = longname
4718 cur_var%longname = fieldname
4720 if(
present(units)) cur_var%units = units
4721 if(
present(position)) cur_var%position = position
4722 if(
present(compressed_axis)) cur_var%compressed_axis = compressed_axis
4723 cur_var%is = 1; cur_var%ie = cur_var%siz(1)
4724 cur_var%js = 1; cur_var%je = cur_var%siz(2)
4726 if(
ASSOCIATED(d_ptr) .AND. .NOT. is_scalar_or_1d )
then 4727 cur_var%domain_present = .true.
4729 if(domain_idx == -1)
then 4732 //
' needs increasing')
4736 tile_count=tile_count)
4738 cur_var%domain_idx = domain_idx
4739 call mpp_get_domain_shift (
array_domain(domain_idx), ishift, jshift, position)
4743 if (ishift .NE. 0)
then 4744 cxsize = cxsize+ishift; dxsize = dxsize+ishift; gxsize = gxsize + ishift
4746 if (jshift .NE. 0)
then 4747 cysize = cysize+jshift; dysize = dysize+jshift; gysize = gysize + jshift
4749 if( (cur_var%siz(1) .NE. cxsize .AND. cur_var%siz(1) .NE. dxsize ) .OR. &
4750 (cur_var%siz(2) .NE. cysize .AND. cur_var%siz(2) .NE. dysize ) )
then 4751 call mpp_error(fatal,
'fms_io(setup_one_field): data should be on either compute domain '//&
4752 'or data domain when domain is present for field '//trim(fieldname)//
' of file '//trim(filename) )
4754 cur_var%is = 1 + (cur_var%siz(1) - cxsize)/2
4755 cur_var%ie = cur_var%is + cxsize - 1;
4756 cur_var%js = 1 + (cur_var%siz(2) - cysize)/2
4757 cur_var%je = cur_var%js + cysize - 1;
4758 cur_var%gsiz(1) = gxsize
4759 cur_var%gsiz(2) = gysize
4761 cur_var%domain_present=.false.
4762 cur_var%gsiz(1:2) = field_siz(1:2)
4773 no_domain, position,tile_count, data_default)
4775 character(len=*),
intent(in) :: filename, fieldname
4776 real,
dimension(:,:,:,:),
intent(in) :: data
4777 real,
dimension(size(data,1),size(data,2),size(data,3)*size(data,4)) :: data_3d
4778 real,
intent(in),
optional :: data_default
4779 type(domain2d),
intent(in),
optional :: domain
4780 logical,
intent(in),
optional :: no_domain
4781 integer,
intent(in),
optional :: position, tile_count
4786 do l = 1,
size(
data,4) ;
do k = 1,
size(
data,3)
4788 data_3d(:,:,i) =
data(:,:,k,l)
4792 no_domain, .false., position, tile_count, data_default)
4798 no_domain, position,tile_count, data_default)
4800 character(len=*),
intent(in) :: filename, fieldname
4801 real,
dimension(:,:),
intent(in) :: data
4802 real,
dimension(size(data,1),size(data,2),1) :: data_3d
4803 real,
intent(in),
optional :: data_default
4804 type(domain2d),
intent(in),
optional :: domain
4805 logical,
intent(in),
optional :: no_domain
4806 integer,
intent(in),
optional :: position, tile_count
4809 data_3d(:,:,1) =
data(:,:)
4812 no_domain, .false., position, tile_count, data_default)
4818 no_domain, tile_count, data_default)
4820 type(domain2d),
intent(in),
optional :: domain
4821 character(len=*),
intent(in) :: filename, fieldname
4822 real,
dimension(:),
intent(in) :: data
4823 real,
dimension(size(data(:)),1,1) :: data_3d
4824 real,
intent(in),
optional :: data_default
4825 logical,
intent(in),
optional :: no_domain
4826 integer,
intent(in),
optional :: tile_count
4829 data_3d(:,1,1) =
data(:)
4831 no_domain=no_domain, scalar_or_1d=.true., tile_count=tile_count, data_default=data_default)
4836 no_domain, tile_count, data_default)
4838 type(domain2d),
intent(in),
optional :: domain
4839 character(len=*),
intent(in) :: filename, fieldname
4840 real,
intent(in) :: data
4841 real,
dimension(1,1,1) :: data_3d
4842 real,
intent(in),
optional :: data_default
4843 logical,
intent(in),
optional :: no_domain
4844 integer,
intent(in),
optional :: tile_count
4848 data_3d(1,1,1) =
data 4850 no_domain=no_domain, scalar_or_1d=.true., tile_count=tile_count, data_default=data_default)
4858 integer,
intent(in) :: nfile
4859 character(len=*),
intent(in) :: fieldname
4865 if (trim(
files_read(nfile)%var(j)%name) == trim(fieldname))
then 4879 type(
domain2d),
intent(in) :: domain
4894 integer,
intent(in) :: axis_sizes(:), siz
4895 type(
domain1d),
optional :: domains(:)
4902 do j=1,
size(axis_sizes(:))
4903 if (siz == axis_sizes(j))
then 4904 if (
PRESENT(domains))
then 4905 if (dom .EQ. domains(j))
then 4915 if (
lookup_axis == -1)
call mpp_error(fatal,
'fms_io(lookup_axis): could not find axis in set of axes')
4940 subroutine field_size(filename, fieldname, siz, field_found, domain, no_domain )
4942 character(len=*),
intent(in) :: filename, fieldname
4943 integer,
intent(inout) :: siz(:)
4944 logical,
intent(out),
optional :: field_found
4945 type(
domain2d),
intent(in),
optional,
target :: domain
4946 logical,
intent(in),
optional :: no_domain
4948 integer :: nfile, unit
4949 logical :: found, found_file
4950 character(len=256) :: actual_file
4951 logical :: read_dist, io_domain_exist, is_no_domain
4953 if (
size(siz(:)) < 4)
call mpp_error(fatal,
'fms_io(field_size): size array must be >=4 to receive field size of ' &
4954 //trim(fieldname)//
' in file '// trim(filename))
4956 is_no_domain = .false.
4957 if(
present(no_domain)) is_no_domain = no_domain
4961 found_file =
get_file_name(filename, actual_file, read_dist, io_domain_exist, no_domain=is_no_domain, &
4964 if(is_no_domain .AND. .NOT. found_file)
call mpp_error(fatal, &
4965 'fms_io_mod(field_size): file '//trim(filename)//
' and corresponding distributed file are not found')
4968 call get_file_unit(actual_file, unit, nfile, read_dist, io_domain_exist, domain=domain)
4969 call get_size(unit,fieldname,siz,found)
4972 if(.not.found .AND. .not. is_no_domain)
then 4973 found_file =
get_file_name(filename, actual_file, read_dist, io_domain_exist, no_domain=.true.)
4975 call get_file_unit(actual_file, unit, nfile, read_dist, io_domain_exist, domain=domain)
4976 call get_size(unit,fieldname,siz,found)
4982 if(
PRESENT(field_found) )
then 4984 else if (.not. found )
then 4985 call mpp_error(fatal,
'fms_io(field_size): field '//trim(fieldname)//
' NOT found in file '//trim(actual_file))
4991 subroutine file_unit(filename, found_file, unit, domain, no_domain)
4993 character(len=*),
intent(in) :: filename
4994 logical,
intent(out) :: found_file
4995 integer,
intent(out) :: unit
4996 type(domain2d),
intent(in),
optional,
target :: domain
4997 logical,
intent(in),
optional :: no_domain
5000 character(len=256) :: actual_file
5001 logical :: read_dist, io_domain_exist, is_no_domain
5004 is_no_domain = .false.
5005 if(
present(no_domain)) is_no_domain = no_domain
5009 found_file =
get_file_name(filename, actual_file, read_dist, io_domain_exist, no_domain=is_no_domain, &
5013 if(is_no_domain .AND. .NOT. found_file)
call mpp_error(fatal, &
5014 'fms_io_mod(field_size): file '//trim(filename)//
' and corresponding distributed file are not found')
5017 call get_file_unit(actual_file, unit, nfile, read_dist, io_domain_exist, domain=domain)
5018 else if(.not. is_no_domain)
then 5019 found_file =
get_file_name(filename, actual_file, read_dist, io_domain_exist, no_domain=.true.)
5021 call get_file_unit(actual_file, unit, nfile, read_dist, io_domain_exist, domain=domain)
5045 character(len=*),
intent(in) :: filename, dimname
5046 type(
domain2d),
intent(in),
optional,
target :: domain
5047 logical,
intent(in),
optional :: no_domain
5050 integer :: nfile, unit
5051 logical :: found, found_file
5052 character(len=256) :: actual_file
5053 logical :: read_dist, io_domain_exist, is_no_domain
5055 is_no_domain = .false.
5056 if(
present(no_domain)) is_no_domain = no_domain
5060 found_file =
get_file_name(filename, actual_file, read_dist, io_domain_exist, no_domain=is_no_domain, &
5063 if(is_no_domain .AND. .NOT. found_file)
call mpp_error(fatal, &
5064 'fms_io_mod(dimesion_size): file '//trim(filename)//
' and corresponding distributed file are not found')
5067 call get_file_unit(actual_file, unit, nfile, read_dist, io_domain_exist, domain=domain)
5071 if(.not.found .AND. .not. is_no_domain)
then 5072 found_file =
get_file_name(filename, actual_file, read_dist, io_domain_exist, no_domain=.true.)
5074 call get_file_unit(actual_file, unit, nfile, read_dist, io_domain_exist, domain=domain)
5080 'fms_io_mod(dimesion_size): failed at inquiring size of dimesion '//trim(dimname)//
' from file '//trim(filename))
5111 subroutine get_field_size(filename, fieldname, siz, field_found, domain, no_domain)
5113 character(len=*),
intent(in) :: filename, fieldname
5114 integer,
intent(inout) :: siz(:)
5115 logical,
intent(out),
optional :: field_found
5116 type(
domain2d),
intent(in),
optional,
target :: domain
5117 logical,
intent(in),
optional :: no_domain
5119 integer :: npes, p, unit
5120 integer,
allocatable :: pelist(:)
5121 logical :: found, found_file
5122 type(
domain2d),
pointer :: domain_in =>null()
5123 type(
domain2d),
pointer :: io_domain =>null()
5126 if(
PRESENT(domain))
then 5131 call mpp_error(fatal,
'fms_io(get_field_size): The domain must be defined')
5134 io_domain =>mpp_get_io_domain(domain)
5135 if(.not.
ASSOCIATED(io_domain))
call mpp_error(fatal,
'fms_io(get_field_size): The io domain must be defined')
5137 npes = mpp_get_domain_npes(io_domain)
5138 allocate(pelist(npes))
5141 call file_unit(filename, found_file, unit, domain, no_domain)
5143 if(mpp_pe() == pelist(1))
then 5145 if(found_file)
call get_size(unit,fieldname,siz,found)
5146 if(.not. found) siz(:) = -1
5151 if( mpp_pe() == pelist(1) )
then 5153 call mpp_send(siz(1), plen=
size(siz(:)), to_pe=pelist(p), tag=comm_tag_1)
5155 call mpp_sync_self()
5157 call mpp_recv(siz(1), glen=
size(siz(:)), from_pe=pelist(1), block=.false., tag=comm_tag_1)
5158 call mpp_sync_self(check=event_recv)
5162 if(siz(1) == -1) found=.false.
5166 if(
PRESENT(field_found) )
then 5168 else if (.not. found )
then 5169 call mpp_error(fatal,
'fms_io(field_size): field '//trim(fieldname)//
' NOT found in file '//trim(filename))
5174 subroutine get_size(unit, fieldname, siz, found)
5175 integer,
intent(in) :: unit
5176 character(len=*),
intent(in) :: fieldname
5177 integer,
intent(inout) :: siz(:)
5178 logical,
intent(out) :: found
5180 character(len=128) :: name
5181 character(len=1) :: cart
5182 integer :: i, ndim, nvar, natt, ntime, siz_in(4), j, len
5183 type(fieldtype) :: fields(max_fields)
5184 type(axistype) :: axes(max_fields)
5186 call mpp_get_info(unit,ndim,nvar,natt,ntime)
5187 if (nvar > max_fields)
then 5188 write(
error_msg,
'(I3,"/",I3)') nvar,max_fields
5189 call mpp_error(fatal,
'fms_io(field_size): max_fields too small, needs increasing, nvar/max_fields=' &
5192 call mpp_get_fields(unit,fields(1:nvar))
5195 if (lowercase(trim(name)) == lowercase(trim(fieldname)))
then 5223 if(.not. found)
then 5224 call mpp_get_axes(unit,axes(1:ndim))
5227 if (lowercase(trim(name)) == lowercase(trim(fieldname)))
then 5262 no_domain,position, tile_count)
5263 character(len=*),
intent(in) :: filename, fieldname
5264 integer,
dimension(:,:,:),
intent(inout) :: data
5265 type(domain2d),
intent(in),
optional :: domain
5266 integer,
intent(in),
optional :: timelevel
5267 logical,
intent(in),
optional :: no_domain
5268 integer,
intent(in) ,
optional :: position, tile_count
5270 real,
dimension(size(data,1),size(data,2),size(data,3)) :: r_data
5273 no_domain, .false., position, tile_count)
5274 data = ceiling(r_data)
5278 no_domain,position, tile_count)
5279 character(len=*),
intent(in) :: filename, fieldname
5280 integer,
dimension(:,:),
intent(inout) :: data
5281 type(domain2d),
intent(in),
optional :: domain
5282 integer,
intent(in),
optional :: timelevel
5283 logical,
intent(in),
optional :: no_domain
5284 integer,
intent(in) ,
optional :: position, tile_count
5285 real,
dimension(size(data,1),size(data,2)) :: r_data
5289 no_domain, position, tile_count)
5290 data = ceiling(r_data)
5294 no_domain, tile_count)
5295 character(len=*),
intent(in) :: filename, fieldname
5296 integer,
dimension(:),
intent(inout) :: data
5297 type(domain2d),
intent(in),
optional :: domain
5298 integer,
intent(in) ,
optional :: timelevel
5299 logical,
intent(in),
optional :: no_domain
5300 integer,
intent(in),
optional :: tile_count
5302 real,
dimension(size(data,1)) :: r_data
5305 no_domain, tile_count)
5306 data = ceiling(r_data)
5310 no_domain, tile_count)
5311 character(len=*),
intent(in) :: filename, fieldname
5312 integer,
intent(inout) :: data
5313 type(domain2d),
intent(in),
optional :: domain
5314 integer,
intent(in) ,
optional :: timelevel
5315 logical,
intent(in),
optional :: no_domain
5316 integer,
intent(in),
optional :: tile_count
5320 no_domain, tile_count)
5321 data = ceiling(r_data)
5325 no_domain, scalar_or_1d, position, tile_count)
5326 character(len=*),
intent(in) :: filename, fieldname
5327 real,
dimension(:,:,:),
intent(inout) :: data
5328 type(domain2d),
target,
optional,
intent(in) :: domain
5329 integer,
optional,
intent(in) :: timelevel
5330 logical,
optional,
intent(in) :: no_domain
5331 logical,
optional,
intent(in) :: scalar_or_1d
5332 integer,
optional,
intent(in) :: position, tile_count
5334 character(len=256) :: fname
5335 integer :: unit, siz_in(4)
5336 integer :: file_index
5338 integer :: index_field
5339 integer :: cxsize, cysize
5340 integer :: dxsize, dysize
5341 integer :: gxsize, gysize
5342 integer :: ishift, jshift
5343 logical :: is_scalar_or_1d = .false.
5344 logical :: is_no_domain = .false.
5345 logical :: read_dist, io_domain_exist, found_file
5346 type(domain2d),
pointer,
save :: d_ptr =>null()
5347 type(domain2d),
pointer,
save :: io_domain =>null()
5355 is_no_domain = .false.
5356 if (
PRESENT(no_domain))
THEN 5357 if(
PRESENT(domain) .AND. no_domain) &
5358 call mpp_error(fatal,
'fms_io(read_data_3d_new): no_domain cannot be .true. when optional argument domain is present.')
5359 is_no_domain = no_domain
5362 if(
PRESENT(domain))
then 5364 elseif (
ASSOCIATED(
current_domain) .AND. .NOT. is_no_domain )
then 5368 is_scalar_or_1d = .false.
5369 if(
present(scalar_or_1d)) is_scalar_or_1d = scalar_or_1d
5371 if(.not.
PRESENT(domain) .and. .not.
ASSOCIATED(
current_domain) ) is_no_domain = .true.
5373 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, is_no_domain, domain, tile_count)
5374 if(.not.found_file)
call mpp_error(fatal,
'fms_io_mod(read_data_3d_new): file ' //trim(filename)// &
5375 '(with the consideration of tile number) and corresponding distributed file are not found')
5376 call get_file_unit(fname, unit, file_index, read_dist, io_domain_exist, domain=domain)
5378 siz_in(3) =
size(
data,3)
5379 if(is_no_domain .or. .NOT.
associated(d_ptr) .or. is_scalar_or_1d)
then 5380 gxsize =
size(
data,1)
5381 gysize =
size(
data,2)
5382 else if(read_dist)
then 5383 if(io_domain_exist)
then 5384 io_domain=>mpp_get_io_domain(d_ptr)
5385 call mpp_get_global_domain(io_domain, xsize = gxsize, ysize = gysize, tile_count=tile_count, position=position)
5388 call mpp_get_compute_domain(d_ptr, xsize = gxsize, ysize = gysize, tile_count=tile_count, position=position)
5391 call mpp_get_compute_domain(d_ptr, xsize = cxsize, ysize = cysize, tile_count=tile_count, position=position)
5392 call mpp_get_data_domain (d_ptr, xsize = dxsize, ysize = dysize, tile_count=tile_count, position=position)
5393 call mpp_get_global_domain (d_ptr, xsize = gxsize, ysize = gysize, tile_count=tile_count, position=position)
5394 call mpp_get_domain_shift (d_ptr, ishift, jshift, position)
5395 if( (
size(
data,1) .NE. cxsize .AND.
size(
data,1) .NE. dxsize) .OR. &
5396 (
size(
data,2) .NE. cysize .AND.
size(
data,2) .NE. dysize) )
then 5397 call mpp_error(fatal,
'fms_io(read_data_3d_new): data should be on either compute domain '//&
5398 'or data domain when domain is present. '//&
5399 'shape(data)=',shape(data),
' cxsize,cysize,dxsize,dysize=',(/cxsize,cysize,dxsize,dysize/))
5403 if (
PRESENT(timelevel))
then 5409 call get_field_id(unit, file_index, fieldname, index_field, is_no_domain, .false. )
5410 siz_in(1:4) =
files_read(file_index)%var(index_field)%siz(1:4)
5411 if(
files_read(file_index)%var(index_field)%is_dimvar )
then 5412 if (.not. read_dist)
then 5413 if (siz_in(1) /= gxsize) &
5414 call mpp_error(fatal,
'fms_io(read_data_3d_new), field '//trim(fieldname)// &
5415 ' in file '//trim(filename)//
' field size mismatch 2')
5418 if (siz_in(1) /= gxsize .or. siz_in(2) /= gysize .or. siz_in(3) /=
size(
data,3))
then 5419 print *, gxsize, gysize,
size(
data, 3), siz_in(1), siz_in(2), siz_in(3)
5420 call mpp_error(fatal,
'fms_io(read_data_3d_new), field '//trim(fieldname)// &
5421 ' in file '//trim(filename)//
': field size mismatch 1')
5424 if ( tlev < 1 .or.
files_read(file_index)%max_ntime < tlev)
then 5426 call mpp_error(fatal,
'fms_io(read_data_3d_new): time level out of range, time level/max_time_level=' &
5427 //trim(
error_msg)//
' in field/file: '//trim(fieldname)//
'/'//trim(filename))
5430 if(is_no_domain .OR. is_scalar_or_1d)
then 5431 if (
files_read(file_index)%var(index_field)%is_dimvar)
then 5432 call mpp_get_axis_data(
files_read(file_index)%var(index_field)%axis,
data(:,1,1))
5437 call mpp_read(unit,
files_read(file_index)%var(index_field)%field,d_ptr,
data,tlev,tile_count)
5447 subroutine read_compressed_i1d(filename,fieldname,data,domain,timelevel,start,nread,threading)
5448 character(len=*),
intent(in) :: filename, fieldname
5449 integer,
dimension(:),
intent(inout) :: data
5450 type(domain2d),
intent(in),
optional :: domain
5451 integer,
intent(in) ,
optional :: timelevel
5452 integer,
intent(in) ,
optional :: start(:), nread(:)
5453 integer,
intent(in) ,
optional :: threading
5454 real,
dimension(size(data)) :: r_data
5457 call read_compressed_1d(filename,fieldname,r_data,domain,timelevel,start,nread,threading)
5458 data = ceiling(r_data)
5461 subroutine read_compressed_i2d(filename,fieldname,data,domain,timelevel,start,nread,threading)
5462 character(len=*),
intent(in) :: filename, fieldname
5463 integer,
dimension(:,:),
intent(inout) :: data
5464 type(domain2d),
intent(in),
optional :: domain
5465 integer,
intent(in),
optional :: timelevel
5466 integer,
intent(in) ,
optional :: start(:), nread(:)
5467 integer,
intent(in) ,
optional :: threading
5468 real,
dimension(size(data,1),size(data,2)) :: r_data
5471 call read_compressed_2d(filename,fieldname,r_data,domain,timelevel,start,nread,threading)
5472 data = ceiling(r_data)
5475 subroutine read_compressed_1d(filename,fieldname,data,domain,timelevel,start,nread,threading)
5476 character(len=*),
intent(in) :: filename, fieldname
5477 real,
dimension(:),
intent(inout) :: data
5478 real,
dimension(size(data,1),1) :: data_2d
5479 type(domain2d),
intent(in),
optional :: domain
5480 integer,
intent(in) ,
optional :: timelevel
5481 integer,
intent(in) ,
optional :: start(:), nread(:)
5482 integer,
intent(in) ,
optional :: threading
5483 #ifdef use_CRI_pointers 5484 pointer( p, data_2d )
5487 call read_compressed_2d(filename,fieldname,data_2d,domain,timelevel,start,nread,threading)
5490 subroutine read_compressed_2d(filename,fieldname,data,domain,timelevel,start,nread,threading)
5491 character(len=*),
intent(in) :: filename, fieldname
5492 real,
dimension(:,:),
intent(inout) :: data
5493 type(domain2d),
target,
optional,
intent(in) :: domain
5494 integer,
intent(in) ,
optional :: timelevel
5495 integer,
intent(in) ,
optional :: start(:), nread(:)
5496 integer,
intent(in) ,
optional :: threading
5498 character(len=256) :: fname
5499 integer :: unit, siz_in(4)
5500 integer :: file_index
5501 integer :: index_field
5502 logical :: read_dist, io_domain_exist, found_file
5503 type(domain2d),
pointer,
save :: d_ptr =>null()
5504 type(domain2d),
pointer,
save :: io_domain =>null()
5509 if(
PRESENT(domain))
then 5514 call mpp_error(fatal,
'fms_io(read_compressed_2d): Domain must be an argument or set by set_domain()')
5517 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, domain=d_ptr)
5518 if(.not. found_file)
then 5519 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, no_domain=.true. )
5521 if(.not.found_file)
call mpp_error(fatal,
'fms_io_mod(read_compressed_2d): file ' //trim(filename)// &
5522 '(with the consideration of tile number) and corresponding distributed file are not found')
5523 call get_file_unit(fname, unit, file_index, read_dist, io_domain_exist, domain=d_ptr)
5524 call get_field_id(unit, file_index, fieldname, index_field, .false., .false. )
5526 if (
files_read(file_index)%var(index_field)%is_dimvar)
then 5527 call mpp_get_axis_data(
files_read(file_index)%var(index_field)%axis,
data(:,1))
5536 character(len=*),
intent(in) :: filename, fieldname
5537 real,
dimension(:,:,:),
intent(inout) :: data
5538 type(domain2d),
target,
optional,
intent(in) :: domain
5539 integer,
intent(in) ,
optional :: timelevel
5541 character(len=256) :: fname
5543 integer :: file_index
5544 integer :: index_field
5545 logical :: read_dist, io_domain_exist, found_file
5546 type(domain2d),
pointer,
save :: d_ptr =>null()
5547 type(domain2d),
pointer,
save :: io_domain =>null()
5552 if(
PRESENT(domain))
then 5557 call mpp_error(fatal,
'fms_io(read_compressed_3d): Domain must be an argument or set by set_domain()')
5560 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, domain=d_ptr)
5561 if(.not. found_file)
then 5562 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, no_domain=.true. )
5564 if(.not.found_file)
call mpp_error(fatal,
'fms_io_mod(read_compressed_3d): file ' //trim(filename)// &
5565 '(with the consideration of tile number) and corresponding distributed file are not found')
5566 call get_file_unit(fname, unit, file_index, read_dist, io_domain_exist, domain=d_ptr)
5567 call get_field_id(unit, file_index, fieldname, index_field, .false., .false. )
5569 if (
files_read(file_index)%var(index_field)%is_dimvar)
then 5570 call mpp_get_axis_data(
files_read(file_index)%var(index_field)%axis,
data(:,1,1))
5579 integer,
intent(in) :: unit
5580 character(*),
intent(in) :: fmt
5581 integer,
intent(out) :: iostat
5582 character(len=*),
dimension(:),
intent(inout) :: data
5590 integer,
intent(in) :: unit
5591 character(*),
intent(in) :: fmt
5592 integer,
intent(out) :: iostat
5593 integer,
dimension(:),
intent(inout) :: data
5595 integer,
allocatable :: pelist(:)
5597 logical :: is_ioroot=.false.
5605 integer,
intent(in) :: unit
5606 character(*),
intent(in) :: fmt
5607 integer,
intent(out) :: iostat
5608 integer,
intent(inout) :: data
5620 integer,
intent(in) :: unit
5621 character(*),
intent(in) :: fmt
5622 integer,
intent(out) :: iostat
5623 real,
dimension(:,:,:),
intent(inout) :: data
5625 real :: data1D(size(data))
5635 integer,
intent(in) :: unit
5636 character(*),
intent(in) :: fmt
5637 integer,
intent(out) :: iostat
5638 real,
dimension(:,:,:,:,:),
intent(inout) :: data
5640 real :: data1D(size(data))
5650 integer,
intent(in) :: unit
5651 character(*),
intent(in) :: fmt
5652 integer,
intent(out) :: iostat
5653 real,
dimension(:),
intent(inout) :: data
5661 no_domain, tile_count)
5662 character(len=*),
intent(in) :: filename, fieldname
5663 real,
dimension(:,:),
intent(inout) :: data
5664 integer,
dimension(:),
intent(in) :: start, nread
5665 type(domain2d),
target,
optional,
intent(in) :: domain
5666 logical,
optional,
intent(in) :: no_domain
5667 integer,
optional,
intent(in) :: tile_count
5668 character(len=256) :: fname
5669 integer :: unit, siz_in(4)
5670 integer :: file_index
5671 integer :: index_field
5672 logical :: is_no_domain = .false.
5673 logical :: read_dist, io_domain_exist, found_file
5674 type(domain2d),
pointer,
save :: d_ptr =>null()
5679 is_no_domain = .false.
5680 if (
PRESENT(no_domain)) is_no_domain = no_domain
5682 if(
PRESENT(domain))
then 5684 elseif (
ASSOCIATED(
current_domain) .AND. .NOT. is_no_domain )
then 5688 if(.not.
PRESENT(domain) .and. .not.
ASSOCIATED(
current_domain) ) is_no_domain = .true.
5690 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, is_no_domain, domain, tile_count)
5691 if(.not.found_file)
call mpp_error(fatal,
'fms_io_mod(read_data_2d_region): file ' //trim(filename)// &
5692 '(with the consideration of tile number) and corresponding distributed file are not found')
5693 call get_file_unit(fname, unit, file_index, read_dist, io_domain_exist, domain=domain)
5696 call get_field_id(unit, file_index, fieldname, index_field, is_no_domain, .false. )
5697 siz_in(1:4) =
files_read(file_index)%var(index_field)%siz(1:4)
5698 if(
files_read(file_index)%var(index_field)%is_dimvar)
then 5699 call mpp_error(fatal,
'fms_io_mod(read_data_2d_region): the field should not be a dimension variable')
5709 no_domain, tile_count)
5710 character(len=*),
intent(in) :: filename, fieldname
5711 real,
dimension(:,:,:),
intent(inout) :: data
5712 integer,
dimension(:),
intent(in) :: start, nread
5713 type(domain2d),
target,
optional,
intent(in) :: domain
5714 logical,
optional,
intent(in) :: no_domain
5715 integer,
optional,
intent(in) :: tile_count
5716 character(len=256) :: fname
5717 integer :: unit, siz_in(4)
5718 integer :: file_index
5719 integer :: index_field
5720 logical :: is_no_domain = .false.
5721 logical :: read_dist, io_domain_exist, found_file
5722 type(domain2d),
pointer,
save :: d_ptr =>null()
5727 is_no_domain = .false.
5728 if (
PRESENT(no_domain)) is_no_domain = no_domain
5730 if(
PRESENT(domain))
then 5732 elseif (
ASSOCIATED(
current_domain) .AND. .NOT. is_no_domain )
then 5736 if(.not.
PRESENT(domain) .and. .not.
ASSOCIATED(
current_domain) ) is_no_domain = .true.
5738 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, is_no_domain, domain, tile_count)
5739 if(.not.found_file)
call mpp_error(fatal,
'fms_io_mod(read_data_2d_region): file ' //trim(filename)// &
5740 '(with the consideration of tile number) and corresponding distributed file are not found')
5741 call get_file_unit(fname, unit, file_index, read_dist, io_domain_exist, domain=domain)
5744 call get_field_id(unit, file_index, fieldname, index_field, is_no_domain, .false. )
5745 siz_in(1:4) =
files_read(file_index)%var(index_field)%siz(1:4)
5746 if(
files_read(file_index)%var(index_field)%is_dimvar)
then 5747 call mpp_error(fatal,
'fms_io_mod(read_data_3d_region): the field should not be a dimension variable')
5758 subroutine read_data_2d_region_r8(filename,fieldname,data,start,nread,domain, &
5759 no_domain, tile_count)
5760 character(len=*),
intent(in) :: filename, fieldname
5761 real(kind=8),
dimension(:,:),
intent(inout) :: data
5762 integer,
dimension(:),
intent(in) :: start, nread
5763 type(domain2d),
target,
optional,
intent(in) :: domain
5764 logical,
optional,
intent(in) :: no_domain
5765 integer,
optional,
intent(in) :: tile_count
5766 character(len=256) :: fname
5767 integer :: unit, siz_in(4)
5768 integer :: file_index
5769 integer :: index_field
5770 logical :: is_no_domain = .false.
5771 logical :: read_dist, io_domain_exist, found_file
5772 type(domain2d),
pointer,
save :: d_ptr =>null()
5777 is_no_domain = .false.
5778 if (
PRESENT(no_domain)) is_no_domain = no_domain
5780 if(
PRESENT(domain))
then 5782 elseif (
ASSOCIATED(
current_domain) .AND. .NOT. is_no_domain )
then 5786 if(.not.
PRESENT(domain) .and. .not.
ASSOCIATED(
current_domain) ) is_no_domain = .true.
5788 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, is_no_domain, domain, tile_count)
5789 if(.not.found_file)
call mpp_error(fatal,
'fms_io_mod(read_data_2d_region): file ' //trim(filename)// &
5790 '(with the consideration of tile number) and corresponding distributed file are not found')
5791 call get_file_unit(fname, unit, file_index, read_dist, io_domain_exist, domain=domain)
5794 call get_field_id(unit, file_index, fieldname, index_field, is_no_domain, .false. )
5795 siz_in(1:4) =
files_read(file_index)%var(index_field)%siz(1:4)
5796 if(
files_read(file_index)%var(index_field)%is_dimvar)
then 5797 call mpp_error(fatal,
'fms_io_mod(read_data_2d_region_r8): the field should not be a dimension variable')
5804 end subroutine read_data_2d_region_r8
5806 subroutine read_data_3d_region_r8(filename,fieldname,data,start,nread,domain, &
5807 no_domain, tile_count)
5808 character(len=*),
intent(in) :: filename, fieldname
5809 real(kind=8),
dimension(:,:,:),
intent(inout) :: data
5810 integer,
dimension(:),
intent(in) :: start, nread
5811 type(domain2d),
target,
optional,
intent(in) :: domain
5812 logical,
optional,
intent(in) :: no_domain
5813 integer,
optional,
intent(in) :: tile_count
5814 character(len=256) :: fname
5815 integer :: unit, siz_in(4)
5816 integer :: file_index
5817 integer :: index_field
5818 logical :: is_no_domain = .false.
5819 logical :: read_dist, io_domain_exist, found_file
5820 type(domain2d),
pointer,
save :: d_ptr =>null()
5825 is_no_domain = .false.
5826 if (
PRESENT(no_domain)) is_no_domain = no_domain
5828 if(
PRESENT(domain))
then 5830 elseif (
ASSOCIATED(
current_domain) .AND. .NOT. is_no_domain )
then 5834 if(.not.
PRESENT(domain) .and. .not.
ASSOCIATED(
current_domain) ) is_no_domain = .true.
5836 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, is_no_domain, domain, tile_count)
5837 if(.not.found_file)
call mpp_error(fatal,
'fms_io_mod(read_data_2d_region): file ' //trim(filename)// &
5838 '(with the consideration of tile number) and corresponding distributed file are not found')
5839 call get_file_unit(fname, unit, file_index, read_dist, io_domain_exist, domain=domain)
5842 call get_field_id(unit, file_index, fieldname, index_field, is_no_domain, .false. )
5843 siz_in(1:4) =
files_read(file_index)%var(index_field)%siz(1:4)
5844 if(
files_read(file_index)%var(index_field)%is_dimvar)
then 5845 call mpp_error(fatal,
'fms_io_mod(read_data_3d_region_r8): the field should not be a dimension variable')
5852 end subroutine read_data_3d_region_r8
5859 character(len=*),
intent(in) :: filename, fieldname
5860 character(len=*),
intent(out) :: data
5861 integer,
intent(in) ,
optional :: level
5862 logical :: file_opened, found_file, read_dist, io_domain_exist
5863 integer :: lev, unit, index_field
5864 integer :: file_index
5865 character(len=256) :: fname
5871 if (
PRESENT(level))
then 5877 found_file =
get_file_name(filename, fname, read_dist, io_domain_exist, no_domain=.true. )
5878 if(.not.found_file)
call mpp_error(fatal,
'fms_io_mod(read_data_text): file ' //trim(filename)// &
5879 '(with the consideration of tile number) and corresponding distributed file are not found')
5880 call get_file_unit(fname, unit, file_index, read_dist, io_domain_exist )
5883 call get_field_id(unit, file_index, fieldname, index_field, .true., .true. )
5885 if ( lev < 1 .or. lev >
files_read(file_index)%var(index_field)%siz(1) )
then 5887 call mpp_error(fatal,
'fms_io(read_data_text): text level out of range, level/max_level=' &
5888 //trim(
error_msg)//
' in field/file: '//trim(fieldname)//
'/'//trim(filename))
5898 no_domain,position,tile_count)
5899 character(len=*),
intent(in) :: filename, fieldname
5900 real,
dimension(:,:,:,:),
intent(inout) :: data
5901 real,
dimension(size(data,1),size(data,2),size(data,3)*size(data,4)) :: data_3d
5902 type(domain2d),
intent(in),
optional :: domain
5903 integer,
intent(in) ,
optional :: timelevel
5904 logical,
intent(in),
optional :: no_domain
5905 integer,
intent(in) ,
optional :: position, tile_count
5908 integer :: isc,iec,jsc,jec,isd,ied,jsd,jed
5909 integer :: isg,ieg,jsg,jeg
5910 integer :: xsize_c,ysize_c,xsize_d,ysize_d
5911 integer :: xsize_g,ysize_g, ishift, jshift
5919 no_domain,.false., position,tile_count)
5921 if(
PRESENT(domain))
then 5922 call mpp_get_global_domain( domain,isg,ieg,jsg,jeg,xsize=xsize_g,ysize=ysize_g, tile_count=tile_count, position=position)
5923 call mpp_get_compute_domain( domain,isc,iec,jsc,jec,xsize=xsize_c,ysize=ysize_c, tile_count=tile_count, position=position)
5924 call mpp_get_data_domain( domain,isd,ied,jsd,jed,xsize=xsize_d,ysize=ysize_d, tile_count=tile_count, position=position)
5925 call mpp_get_domain_shift (domain, ishift, jshift, position)
5926 if(((
size(
data,1)==xsize_c) .and. (
size(
data,2)==ysize_c)))
then 5928 do l = 1,
size(
data,4) ;
do k = 1,
size(
data,3)
5930 data(:,:,k,l) = data_3d(:,:,i)
5932 else if((
size(
data,1)==xsize_d) .and. (
size(
data,2)==ysize_d))
then 5934 do l = 1,
size(
data,4) ;
do k = 1,
size(
data,3)
5936 data(isc-isd+1:iec-isd+1,jsc-jsd+1:jec-jsd+1,k,l) = data_3d(isc-isd+1:iec-isd+1,jsc-jsd+1:jec-jsd+1,i)
5938 else if((
size(
data,1)==xsize_g) .and. (
size(
data,2)==ysize_g))
then 5940 do l = 1,
size(
data,4) ;
do k = 1,
size(
data,3)
5942 data(:,:,k,l) = data_3d(:,:,i)
5945 call mpp_error(fatal,
'error in read_data_4d_new, field '//trim(fieldname)// &
5946 ' in file '//trim(filename)//
' data must be in compute or data domain')
5950 do l = 1,
size(
data,4) ;
do k = 1,
size(
data,3)
5952 data(:,:,k,l) = data_3d(:,:,i)
5958 subroutine read_data_2d_ug(filename,fieldname,data,SG_domain,UG_domain,timelevel)
5959 character(len=*),
intent(in) :: filename, fieldname
5960 real,
dimension(:),
intent(inout) :: data
5961 type(domain2d),
intent(in) :: SG_domain
5962 type(domainUG),
intent(in) :: UG_domain
5963 integer,
intent(in) ,
optional :: timelevel
5964 real,
dimension(:,:),
allocatable :: data_2d
5965 integer :: is, ie, js, je
5968 allocate(data_2d(is:ie,js:je))
5976 no_domain,position,tile_count)
5977 character(len=*),
intent(in) :: filename, fieldname
5978 real,
dimension(:,:),
intent(inout) :: data
5979 real,
dimension(size(data,1),size(data,2),1) :: data_3d
5980 type(domain2d),
intent(in),
optional :: domain
5981 integer,
intent(in) ,
optional :: timelevel
5982 logical,
intent(in),
optional :: no_domain
5983 integer,
intent(in) ,
optional :: position, tile_count
5986 integer :: isc,iec,jsc,jec,isd,ied,jsd,jed
5987 integer :: isg,ieg,jsg,jeg
5988 integer :: xsize_c,ysize_c,xsize_d,ysize_d
5989 integer :: xsize_g,ysize_g, ishift, jshift
5997 no_domain,.false., position,tile_count)
5999 if(
PRESENT(domain))
then 6000 call mpp_get_global_domain( domain,isg,ieg,jsg,jeg,xsize=xsize_g,ysize=ysize_g, tile_count=tile_count, position=position)
6001 call mpp_get_compute_domain( domain,isc,iec,jsc,jec,xsize=xsize_c,ysize=ysize_c, tile_count=tile_count, position=position)
6002 call mpp_get_data_domain( domain,isd,ied,jsd,jed,xsize=xsize_d,ysize=ysize_d, tile_count=tile_count, position=position)
6003 call mpp_get_domain_shift (domain, ishift, jshift, position)
6004 if(((
size(
data,1)==xsize_c) .and. (
size(
data,2)==ysize_c)))
then 6005 data(:,:) = data_3d(:,:,1)
6006 else if((
size(
data,1)==xsize_d) .and. (
size(
data,2)==ysize_d))
then 6007 data(isc-isd+1:iec-isd+1,jsc-jsd+1:jec-jsd+1) = data_3d(isc-isd+1:iec-isd+1,jsc-jsd+1:jec-jsd+1,1)
6008 else if((
size(
data,1)==xsize_g) .and. (
size(
data,2)==ysize_g))
then 6009 data(:,:) = data_3d(:,:,1)
6011 call mpp_error(fatal,
'error in read_data_2d_new, field '//trim(fieldname)// &
6012 ' in file '//trim(filename)//
' data must be in compute or data domain')
6015 data(:,:) = data_3d(:,:,1)
6021 no_domain, tile_count)
6022 character(len=*),
intent(in) :: filename, fieldname
6023 real,
dimension(:),
intent(inout) :: data
6024 real,
dimension(size(data,1),1,1) :: data_3d
6025 type(domain2d),
intent(in),
optional :: domain
6026 integer,
intent(in) ,
optional :: timelevel
6027 logical,
intent(in),
optional :: no_domain
6028 integer,
intent(in),
optional :: tile_count
6029 #ifdef use_CRI_pointers 6030 pointer( p, data_3d )
6035 no_domain=no_domain, scalar_or_1d=.true., tile_count=tile_count)
6041 no_domain, tile_count)
6044 character(len=*),
intent(in) :: filename, fieldname
6045 real,
intent(inout) :: data
6046 real,
dimension(1,1,1) :: data_3d
6047 type(domain2d),
intent(in),
optional :: domain
6048 integer,
intent(in) ,
optional :: timelevel
6049 logical,
intent(in),
optional :: no_domain
6050 integer,
intent(in),
optional :: tile_count
6052 if(
present(no_domain))
then 6053 if(.NOT. no_domain)
call mpp_error(fatal,
'fms_io(read_data_scalar_new): no_domain should be true for field ' &
6054 //trim(fieldname)//
' of file '//trim(filename) )
6058 no_domain=no_domain, scalar_or_1d=.true., tile_count=tile_count)
6060 data = data_3d(1,1,1)
6065 function unique_axes(file, index, id_axes, siz_axes, dom)
6067 integer,
intent(in) :: index
6068 integer,
dimension(:),
intent(out) :: id_axes
6069 integer,
dimension(:),
intent(out) :: siz_axes
6070 type(
domain1d),
dimension(:),
intent(in),
optional :: dom
6072 type(
var_type),
pointer,
save :: cur_var => null()
6078 if(index <0 .OR. index > 4)
call mpp_error(fatal,
"unique_axes(fms_io_mod): index should be 1, 2, 3 or 4")
6081 cur_var => file%var(i)
6082 if(cur_var%read_only) cycle
6083 if(cur_var%ndim < index) cycle
6086 if(siz_axes(j) == cur_var%gsiz(index) )
then 6087 if(
PRESENT(dom))
then 6088 if(cur_var%domain_idx == id_axes(j) )
then 6091 else if(cur_var%domain_idx >0 .AND. id_axes(j) >0)
then 6092 if(dom(cur_var%domain_idx) .EQ. dom(id_axes(j)) )
then 6104 cur_var%id_axes(index) = j
6109 if(index == 1 )
then 6110 call mpp_error(fatal,
'# x axes exceeded max_axes in fms_io,num_axes/max_axes= '//trim(
error_msg))
6111 else if(index == 2 )
then 6112 call mpp_error(fatal,
'# y axes exceeded max_axes in fms_io,num_axes/max_axes= '//trim(
error_msg))
6114 call mpp_error(fatal,
'# z axes exceeded max_axes in fms_io,num_axes/max_axes= '//trim(
error_msg))
6120 call mpp_error(fatal,
'fms_io_mod(unique_axes): size_axes is greater than max_axis_size, '//&
6121 'increase fms_io_nml variable max_axis_size to at least ', siz_axes(
unique_axes))
6149 integer,
intent(in) :: unit
6150 real,
intent(out),
dimension(isd:,jsd:) :: data
6151 logical,
intent(out),
optional :: end
6152 real,
dimension(isg:ieg,jsg:jeg) :: gdata
6156 include
"read_data_2d.inc" 6163 integer,
intent(in) :: unit
6164 logical,
intent(out),
dimension(isd:,jsd:) :: data
6165 logical,
intent(out),
optional :: end
6166 logical,
dimension(isg:ieg,jsg:jeg) :: gdata
6170 include
"read_data_2d.inc" 6176 integer,
intent(in) :: unit
6177 integer,
intent(out),
dimension(isd:,jsd:) :: data
6178 logical,
intent(out),
optional :: end
6179 integer,
dimension(isg:ieg,jsg:jeg) :: gdata
6183 include
"read_data_2d.inc" 6189 subroutine read_cdata_2d ( unit, data, end)
6191 integer,
intent(in) :: unit
6192 complex,
intent(out),
dimension(isd:,jsd:) :: data
6193 logical,
intent(out),
optional :: end
6194 complex,
dimension(isg:ieg,jsg:jeg) :: gdata
6198 include
"read_data_2d.inc" 6199 end subroutine read_cdata_2d
6206 integer,
intent(in) :: unit
6207 real,
intent(out),
dimension(isd:,jsd:,:) :: data
6208 logical,
intent(out),
optional :: end
6209 real,
dimension(isg:ieg,jsg:jeg,size(data,3)) :: gdata
6213 include
"read_data_3d.inc" 6219 subroutine read_cdata_3d ( unit, data, end)
6221 integer,
intent(in) :: unit
6222 complex,
intent(out),
dimension(isd:,jsd:,:) :: data
6223 logical,
intent(out),
optional :: end
6224 complex,
dimension(isg:ieg,jsg:jeg,size(data,3)) :: gdata
6228 include
"read_data_3d.inc" 6229 end subroutine read_cdata_3d
6236 integer,
intent(in) :: unit
6237 real,
intent(out),
dimension(isd:,jsd:,:,:) :: data
6238 logical,
intent(out),
optional :: end
6239 real,
dimension(isg:ieg,jsg:jeg,size(data,3),size(data,4)) :: gdata
6244 include
"read_data_4d.inc" 6250 subroutine read_cdata_4d ( unit, data, end)
6252 integer,
intent(in) :: unit
6253 complex,
intent(out),
dimension(isd:,jsd:,:,:) :: data
6254 logical,
intent(out),
optional :: end
6255 complex,
dimension(isg:ieg,jsg:jeg,size(data,3),size(data,4)) :: gdata
6260 include
"read_data_4d.inc" 6261 end subroutine read_cdata_4d
6270 integer,
intent(in) :: unit
6271 real,
intent(in),
dimension(isd:,jsd:) :: data
6272 real,
dimension(isg:ieg,jsg:jeg) :: gdata
6274 include
"write_data.inc" 6281 integer,
intent(in) :: unit
6282 logical,
intent(in),
dimension(isd:,jsd:) :: data
6283 logical,
dimension(isg:ieg,jsg:jeg) :: gdata
6285 include
"write_data.inc" 6291 integer,
intent(in) :: unit
6292 integer,
intent(in),
dimension(isd:,jsd:) :: data
6293 integer,
dimension(isg:ieg,jsg:jeg) :: gdata
6295 include
"write_data.inc" 6301 subroutine write_cdata_2d ( unit, data )
6303 integer,
intent(in) :: unit
6304 complex,
intent(in),
dimension(isd:,jsd:) :: data
6305 complex,
dimension(isg:ieg,jsg:jeg) :: gdata
6307 include
"write_data.inc" 6308 end subroutine write_cdata_2d
6315 integer,
intent(in) :: unit
6316 real,
intent(in),
dimension(isd:,jsd:,:) :: data
6317 real,
dimension(isg:ieg,jsg:jeg,size(data,3)) :: gdata
6319 include
"write_data.inc" 6325 subroutine write_cdata_3d ( unit, data )
6327 integer,
intent(in) :: unit
6328 complex,
intent(in),
dimension(isd:,jsd:,:) :: data
6329 complex,
dimension(isg:ieg,jsg:jeg,size(data,3)) :: gdata
6331 include
"write_data.inc" 6332 end subroutine write_cdata_3d
6338 integer,
intent(in) :: unit
6339 real,
intent(in),
dimension(isd:,jsd:,:,:) :: data
6340 real,
dimension(isg:ieg,jsg:jeg,size(data,3),size(data,4)) :: gdata
6344 call mpp_error(fatal,
'fms_io(write_data_4d): need to call set_domain ')
6348 do n = 1,
size(
data,4)
6351 if ( mpp_pe() == mpp_root_pe() )
write (unit) gdata
6357 subroutine write_cdata_4d ( unit, data )
6359 integer,
intent(in) :: unit
6360 complex,
intent(in),
dimension(isd:,jsd:,:,:) :: data
6361 complex,
dimension(isg:ieg,jsg:jeg,size(data,3),size(data,4)) :: gdata
6368 do n = 1,
size(
data,4)
6371 if ( mpp_pe() == mpp_root_pe() )
write (unit) gdata
6372 end subroutine write_cdata_4d
6381 logical,
intent(out),
optional :: end_found
6383 if (
present(end_found))
then 6386 call mpp_error(fatal,
'fms_io(read_eof): unexpected EOF')
6403 integer,
intent(in) :: id_field
6404 character(len=*),
intent(in) :: name
6406 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_name): " // &
6407 "restart_file_type data must be initialized by calling register_restart_field before using it")
6409 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6410 "fms_io(reset_field_name): id_field should be positive integer and "// &
6411 "no larger than number of fields in the file "//trim(fileobj%name) )
6413 fileobj%var(id_field)%name = trim(name)
6420 type(restart_file_type),
intent(inout) :: fileObj
6421 integer,
intent(in) :: id_field
6422 real,
intent(in),
target :: data
6424 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r0d): " // &
6425 "restart_file_type data must be initialized by calling register_restart_field before using it")
6427 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6428 "fms_io(reset_field_pointer_r0d): id_field should be positive integer and "// &
6429 "no larger than number of fields in the file "//trim(fileobj%name) )
6430 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6431 "fms_io(reset_field_pointer_r0d): one-level reset_field_pointer is called, but "//&
6432 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6434 fileobj%p0dr(1, id_field)%p =>
data 6441 type(restart_file_type),
intent(inout) :: fileObj
6442 integer,
intent(in) :: id_field
6443 real,
dimension(:),
intent(in),
target :: data
6445 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r1d): " // &
6446 "restart_file_type data must be initialized by calling register_restart_field before using it")
6448 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6449 "fms_io(reset_field_pointer_r1d): id_field should be positive integer and "// &
6450 "no larger than number of fields in the file "//trim(fileobj%name) )
6451 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6452 "fms_io(reset_field_pointer_r1d): one-level reset_field_pointer is called, but "//&
6453 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6455 fileobj%p1dr(1, id_field)%p =>
data 6462 type(restart_file_type),
intent(inout) :: fileObj
6463 integer,
intent(in) :: id_field
6464 real,
dimension(:,:),
intent(in),
target :: data
6466 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r2d): " // &
6467 "restart_file_type data must be initialized by calling register_restart_field before using it")
6469 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6470 "fms_io(reset_field_pointer_r2d): id_field should be positive integer and "// &
6471 "no larger than number of fields in the file "//trim(fileobj%name) )
6472 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6473 "fms_io(reset_field_pointer_r2d): one-level reset_field_pointer is called, but "//&
6474 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6476 fileobj%p2dr(1, id_field)%p =>
data 6483 type(restart_file_type),
intent(inout) :: fileObj
6484 integer,
intent(in) :: id_field
6485 real,
dimension(:,:,:),
intent(in),
target :: data
6487 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r3d): " // &
6488 "restart_file_type data must be initialized by calling register_restart_field before using it")
6490 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6491 "fms_io(reset_field_pointer_r3d): id_field should be positive integer and "// &
6492 "no larger than number of fields in the file "//trim(fileobj%name) )
6493 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6494 "fms_io(reset_field_pointer_r3d): one-level reset_field_pointer is called, but "//&
6495 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6497 fileobj%p3dr(1, id_field)%p =>
data 6504 type(restart_file_type),
intent(inout) :: fileObj
6505 integer,
intent(in) :: id_field
6506 real,
dimension(:,:,:,:),
intent(in),
target :: data
6508 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r4d): " // &
6509 "restart_file_type data must be initialized by calling register_restart_field before using it")
6511 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6512 "fms_io(reset_field_pointer_r4d): id_field should be positive integer and "// &
6513 "no larger than number of fields in the file "//trim(fileobj%name) )
6514 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6515 "fms_io(reset_field_pointer_r4d): one-level reset_field_pointer is called, but "//&
6516 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6518 fileobj%p4dr(1, id_field)%p =>
data 6526 type(restart_file_type),
intent(inout) :: fileObj
6527 integer,
intent(in) :: id_field
6528 integer,
intent(in),
target :: data
6530 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_i0d): " // &
6531 "restart_file_type data must be initialized by calling register_restart_field before using it")
6533 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6534 "fms_io(reset_field_pointer_i0d): id_field should be positive integer and "// &
6535 "no larger than number of fields in the file "//trim(fileobj%name) )
6536 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6537 "fms_io(reset_field_pointer_i0d): one-level reset_field_pointer is called, but "//&
6538 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6540 fileobj%p0di(1, id_field)%p =>
data 6547 type(restart_file_type),
intent(inout) :: fileObj
6548 integer,
intent(in) :: id_field
6549 integer,
dimension(:),
intent(in),
target :: data
6551 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_i1d): " // &
6552 "restart_file_type data must be initialized by calling register_restart_field before using it")
6554 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6555 "fms_io(reset_field_pointer_i1d): id_field should be positive integer and "// &
6556 "no larger than number of fields in the file "//trim(fileobj%name) )
6557 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6558 "fms_io(reset_field_pointer_i1d): one-level reset_field_pointer is called, but "//&
6559 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6561 fileobj%p1di(1, id_field)%p =>
data 6568 type(restart_file_type),
intent(inout) :: fileObj
6569 integer,
intent(in) :: id_field
6570 integer,
dimension(:,:),
intent(in),
target :: data
6572 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_i2d): " // &
6573 "restart_file_type data must be initialized by calling register_restart_field before using it")
6575 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6576 "fms_io(reset_field_pointer_i2d): id_field should be positive integer and "// &
6577 "no larger than number of fields in the file "//trim(fileobj%name) )
6578 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6579 "fms_io(reset_field_pointer_i2d): one-level reset_field_pointer is called, but "//&
6580 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6582 fileobj%p2di(1, id_field)%p =>
data 6589 type(restart_file_type),
intent(inout) :: fileObj
6590 integer,
intent(in) :: id_field
6591 integer,
dimension(:,:,:),
intent(in),
target :: data
6593 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_i3d): " // &
6594 "restart_file_type data must be initialized by calling register_restart_field before using it")
6596 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6597 "fms_io(reset_field_pointer_i3d): id_field should be positive integer and "// &
6598 "no larger than number of fields in the file "//trim(fileobj%name) )
6599 if(fileobj%var(id_field)%siz(4) .NE. 1)
call mpp_error(fatal, &
6600 "fms_io(reset_field_pointer_i3d): one-level reset_field_pointer is called, but "//&
6601 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not one level" )
6603 fileobj%p3di(1, id_field)%p =>
data 6610 type(restart_file_type),
intent(inout) :: fileObj
6611 integer,
intent(in) :: id_field
6612 real,
intent(in),
target :: data1, data2
6614 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r0d_2level): " // &
6615 "restart_file_type data must be initialized by calling register_restart_field before using it")
6617 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6618 "fms_io(reset_field_pointer_r0d_2level): id_field should be positive integer and "// &
6619 "no larger than number of fields in the file "//trim(fileobj%name) )
6620 if(fileobj%var(id_field)%siz(4) .NE. 2)
call mpp_error(fatal, &
6621 "fms_io(reset_field_pointer_r0d_2level): two-level reset_field_pointer is called, but "//&
6622 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not two level" )
6624 fileobj%p0dr(1, id_field)%p => data1
6625 fileobj%p0dr(2, id_field)%p => data2
6632 type(restart_file_type),
intent(inout) :: fileObj
6633 integer,
intent(in) :: id_field
6634 real,
dimension(:),
intent(in),
target :: data1, data2
6636 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r1d_2level): " // &
6637 "restart_file_type data must be initialized by calling register_restart_field before using it")
6639 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6640 "fms_io(reset_field_pointer_r1d_2level): id_field should be positive integer and "// &
6641 "no larger than number of fields in the file "//trim(fileobj%name) )
6642 if(fileobj%var(id_field)%siz(4) .NE. 2)
call mpp_error(fatal, &
6643 "fms_io(reset_field_pointer_r1d_2level): two-level reset_field_pointer is called, but "//&
6644 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not two level" )
6646 fileobj%p1dr(1, id_field)%p => data1
6647 fileobj%p1dr(2, id_field)%p => data2
6654 type(restart_file_type),
intent(inout) :: fileObj
6655 integer,
intent(in) :: id_field
6656 real,
dimension(:,:),
intent(in),
target :: data1, data2
6658 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r2d_2level): " // &
6659 "restart_file_type data must be initialized by calling register_restart_field before using it")
6661 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6662 "fms_io(reset_field_pointer_r2d_2level): id_field should be positive integer and "// &
6663 "no larger than number of fields in the file "//trim(fileobj%name) )
6664 if(fileobj%var(id_field)%siz(4) .NE. 2)
call mpp_error(fatal, &
6665 "fms_io(reset_field_pointer_r2d_2level): two-level reset_field_pointer is called, but "//&
6666 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not two level" )
6668 fileobj%p2dr(1, id_field)%p => data1
6669 fileobj%p2dr(2, id_field)%p => data2
6676 type(restart_file_type),
intent(inout) :: fileObj
6677 integer,
intent(in) :: id_field
6678 real,
dimension(:,:,:),
intent(in),
target :: data1, data2
6680 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_r3d_2level): " // &
6681 "restart_file_type data must be initialized by calling register_restart_field before using it")
6683 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6684 "fms_io(reset_field_pointer_r3d_2level): id_field should be positive integer and "// &
6685 "no larger than number of fields in the file "//trim(fileobj%name) )
6686 if(fileobj%var(id_field)%siz(4) .NE. 2)
call mpp_error(fatal, &
6687 "fms_io(reset_field_pointer_r3d_2level): two-level reset_field_pointer is called, but "//&
6688 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not two level" )
6690 fileobj%p3dr(1, id_field)%p => data1
6691 fileobj%p3dr(2, id_field)%p => data2
6698 type(restart_file_type),
intent(inout) :: fileObj
6699 integer,
intent(in) :: id_field
6700 integer,
intent(in),
target :: data1, data2
6702 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_i0d_2level): " // &
6703 "restart_file_type data must be initialized by calling register_restart_field before using it")
6705 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6706 "fms_io(reset_field_pointer_i0d_2level): id_field should be positive integer and "// &
6707 "no larger than number of fields in the file "//trim(fileobj%name) )
6708 if(fileobj%var(id_field)%siz(4) .NE. 2)
call mpp_error(fatal, &
6709 "fms_io(reset_field_pointer_i0d_2level): two-level reset_field_pointer is called, but "//&
6710 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not two level" )
6712 fileobj%p0di(1, id_field)%p => data1
6713 fileobj%p0di(2, id_field)%p => data2
6720 type(restart_file_type),
intent(inout) :: fileObj
6721 integer,
intent(in) :: id_field
6722 integer,
dimension(:),
intent(in),
target :: data1, data2
6724 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_i1d_2level): " // &
6725 "restart_file_type data must be initialized by calling register_restart_field before using it")
6727 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6728 "fms_io(reset_field_pointer_i1d_2level): id_field should be positive integer and "// &
6729 "no larger than number of fields in the file "//trim(fileobj%name) )
6730 if(fileobj%var(id_field)%siz(4) .NE. 2)
call mpp_error(fatal, &
6731 "fms_io(reset_field_pointer_i1d_2level): two-level reset_field_pointer is called, but "//&
6732 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not two level" )
6734 fileobj%p1di(1, id_field)%p => data1
6735 fileobj%p1di(2, id_field)%p => data2
6742 type(restart_file_type),
intent(inout) :: fileObj
6743 integer,
intent(in) :: id_field
6744 integer,
dimension(:,:),
intent(in),
target :: data1, data2
6746 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_i2d_2level): " // &
6747 "restart_file_type data must be initialized by calling register_restart_field before using it")
6749 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6750 "fms_io(reset_field_pointer_i2d_2level): id_field should be positive integer and "// &
6751 "no larger than number of fields in the file "//trim(fileobj%name) )
6752 if(fileobj%var(id_field)%siz(4) .NE. 2)
call mpp_error(fatal, &
6753 "fms_io(reset_field_pointer_i2d_2level): two-level reset_field_pointer is called, but "//&
6754 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not two level" )
6756 fileobj%p2di(1, id_field)%p => data1
6757 fileobj%p2di(2, id_field)%p => data2
6764 type(restart_file_type),
intent(inout) :: fileObj
6765 integer,
intent(in) :: id_field
6766 integer,
dimension(:,:,:),
intent(in),
target :: data1, data2
6768 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(reset_field_pointer_i3d_2level): " // &
6769 "restart_file_type data must be initialized by calling register_restart_field before using it")
6771 if(id_field < 0 .OR. id_field > fileobj%nvar)
call mpp_error(fatal, &
6772 "fms_io(reset_field_pointer_i3d_2level): id_field should be positive integer and "// &
6773 "no larger than number of fields in the file "//trim(fileobj%name) )
6774 if(fileobj%var(id_field)%siz(4) .NE. 2)
call mpp_error(fatal, &
6775 "fms_io(reset_field_pointer_i3d_2level): two-level reset_field_pointer is called, but "//&
6776 "field "//trim(fileobj%var(id_field)%name)//
" of file "//trim(fileobj%name)//
" is not two level" )
6778 fileobj%p3di(1, id_field)%p => data1
6779 fileobj%p3di(2, id_field)%p => data2
6792 integer,
intent(in) :: id
6796 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(query_initialized_id): " // &
6797 "restart_file_type data must be initialized by calling register_restart_field before using it")
6799 if(id < 1 .OR. id > fileobj%nvar)
call mpp_error(fatal,
"fms_io(query_initialized_id): " // &
6800 "argument id must be between 1 and nvar in the restart_file_type object")
6817 character(len=*),
intent(in) :: name
6823 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(query_initialized_name): " // &
6824 "restart_file_type data must be initialized by calling register_restart_field before using it")
6828 if (trim(name) == fileobj%var(m)%name)
then 6835 if ((m>fileobj%nvar) .and. (mpp_pe() == mpp_root_pe()))
then 6836 call mpp_error(note,
"fms_io(query_initialized_name): Unknown restart variable "//name// &
6837 " queried for initialization.")
6854 real,
dimension(:,:),
target,
intent(in) :: f_ptr
6855 character(len=*),
intent(in) :: name
6860 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(query_initialized_r2d): " // &
6861 "restart_file_type data must be initialized by calling register_restart_field before using it")
6864 do m=1, fileobj%nvar
6865 if (
ASSOCIATED(fileobj%p2dr(1,m)%p,f_ptr))
then 6872 if (m>fileobj%nvar)
then 6873 if (mpp_pe() == mpp_root_pe() )
call mpp_error(note,
"fms_io(query_initialized_r2d): Unable to find "// &
6874 trim(name)//
" queried by pointer, "//
"probably because of the suspect comparison of pointers by ASSOCIATED.")
6877 "fms_io(query_initialized_r2d): "//trim(name)//
" initialization confirmed by name.")
6896 real,
dimension(:,:,:),
target,
intent(in) :: f_ptr
6897 character(len=*),
intent(in) :: name
6902 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(query_initialized_r3d): " // &
6903 "restart_file_type data must be initialized by calling register_restart_field before using it")
6906 do m=1, fileobj%nvar
6907 if (
ASSOCIATED(fileobj%p3dr(1,m)%p,f_ptr))
then 6914 if (m>fileobj%nvar)
then 6915 if (mpp_pe() == mpp_root_pe() )
call mpp_error(note,
"fms_io(query_initialized_r3d): Unable to find "// &
6916 trim(name)//
" queried by pointer, "//
"probably because of the suspect comparison of pointers by ASSOCIATED.")
6919 "fms_io(query_initialized_r3d): "//trim(name)//
" initialization confirmed by name.")
6939 real,
dimension(:,:,:,:),
target,
intent(in) :: f_ptr
6940 character(len=*),
intent(in) :: name
6945 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(query_initialized_r4d): " // &
6946 "restart_file_type data must be initialized by calling register_restart_field before using it")
6949 do m=1, fileobj%nvar
6950 if (
ASSOCIATED(fileobj%p4dr(1,m)%p,f_ptr))
then 6957 if (m>fileobj%nvar)
then 6958 if (mpp_pe() == mpp_root_pe() )
call mpp_error(note,
"fms_io(query_initialized_r4d): Unable to find "// &
6959 trim(name)//
" queried by pointer, "//
"probably because of the suspect comparison of pointers by ASSOCIATED.")
6962 "fms_io(query_initialized_r4d): "//trim(name)//
" initialization confirmed by name.")
6976 type(restart_file_type),
intent(inout) :: fileObj
6977 integer ,
intent(in) :: id
6978 logical,
optional,
intent(in) :: is_set
6984 if (
present(is_set)) set_val = is_set
6986 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(set_initialized_id): " // &
6987 "restart_file_type data must be initialized by calling set_restart_field before using it")
6989 if(id < 1 .OR. id > fileobj%nvar)
call mpp_error(fatal,
"fms_io(set_initialized_id): " // &
6990 "argument id must be between 1 and nvar in the restart_file_type object")
6992 fileobj%var(id)%initialized = set_val
7004 type(restart_file_type),
intent(inout) :: fileObj
7005 character(len=*),
intent(in) :: name
7006 logical,
optional,
intent(in) :: is_set
7012 if (
present(is_set)) set_val = is_set
7014 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(set_initialized_name): " // &
7015 "restart_file_type data must be initialized by calling set_restart_field before using it")
7018 if (trim(name) == fileobj%var(m)%name)
then 7019 fileobj%var(m)%initialized = set_val
7024 if (m>fileobj%nvar)
then 7025 call mpp_error(note,
"fms_io(set_initialized_name): Unknown restart variable "//name// &
7026 " attempted to set initialization.")
7038 type(restart_file_type),
intent(inout) :: fileObj
7039 real,
dimension(:,:),
target,
intent(in) :: f_ptr
7040 character(len=*),
intent(in) :: name
7041 logical,
optional,
intent(in) :: is_set
7046 if (
present(is_set)) set_val = is_set
7048 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(set_initialized_r2d): " // &
7049 "restart_file_type data must be initialized by calling set_restart_field before using it")
7051 do m=1, fileobj%nvar
7052 if (
ASSOCIATED(fileobj%p2dr(1,m)%p,f_ptr))
then 7053 fileobj%var(m)%initialized = set_val
7058 if (m>fileobj%nvar .AND. mpp_pe() == mpp_root_pe() )
then 7059 call mpp_error(note,
"fms_io(set_initialized_r2d): Unable to find "// &
7060 trim(name)//
" queried by pointer, "//
"probably because of the suspect comparison of pointers by ASSOCIATED"// &
7061 " when attempting to set initialization.")
7065 if (trim(name) == fileobj%var(m)%name)
then 7066 fileobj%var(m)%initialized = set_val
7071 if (m>fileobj%nvar .AND. mpp_pe() == mpp_root_pe() )
then 7072 call mpp_error(note,
"fms_io(set_initialized_r2d): Unknown restart variable "//name// &
7073 " attempted to set initialization.")
7085 type(restart_file_type),
intent(inout) :: fileObj
7086 real,
dimension(:,:,:),
target,
intent(in) :: f_ptr
7087 character(len=*),
intent(in) :: name
7088 logical,
optional,
intent(in) :: is_set
7093 if (
present(is_set)) set_val = is_set
7095 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(set_initialized_r3d): " // &
7096 "restart_file_type data must be initialized by calling set_restart_field before using it")
7098 do m=1, fileobj%nvar
7099 if (
ASSOCIATED(fileobj%p3dr(1,m)%p,f_ptr))
then 7100 fileobj%var(m)%initialized = set_val
7105 if (m>fileobj%nvar .AND. mpp_pe() == mpp_root_pe() )
then 7106 call mpp_error(note,
"fms_io(set_initialized_r3d): Unable to find "// &
7107 trim(name)//
" queried by pointer, "//
"probably because of the suspect comparison of pointers by ASSOCIATED"//&
7108 " when attempting to set initialization.")
7112 if (trim(name) == fileobj%var(m)%name)
then 7113 fileobj%var(m)%initialized = set_val
7118 if (m>fileobj%nvar .AND. mpp_pe() == mpp_root_pe() )
then 7119 call mpp_error(note,
"fms_io(set_initialized_r3d): Unknown restart variable "//name// &
7120 " attempted to set initialization.")
7133 type(restart_file_type),
intent(inout) :: fileObj
7134 real,
dimension(:,:,:,:),
target,
intent(in) :: f_ptr
7135 character(len=*),
intent(in) :: name
7136 logical,
optional,
intent(in) :: is_set
7141 if (
present(is_set)) set_val = is_set
7143 if (.not.
associated(fileobj%var))
call mpp_error(fatal,
"fms_io(set_initialized_r4d): " // &
7144 "restart_file_type data must be initialized by calling set_restart_field before using it")
7146 do m=1, fileobj%nvar
7147 if (
ASSOCIATED(fileobj%p4dr(1,m)%p,f_ptr))
then 7148 fileobj%var(m)%initialized = set_val
7153 if (m>fileobj%nvar .AND. mpp_pe() == mpp_root_pe() )
then 7154 call mpp_error(note,
"fms_io(set_initialized_r4d): Unable to find "// &
7155 trim(name)//
" queried by pointer, "//
"probably because of the suspect comparison of pointers by ASSOCIATED"//&
7156 " when attempting to set initialization.")
7160 if (trim(name) == fileobj%var(m)%name)
then 7161 fileobj%var(m)%initialized = set_val
7166 if (m>fileobj%nvar .AND. mpp_pe() == mpp_root_pe() )
then 7167 call mpp_error(note,
"fms_io(set_initialized_r4d): Unknown restart variable "//name// &
7168 " attempted to set initialization.")
7204 character(len=*),
intent(in),
optional :: file
7207 character(len=32) :: pelist_name
7208 character(len=128) :: filename
7210 #ifdef INTERNAL_FILE_NML 7215 if (
present(file))
then 7216 call mpp_open ( unit, file,
form=mpp_ascii, action=mpp_rdonly, &
7217 access=mpp_sequential, threading=mpp_single )
7220 pelist_name = mpp_get_current_pelist_name()
7221 if (
file_exist(
'input_'//trim(pelist_name)//
'.nml', no_domain=.true.) )
then 7222 filename=
'input_'//trim(pelist_name)//
'.nml' 7224 filename=
'input.nml' 7226 call mpp_open ( unit, trim(filename),
form=mpp_ascii, action=mpp_rdonly, &
7227 access=mpp_sequential, threading=mpp_single )
7248 character(len=*),
intent(in) :: file, action
7250 integer :: mpp_action
7256 select case (lowercase(trim(action)))
7258 mpp_action = mpp_rdonly
7260 mpp_action = mpp_overwr
7262 call mpp_error(fatal,
'fms_io(open_restart_file): action should be either read or write in file'//trim(file))
7265 call mpp_open ( unit, file,
form=mpp_native, action=mpp_action, &
7266 access=mpp_sequential, threading=mpp_single, nohdrs=.true. )
7280 character(len=*),
intent(in) :: file, action
7281 integer,
intent(in) :: recl
7284 integer :: mpp_action
7290 select case (lowercase(trim(action)))
7292 mpp_action = mpp_rdonly
7294 mpp_action = mpp_overwr
7296 call mpp_error(fatal,
'invalid option for argument action')
7299 call mpp_open ( unit, file,
form=mpp_native, action=mpp_action, &
7300 access=mpp_direct, threading=mpp_single, nohdrs=.true., recl=recl )
7321 character(len=*),
intent(in) :: file, action
7323 integer :: mpp_action
7328 select case (lowercase(trim(action)))
7330 mpp_action = mpp_rdonly
7332 mpp_action = mpp_overwr
7334 call mpp_error (fatal,
'fms_io(open_ieee32_file): action should be either read or write in file'//trim(file))
7338 call mpp_open ( unit, file,
form=mpp_ieee32, action=mpp_action, &
7339 access=mpp_sequential, threading=mpp_single, &
7342 call mpp_open ( unit, file,
form=mpp_ieee32, action=mpp_action, &
7343 access=mpp_sequential, threading=mpp_single, &
7363 integer,
intent(in) :: unit
7364 character(len=*),
intent(in),
optional :: status
7365 logical,
intent(in),
optional :: dist
7368 if(
PRESENT(dist))
then 7375 if (unit == stdlog())
return 7376 if (
present(status))
then 7377 if (lowercase(trim(status)) ==
'delete')
then 7378 call mpp_close (unit, action=mpp_delete)
7380 call mpp_error(fatal,
'fms_io(close_file): status should be DELETE')
7383 call mpp_close (unit)
7402 type(domain2d),
intent(in),
target :: domain2
7444 type(domain2d),
intent(inout) :: domain2
7449 domain2 = null_domain2d
7472 integer,
intent(out),
dimension(4) :: x, y
7474 if (mpp_pe() == mpp_root_pe())
call mpp_error(note, &
7475 'subroutine get_domain_decomp will be removed with the next release')
7484 type(axistype),
intent(in) :: axis
7485 character(len=1),
intent(out) :: cart
7486 character(len=1) :: axis_cart
7487 character(len=16),
dimension(2) :: lon_names, lat_names
7488 character(len=16),
dimension(3) :: z_names
7489 character(len=16),
dimension(2) :: t_names
7490 character(len=16),
dimension(2) :: lon_units, lat_units
7491 character(len=8) ,
dimension(4) :: z_units
7492 character(len=3) ,
dimension(4) :: t_units
7493 character(len=32) :: name
7496 lon_names = (/
'lon',
'x '/)
7497 lat_names = (/
'lat',
'y '/)
7498 z_names = (/
'depth ',
'height',
'z '/)
7499 t_names = (/
'time',
't '/)
7500 lon_units = (/
'degrees_e ',
'degrees_east'/)
7501 lat_units = (/
'degrees_n ',
'degrees_north'/)
7502 z_units = (/
'cm ',
'm ',
'pa ',
'hpa'/)
7503 t_units = (/
'sec',
'min',
'hou',
'day'/)
7504 call mpp_get_atts(axis,cartesian=axis_cart)
7506 if (axis_cart ==
'x' ) cart =
'X' 7507 if (axis_cart ==
'y' ) cart =
'Y' 7508 if (axis_cart ==
'z' ) cart =
'Z' 7509 if (axis_cart ==
't' ) cart =
'T' 7510 if (cart /=
'X' .and. cart /=
'Y' .and. cart /=
'Z' .and. cart /=
'T')
then 7511 call mpp_get_atts(axis,name=name)
7512 name = lowercase(name)
7513 do i=1,
size(lon_names(:))
7514 if (lowercase(name(1:3)) == trim(lon_names(i))) cart =
'X' 7516 do i=1,
size(lat_names(:))
7517 if (name(1:3) == trim(lat_names(i))) cart =
'Y' 7519 do i=1,
size(z_names(:))
7520 if (name == trim(z_names(i))) cart =
'Z' 7522 do i=1,
size(t_names(:))
7523 if (name(1:3) == t_names(i)) cart =
'T' 7527 if (cart /=
'X' .and. cart /=
'Y' .and. cart /=
'Z' .and. cart /=
'T')
then 7528 call mpp_get_atts(axis,units=name)
7529 name = lowercase(name)
7530 do i=1,
size(lon_units(:))
7531 if (trim(name) == trim(lon_units(i))) cart =
'X' 7533 do i=1,
size(lat_units(:))
7534 if (trim(name) == trim(lat_units(i))) cart =
'Y' 7536 do i=1,
size(z_units(:))
7537 if (trim(name) == trim(z_units(i))) cart =
'Z' 7539 do i=1,
size(t_units(:))
7540 if (name(1:3) == trim(t_units(i))) cart =
'T' 7551 function open_file(file, form, action, access, threading, recl, dist)
result(unit)
7553 character(len=*),
intent(in) :: file
7554 character(len=*),
intent(in),
optional ::
form, action, access, threading
7555 integer ,
intent(in),
optional :: recl
7556 logical ,
intent(in),
optional :: dist
7559 character(len=32) :: form_local, action_local, access_local, thread_local
7560 character(len=32) :: action_ieee32
7561 logical :: open, no_headers, do_ieee32
7562 integer :: mpp_format, mpp_action, mpp_access, mpp_thread
7567 if (
present(action))
then 7568 action_local = action
7570 call mpp_error (fatal,
'open_file in fms_mod : argument action not present')
7574 if(
PRESENT(dist))
then 7575 if(lowercase(trim(action_local)) /=
'read') &
7576 call mpp_error(fatal,
'open_file in fms_mod: distributed'//lowercase(trim(action_local))// &
7577 ' not currently supported')
7586 if (trim(file) ==
'logfile.out')
then 7593 inquire (file=trim(file), opened=
open, number=unit)
7598 if (
open .and. unit >= 0 )
then 7599 call mpp_error (fatal,
'open_file in fms_mod : '// &
7600 'file '//trim(file)//
' is already open')
7605 form_local =
'formatted';
if (
present(
form)) form_local =
form 7606 access_local =
'sequential';
if (
present(access)) access_local = access
7607 thread_local =
'single';
if (
present(threading)) thread_local = threading
7613 select case (lowercase(trim(form_local)))
7615 mpp_format = mpp_ascii
7617 mpp_format = mpp_ascii
7618 case (
'unformatted')
7619 mpp_format = mpp_native
7621 mpp_format = mpp_native
7625 mpp_format = mpp_netcdf
7627 call mpp_error (fatal,
'open_file in fms_mod : '// &
7628 'invalid option for argument form')
7633 select case (lowercase(trim(action_local)))
7635 mpp_action = mpp_rdonly
7637 mpp_action = mpp_overwr
7639 mpp_action = mpp_append
7641 call mpp_error (fatal,
'open_file in fms_mod : '// &
7642 'invalid option for argument action')
7647 select case (lowercase(trim(access_local)))
7649 mpp_access = mpp_sequential
7651 mpp_access = mpp_direct
7653 call mpp_error (fatal,
'open_file in fms_mod : '// &
7654 'invalid option for argument access')
7659 select case (lowercase(trim(thread_local)))
7661 mpp_thread = mpp_single
7663 mpp_thread = mpp_multi
7665 call mpp_error (fatal,
'open_file in fms_mod : '// &
7666 'invalid option for argument thread')
7667 if (trim(file) /=
'_read_error.nml') no_headers = .false.
7672 if ( .not.do_ieee32 )
then 7673 call mpp_open ( unit, file,
form=mpp_format, action=mpp_action, &
7674 access=mpp_access, threading=mpp_thread, &
7675 fileset=mpp_single,nohdrs=no_headers, recl=recl )
7680 action_ieee32 = action_local
7681 if (lowercase(trim(action_ieee32)) ==
'append') action_ieee32 =
'write' 7692 integer,
intent(in) :: n
7696 call mpp_error(fatal,
'fms_io_mod: n should be non-negative integer, contact developer')
7697 else if( n<10 )
then 7699 else if( n<100 )
then 7701 else if( n<1000 )
then 7703 else if( n<10000 )
then 7705 else if( n<100000 )
then 7707 else if( n<1000000 )
then 7709 else if( n<10000000 )
then 7711 else if( n<100000000 )
then 7714 call mpp_error(fatal,
'fms_io_mod: n is too big, contact developer')
7723 real,
intent(in) :: a
7735 character(len=*),
intent(inout) :: str_out
7736 character(len=*),
intent(in) :: str_in
7737 integer,
intent(in) :: tile
7738 character(len=*),
intent(in),
optional :: str2_in
7740 if(tile > 0 .AND. tile < 9)
then 7741 write(str_out,
'(a,i1)') trim(str_in), tile
7742 else if(tile >= 10 .AND. tile < 99)
then 7743 write(str_out,
'(a,i2)') trim(str_in), tile
7745 call mpp_error(fatal,
"FMS_IO: get_tile_string: tile must be a positive number less than 100")
7748 if(
present(str2_in)) str_out=trim(str_out)//trim(str2_in)
7755 character(len=*),
intent(in) :: file_in
7756 character(len=*),
intent(out) :: file_out
7757 logical,
intent(in) :: is_no_domain
7758 type(domain2D),
intent(in),
optional,
target :: domain
7759 integer,
intent(in),
optional :: tile_count
7760 character(len=256) :: basefile, tilename
7761 integer :: lens, ntiles, ntileMe, tile, my_tile_id
7762 integer,
dimension(:),
allocatable :: tile_id
7763 type(domain2d),
pointer,
save :: d_ptr =>null()
7764 logical :: domain_exist
7766 if(index(file_in,
'.nc', back=.true.)==0)
then 7767 basefile = trim(file_in)
7769 lens = len_trim(file_in)
7770 if(file_in(lens-2:lens) .NE.
'.nc')
call mpp_error(fatal, &
7771 'fms_io_mod: .nc should be at the end of file '//trim(file_in))
7772 basefile = file_in(1:lens-3)
7778 domain_exist = .false.
7779 if(
PRESENT(domain))
then 7780 domain_exist = .true.
7781 ntiles = mpp_get_ntile_count(domain)
7783 elseif (
ASSOCIATED(
current_domain) .AND. .NOT. is_no_domain )
then 7784 domain_exist = .true.
7789 if(domain_exist)
then 7790 ntileme = mpp_get_current_ntile(d_ptr)
7791 allocate(tile_id(ntileme))
7792 tile_id = mpp_get_tile_id(d_ptr)
7794 if(
present(tile_count)) tile = tile_count
7795 my_tile_id = tile_id(tile)
7798 if(ntiles > 1 .or. my_tile_id > 1 )
then 7799 tilename =
'tile'//
string(my_tile_id)
7800 if(index(basefile,
'.'//trim(tilename),back=.true.) == 0)
then 7801 basefile = trim(basefile)//
'.'//trim(tilename);
7804 if(
allocated(tile_id))
deallocate(tile_id)
7806 file_out = trim(basefile)//
'.nc' 7813 character(len=*),
intent(in) :: file_in
7814 character(len=*),
intent(out) :: file_out
7815 type(domainug),
intent(in),
optional :: domain
7816 character(len=256) :: basefile, tilename
7817 integer :: lens, ntiles, my_tile_id
7819 if(index(file_in,
'.nc', back=.true.)==0)
then 7820 basefile = trim(file_in)
7822 lens = len_trim(file_in)
7823 if(file_in(lens-2:lens) .NE.
'.nc')
call mpp_error(fatal, &
7824 'fms_io_mod: .nc should be at the end of file '//trim(file_in))
7825 basefile = file_in(1:lens-3)
7831 if(
PRESENT(domain))
then 7832 ntiles = mpp_get_ug_domain_ntiles(domain)
7833 my_tile_id = mpp_get_ug_domain_tile_id(domain)
7836 if(ntiles > 1 .or. my_tile_id > 1 )
then 7837 tilename =
'tile'//
string(my_tile_id)
7838 if(index(basefile,
'.'//trim(tilename),back=.true.) == 0)
then 7839 basefile = trim(basefile)//
'.'//trim(tilename);
7843 file_out = trim(basefile)//
'.nc' 7850 character(len=*),
intent(out) :: grid_file
7851 character(len=*),
intent(in) :: mosaic_file
7852 type(domain2d),
intent(in) :: domain
7853 integer,
intent(in),
optional :: tile_count
7854 integer :: tile, ntileme
7855 integer,
dimension(:),
allocatable :: tile_id
7858 if(
present(tile_count)) tile = tile_count
7859 ntileme = mpp_get_current_ntile(domain)
7860 allocate(tile_id(ntileme))
7861 tile_id = mpp_get_tile_id(domain)
7862 call read_data(mosaic_file,
"gridfiles", grid_file, level=tile_id(tile) )
7863 grid_file =
'INPUT/'//trim(grid_file)
7869 character(len=*),
intent(in) :: file
7870 character(len=*),
intent(in) :: varname
7871 character(len=*),
intent(in) :: attname
7872 character(len=*),
intent(inout) :: attvalue
7875 call mpp_open(unit,trim(file),mpp_rdonly,mpp_netcdf,threading=mpp_multi,fileset=mpp_single)
7876 call mpp_get_att_value(unit, varname, attname, attvalue)
7877 call mpp_close(unit)
7886 character(len=*),
intent(in) :: file
7887 character(len=*),
intent(in) :: att
7888 character(len=*),
intent(inout) :: attvalue
7890 integer :: unit, ndim, nvar, natt, ntime, i
7891 type(atttype),
allocatable :: global_atts(:)
7894 call mpp_open(unit,trim(file),mpp_rdonly,mpp_netcdf,threading=mpp_multi,fileset=mpp_single)
7895 call mpp_get_info(unit, ndim, nvar, natt, ntime)
7896 allocate(global_atts(natt))
7897 call mpp_get_atts(unit,global_atts)
7899 if( trim(mpp_get_att_name(global_atts(i))) == trim(att) )
then 7900 attvalue = trim(mpp_get_att_char(global_atts(i)))
7905 deallocate(global_atts)
7914 character(len=*),
intent(in) :: file
7915 character(len=*),
intent(in) :: att
7916 real,
intent(inout) :: attvalue
7918 integer :: unit, ndim, nvar, natt, ntime, i
7919 type(atttype),
allocatable :: global_atts(:)
7922 call mpp_open(unit,trim(file),mpp_rdonly,mpp_netcdf,threading=mpp_multi,fileset=mpp_single)
7923 call mpp_get_info(unit, ndim, nvar, natt, ntime)
7924 allocate(global_atts(natt))
7925 call mpp_get_atts(unit,global_atts)
7927 if( trim(mpp_get_att_name(global_atts(i))) == trim(att) )
then 7928 attvalue = mpp_get_att_real_scalar(global_atts(i))
7933 deallocate(global_atts)
7942 function get_file_name(orig_file, actual_file, read_dist, io_domain_exist, no_domain, domain, &
7944 character(len=*),
intent(in) :: orig_file
7945 character(len=*),
intent(out) :: actual_file
7946 logical,
intent(out) :: read_dist
7947 logical,
intent(out) :: io_domain_exist
7948 logical,
optional,
intent(in) :: no_domain
7949 type(domain2d),
target,
optional,
intent(in) :: domain
7950 integer,
optional,
intent(in) :: tile_count
7953 type(domain2d),
pointer,
save :: d_ptr, io_domain
7954 logical :: fexist, is_no_domain
7955 integer :: tile_id(1)
7956 character(len=256) :: fname
7957 character(len=512) :: actual_file_tmp
7959 is_no_domain=.false.
7960 if(
PRESENT(no_domain)) is_no_domain = no_domain
7966 io_domain_exist = .false.
7969 if(index(orig_file,
'.nc', back=.true.) == 0)
then 7970 inquire (file=trim(orig_file), exist=fexist)
7972 actual_file = orig_file
7978 if(
present(domain))
then 7980 elseif (
ASSOCIATED(
current_domain) .AND. .NOT. is_no_domain )
then 7990 if(
ASSOCIATED(d_ptr))
then 7991 io_domain => mpp_get_io_domain(d_ptr)
7992 if(
associated(io_domain))
then 7993 tile_id = mpp_get_tile_id(io_domain)
7994 write(fname,
'(a,i4.4)' ) trim(actual_file)//
'.', tile_id(1)
7995 inquire (file=trim(fname), exist=fexist)
7996 if(.not. fexist)
then 7997 write(fname,
'(a,i6.6)' ) trim(actual_file)//
'.', tile_id(1)
7998 inquire (file=trim(fname), exist=fexist)
8000 if(fexist) io_domain_exist = .true.
8012 inquire (file=trim(actual_file), exist=fexist)
8022 if(index(orig_file,
'.nc', back=.true.) == 0)
then 8023 inquire (file=trim(actual_file), exist=fexist)
8032 actual_file_tmp = actual_file
8036 if(
ASSOCIATED(d_ptr))
then 8037 io_domain => mpp_get_io_domain(d_ptr)
8038 if(
associated(io_domain))
then 8039 tile_id = mpp_get_tile_id(io_domain)
8040 if(mpp_npes()>10000)
then 8041 write(fname,
'(a,i6.6)' ) trim(actual_file)//
'.', tile_id(1)
8043 write(fname,
'(a,i4.4)' ) trim(actual_file)//
'.', tile_id(1)
8045 inquire (file=trim(fname), exist=fexist)
8046 if(fexist) io_domain_exist = .true.
8058 inquire (file=trim(actual_file), exist=fexist)
8071 subroutine get_file_unit(filename, unit, index_file, read_dist, io_domain_exist, domain )
8072 character(len=*),
intent(in) :: filename
8073 integer,
intent(out) :: unit, index_file
8074 logical,
intent(in) :: read_dist, io_domain_exist
8075 type(domain2d),
optional,
intent(in) :: domain
8077 logical :: file_opened
8083 if (
files_read(i)%name == trim(filename))
then 8093 call mpp_error(fatal,
'fms_io(get_file_unit): max_files_r exceeded, increase it via fms_io_nml')
8096 if(io_domain_exist)
then 8097 if(
present(domain))
then 8098 call mpp_open(unit,filename,
form=
form,action=mpp_rdonly,threading=mpp_multi, &
8099 fileset=mpp_multi, domain=domain)
8101 call mpp_open(unit,filename,
form=
form,action=mpp_rdonly,threading=mpp_multi, &
8104 call mpp_error(fatal,
'fms_io(get_file_unit): when io_domain_exsit = .true., '// &
8105 'either domain is present or current_domain is associated')
8108 call mpp_open(unit,trim(filename),
form=
form,action=mpp_rdonly,threading=mpp_multi, &
8112 call mpp_open(unit,trim(filename),
form=
form,action=mpp_rdonly,threading=mpp_multi, &
8124 subroutine get_field_id(unit, index_file, fieldname, index_field, is_no_domain, is_not_dim)
8125 integer,
intent(in) :: unit
8126 integer,
intent(in) :: index_file
8127 character(len=*),
intent(in) :: fieldname
8128 integer,
intent(out) :: index_field
8129 logical,
intent(in) :: is_no_domain
8130 logical,
intent(in) :: is_not_dim
8132 character(len=128) :: name
8133 type(axistype),
dimension(max_axes) :: axes
8134 type(fieldtype),
dimension(max_fields) :: fields
8135 integer :: i, j, ndim, nvar, natt, var_dim
8136 integer :: siz_in(4)
8140 if (trim(
files_read(index_file)%var(j)%name) == trim(fieldname))
then 8150 call mpp_error(fatal,
'fms_io(get_field_id): max_fields exceeded, needs increasing, nvar/max_fields=' &
8153 call mpp_get_info(unit, ndim, nvar, natt,
files_read(index_file)%max_ntime)
8157 call mpp_error(fatal,
'fms_io(get_field_id): max_fields too small needs increasing,nvar/max_fields=' &
8160 call mpp_get_fields(unit, fields(1:nvar))
8163 files_read(index_file)%var(index_field)%is_dimvar = .false.
8166 call mpp_get_atts(fields(i),name=name,ndim=var_dim,siz=siz_in)
8167 if(var_dim .GT. 4)
call mpp_error(fatal,
'fms_io(get_field_id): number of dimension of field '// &
8168 trim(name)//
' in file '//trim(
files_read(index_file)%name)//
' should not be greater than 4')
8169 if (lowercase(trim(name)) == lowercase(trim(fieldname)))
then 8170 if(var_dim .lt.3)
then 8175 files_read(index_file)%var(index_field)%name = fieldname
8176 files_read(index_file)%var(index_field)%field = fields(i)
8177 files_read(index_file)%var(index_field)%siz(1:4) = siz_in(1:4)
8178 files_read(index_file)%var(index_field)%gsiz(1:3) = siz_in(1:3)
8184 if( .not. is_not_dim)
then 8187 call mpp_error(fatal,
'fms_io(get_field_id): max_axes exceeded, needs increasing, ndim/max_fields=' &
8190 call mpp_get_axes(unit, axes(1:ndim))
8192 call mpp_get_atts(axes(i), name=name, len = siz_in(1))
8193 if (lowercase(trim(name)) == lowercase(trim(fieldname)))
then 8196 files_read(index_file)%var(index_field)%is_dimvar = .true.
8197 files_read(index_file)%var(index_field)%name = fieldname
8198 files_read(index_file)%var(index_field)%axis = axes(i)
8199 files_read(index_file)%var(index_field)%siz(1:4) = siz_in(1:4)
8200 files_read(index_file)%var(index_field)%gsiz(1:3) = siz_in(1:3)
8206 call mpp_error(fatal,
'fms_io(get_field_id): field '//trim(fieldname)// &
8207 ' NOT found in file '//trim(
files_read(index_file)%name))
8245 function file_exist (file_name, domain, no_domain)
8246 character(len=*),
intent(in) :: file_name
8247 type(domain2d),
intent(in),
optional :: domain
8248 logical,
intent(iN),
optional :: no_domain
8251 character(len=256) :: fname
8252 logical :: read_dist, io_domain_exist
8254 is_no_domain = .false.
8255 if(
present(no_domain)) is_no_domain = no_domain
8257 file_exist =
get_file_name(file_name, fname, read_dist, io_domain_exist, no_domain=is_no_domain, domain=domain)
8258 if(is_no_domain)
return 8297 function field_exist (file_name, field_name, domain, no_domain)
8298 character(len=*),
intent(in) :: file_name
8299 character(len=*),
intent(in) :: field_name
8300 type(domain2d),
intent(in),
optional,
target :: domain
8301 logical,
intent(in),
optional :: no_domain
8303 integer :: unit, ndim, nvar, natt, ntime, i, nfile
8304 character(len=64) :: name
8305 type(fieldtype),
allocatable :: fields(:)
8306 logical ::
file_exist, read_dist, io_domain_exist
8307 character(len=256) :: fname
8310 if (len_trim(field_name) == 0)
return 8311 if (field_name(1:1) ==
' ')
return 8313 is_no_domain = .false.
8314 if(
present(no_domain)) is_no_domain = no_domain
8318 call get_file_unit(fname, unit, nfile, read_dist, io_domain_exist, domain=domain)
8319 call mpp_get_info(unit, ndim, nvar, natt, ntime)
8320 allocate(fields(nvar))
8321 call mpp_get_fields(unit,fields)
8324 call mpp_get_atts(fields(i),name=name)
8325 if(lowercase(trim(name)) == lowercase(trim(field_name)))
field_exist = .true.
8332 call get_file_unit(fname, unit, nfile, read_dist, io_domain_exist)
8333 call mpp_get_info(unit, ndim, nvar, natt, ntime)
8334 allocate(fields(nvar))
8335 call mpp_get_fields(unit,fields)
8337 call mpp_get_atts(fields(i),name=name)
8338 if(lowercase(trim(name)) == lowercase(trim(field_name)))
field_exist = .true.
8350 character(len=*) ,
intent(out) :: string_out
8366 character(len=*) ,
intent(in) :: string_in
8368 integer :: index_num
8372 if ( index_num .le. 0 )
then 8379 character(len=*) ,
intent(in) :: name_in
8380 character(len=*),
intent(inout) :: name_out
8383 length = len_trim(name_in)
8384 name_out = name_in(1:length)
8387 if(name_in(length-2:length) ==
'.nc')
then 8399 character(len=*),
intent(in) :: mask_table
8400 logical,
intent(out) :: maskmap(:,:)
8401 character(len=*),
intent(in) :: modelname
8402 integer :: nmask, layout(2)
8403 integer,
allocatable :: mask_list(:,:)
8404 integer :: unit, mystat, n, stdoutunit
8405 character(len=128) :: record
8409 stdoutunit = stdout()
8410 if( mpp_pe() == mpp_root_pe() )
then 8411 call mpp_open(unit, mask_table, action=mpp_rdonly)
8412 read(unit, fmt=*, iostat=mystat) nmask
8413 if( mystat /= 0 )
call mpp_error(fatal, &
8414 "fms_io(parse_mask_table_2d): Error reading nmask from file " //trim(mask_table))
8415 write(stdoutunit,*)
"parse_mask_table: Number of domain regions masked in ", trim(modelname),
" = ", nmask
8416 if( nmask > 0 )
then 8418 read(unit, fmt=*, iostat=mystat) layout
8419 if( mystat /= 0 )
call mpp_error(fatal, &
8420 "fms_io(parse_mask_talbe_2d): Error reading layout from file " //trim(mask_table))
8421 if( (layout(1) .NE.
size(maskmap,1)) .OR. (layout(2) .NE.
size(maskmap,2)) )
then 8422 write(stdoutunit,*)
"layout=", layout,
", size(maskmap) = ",
size(maskmap,1),
size(maskmap,2)
8423 call mpp_error(fatal,
"fms_io(parse_mask_table_2d): layout in file "//trim(mask_table)// &
8424 "does not match size of maskmap for "//trim(modelname))
8427 if( mpp_npes() .NE. layout(1)*layout(2) - nmask )
call mpp_error(fatal, &
8428 .NE.
"fms_io(parse_mask_table_2d): mpp_npes() layout(1)*layout(2) - nmask for "//trim(modelname))
8432 call mpp_broadcast(nmask, mpp_root_pe())
8435 if( mpp_pe() == mpp_root_pe() )
call mpp_close(unit)
8439 allocate(mask_list(nmask,2))
8441 if( mpp_pe() == mpp_root_pe() )
then 8444 read(unit,
'(a)',end=999) record
8445 if (record(1:1) ==
'#') cycle
8446 if (record(1:10) ==
' ') cycle
8448 if( n > nmask )
then 8449 call mpp_error(fatal,
"fms_io(parse_mask_table_2d): number of mask_list entry "// &
8450 "is greater than nmask in file "//trim(mask_table) )
8452 read(record,*,err=888) mask_list(n,1), mask_list(n,2)
8454 888
call mpp_error(fatal,
"fms_io(parse_mask_table_2d): Error in reading mask_list from file "//trim(mask_table))
8458 if( n .NE. nmask)
call mpp_error(fatal, &
8459 "fms_io(parse_mask_table_2d): number of mask_list entry does not match nmask in file "//trim(mask_table))
8460 call mpp_close(unit)
8463 call mpp_broadcast(mask_list, 2*nmask, mpp_root_pe())
8466 write(stdoutunit,*)
"==>NOTE from parse_mask_table_2d: ", trim(modelname),
" mask_list = ", mask_list(n,1), mask_list(n,2)
8468 maskmap(mask_list(n,1),mask_list(n,2)) = .false.
8471 deallocate(mask_list)
8479 character(len=*),
intent(in) :: mask_table
8480 logical,
intent(out) :: maskmap(:,:,:)
8481 character(len=*),
intent(in) :: modelname
8482 integer :: nmask, layout(2)
8483 integer,
allocatable :: mask_list(:,:)
8484 integer :: unit, mystat, n, stdoutunit, ntiles
8485 character(len=128) :: record
8489 stdoutunit = stdout()
8490 if( mpp_pe() == mpp_root_pe() )
then 8491 call mpp_open(unit, mask_table, action=mpp_rdonly)
8492 read(unit, fmt=*, iostat=mystat) nmask
8493 if( mystat /= 0 )
call mpp_error(fatal, &
8494 "fms_io(parse_mask_table_3d): Error reading nmask from file " //trim(mask_table))
8495 write(stdoutunit,*)
"parse_mask_table: Number of domain regions masked in ", trim(modelname),
" = ", nmask
8496 if( nmask > 0 )
then 8498 read(unit, fmt=*, iostat=mystat) layout(1), layout(2), ntiles
8499 if( mystat /= 0 )
call mpp_error(fatal, &
8500 "fms_io(parse_mask_talbe_3d): Error reading layout from file " //trim(mask_table))
8501 if( (layout(1) .NE.
size(maskmap,1)) .OR. (layout(2) .NE.
size(maskmap,2)) )
then 8502 write(stdoutunit,*)
"layout=", layout,
", size(maskmap) = ",
size(maskmap,1),
size(maskmap,2)
8503 call mpp_error(fatal,
"fms_io(parse_mask_table_3d): layout in file "//trim(mask_table)// &
8504 "does not match size of maskmap for "//trim(modelname))
8506 if( ntiles .NE.
size(maskmap,3) )
then 8507 write(stdoutunit,*)
"ntiles=", ntiles,
", size(maskmap,3) = ",
size(maskmap,3)
8508 call mpp_error(fatal,
"fms_io(parse_mask_table_3d): ntiles in file "//trim(mask_table)// &
8509 "does not match size of maskmap for "//trim(modelname))
8512 if( mpp_npes() .NE. layout(1)*layout(2)*ntiles - nmask )
then 8513 print*,
"layout=", layout, nmask, mpp_npes()
8515 .NE.
"fms_io(parse_mask_table_3d): mpp_npes() layout(1)*layout(2) - nmask for "//trim(modelname))
8520 call mpp_broadcast(nmask, mpp_root_pe())
8523 if( mpp_pe() == mpp_root_pe() )
call mpp_close(unit)
8527 allocate(mask_list(nmask,3))
8529 if( mpp_pe() == mpp_root_pe() )
then 8532 read(unit,
'(a)',end=999) record
8533 if (record(1:1) ==
'#') cycle
8534 if (record(1:10) ==
' ') cycle
8536 if( n > nmask )
then 8537 call mpp_error(fatal,
"fms_io(parse_mask_table_3d): number of mask_list entry "// &
8538 "is greater than nmask in file "//trim(mask_table) )
8540 read(record,*,err=888) mask_list(n,1), mask_list(n,2), mask_list(n,3)
8542 888
call mpp_error(fatal,
"fms_io(parse_mask_table_3d): Error in reading mask_list from file "//trim(mask_table))
8546 if( n .NE. nmask)
call mpp_error(fatal, &
8547 "fms_io(parse_mask_table_3d): number of mask_list entry does not match nmask in file "//trim(mask_table))
8548 call mpp_close(unit)
8551 call mpp_broadcast(mask_list, 3*nmask, mpp_root_pe())
8554 write(stdoutunit,*)
"==>NOTE from parse_mask_table_3d: ", trim(modelname),
" mask_list = ", &
8555 mask_list(n,1), mask_list(n,2), mask_list(n,3)
8557 maskmap(mask_list(n,1),mask_list(n,2),mask_list(n,3)) = .false.
8560 deallocate(mask_list)
8569 "fms_io(use_great_circle_algorithm): fms_io_init is not called yet")
8612 character(len=*),
intent(in) :: version
8613 character(len=*),
intent(in),
optional :: tag
8614 integer,
intent(in),
optional :: unit
8621 if (
present(unit))
then 8625 if ( mpp_pe() /= mpp_root_pe() )
return 8628 if (
present(tag))
then 8629 write (logunit,
'(/,80("="),/(a))') trim(version), trim(tag)
8631 write (logunit,
'(/,80("="),/(a))') trim(version)
8639 #include <fms_io_unstructured_register_restart_axis.inc> 8640 #include <fms_io_unstructured_setup_one_field.inc> 8641 #include <fms_io_unstructured_register_restart_field.inc> 8642 #include <fms_io_unstructured_save_restart.inc> 8643 #include <fms_io_unstructured_read.inc> 8644 #include <fms_io_unstructured_get_file_name.inc> 8645 #include <fms_io_unstructured_get_file_unit.inc> 8646 #include <fms_io_unstructured_file_unit.inc> 8647 #include <fms_io_unstructured_get_field_size.inc> 8648 #include <fms_io_unstructured_field_exist.inc>
subroutine, public set_meta_global(fileObj, name, rval, ival, cval)
integer function register_restart_field_r1d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, compressed_axis, read_only, restart_owns_data)
logical function, public get_great_circle_algorithm()
subroutine read_distributed_r3d(unit, fmt, iostat, data)
subroutine, public set_domain(Domain2)
integer function register_restart_field_r4d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only, restart_owns_data)
logical fms_netcdf_restart
subroutine read_data_3d(unit, data, end)
integer, parameter, private max_time_level_write
subroutine, public free_restart_type(fileObj)
subroutine, public nullify_filename_appendix()
subroutine read_data_iscalar_new(filename, fieldname, data, domain, timelevel, no_domain, tile_count)
character(len=128), dimension(:), allocatable registered_file
subroutine save_unlimited_axis_restart(fileObj, restartpath)
integer function register_restart_region_r2d(fileObj, filename, fieldname, data, indices, global_size, pelist, is_root_pe, longname, units, position, x_halo, y_halo, ishift, jshift, read_only, mandatory)
type(atttype), save, public default_att
logical function query_initialized_id(fileObj, id)
integer function, public open_direct_file(file, action, recl)
subroutine register_restart_axis_i1d(fileObj, filename, fieldname, data, compressed, compressed_axis, dimlen, dimlen_name, dimlen_lname, units, longname, imin)
integer function register_restart_field_r0d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only, restart_owns_data)
logical function query_initialized_r2d(fileObj, f_ptr, name)
subroutine write_data_1d_new(filename, fieldname, data, domain, no_domain, tile_count, data_default)
integer function, private lookup_axis(axis_sizes, siz, domains, dom)
integer, parameter, private max_domains
integer function register_restart_field_r1d_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only)
character(len=128) error_msg
subroutine read_distributed_r1d(unit, fmt, iostat, data)
subroutine read_compressed_i1d(filename, fieldname, data, domain, timelevel, start, nread, threading)
logical time_stamp_restart
subroutine reset_field_pointer_r4d(fileObj, id_field, data)
integer function register_restart_field_r2d_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only)
logical function, public file_exist(file_name, domain, no_domain)
subroutine reset_field_pointer_i1d_2level(fileObj, id_field, data1, data2)
subroutine set_initialized_r2d(fileObj, f_ptr, name, is_set)
integer function register_restart_field_r2d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, compressed, position, tile_count, data_default, longname, units, compressed_axis, read_only, restart_owns_data)
integer, parameter max_axis_size
logical function do_read()
subroutine reset_field_pointer_r2d_2level(fileObj, id_field, data1, data2)
character(len=32), save filename_appendix
subroutine write_data_4d(unit, data)
subroutine read_compressed_i2d(filename, fieldname, data, domain, timelevel, start, nread, threading)
integer function register_restart_region_r3d(fileObj, filename, fieldname, data, indices, global_size, pelist, is_root_pe, longname, units, position, x_halo, y_halo, ishift, jshift, read_only, mandatory)
subroutine save_default_restart(fileObj, restartpath)
subroutine write_data_4d_new(filename, fieldname, data, domain, no_domain, position, tile_count, data_default)
integer function, private unique_axes(file, index, id_axes, siz_axes, dom)
subroutine parse_mask_table_3d(mask_table, maskmap, modelname)
logical function get_global_att_value_text(file, att, attvalue)
subroutine write_chksum(fileObj, action)
subroutine read_compressed_1d(filename, fieldname, data, domain, timelevel, start, nread, threading)
subroutine read_data_2d(unit, data, end)
integer function register_restart_field_i1d_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only)
subroutine write_data_3d(unit, data)
subroutine write_ldata_2d(unit, data)
subroutine, public reset_field_name(fileObj, id_field, name)
subroutine, public write_version_number(version, tag, unit)
subroutine parse_mask_table_2d(mask_table, maskmap, modelname)
integer, parameter, private max_split_file
subroutine get_var_att_value_text(file, varname, attname, attvalue)
subroutine, public get_field_size(filename, fieldname, siz, field_found, domain, no_domain)
subroutine restore_state_all(fileObj, directory, nonfatal_missing_files)
subroutine reset_field_pointer_i3d_2level(fileObj, id_field, data1, data2)
type(restart_file_type), dimension(:), allocatable files_read
integer function register_restart_field_r3d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only, compressed, compressed_axis, restart_owns_data)
subroutine set_initialized_r3d(fileObj, f_ptr, name, is_set)
type(domain1d), dimension(max_domains), save domain_y
integer function register_restart_field_i1d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, compressed_axis, read_only, restart_owns_data)
subroutine read_compressed_3d(filename, fieldname, data, domain, timelevel)
subroutine read_data_2d_region(filename, fieldname, data, start, nread, domain, no_domain, tile_count)
integer, parameter, private max_axes
subroutine read_distributed_i1d(unit, fmt, iostat, data)
logical function query_initialized_r4d(fileObj, f_ptr, name)
integer(int_kind), parameter, public ccidx
subroutine write_idata_2d(unit, data)
subroutine read_distributed_iscalar(unit, fmt, iostat, data)
subroutine read_data_i1d_new(filename, fieldname, data, domain, timelevel, no_domain, tile_count)
subroutine read_ldata_2d(unit, data, end)
subroutine set_initialized_r4d(fileObj, f_ptr, name, is_set)
logical checksum_required
subroutine reset_field_pointer_i0d_2level(fileObj, id_field, data1, data2)
logical function all_field_read_only(fileObj)
integer(int_kind), parameter, public uidx
character(len=input_str_length), dimension(:), allocatable, target, public input_nml_file
subroutine read_data_i3d_new(filename, fieldname, data, domain, timelevel, no_domain, position, tile_count)
subroutine read_compressed_2d(filename, fieldname, data, domain, timelevel, start, nread, threading)
integer function, public dimension_size(filename, dimname, domain, no_domain)
subroutine reset_field_pointer_r1d_2level(fileObj, id_field, data1, data2)
integer function register_restart_field_i3d_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only)
subroutine, public set_filename_appendix(string_in)
subroutine reset_field_pointer_i1d(fileObj, id_field, data)
logical function, public get_file_name(orig_file, actual_file, read_dist, io_domain_exist, no_domain, domain, tile_count)
subroutine register_restart_axis_unlimited(fileObj, filename, fieldname, nelem, units, longname)
subroutine reset_field_pointer_r0d(fileObj, id_field, data)
integer function, public open_ieee32_file(file, action)
subroutine reset_field_pointer_r2d(fileObj, id_field, data)
type(domain1d), dimension(max_domains), save domain_x
subroutine restore_state_one_field(fileObj, id_field, directory, nonfatal_missing_files)
subroutine, public get_restart_io_mode(do_netcdf_restart)
subroutine read_data_i2d_new(filename, fieldname, data, domain, timelevel, no_domain, position, tile_count)
type(domain2d), save, public null_domain2d
subroutine reset_field_pointer_r0d_2level(fileObj, id_field, data1, data2)
integer, parameter, public comm_tag_2
subroutine reset_field_pointer_r3d(fileObj, id_field, data)
subroutine read_distributed_r5d(unit, fmt, iostat, data)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call mpp_error(FATAL, 'MPP_TRANSMIT:you cannot transmit to ANY_PE using MPI.') else if(to_pe.NE.NULL_PE) then !no other valid cases except NULL_PE call mpp_error(FATAL
subroutine, public get_domain_decomp(x, y)
subroutine, public fms_io_init()
subroutine, public field_size(filename, fieldname, siz, field_found, domain, no_domain)
subroutine write_data_2d(unit, data)
subroutine read_data_4d(unit, data, end)
subroutine get_field_id(unit, index_file, fieldname, index_field, is_no_domain, is_not_dim)
character(len=32) threading_read
type(axistype), save, public default_axis
subroutine get_file_unit(filename, unit, index_file, read_dist, io_domain_exist, domain)
subroutine, public nullify_domain()
subroutine write_meta_global(unit, fileObj)
subroutine write_data_3d_new(filename, fieldname, data, domain, no_domain, scalar_or_1d, position, tile_count, data_default)
integer, parameter, private nidx
subroutine, public save_restart_border(fileObj, time_stamp, directory)
subroutine reset_field_pointer_i3d(fileObj, id_field, data)
subroutine, public restore_state_border(fileObj, directory, nonfatal_missing_files)
integer function, public open_namelist_file(file)
type(domain2d), pointer, private current_domain
integer function register_restart_field_i2d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, compressed, position, tile_count, data_default, longname, units, compressed_axis, read_only, restart_owns_data)
subroutine save_compressed_restart(fileObj, restartpath, append, time_level)
subroutine read_data_1d_new(filename, fieldname, data, domain, timelevel, no_domain, tile_count)
subroutine set_initialized_name(fileObj, name, is_set)
subroutine reset_field_pointer_r3d_2level(fileObj, id_field, data1, data2)
integer num_registered_files
subroutine reset_field_pointer_i2d_2level(fileObj, id_field, data1, data2)
subroutine reset_field_pointer_i0d(fileObj, id_field, data)
logical function get_global_att_value_real(file, att, attvalue)
subroutine reset_field_pointer_r1d(fileObj, id_field, data)
subroutine, public get_mosaic_tile_file_ug(file_in, file_out, domain)
integer(int_kind), parameter, public cidx
integer, parameter, private max_time_level_register
subroutine register_restart_axis_r1d(fileObj, filename, fieldname, data, cartesian, units, longname, sense, min, calendar)
character(len=16) function string_from_integer(n)
subroutine read_eof(end_found)
logical great_circle_algorithm
integer function register_restart_field_i0d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only, restart_owns_data)
subroutine read_data_scalar_new(filename, fieldname, data, domain, timelevel, no_domain, tile_count)
subroutine read_distributed_a1d(unit, fmt, iostat, data)
subroutine get_size(unit, fieldname, siz, found)
integer function lookup_domain(domain)
logical show_open_namelist_file_warning
subroutine, public fms_io_exit()
logical function query_initialized_r3d(fileObj, f_ptr, name)
integer function, public open_restart_file(file, action)
type(domain2d), dimension(max_domains), target, save array_domain
integer function, public open_file(file, form, action, access, threading, recl, dist)
subroutine read_data_2d_ug(filename, fieldname, data, SG_domain, UG_domain, timelevel)
character(len=32) function string_from_real(a)
subroutine, public get_filename_appendix(string_out)
subroutine, public get_tile_string(str_out, str_in, tile, str2_in)
subroutine, public get_mosaic_tile_grid(grid_file, mosaic_file, domain, tile_count)
integer(int_kind), parameter, public yidx
integer(int_kind), parameter, public hidx
subroutine write_data_i3d_new(filename, fieldname, data, domain, no_domain, position, tile_count, data_default)
subroutine get_axis_cart(axis, cart)
subroutine read_data_3d_new(filename, fieldname, data, domain, timelevel, no_domain, scalar_or_1d, position, tile_count)
subroutine write_data_scalar_new(filename, fieldname, data, domain, no_domain, tile_count, data_default)
integer, parameter, private max_fields
subroutine write_data_2d_new(filename, fieldname, data, domain, no_domain, position, tile_count, data_default)
subroutine, public get_instance_filename(name_in, name_out)
subroutine read_data_2d_new(filename, fieldname, data, domain, timelevel, no_domain, position, tile_count)
subroutine reset_field_pointer_i2d(fileObj, id_field, data)
subroutine read_data_3d_region(filename, fieldname, data, start, nread, domain, no_domain, tile_count)
integer, parameter, private max_atts
subroutine get_mosaic_tile_file_sg(file_in, file_out, is_no_domain, domain, tile_count)
integer(int_kind), parameter, public zidx
logical fms_netcdf_override
type(restart_file_type), dimension(:), allocatable, target files_write
subroutine read_idata_2d(unit, data, end)
integer function register_restart_field_r3d_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only)
integer(int_kind), parameter, public tidx
subroutine read_data_4d_new(filename, fieldname, data, domain, timelevel, no_domain, position, tile_count)
subroutine set_initialized_id(fileObj, id, is_set)
integer function register_restart_field_i0d_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only)
character(len=64) iospec_ieee32
subroutine setup_one_field(fileObj, filename, fieldname, field_siz, index_field, domain, mandatory, no_domain, scalar_or_1d, position, tile_count, data_default, longname, units, compressed_axis, read_only, owns_data)
integer function, private lookup_field_r(nfile, fieldname)
subroutine write_data_i1d_new(filename, fieldname, data, domain, no_domain, tile_count, data_default)
logical module_is_initialized
subroutine write_data_i2d_new(filename, fieldname, data, domain, no_domain, position, tile_count, data_default)
type(fieldtype), save, public default_field
logical function query_initialized_name(fileObj, name)
subroutine, public close_file(unit, status, dist)
subroutine file_unit(filename, found_file, unit, domain, no_domain)
subroutine write_data_iscalar_new(filename, fieldname, data, domain, no_domain, tile_count, data_default)
integer function register_restart_field_i2d_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only)
subroutine, public return_domain(domain2)
logical function, public field_exist(file_name, field_name, domain, no_domain)
integer(int_kind), parameter, public xidx
subroutine, public save_restart(fileObj, time_stamp, directory, append, time_level)
integer function register_restart_field_i3d(fileObj, filename, fieldname, data, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only, restart_owns_data)
integer function register_restart_field_r0d_2level(fileObj, filename, fieldname, data1, data2, domain, mandatory, no_domain, position, tile_count, data_default, longname, units, read_only)
subroutine read_data_text(filename, fieldname, data, level)
type(domain1d), save, public null_domain1d