36 public :: fileio_write
43 end interface fileio_read
45 interface fileio_write
51 end interface fileio_write
65 real(RP),
private,
allocatable :: axis_lon (:,:)
66 real(RP),
private,
allocatable :: axis_lonx(:,:)
67 real(RP),
private,
allocatable :: axis_lony(:,:)
68 real(RP),
private,
allocatable :: axis_lonxy(:,:)
69 real(RP),
private,
allocatable :: axis_lat (:,:)
70 real(RP),
private,
allocatable :: axis_latx(:,:)
71 real(RP),
private,
allocatable :: axis_laty(:,:)
72 real(RP),
private,
allocatable :: axis_latxy(:,:)
82 if(
io_l )
write(
io_fid_log,*)
'++++++ Module[FIELIO] / Categ[ATMOS-RM IO] / Origin[SCALElib]' 118 real(RP),
intent(in) :: LON (
ia,
ja)
119 real(RP),
intent(in) :: LONX(
ia,
ja)
120 real(RP),
intent(in) :: LONY(
ia,
ja)
121 real(RP),
intent(in) :: LONXY(
ia,
ja)
122 real(RP),
intent(in) :: LAT (
ia,
ja)
123 real(RP),
intent(in) :: LATX(
ia,
ja)
124 real(RP),
intent(in) :: LATY(
ia,
ja)
125 real(RP),
intent(in) :: LATXY(
ia,
ja)
126 real(RP),
intent(in) :: CZ (
ka,
ia,
ja)
127 real(RP),
intent(in) :: FZ (0:
ka,
ia,
ja)
151 fileputassociatedcoordinates
187 integer,
intent(in) :: fid
188 integer,
intent(in) :: dtype
189 logical,
intent(in),
optional :: xy
191 character(len=2) :: AXIS_name(2)
195 if (
present(xy) )
then 201 if ( .NOT. xy_ )
then 202 call fileputaxis( fid,
'z',
'Z',
'm',
'z', dtype,
grid_cz(
ks:
ke) )
204 call fileputaxis( fid,
'x',
'X',
'm',
'x', dtype,
grid_cx(
isb:
ieb) )
205 call fileputaxis( fid,
'y',
'Y',
'm',
'y', dtype,
grid_cy(
jsb:
jeb) )
206 if ( .NOT. xy_ )
then 207 call fileputaxis( fid,
'zh',
'Z (half level)',
'm',
'zh', dtype,
grid_fz(
ks:
ke) )
209 call fileputaxis( fid,
'xh',
'X (half level)',
'm',
'xh', dtype,
grid_fx(
isb:
ieb) )
210 call fileputaxis( fid,
'yh',
'Y (half level)',
'm',
'yh', dtype,
grid_fy(
jsb:
jeb) )
212 if ( .NOT. xy_ )
then 213 call fileputaxis( fid,
'lz',
'LZ',
'm',
'lz', dtype,
grid_lcz(
lks:
lke) )
214 call fileputaxis( fid,
'lzh',
'LZ (half level)',
'm',
'lzh', dtype,
grid_lfz(
lks:
lke) )
215 call fileputaxis( fid,
'uz',
'UZ',
'm',
'uz', dtype,
grid_ucz(
uks:
uke) )
216 call fileputaxis( fid,
'uzh',
'UZ (half level)',
'm',
'uzh', dtype,
grid_ufz(
uks:
uke) )
220 if ( .NOT. xy_ )
then 221 call fileputaxis( fid,
'CZ',
'Atmos Grid Center Position Z',
'm',
'CZ', dtype,
grid_cz )
223 call fileputaxis( fid,
'CX',
'Atmos Grid Center Position X',
'm',
'CX', dtype,
grid_cx )
224 call fileputaxis( fid,
'CY',
'Atmos Grid Center Position Y',
'm',
'CY', dtype,
grid_cy )
225 if ( .NOT. xy_ )
then 226 call fileputaxis( fid,
'FZ',
'Atmos Grid Face Position Z',
'm',
'FZ', dtype,
grid_fz )
228 call fileputaxis( fid,
'FX',
'Atmos Grid Face Position X',
'm',
'FX', dtype,
grid_fx )
229 call fileputaxis( fid,
'FY',
'Atmos Grid Face Position Y',
'm',
'FY', dtype,
grid_fy )
231 if ( .NOT. xy_ )
then 232 call fileputaxis( fid,
'CDZ',
'Grid Cell length Z',
'm',
'CZ', dtype,
grid_cdz )
234 call fileputaxis( fid,
'CDX',
'Grid Cell length X',
'm',
'CX', dtype,
grid_cdx )
235 call fileputaxis( fid,
'CDY',
'Grid Cell length Y',
'm',
'CY', dtype,
grid_cdy )
236 if ( .NOT. xy_ )
then 237 call fileputaxis( fid,
'FDZ',
'Grid distance Z',
'm',
'FDZ', dtype,
grid_fdz )
239 call fileputaxis( fid,
'FDX',
'Grid distance X',
'm',
'FDX', dtype,
grid_fdx )
240 call fileputaxis( fid,
'FDY',
'Grid distance Y',
'm',
'FDY', dtype,
grid_fdy )
242 if ( .NOT. xy_ )
then 243 call fileputaxis( fid,
'LCZ',
'Land Grid Center Position Z',
'm',
'LCZ', dtype,
grid_lcz )
244 call fileputaxis( fid,
'LFZ',
'Land Grid Face Position Z',
'm',
'LFZ', dtype,
grid_lfz )
245 call fileputaxis( fid,
'LCDZ',
'Land Grid Cell length Z',
'm',
'LCZ', dtype,
grid_lcz )
247 call fileputaxis( fid,
'UCZ',
'Urban Grid Center Position Z',
'm',
'UCZ', dtype,
grid_ucz )
248 call fileputaxis( fid,
'UFZ',
'Urban Grid Face Position Z',
'm',
'UFZ', dtype,
grid_ufz )
249 call fileputaxis( fid,
'UCDZ',
'Urban Grid Cell length Z',
'm',
'UCZ', dtype,
grid_ucz )
252 if ( .NOT. xy_ )
then 253 call fileputaxis( fid,
'CBFZ',
'Boundary factor Center Z',
'1',
'CZ', dtype,
grid_cbfz )
255 call fileputaxis( fid,
'CBFX',
'Boundary factor Center X',
'1',
'CX', dtype,
grid_cbfx )
256 call fileputaxis( fid,
'CBFY',
'Boundary factor Center Y',
'1',
'CY', dtype,
grid_cbfy )
257 if ( .NOT. xy_ )
then 258 call fileputaxis( fid,
'FBFZ',
'Boundary factor Face Z',
'1',
'CZ', dtype,
grid_fbfz )
260 call fileputaxis( fid,
'FBFX',
'Boundary factor Face X',
'1',
'CX', dtype,
grid_fbfx )
261 call fileputaxis( fid,
'FBFY',
'Boundary factor Face Y',
'1',
'CY', dtype,
grid_fbfy )
263 call fileputaxis( fid,
'CXG',
'Grid Center Position X (global)',
'm',
'CXG', dtype,
grid_cxg )
264 call fileputaxis( fid,
'CYG',
'Grid Center Position Y (global)',
'm',
'CYG', dtype,
grid_cyg )
265 call fileputaxis( fid,
'FXG',
'Grid Face Position X (global)',
'm',
'FXG', dtype,
grid_fxg )
266 call fileputaxis( fid,
'FYG',
'Grid Face Position Y (global)',
'm',
'FYG', dtype,
grid_fyg )
268 call fileputaxis( fid,
'CBFXG',
'Boundary factor Center X (global)',
'1',
'CXG', dtype,
grid_cbfxg )
269 call fileputaxis( fid,
'CBFYG',
'Boundary factor Center Y (global)',
'1',
'CYG', dtype,
grid_cbfyg )
270 call fileputaxis( fid,
'FBFXG',
'Boundary factor Face X (global)',
'1',
'CXG', dtype,
grid_fbfxg )
271 call fileputaxis( fid,
'FBFYG',
'Boundary factor Face Y (global)',
'1',
'CYG', dtype,
grid_fbfyg )
275 axis_name = (/
'x ',
'y '/)
276 call fileputassociatedcoordinates( fid,
'lon' ,
'longitude' , &
277 'degrees_east' , axis_name, dtype, axis_lon(:,:) )
278 axis_name = (/
'xh',
'y '/)
279 call fileputassociatedcoordinates( fid,
'lon_uy',
'longitude (half level uy)', &
280 'degrees_east' , axis_name, dtype, axis_lonx(:,:) )
281 axis_name = (/
'x ',
'yh'/)
282 call fileputassociatedcoordinates( fid,
'lon_xv',
'longitude (half level xv)', &
283 'degrees_east' , axis_name, dtype, axis_lony(:,:) )
284 axis_name = (/
'xh',
'yh'/)
285 call fileputassociatedcoordinates( fid,
'lon_uv',
'longitude (half level uv)', &
286 'degrees_east' , axis_name, dtype, axis_lonxy(:,:) )
287 axis_name = (/
'x ',
'y '/)
288 call fileputassociatedcoordinates( fid,
'lat' ,
'latitude' , &
289 'degrees_north', axis_name, dtype, axis_lat(:,:) )
290 axis_name = (/
'xh',
'y '/)
291 call fileputassociatedcoordinates( fid,
'lat_uy',
'latitude (half level uy)' , &
292 'degrees_north', axis_name, dtype, axis_latx(:,:) )
293 axis_name = (/
'x ',
'yh'/)
294 call fileputassociatedcoordinates( fid,
'lat_xv',
'latitude (half level xv)' , &
295 'degrees_north', axis_name, dtype, axis_laty(:,:) )
296 axis_name = (/
'xh',
'yh'/)
297 call fileputassociatedcoordinates( fid,
'lat_uv',
'latitude (half level uv)' , &
298 'degrees_north', axis_name, dtype, axis_latxy(:,:) )
301 if ( .NOT. xy_ )
then 330 real(RP),
intent(out) :: var(:)
331 character(len=*),
intent(in) :: basename
332 character(len=*),
intent(in) :: varname
333 character(len=*),
intent(in) :: axistype
334 integer,
intent(in) :: step
336 integer :: dim1_max, dim1_S, dim1_E
337 real(RP),
allocatable :: var1D(:)
342 if(
io_l )
write(
io_fid_log,
'(1x,A,A15)')
'*** Read 1D var: ', trim(varname)
344 if ( axistype ==
'Z' )
then 348 elseif( axistype ==
'X' )
then 352 elseif( axistype ==
'Y' )
then 357 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
361 allocate( var1d(dim1_max) )
363 call fileread( var1d(:), basename, varname, step,
prc_myrank )
364 var(dim1_s:dim1_e) = var1d(1:dim1_max)
388 real(RP),
intent(out) :: var(:,:)
389 character(len=*),
intent(in) :: basename
390 character(len=*),
intent(in) :: varname
391 character(len=*),
intent(in) :: axistype
392 integer,
intent(in) :: step
394 integer :: dim1_max, dim1_S, dim1_E
395 integer :: dim2_max, dim2_S, dim2_E
396 real(RP),
allocatable :: var2D(:,:)
401 if(
io_l )
write(
io_fid_log,
'(1x,A,A15)')
'*** Read 2D var: ', trim(varname)
403 if ( axistype ==
'XY' )
then 410 elseif( axistype ==
'ZX' )
then 418 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
422 allocate( var2d(dim1_max,dim2_max) )
424 call fileread( var2d(:,:), basename, varname, step,
prc_myrank )
425 var(dim1_s:dim1_e,dim2_s:dim2_e) = var2d(1:dim1_max,1:dim2_max)
449 real(RP),
intent(out) :: var(:,:,:)
450 character(len=*),
intent(in) :: basename
451 character(len=*),
intent(in) :: varname
452 character(len=*),
intent(in) :: axistype
453 integer,
intent(in) :: step
455 integer :: dim1_max, dim1_S, dim1_E
456 integer :: dim2_max, dim2_S, dim2_E
457 integer :: dim3_max, dim3_S, dim3_E
458 real(RP),
allocatable :: var3D(:,:,:)
463 if(
io_l )
write(
io_fid_log,
'(1x,A,A15)')
'*** Read 3D var: ', trim(varname)
465 if ( axistype ==
'ZXY' )
then 475 else if ( axistype ==
'XYT' )
then 485 else if ( axistype ==
'Land' )
then 495 else if ( axistype ==
'Urban' )
then 506 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
510 allocate( var3d(dim1_max,dim2_max,dim3_max) )
512 call fileread( var3d(:,:,:), basename, varname, step,
prc_myrank )
513 var(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e) = var3d(1:dim1_max,1:dim2_max,1:dim3_max)
537 real(RP),
intent(out) :: var(:,:,:,:)
538 character(len=*),
intent(in) :: basename
539 character(len=*),
intent(in) :: varname
540 character(len=*),
intent(in) :: axistype
541 integer,
intent(in) :: step
543 integer :: dim1_max, dim1_S, dim1_E
544 integer :: dim2_max, dim2_S, dim2_E
545 integer :: dim3_max, dim3_S, dim3_E
546 integer :: dim4_max, dim4_S, dim4_E
547 real(RP),
allocatable :: var4D(:,:,:,:)
552 if(
io_l )
write(
io_fid_log,
'(1x,A,A15)')
'*** Read 4D var: ', trim(varname)
554 if ( axistype ==
'ZXYT' )
then 568 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
572 allocate( var4d(dim1_max,dim2_max,dim3_max,dim4_max) )
574 call fileread( var4d(:,:,:,:), basename, varname, step,
prc_myrank )
575 var(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e,dim4_s:dim4_e) = var4d(1:dim1_max,1:dim2_max,1:dim3_max,1:dim4_max)
604 filesetglobalattribute, &
618 real(RP),
intent(in) :: var(:)
619 character(len=*),
intent(in) :: basename
620 character(len=*),
intent(in) :: title
621 character(len=*),
intent(in) :: varname
622 character(len=*),
intent(in) :: desc
623 character(len=*),
intent(in) :: unit
624 character(len=*),
intent(in) :: axistype
625 character(len=*),
intent(in) :: datatype
627 integer,
optional,
intent(in) :: date(6)
628 real(DP),
optional,
intent(in) :: subsec
629 logical,
optional,
intent(in) :: append
632 character(len=2) :: dims(1)
633 integer :: dim1_max, dim1_S, dim1_E
634 real(RP),
allocatable :: var1D(:)
636 integer :: rankidx(2)
637 logical :: fileexisted
639 character(len=34) :: tunits
647 if ( datatype ==
'REAL8' )
then 649 elseif( datatype ==
'REAL4' )
then 654 elseif(
rp == 4 )
then 657 write(*,*)
'xxx unsupported data type. Check!', trim(datatype),
' item:',trim(varname)
673 if ( .NOT. fileexisted )
then 675 if (
present( subsec ) )
then 676 call filesetglobalattribute( fid,
"time", (/subsec/) )
678 call filesetglobalattribute( fid,
"time", (/nowms/) )
680 if (
present( date ) )
then 685 call filesetglobalattribute( fid,
"time_units", tunits )
688 if ( axistype ==
'Z' )
then 693 elseif( axistype ==
'X' )
then 698 elseif( axistype ==
'Y' )
then 704 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
708 call fileaddvariable( vid, fid, varname, desc, unit, dims, dtype )
710 allocate( var1d(dim1_max) )
712 var1d(1:dim1_max) = var(dim1_s:dim1_e)
713 call filewrite( fid, vid, var1d(:), nowsec, nowsec )
746 filesetglobalattribute, &
760 real(RP),
intent(in) :: var(:,:)
761 character(len=*),
intent(in) :: basename
762 character(len=*),
intent(in) :: title
763 character(len=*),
intent(in) :: varname
764 character(len=*),
intent(in) :: desc
765 character(len=*),
intent(in) :: unit
766 character(len=*),
intent(in) :: axistype
767 character(len=*),
intent(in) :: datatype
768 integer,
optional,
intent(in) :: date(6)
769 real(DP),
optional,
intent(in) :: subsec
770 logical,
optional,
intent(in) :: append
771 logical,
optional,
intent(in) :: nohalo
772 logical,
optional,
intent(in) :: nozcoord
774 real(RP) :: varhalo( size(var(:,1)), size(var(1,:)) )
777 character(len=2) :: dims(2)
778 integer :: dim1_max, dim1_S, dim1_E
779 integer :: dim2_max, dim2_S, dim2_E
780 real(RP),
allocatable :: var2D(:,:)
782 integer :: rankidx(2)
783 logical :: fileexisted
787 character(len=34) :: tunits
793 if (
present(nohalo) ) nohalo_ = nohalo
798 if ( datatype ==
'REAL8' )
then 800 elseif( datatype ==
'REAL4' )
then 805 elseif(
rp == 4 )
then 808 write(*,*)
'xxx unsupported data type. Check!', trim(datatype),
' item:',trim(varname)
824 if ( axistype ==
'XY' )
then 832 elseif ( axistype ==
'UY' )
then 840 elseif ( axistype ==
'XV' )
then 848 elseif ( axistype ==
'UV' )
then 856 elseif( axistype ==
'ZX' )
then 865 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
869 if ( .NOT. fileexisted )
then 871 if (
present( subsec ) )
then 872 call filesetglobalattribute( fid,
"time", (/subsec/) )
874 call filesetglobalattribute( fid,
"time", (/nowms/) )
876 if (
present( date ) )
then 881 call filesetglobalattribute( fid,
"time_units", tunits )
884 varhalo(:,:) = var(:,:)
913 call fileaddvariable( vid, fid, varname, desc, unit, dims, dtype )
915 allocate( var2d(dim1_max,dim2_max) )
917 var2d(1:dim1_max,1:dim2_max) = varhalo(dim1_s:dim1_e,dim2_s:dim2_e)
918 call filewrite( fid, vid, var2d(:,:), nowsec, nowsec )
950 filesetglobalattribute, &
964 real(RP),
intent(in) :: var(:,:,:)
965 character(len=*),
intent(in) :: basename
966 character(len=*),
intent(in) :: title
967 character(len=*),
intent(in) :: varname
968 character(len=*),
intent(in) :: desc
969 character(len=*),
intent(in) :: unit
970 character(len=*),
intent(in) :: axistype
971 character(len=*),
intent(in) :: datatype
972 integer,
optional,
intent(in) :: date(6)
973 real(DP),
optional,
intent(in) :: subsec
974 logical,
optional,
intent(in) :: append
975 logical,
optional,
intent(in) :: nohalo
977 real(RP) :: varhalo( size(var(:,1,1)), size(var(1,:,1)), size(var(1,1,:)) )
980 character(len=2) :: dims(3)
981 integer :: dim1_max, dim1_S, dim1_E
982 integer :: dim2_max, dim2_S, dim2_E
983 integer :: dim3_max, dim3_S, dim3_E
985 real(RP),
allocatable :: var3D(:,:,:)
987 integer :: rankidx(2)
989 logical :: fileexisted
993 character(len=34) :: tunits
999 if (
present(nohalo) ) nohalo_ = nohalo
1004 if ( datatype ==
'REAL8' )
then 1006 elseif( datatype ==
'REAL4' )
then 1011 elseif(
rp == 4 )
then 1014 write(*,*)
'xxx unsupported data type. Check!', trim(datatype),
' item:',trim(varname)
1020 if (
present(append) )
then 1033 append = append_sw )
1035 if ( .NOT. fileexisted )
then 1037 if (
present( subsec ) )
then 1038 call filesetglobalattribute( fid,
"time", (/subsec/) )
1040 call filesetglobalattribute( fid,
"time", (/nowms/) )
1042 if (
present( date ) )
then 1047 call filesetglobalattribute( fid,
"time_units", tunits )
1050 if ( axistype ==
'ZXY' )
then 1051 dims = (/
'z',
'x',
'y'/)
1061 elseif( axistype ==
'ZHXY' )
then 1062 dims = (/
'zh',
'x ',
'y '/)
1072 elseif( axistype ==
'ZXHY' )
then 1073 dims = (/
'z ',
'xh',
'y '/)
1083 elseif( axistype ==
'ZXYH' )
then 1084 dims = (/
'z ',
'x ',
'yh'/)
1094 elseif( axistype ==
'Land' )
then 1095 dims = (/
'lz',
'x ',
'y '/)
1105 elseif( axistype ==
'Urban' )
then 1106 dims = (/
'uz',
'x ',
'y '/)
1117 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
1121 varhalo(:,:,:) = var(:,:,:)
1128 varhalo(k,i,j) = rmiss
1136 varhalo(k,i,j) = rmiss
1144 varhalo(k,i,j) = rmiss
1152 varhalo(k,i,j) = rmiss
1158 call fileaddvariable( vid, fid, varname, desc, unit, dims, dtype )
1160 allocate( var3d(dim1_max,dim2_max,dim3_max) )
1162 var3d(1:dim1_max,1:dim2_max,1:dim3_max) = varhalo(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e)
1163 call filewrite( fid, vid, var3d(:,:,:), nowsec, nowsec )
1206 real(RP),
intent(in) :: var(:,:,:)
1207 character(len=*),
intent(in) :: basename
1208 character(len=*),
intent(in) :: title
1209 character(len=*),
intent(in) :: varname
1210 character(len=*),
intent(in) :: desc
1211 character(len=*),
intent(in) :: unit
1212 character(len=*),
intent(in) :: axistype
1213 character(len=*),
intent(in) :: datatype
1214 real(RP),
intent(in) :: timeintv
1215 integer ,
intent(in) :: tsince(6)
1216 logical,
optional,
intent(in) :: append
1217 integer,
optional,
intent(in) :: timetarg
1218 logical,
optional,
intent(in) :: nohalo
1220 real(RP) :: varhalo( size(var(:,1,1)), size(var(1,:,1)) )
1223 character(len=2) :: dims(2)
1224 integer :: dim1_max, dim1_S, dim1_E
1225 integer :: dim2_max, dim2_S, dim2_E
1227 real(RP),
allocatable :: var2D(:,:)
1228 real(DP) :: time_interval, nowtime
1230 character(len=34) :: tunits
1232 integer :: rankidx(2)
1233 logical :: append_sw
1234 logical :: fileexisted
1244 if (
present(nohalo) ) nohalo_ = nohalo
1246 time_interval = timeintv
1247 step =
size(var(
isb,
jsb,:))
1252 if ( datatype ==
'REAL8' )
then 1254 elseif( datatype ==
'REAL4' )
then 1259 elseif(
rp == 4 )
then 1262 write(*,*)
'xxx unsupported data type. Check!', trim(datatype),
' item:',trim(varname)
1268 if (
present(append) )
then 1272 write(tunits,
'(a,i4.4,"-",i2.2,"-",i2.2," ",i2.2,":",i2.2,":",i2.2)')
'seconds since ', tsince
1283 time_units = tunits, &
1284 append = append_sw )
1286 if ( .NOT. fileexisted )
then 1290 if ( axistype ==
'XYT' )
then 1299 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
1303 call fileaddvariable( vid, fid, varname, desc, unit, dims, dtype, time_interval )
1304 allocate( var2d(dim1_max,dim2_max) )
1306 if (
present(timetarg) )
then 1307 varhalo(:,:) = var(:,:,timetarg)
1313 varhalo(i,j) = rmiss
1319 varhalo(i,j) = rmiss
1325 varhalo(i,j) = rmiss
1331 varhalo(i,j) = rmiss
1336 nowtime = (timetarg-1) * time_interval
1337 var2d(1:dim1_max,1:dim2_max) = varhalo(dim1_s:dim1_e,dim2_s:dim2_e)
1338 call filewrite( fid, vid, var2d(:,:), nowtime, nowtime )
1342 varhalo(:,:) = var(:,:,n)
1348 varhalo(i,j) = rmiss
1354 varhalo(i,j) = rmiss
1360 varhalo(i,j) = rmiss
1366 varhalo(i,j) = rmiss
1371 var2d(1:dim1_max,1:dim2_max) = varhalo(dim1_s:dim1_e,dim2_s:dim2_e)
1372 call filewrite( fid, vid, var2d(:,:), nowtime, nowtime )
1373 nowtime = nowtime + time_interval
1418 real(RP),
intent(in) :: var(:,:,:,:)
1419 character(len=*),
intent(in) :: basename
1420 character(len=*),
intent(in) :: title
1421 character(len=*),
intent(in) :: varname
1422 character(len=*),
intent(in) :: desc
1423 character(len=*),
intent(in) :: unit
1424 character(len=*),
intent(in) :: axistype
1425 character(len=*),
intent(in) :: datatype
1426 real(RP),
intent(in) :: timeintv
1427 integer ,
intent(in) :: tsince(6)
1428 logical,
optional,
intent(in) :: append
1429 integer,
optional,
intent(in) :: timetarg
1430 logical,
optional,
intent(in) :: nohalo
1432 real(RP) :: varhalo( size(var(:,1,1,1)), size(var(1,:,1,1)), size(var(1,1,:,1)) )
1435 character(len=2) :: dims(3)
1436 integer :: dim1_max, dim1_S, dim1_E
1437 integer :: dim2_max, dim2_S, dim2_E
1438 integer :: dim3_max, dim3_S, dim3_E
1440 real(RP),
allocatable :: var3D(:,:,:)
1441 real(DP) :: time_interval, nowtime
1443 character(len=34) :: tunits
1445 integer :: rankidx(2)
1446 logical :: append_sw
1447 logical :: fileexisted
1450 integer :: i, j, k, n
1457 if (
present(nohalo) ) nohalo_ = nohalo
1459 time_interval = timeintv
1465 if ( datatype ==
'REAL8' )
then 1467 elseif( datatype ==
'REAL4' )
then 1472 elseif(
rp == 4 )
then 1475 write(*,*)
'xxx unsupported data type. Check!', trim(datatype),
' item:',trim(varname)
1481 if (
present(append) )
then 1496 time_units = tunits, &
1497 append = append_sw )
1499 if ( .NOT. fileexisted )
then 1503 if ( axistype ==
'ZXYT' )
then 1504 dims = (/
'z',
'x',
'y'/)
1515 write(*,*)
'xxx unsupported axis type. Check!', trim(axistype),
' item:',trim(varname)
1519 call fileaddvariable( vid, fid, varname, desc, unit, dims, dtype, time_interval )
1520 allocate( var3d(dim1_max,dim2_max,dim3_max) )
1522 if (
present(timetarg) )
then 1523 varhalo(:,:,:) = var(:,:,:,timetarg)
1530 varhalo(k,i,j) = rmiss
1538 varhalo(k,i,j) = rmiss
1546 varhalo(k,i,j) = rmiss
1554 varhalo(k,i,j) = rmiss
1560 nowtime = (timetarg-1) * time_interval
1561 var3d(1:dim1_max,1:dim2_max,1:dim3_max) = varhalo(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e)
1562 call filewrite( fid, vid, var3d(:,:,:), nowtime, nowtime )
1566 varhalo(:,:,:) = var(:,:,:,n)
1573 varhalo(k,i,j) = rmiss
1581 varhalo(k,i,j) = rmiss
1589 varhalo(k,i,j) = rmiss
1597 varhalo(k,i,j) = rmiss
1603 var3d(1:dim1_max,1:dim2_max,1:dim3_max) = varhalo(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e)
1604 call filewrite( fid, vid, var3d(:,:,:), nowtime, nowtime )
1605 nowtime = nowtime + time_interval
1619 character(len=34),
intent(out) :: tunits
1620 integer,
intent(in) :: date(6)
1622 write(tunits,
'(a,i4.4,"-",i2.2,"-",i2.2," ",i2.2,":",i2.2,":",i2.2)')
'seconds since ', date
integer, public is
start point of inner domain: x, local
integer, public je
end point of inner domain: y, local
subroutine fileio_read_1d(var, basename, varname, axistype, step)
Read 1D data from file.
real(rp), dimension(:), allocatable, public grid_cyg
center coordinate [m]: y, global
subroutine, public prc_mpistop
Abort MPI.
real(rp), dimension(:), allocatable, public grid_cbfyg
center buffer factor [0-1]: y, global
real(dp), public time_nowms
subsecond part of current time [millisec]
real(rp), dimension(:), allocatable, public grid_cxg
center coordinate [m]: x, global
real(rp), dimension(:), allocatable, public grid_fdy
y-length of grid(j+1) to grid(j) [m]
logical, public io_l
output log or not? (this process)
real(rp), dimension(:), allocatable, public grid_cz
center coordinate [m]: z, local=global
real(rp), dimension(:), allocatable, public grid_fxg
face coordinate [m]: x, global
real(rp), dimension(:), allocatable, public grid_fbfy
face buffer factor [0-1]: y
subroutine, public fileio_setup
Setup.
real(dp), public time_nowdaysec
second of current time [sec]
integer, public ke
end point of inner domain: z, local
subroutine fileio_write_3d_t(var, basename, title, varname, desc, unit, axistype, datatype, timeintv, tsince, append, timetarg, nohalo)
Write 3D data with time dimension to file.
real(rp), public const_d2r
degree to radian
subroutine fileio_write_4d(var, basename, title, varname, desc, unit, axistype, datatype, timeintv, tsince, append, timetarg, nohalo)
Write 4D data to file.
module GRID (cartesian) for land
subroutine fileio_read_4d(var, basename, varname, axistype, step)
Read 4D data from file.
real(rp), dimension(:), allocatable, public grid_fx
face coordinate [m]: x, local
real(rp), dimension(:), allocatable, public grid_lfz
face coordinate [m]: z, local=global
integer, public ia
of x whole cells (local, with HALO)
character(len=h_mid), public h_source
for file header
module GRID (cartesian) for urban
real(rp), dimension(:), allocatable, public grid_fbfx
face buffer factor [0-1]: x
real(rp), dimension(:), allocatable, public grid_fdz
z-length of grid(k+1) to grid(k) [m]
real(rp), dimension(:), allocatable, public grid_ufz
face coordinate [m]: z, local=global
integer, public ka
of z whole cells (local, with HALO)
real(rp), dimension(:), allocatable, public grid_fbfxg
face buffer factor [0-1]: x, global
subroutine fileio_write_2d(var, basename, title, varname, desc, unit, axistype, datatype, date, subsec, append, nohalo, nozcoord)
Write 2D data to file.
integer, public kmax
of computational cells: z
real(rp), dimension(:), allocatable, public grid_fz
face coordinate [m]: z, local=global
real(rp), dimension(:), allocatable, public grid_fbfz
face buffer factor [0-1]: z
subroutine fileio_write_3d(var, basename, title, varname, desc, unit, axistype, datatype, date, subsec, append, nohalo)
Write 3D data to file.
integer, public js
start point of inner domain: y, local
real(rp), dimension(:), allocatable, public grid_cbfx
center buffer factor [0-1]: x
real(rp), dimension(:), allocatable, public grid_fbfyg
face buffer factor [0-1]: y, global
real(rp), dimension(:), allocatable, public grid_ucz
center coordinate [m]: z, local=global
integer, parameter, public prc_masterrank
master process in each communicator
integer, public ks
start point of inner domain: z, local
real(rp), dimension(:), allocatable, public grid_cbfz
center buffer factor [0-1]: z
integer, public prc_myrank
process num in local communicator
real(rp), dimension(:), allocatable, public grid_cx
center coordinate [m]: x, local
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
integer, public ie
end point of inner domain: x, local
subroutine getcftunits(tunits, date)
character(len=h_mid), public h_institute
for file header
integer, dimension(:,:), allocatable, public prc_2drank
node index in 2D topology
real(rp), dimension(:), allocatable, public grid_cdz
z-length of control volume [m]
real(rp), dimension(:), allocatable, public grid_fdx
x-length of grid(i+1) to grid(i) [m]
real(rp), dimension(:), allocatable, public grid_lcz
center coordinate [m]: z, local=global
real(rp), dimension(:), allocatable, public grid_cdy
y-length of control volume [m]
real(rp), dimension(:), allocatable, public grid_cbfy
center buffer factor [0-1]: y
integer, dimension(6), public time_nowdate
current time [YYYY MM DD HH MM SS]
subroutine, public fileio_set_coordinates(LON, LONX, LONY, LONXY, LAT, LATX, LATY, LATXY, CZ, FZ)
set latlon and z
integer, public io_fid_log
Log file ID.
subroutine, public fileio_set_axes(fid, dtype, xy)
write axis to the file
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
integer, parameter, public rp
real(rp), dimension(:), allocatable, public grid_cdx
x-length of control volume [m]
real(rp), dimension(:), allocatable, public grid_fyg
face coordinate [m]: y, global
real(rp), dimension(:), allocatable, public grid_cy
center coordinate [m]: y, local
subroutine fileio_read_2d(var, basename, varname, axistype, step)
Read 2D data from file.
real(rp), dimension(:), allocatable, public grid_cbfxg
center buffer factor [0-1]: x, global
subroutine fileio_read_3d(var, basename, varname, axistype, step)
Read 3D data from file.
subroutine fileio_write_1d(var, basename, title, varname, desc, unit, axistype, datatype, date, subsec, append)
Write 1D data to file.
integer, public ja
of y whole cells (local, with HALO)
real(rp), dimension(:), allocatable, public grid_fy
face coordinate [m]: y, local