39 public :: file_cartesc_check_coordinates
41 public :: file_cartesc_get_size
47 public :: file_cartesc_write_var
48 public :: file_cartesc_read
49 public :: file_cartesc_write
53 interface file_cartesc_check_coordinates
54 module procedure file_cartesc_check_coordinates_name
55 module procedure file_cartesc_check_coordinates_id
56 end interface file_cartesc_check_coordinates
58 interface file_cartesc_get_size
60 module procedure file_cartesc_get_size_name
61 end interface file_cartesc_get_size
63 interface file_cartesc_read
65 module procedure file_cartesc_read_2d
66 module procedure file_cartesc_read_3d
67 module procedure file_cartesc_read_4d
68 module procedure file_cartesc_read_var_1d
74 end interface file_cartesc_read
76 interface file_cartesc_write
78 module procedure file_cartesc_write_2d
79 module procedure file_cartesc_write_3d
80 module procedure file_cartesc_write_3d_t
81 module procedure file_cartesc_write_4d
82 end interface file_cartesc_write
84 interface file_cartesc_write_var
90 end interface file_cartesc_write_var
97 integer :: size_global (1)
98 integer :: start_global(1)
99 integer :: halo_global (2)
100 integer :: halo_local (2)
117 real(
rp),
private :: file_cartesc_datacheck_criteria
120 character(len=H_SHORT) :: name
122 character(len=H_SHORT) :: dims(3)
125 character(len=H_SHORT) :: area
126 character(len=H_SHORT) :: area_x
127 character(len=H_SHORT) :: area_y
128 character(len=H_SHORT) :: volume
129 character(len=H_SHORT) :: location
130 character(len=H_SHORT) :: grid
132 integer,
parameter :: file_cartesc_ndims = 44
133 type(dims) :: file_cartesc_dims(file_cartesc_ndims)
138 real(
rp),
private,
allocatable :: axis_hgt (:,:,:)
139 real(
rp),
private,
allocatable :: axis_hgtwxy(:,:,:)
141 real(
rp),
private,
allocatable :: axis_lon (:,:)
142 real(
rp),
private,
allocatable :: axis_lonuy(:,:)
143 real(
rp),
private,
allocatable :: axis_lonxv(:,:)
144 real(
rp),
private,
allocatable :: axis_lonuv(:,:)
145 real(
rp),
private,
allocatable :: axis_lat (:,:)
146 real(
rp),
private,
allocatable :: axis_latuy(:,:)
147 real(
rp),
private,
allocatable :: axis_latxv(:,:)
148 real(
rp),
private,
allocatable :: axis_latuv(:,:)
150 real(
rp),
private,
allocatable :: axis_topo (:,:)
151 real(
rp),
private,
allocatable :: axis_lsmask(:,:)
153 real(
rp),
private,
allocatable :: axis_area (:,:)
154 real(
rp),
private,
allocatable :: axis_areazuy_x(:,:,:)
155 real(
rp),
private,
allocatable :: axis_areazxv_y(:,:,:)
156 real(
rp),
private,
allocatable :: axis_areawuy_x(:,:,:)
157 real(
rp),
private,
allocatable :: axis_areawxv_y(:,:,:)
158 real(
rp),
private,
allocatable :: axis_areauy (:,:)
159 real(
rp),
private,
allocatable :: axis_areazxy_x(:,:,:)
160 real(
rp),
private,
allocatable :: axis_areazuv_y(:,:,:)
161 real(
rp),
private,
allocatable :: axis_areaxv (:,:)
162 real(
rp),
private,
allocatable :: axis_areazuv_x(:,:,:)
163 real(
rp),
private,
allocatable :: axis_areazxy_y(:,:,:)
165 real(
rp),
private,
allocatable :: axis_vol (:,:,:)
166 real(
rp),
private,
allocatable :: axis_volwxy(:,:,:)
167 real(
rp),
private,
allocatable :: axis_volzuy(:,:,:)
168 real(
rp),
private,
allocatable :: axis_volzxv(:,:,:)
170 real(
rp),
private,
allocatable :: axis_volo(:,:,:)
171 real(
rp),
private,
allocatable :: axis_voll(:,:,:)
172 real(
rp),
private,
allocatable :: axis_volu(:,:,:)
180 integer,
private,
target :: startxy (3), countxy (3)
181 integer,
private,
target :: startzx (2), countzx (2)
182 integer,
private,
target :: startzxy (4), countzxy (4)
183 integer,
private,
target :: startzhxy (4), countzhxy (4)
184 integer,
private,
target :: startocean(4), countocean(4)
185 integer,
private,
target :: startland (4), countland (4)
186 integer,
private,
target :: starturban(4), counturban(4)
188 integer,
private :: isb2, ieb2, jsb2, jeb2
191 integer,
private :: etype
194 integer,
private :: centertypexy
195 integer,
private :: centertypezx
196 integer,
private :: centertypezxy
197 integer,
private :: centertypezhxy
198 integer,
private :: centertypeocean
199 integer,
private :: centertypeland
200 integer,
private :: centertypeurban
202 logical,
private :: set_coordinates = .false.
220 namelist / param_file_cartesc / &
221 file_cartesc_datacheck_criteria
231 log_info(
"FILE_CARTESC_setup",*)
'Setup'
233 file_cartesc_datacheck_criteria = 0.1_rp**(
rp)
237 read(
io_fid_conf,nml=param_file_cartesc,iostat=ierr)
239 log_info(
"FILE_CARTESC_setup",*)
'Not found namelist. Default used.'
240 elseif( ierr > 0 )
then
241 log_error(
"FILE_CARTESC_setup",*)
'Not appropriate names in namelist PARAM_FILE_CARTESC. Check!'
244 log_nml(param_file_cartesc)
247 log_info(
"FILE_CARTESC_setup",*)
'NetCDF header information '
248 log_info_cont(*)
'Data source : ', trim(
h_source)
252 log_info(
"FILE_CARTESC_setup",*)
'Data consistency criteria : ', &
253 '(file-internal)/internal = ', file_cartesc_datacheck_criteria
268 allocate( axis_hgt(
kmax ,im,jm) )
269 allocate( axis_hgtwxy(
kmax+1,im,jm) )
271 allocate( axis_lon(im,jm) )
272 allocate( axis_lonuy(im,jm) )
273 allocate( axis_lonxv(im,jm) )
274 allocate( axis_lonuv(im,jm) )
275 allocate( axis_lat(im,jm) )
276 allocate( axis_latuy(im,jm) )
277 allocate( axis_latxv(im,jm) )
278 allocate( axis_latuv(im,jm) )
280 allocate( axis_topo(im,jm) )
281 allocate( axis_lsmask(im,jm) )
283 allocate( axis_area( im,jm) )
284 allocate( axis_areazuy_x(
kmax, im,jm) )
285 allocate( axis_areazxv_y(
kmax, im,jm) )
286 allocate( axis_areawuy_x(
kmax+1,im,jm) )
287 allocate( axis_areawxv_y(
kmax+1,im,jm) )
288 allocate( axis_areauy( im,jm) )
289 allocate( axis_areazxy_x(
kmax, im,jm) )
290 allocate( axis_areazuv_y(
kmax, im,jm) )
291 allocate( axis_areaxv( im,jm) )
292 allocate( axis_areazuv_x(
kmax, im,jm) )
293 allocate( axis_areazxy_y(
kmax, im,jm) )
295 allocate( axis_vol(
kmax ,im,jm) )
296 allocate( axis_volwxy(
kmax+1,im,jm) )
297 allocate( axis_volzuy(
kmax ,im,jm) )
298 allocate( axis_volzxv(
kmax ,im,jm) )
300 allocate( axis_volo(
okmax,im,jm) )
301 allocate( axis_voll(
lkmax,im,jm) )
302 allocate( axis_volu(
ukmax,im,jm) )
306 write_buf_amount(:) = 0
317 deallocate( axis_hgt )
318 deallocate( axis_hgtwxy )
320 deallocate( axis_lon )
321 deallocate( axis_lonuy )
322 deallocate( axis_lonxv )
323 deallocate( axis_lonuv )
324 deallocate( axis_lat )
325 deallocate( axis_latuy )
326 deallocate( axis_latxv )
327 deallocate( axis_latuv )
329 deallocate( axis_topo )
330 deallocate( axis_lsmask )
332 deallocate( axis_area )
333 deallocate( axis_areazuy_x )
334 deallocate( axis_areazxv_y )
335 deallocate( axis_areawuy_x )
336 deallocate( axis_areawxv_y )
337 deallocate( axis_areauy )
338 deallocate( axis_areazxy_x )
339 deallocate( axis_areazuv_y )
340 deallocate( axis_areaxv )
341 deallocate( axis_areazuv_x )
342 deallocate( axis_areazxy_y )
344 deallocate( axis_vol )
345 deallocate( axis_volwxy )
346 deallocate( axis_volzuy )
347 deallocate( axis_volzxv )
349 deallocate( axis_volo )
350 deallocate( axis_voll )
351 deallocate( axis_volu )
365 subroutine file_cartesc_get_size_name( &
367 KMAX, OKMAX, LKMAX, UKMAX, &
369 KHALO, IHALO, JHALO, &
373 character(len=*),
intent(in) :: basename
379 logical,
intent(in),
optional :: aggregate
385 aggregate=aggregate )
393 end subroutine file_cartesc_get_size_name
396 KMAX, OKMAX, LKMAX, UKMAX, &
398 KHALO, IHALO, JHALO )
402 integer,
intent(in) :: fid
404 integer,
intent(out) :: KMAX, OKMAX, LKMAX, UKMAX
405 integer,
intent(out) :: IMAXG, JMAXG
406 integer,
intent(out) :: KHALO, IHALO, JHALO
411 call file_get_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_kmax", buf(:) )
413 call file_get_attribute( fid,
"global",
"scale_ocean_grid_cartesC_index_kmax", buf(:), existed=existed )
419 call file_get_attribute( fid,
"global",
"scale_land_grid_cartesC_index_kmax", buf(:), existed=existed )
425 call file_get_attribute( fid,
"global",
"scale_urban_grid_cartesC_index_kmax", buf(:), existed=existed )
432 call file_get_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_imaxg", buf(:) )
434 call file_get_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_jmaxg", buf(:) )
437 call file_get_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_khalo", buf(:) )
439 call file_get_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_ihalo", buf(:) )
441 call file_get_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_jhalo", buf(:) )
451 LON, LONUY, LONXV, LONUV, &
452 LAT, LATUY, LATXV, LATUV, &
458 real(
rp),
intent(in) :: cz(
ka,
ia,
ja)
459 real(
rp),
intent(in) :: fz(0:
ka,
ia,
ja)
460 real(
rp),
intent(in) :: lon (
ia,
ja)
461 real(
rp),
intent(in) :: lonuy(0:
ia,
ja)
462 real(
rp),
intent(in) :: lonxv(
ia,0:
ja)
463 real(
rp),
intent(in) :: lonuv(0:
ia,0:
ja)
464 real(
rp),
intent(in) :: lat (
ia,
ja)
465 real(
rp),
intent(in) :: latuy(0:
ia,
ja)
466 real(
rp),
intent(in) :: latxv(
ia,0:
ja)
467 real(
rp),
intent(in) :: latuv(0:
ia,0:
ja)
468 real(
rp),
intent(in) :: topo (
ia,
ja)
469 real(
rp),
intent(in) :: lsmask(
ia,
ja)
472 axis_hgt(:,:,:) = cz(
ks :
ke,isb2:ieb2,jsb2:jeb2)
473 axis_hgtwxy(:,:,:) = fz(
ks-1:
ke,isb2:ieb2,jsb2:jeb2)
475 axis_lon(:,:) = lon(isb2:ieb2,jsb2:jeb2) / d2r
476 axis_lonuy(:,:) = lonuy(isb2:ieb2,jsb2:jeb2) / d2r
477 axis_lonxv(:,:) = lonxv(isb2:ieb2,jsb2:jeb2) / d2r
478 axis_lonuv(:,:) = lonuv(isb2:ieb2,jsb2:jeb2) / d2r
479 axis_lat(:,:) = lat(isb2:ieb2,jsb2:jeb2) / d2r
480 axis_latuy(:,:) = latuy(isb2:ieb2,jsb2:jeb2) / d2r
481 axis_latxv(:,:) = latxv(isb2:ieb2,jsb2:jeb2) / d2r
482 axis_latuv(:,:) = latuv(isb2:ieb2,jsb2:jeb2) / d2r
484 axis_topo(:,:) = topo(isb2:ieb2,jsb2:jeb2)
485 axis_lsmask(:,:) = lsmask(isb2:ieb2,jsb2:jeb2)
487 set_coordinates = .true.
495 AREA, AREAZUY_X, AREAZXV_Y, &
496 AREAWUY_X, AREAWXV_Y, &
497 AREAUY, AREAZXY_X, AREAZUV_Y, &
498 AREAXV, AREAZUV_X, AREAZXY_Y, &
499 VOL, VOLWXY, VOLZUY, VOLZXV )
503 real(
rp),
intent(in) :: area (
ia,
ja)
504 real(
rp),
intent(in) :: areazuy_x(
ka,
ia,
ja)
505 real(
rp),
intent(in) :: areazxv_y(
ka,
ia,
ja)
506 real(
rp),
intent(in) :: areawuy_x(0:
ka,
ia,
ja)
507 real(
rp),
intent(in) :: areawxv_y(0:
ka,
ia,
ja)
508 real(
rp),
intent(in) :: areauy (
ia,
ja)
509 real(
rp),
intent(in) :: areazxy_x(
ka,
ia,
ja)
510 real(
rp),
intent(in) :: areazuv_y(
ka,
ia,
ja)
511 real(
rp),
intent(in) :: areaxv (
ia,
ja)
512 real(
rp),
intent(in) :: areazuv_x(
ka,
ia,
ja)
513 real(
rp),
intent(in) :: areazxy_y(
ka,
ia,
ja)
514 real(
rp),
intent(in) :: vol (
ka,
ia,
ja)
515 real(
rp),
intent(in) :: volwxy(0:
ka,
ia,
ja)
516 real(
rp),
intent(in) :: volzuy(
ka,
ia,
ja)
517 real(
rp),
intent(in) :: volzxv(
ka,
ia,
ja)
519 axis_area(:,:) = area( isb2:ieb2,jsb2:jeb2)
520 axis_areazuy_x(:,:,:) = areazuy_x(
ks :
ke,isb2:ieb2,jsb2:jeb2)
521 axis_areazxv_y(:,:,:) = areazxv_y(
ks :
ke,isb2:ieb2,jsb2:jeb2)
522 axis_areawuy_x(:,:,:) = areawuy_x(
ks-1:
ke,isb2:ieb2,jsb2:jeb2)
523 axis_areawxv_y(:,:,:) = areawxv_y(
ks-1:
ke,isb2:ieb2,jsb2:jeb2)
524 axis_areauy(:,:) = areauy( isb2:ieb2,jsb2:jeb2)
525 axis_areazxy_x(:,:,:) = areazxy_x(
ks :
ke,isb2:ieb2,jsb2:jeb2)
526 axis_areazuv_y(:,:,:) = areazuv_y(
ks :
ke,isb2:ieb2,jsb2:jeb2)
527 axis_areaxv(:,:) = areaxv( isb2:ieb2,jsb2:jeb2)
528 axis_areazuv_x(:,:,:) = areazuv_x(
ks :
ke,isb2:ieb2,jsb2:jeb2)
529 axis_areazxy_y(:,:,:) = areazxy_y(
ks :
ke,isb2:ieb2,jsb2:jeb2)
531 axis_vol(:,:,:) = vol(
ks :
ke,isb2:ieb2,jsb2:jeb2)
532 axis_volwxy(:,:,:) = volwxy(
ks-1:
ke,isb2:ieb2,jsb2:jeb2)
533 axis_volzuy(:,:,:) = volzuy(
ks :
ke,isb2:ieb2,jsb2:jeb2)
534 axis_volzxv(:,:,:) = volzxv(
ks :
ke,isb2:ieb2,jsb2:jeb2)
548 axis_volo(:,:,:) = vol(
oks:
oke,isb2:ieb2,jsb2:jeb2)
562 axis_voll(:,:,:) = vol(
lks:
lke,isb2:ieb2,jsb2:jeb2)
576 axis_volu(:,:,:) = vol(
uks:
uke,isb2:ieb2,jsb2:jeb2)
583 subroutine file_cartesc_check_coordinates_name( &
585 atmos, ocean, land, urban, &
589 character(len=*),
intent(in) :: basename
590 logical,
intent(in),
optional :: atmos
591 logical,
intent(in),
optional :: ocean
592 logical,
intent(in),
optional :: land
593 logical,
intent(in),
optional :: urban
594 logical,
intent(in),
optional :: transpose
600 logical :: transpose_
611 if(
present(atmos) ) atmos_ = atmos
612 if(
present(ocean) ) ocean_ = ocean
613 if(
present(land ) ) land_ = land
614 if(
present(urban) ) urban_ = urban
615 if(
present(transpose) ) transpose_ = transpose
620 call file_cartesc_check_coordinates_id( fid, &
621 atmos_, ocean_, land_, urban_, &
625 end subroutine file_cartesc_check_coordinates_name
629 subroutine file_cartesc_check_coordinates_id( &
631 atmos, ocean, land, urban, &
645 integer,
intent(in) :: fid
646 logical,
intent(in),
optional :: atmos
647 logical,
intent(in),
optional :: ocean
648 logical,
intent(in),
optional :: land
649 logical,
intent(in),
optional :: urban
650 logical,
intent(in),
optional :: transpose
656 logical :: transpose_
658 real(
rp) :: buffer_z (
ka)
659 real(
rp) :: buffer_x (
ia)
660 real(
rp) :: buffer_y (
ja)
661 real(
rp) :: buffer_xy (
ia,
ja)
667 integer :: xsb, xeb, ysb, yeb
671 log_info(
"FILE_CARTESC_check_coordinates_id",*)
'Check consistency of axis '
679 if(
present(atmos) ) atmos_ = atmos
680 if(
present(ocean) ) ocean_ = ocean
681 if(
present(land ) ) land_ = land
682 if(
present(urban) ) urban_ = urban
683 if(
present(transpose) ) transpose_ = transpose
691 call file_cartesc_read_var_1d( fid,
'x',
'X', buffer_x(:) )
692 call file_cartesc_read_var_1d( fid,
'y',
'Y', buffer_y(:) )
697 if ( set_coordinates )
then
700 call check_2d( axis_lon(xsb:xeb,ysb:yeb), buffer_xy(
isb:
ieb,
jsb:
jeb),
'lon' )
704 call check_2d( axis_lat(xsb:xeb,ysb:yeb), buffer_xy(
isb:
ieb,
jsb:
jeb),
'lat' )
708 call file_cartesc_read_var_1d( fid,
'z',
'Z', buffer_z(:) )
709 if ( .not. transpose_ )
then
714 if ( .not. transpose_ )
then
715 call check_3d( axis_hgt(:,xsb:xeb,ysb:yeb), buffer_zxy(
ks:
ke,
isb:
ieb,
jsb:
jeb),
'height', transpose_ )
720 call file_cartesc_read_var_1d( fid,
'oz',
'OZ', buffer_o(:) )
726 call file_cartesc_read_var_1d( fid,
'lz',
'LZ', buffer_l(:) )
732 call file_cartesc_read_var_1d( fid,
'uz',
'UZ', buffer_u(:) )
738 end subroutine file_cartesc_check_coordinates_id
755 character(len=*),
intent(in) :: basename
756 integer,
intent(out) :: fid
757 logical,
intent(in),
optional :: aggregate
764 aggregate=aggregate, &
775 basename, title, datatype, &
779 append, aggregate, single )
803 character(len=*),
intent(in) :: basename
804 character(len=*),
intent(in) :: title
805 character(len=*),
intent(in) :: datatype
806 integer,
intent(out) :: fid
807 integer,
intent(in),
optional :: date(6)
808 real(
dp),
intent(in),
optional :: subsec
809 logical,
intent(in),
optional :: append
810 logical,
intent(in),
optional :: haszcoord
811 logical,
intent(in),
optional :: aggregate
812 logical,
intent(in),
optional :: single
816 character(len=34) :: tunits
817 character(len=H_SHORT) :: calendar
819 integer :: rank_x, rank_y
820 integer :: num_x, num_y
821 logical :: fileexisted
822 logical :: aggregate_
829 if (
present(single) )
then
836 if ( datatype ==
'REAL8' )
then
838 elseif( datatype ==
'REAL4' )
then
843 elseif(
rp == 4 )
then
846 log_error(
"FILE_CARTESC_create",*)
'unsupported data type. Check!', trim(datatype)
852 if (
present(append) )
then
857 if (
present(date) )
then
860 date_(:) = nowdate(:)
862 if ( date_(1) > 0 )
then
872 if (
present(aggregate) )
then
873 aggregate_ = aggregate
886 aggregate = aggregate_, &
887 time_units = tunits, &
888 calendar = calendar, &
892 if ( fid > 0 .and. (.not. fileexisted) )
then
894 file_axes_written(fid) = .false.
896 if (
present( haszcoord ) )
then
897 file_haszcoord(fid) = haszcoord
899 file_haszcoord(fid) = .true.
902 if ( aggregate_ )
then
914 if (
present( subsec ) )
then
927 subsec_, tunits, calendar )
931 file_haszcoord(fid) )
952 integer,
intent(in) :: fid
964 if ( .NOT. file_axes_written(fid) )
then
977 file_haszcoord(fid), &
986 file_axes_written(fid) = .true.
1004 integer,
intent(in) :: fid
1032 integer,
intent(in) :: fid
1041 if ( write_buf_amount(fid) > 0 )
then
1043 write_buf_amount(fid) = 0
1061 basename, varname, &
1068 character(len=*),
intent(in) :: basename
1069 character(len=*),
intent(in) :: varname
1070 character(len=*),
intent(in) :: dim_type
1072 real(RP),
intent(out) :: var(:)
1074 integer,
intent(in),
optional :: step
1075 logical,
intent(in),
optional :: aggregate
1076 logical,
intent(in),
optional :: allow_missing
1083 aggregate=aggregate )
1085 call file_cartesc_read_var_1d( fid, varname, dim_type, &
1088 allow_missing=allow_missing )
1097 subroutine file_cartesc_read_2d( &
1098 basename, varname, &
1105 character(len=*),
intent(in) :: basename
1106 character(len=*),
intent(in) :: varname
1107 character(len=*),
intent(in) :: dim_type
1109 real(RP),
intent(out) :: var(:,:)
1111 integer,
intent(in),
optional :: step
1112 logical,
intent(in),
optional :: aggregate
1113 logical,
intent(in),
optional :: allow_missing
1120 aggregate=aggregate )
1125 allow_missing=allow_missing )
1130 end subroutine file_cartesc_read_2d
1134 subroutine file_cartesc_read_3d( &
1135 basename, varname, &
1142 character(len=*),
intent(in) :: basename
1143 character(len=*),
intent(in) :: varname
1144 character(len=*),
intent(in) :: dim_type
1146 real(RP),
intent(out) :: var(:,:,:)
1148 integer,
intent(in),
optional :: step
1149 logical,
intent(in),
optional :: aggregate
1150 logical,
intent(in),
optional :: allow_missing
1157 aggregate=aggregate )
1162 allow_missing=allow_missing )
1167 end subroutine file_cartesc_read_3d
1171 subroutine file_cartesc_read_4d( &
1172 basename, varname, &
1178 character(len=*),
intent(in) :: basename
1179 character(len=*),
intent(in) :: varname
1180 character(len=*),
intent(in) :: dim_type
1181 integer,
intent(in) :: step
1183 real(RP),
intent(out) :: var(:,:,:,:)
1185 logical,
intent(in),
optional :: aggregate
1186 logical,
intent(in),
optional :: allow_missing
1193 aggregate=aggregate )
1197 allow_missing=allow_missing )
1202 end subroutine file_cartesc_read_4d
1206 subroutine file_cartesc_read_var_1d( &
1224 integer,
intent(in) :: fid
1225 character(len=*),
intent(in) :: varname
1226 character(len=*),
intent(in) :: dim_type
1228 real(RP),
intent(out) :: var(:)
1230 integer,
intent(in),
optional :: step
1231 logical,
intent(in),
optional :: allow_missing
1234 integer :: dim1_S, dim1_E
1243 log_info(
"FILE_CARTESC_read_var_1D",
'(1x,2A)')
'Read from file (1D), name : ', trim(varname)
1247 if ( dim_type ==
'Z' )
then
1252 elseif( dim_type ==
'OZ' )
then
1257 elseif( dim_type ==
'LZ' )
then
1262 elseif( dim_type ==
'UZ' )
then
1267 elseif( dim_type ==
'X' .OR. dim_type ==
'CX' )
then
1272 elseif( dim_type ==
'Y' .OR. dim_type ==
'CY' )
then
1278 log_error(
"FILE_CARTESC_read_var_1D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
1282 if (
size(var) .ne. vsize )
then
1283 log_error(
"FILE_CARTESC_read_var_1D",*)
'size of var is invalid: ', trim(varname),
size(var), vsize
1286 count(1) = dim1_e - dim1_s + 1
1287 call file_read( fid, varname, &
1288 var(dim1_s:dim1_e), &
1289 step=step, allow_missing=allow_missing, &
1290 ntypes=count(1), dtype=etype, start=start, count=count )
1293 if ( dim_type ==
'Z' )
then
1297 elseif( dim_type ==
'OZ' )
then
1301 elseif( dim_type ==
'LZ' )
then
1305 elseif( dim_type ==
'UZ' )
then
1309 elseif( dim_type ==
'X' )
then
1313 elseif( dim_type ==
'CX' )
then
1317 elseif( dim_type ==
'Y' )
then
1321 elseif( dim_type ==
'CY' )
then
1326 log_error(
"FILE_CARTESC_read_var_1D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
1330 if (
size(var) .ne. vsize )
then
1331 log_error(
"FILE_CARTESC_read_var_1D",*)
'size of var is invalid: ', trim(varname),
size(var), vsize
1334 call file_read( fid, varname, var(dim1_s:dim1_e), step=step )
1340 end subroutine file_cartesc_read_var_1d
1358 integer,
intent(in) :: fid
1359 character(len=*),
intent(in) :: varname
1360 character(len=*),
intent(in) :: dim_type
1362 real(RP),
intent(out) :: var(:,:)
1364 integer,
intent(in),
optional :: step
1365 logical,
intent(in),
optional :: allow_missing
1368 integer :: ntypes, dtype
1369 integer,
pointer :: start(:), count(:)
1370 integer :: dim1_S, dim1_E
1371 integer :: dim2_S, dim2_E
1378 log_info(
"FILE_CARTESC_read_var_2D",
'(1x,2A)')
'Read from file (2D), name : ', trim(varname)
1383 if ( dim_type ==
'XY' )
then
1389 elseif( dim_type ==
'ZX' )
then
1394 dtype = centertypezx
1398 log_error(
"FILE_CARTESC_read_var_2D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
1402 if (
size(var) .ne. vsize )
then
1403 log_error(
"FILE_CARTESC_read_var_2D",*)
'size of var is invalid: ', trim(varname),
size(var), vsize
1406 call file_read( fid, varname, &
1408 step=step, allow_missing=allow_missing, &
1409 ntypes=ntypes, dtype=dtype, start=start, count=count )
1413 if ( dim_type ==
'XY' )
then
1419 elseif( dim_type ==
'ZX' )
then
1426 log_error(
"FILE_CARTESC_read_var_2D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
1430 if (
size(var) .ne. vsize )
then
1431 log_error(
"FILE_CARTESC_read_var_2D",*)
'size of var is invalid: ', trim(varname),
size(var), vsize
1434 call file_read( fid, varname, var(dim1_s:dim1_e,dim2_s:dim2_e), step=step )
1461 integer,
intent(in) :: fid
1462 character(len=*),
intent(in) :: varname
1463 character(len=*),
intent(in) :: dim_type
1465 real(RP),
intent(out) :: var(:,:,:)
1467 integer,
intent(in),
optional :: step
1468 logical,
intent(in),
optional :: allow_missing
1471 integer :: ntypes, dtype
1472 integer,
pointer :: start(:), count(:)
1473 integer :: dim1_S, dim1_E
1474 integer :: dim2_S, dim2_E
1475 integer :: dim3_S, dim3_E
1482 log_info(
"FILE_CARTESC_read_var_3D",
'(1x,2A)')
'Read from file (3D), name : ', trim(varname)
1489 if( dim_type ==
'ZXY' &
1490 .or. dim_type ==
'ZXHY' &
1491 .or. dim_type ==
'ZXYH' )
then
1494 dtype = centertypezxy
1497 elseif( dim_type ==
'ZHXY' )
then
1500 dtype = centertypezhxy
1503 elseif( dim_type ==
'XYT' )
then
1504 if ( .not.
present(step) )
then
1505 log_error(
"FILE_CARTESC_read_var_3D",*)
'step is necessary for "XYT"'
1508 vsize =
ia *
ja * step
1509 ntypes =
ia *
ja * step
1515 elseif( dim_type ==
'OXY' )
then
1518 dtype = centertypeocean
1521 elseif( dim_type ==
'LXY' )
then
1524 dtype = centertypeland
1527 elseif( dim_type ==
'UXY' )
then
1530 dtype = centertypeurban
1534 log_error(
"FILE_CARTESC_read_var_3D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
1538 if (
size(var) .ne. vsize )
then
1539 log_error(
"FILE_CARTESC_read_var_3D",*)
'size of var is invalid: ', trim(varname),
size(var), vsize
1542 call file_read( fid, varname, &
1544 step=step, allow_missing=allow_missing, &
1545 ntypes=ntypes, dtype=dtype, start=start, count=count )
1548 if( dim_type ==
'ZXY' &
1549 .or. dim_type ==
'ZXHY' &
1550 .or. dim_type ==
'ZXYH' )
then
1558 elseif( dim_type ==
'ZHXY' )
then
1566 elseif( dim_type ==
'XYT' )
then
1567 if ( .not.
present(step) )
then
1568 log_error(
"FILE_CARTESC_read_var_3D",*)
'step is necessary for "XYT"'
1571 vsize =
ia *
ja * step
1578 elseif( dim_type ==
'OXY' )
then
1586 elseif( dim_type ==
'LXY' )
then
1594 elseif( dim_type ==
'UXY' )
then
1603 log_error(
"FILE_CARTESC_read_var_3D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
1607 if (
size(var) .ne. vsize )
then
1608 log_error(
"FILE_CARTESC_read_var_3D",*)
'size of var is invalid: ', trim(varname),
size(var), vsize
1611 call file_read( fid, varname, var(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e), &
1612 step=step, allow_missing=allow_missing )
1640 integer,
intent(in) :: fid
1641 character(len=*),
intent(in) :: varname
1642 character(len=*),
intent(in) :: dim_type
1643 integer,
intent(in) :: step
1645 real(RP),
intent(out) :: var(:,:,:,:)
1647 logical,
intent(in),
optional :: allow_missing
1651 integer,
pointer :: start(:), count(:)
1652 integer :: dim1_S, dim1_E
1653 integer :: dim2_S, dim2_E
1654 integer :: dim3_S, dim3_E
1655 integer :: dim4_S, dim4_E
1662 log_info(
"FILE_CARTESC_read_var_4D",
'(1x,2A)')
'Read from file (4D), name : ', trim(varname)
1666 if ( dim_type ==
'ZXYT' &
1667 .or. dim_type ==
'ZXHYT' &
1668 .or. dim_type ==
'ZXYHT' )
then
1669 vsize =
ka *
ia *
ja * step
1670 dtype = centertypezxy
1673 elseif ( dim_type ==
'ZHXYT' )
then
1674 vsize =
ka *
ia *
ja * step
1675 dtype = centertypezhxy
1678 elseif ( dim_type ==
'OXYT' )
then
1680 dtype = centertypeocean
1683 elseif ( dim_type ==
'LXYT' )
then
1685 dtype = centertypeland
1688 elseif ( dim_type ==
'LXYT' )
then
1690 dtype = centertypeland
1693 elseif ( dim_type ==
'UXYT' )
then
1695 dtype = centertypeurban
1699 log_error(
"FILE_CARTESC_read_var_4D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
1703 if (
size(var) .ne. vsize )
then
1704 log_error(
"FILE_CARTESC_read_var_4D",*)
'size of var is invalid: ', trim(varname),
size(var), vsize
1709 call file_read( fid, varname, &
1711 allow_missing=allow_missing, &
1712 ntypes=step, dtype=dtype, start=start, count=count )
1715 if ( dim_type ==
'ZXYT' &
1716 .or. dim_type ==
'ZXHYT' &
1717 .or. dim_type ==
'ZXYHT' )
then
1718 vsize =
ka *
ia *
ja * step
1725 elseif ( dim_type ==
'ZHXYT' )
then
1726 vsize =
ka *
ia *
ja * step
1733 elseif ( dim_type ==
'OXYT' )
then
1741 elseif ( dim_type ==
'LXYT' )
then
1749 elseif ( dim_type ==
'OXYT' )
then
1758 log_error(
"FILE_CARTESC_read_var_4D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
1762 if (
size(var) .ne. vsize )
then
1763 log_error(
"FILE_CARTESC_read_var_4D",*)
'size of var is invalid: ', trim(varname),
size(var), vsize
1768 call file_read( fid, varname, &
1769 var(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e,dim4_s:dim4_e) )
1787 file_get_datainfo, &
1788 file_get_attribute, &
1793 integer,
intent(in) :: fid
1794 character(len=*),
intent(in) :: varname
1796 real(RP),
intent(out) :: var(:,:)
1798 integer,
intent(in),
optional :: step
1800 logical,
intent(out),
optional :: existed
1806 character(len=H_SHORT) :: dnames(2)
1820 log_info(
"FILE_CARTESC_read_auto_2D",
'(1x,2A)')
'Read from file (2D), name : ', trim(varname)
1822 call file_get_datainfo( fid, varname, dim_name=dnames(:), existed=existed2 )
1824 if (
present( existed ) )
then
1826 if ( .not. existed2 )
return
1829 if ( .not. existed2 )
then
1830 log_error(
"FILE_CARTESC_read_auto_2D",*)
'variable not found: ', trim(varname)
1834 call file_get_shape( fid, varname, dims(:) )
1838 if ( nx==dims(1) .and. ny==dims(2) )
then
1842 call file_get_attribute( fid, dnames(n),
"halo_local", halos(:), existed=existed2 )
1843 if ( existed2 )
then
1844 start(n) = halos(1) + 1
1850 count(:) = (/nx,ny/)
1852 call file_read( fid, varname, var(:,:), step=step, start=start(:), count=count(:) )
1870 file_get_datainfo, &
1871 file_get_attribute, &
1876 integer,
intent(in) :: fid
1877 character(len=*),
intent(in) :: varname
1879 real(RP),
intent(out) :: var(:,:,:)
1881 integer,
intent(in),
optional :: step
1883 logical,
intent(out),
optional :: existed
1889 character(len=H_SHORT) :: dnames(3)
1893 real(RP),
allocatable :: buf(:,:,:)
1894 integer :: nx, ny, nz
1905 log_info(
"FILE_CARTESC_read_auto_3D",
'(1x,2A)')
'Read from file (3D), name : ', trim(varname)
1907 call file_get_datainfo( fid, varname, dim_name=dnames(:), existed=existed2 )
1909 if (
present(existed) )
then
1911 if ( .not. existed2 )
return
1914 if ( .not. existed2 )
then
1915 log_error(
"FILE_CARTESC_read_auto_3D",*)
'variable not found: ', trim(varname)
1919 call file_get_shape( fid, varname, dims(:) )
1924 if ( ( dnames(1)(1:1)==
"z" .or. dnames(1)(2:2)==
"z" ) .and. dnames(2)(1:1)==
"x" .and. dnames(3)(1:1)==
"y" )
then
1925 if ( nz==dims(1) .and. nx==dims(2) .and. ny==dims(3) )
then
1926 start(:) = (/1,1,1/)
1927 else if ( dnames(1)==
"zh" .and. nz+1==dims(1) .and. nx==dims(2) .and. ny==dims(3) )
then
1928 start(:) = (/2,1,1/)
1931 call file_get_attribute( fid, dnames(n),
"halo_local", halos(:), existed=existed2 )
1932 if ( existed2 )
then
1933 start(n) = halos(1) + 1
1934 else if ( dnames(n)==
"zh" )
then
1941 count(:) = (/nz,nx,ny/)
1942 call file_read( fid, varname, var(:,:,:), step=step, start=start(:), count=count(:) )
1944 else if ( dnames(1)(1:1)==
"x" .and. dnames(2)(1:1)==
"y" .and. ( dnames(3)(1:1)==
"z" .or. dnames(3)(2:2)==
"z" ) )
then
1945 allocate( buf(nx,ny,nz) )
1946 if ( nx==dims(1) .and. ny==dims(2) .and. nz==dims(3) )
then
1947 start(:) = (/1,1,1/)
1948 else if ( nx==dims(1) .and. ny==dims(2) .and. nz+1==dims(3) .and. dnames(3)==
"zh" )
then
1949 start(:) = (/1,1,2/)
1952 call file_get_attribute( fid, dnames(n),
"halo_local", halos(:), existed=existed2 )
1953 if ( existed2 )
then
1954 start(n) = halos(1) + 1
1955 else if ( dnames(n)==
"zh" )
then
1962 count(:) = (/nx,ny,nz/)
1963 call file_read( fid, varname, buf(:,:,:), step=step, start=start(:), count=count(:) )
1970 var(k,i,j) = buf(i,j,k)
1976 log_error(
"FILE_CARTESC_read_auto_3D",*)
'invalid dimension'
1994 varname, desc, unit, &
1995 dim_type, datatype, &
1997 append, aggregate, &
2002 real(RP),
intent(in) :: var(:)
2003 character(len=*),
intent(in) :: basename
2004 character(len=*),
intent(in) :: title
2005 character(len=*),
intent(in) :: varname
2006 character(len=*),
intent(in) :: desc
2007 character(len=*),
intent(in) :: unit
2008 character(len=*),
intent(in) :: dim_type
2009 character(len=*),
intent(in) :: datatype
2011 integer,
intent(in),
optional :: date(6)
2012 real(DP),
intent(in),
optional :: subsec
2013 logical,
intent(in),
optional :: append
2014 logical,
intent(in),
optional :: aggregate
2015 character(len=*),
intent(in),
optional :: standard_name
2016 character(len=*),
intent(in),
optional :: cell_measures
2021 log_info(
"FILE_CARTESC_write_1D",
'(1x,2A)')
'Write to file (1D), name : ', trim(varname)
2025 date=date, subsec=subsec, &
2026 append=append, aggregate=aggregate, single=.true. )
2030 standard_name=standard_name, &
2031 cell_measures=cell_measures )
2042 subroutine file_cartesc_write_2d( &
2045 varname, desc, unit, &
2046 dim_type, datatype, &
2048 fill_halo, haszcoord, &
2049 append, aggregate, &
2054 real(RP),
intent(in) :: var(:,:)
2055 character(len=*),
intent(in) :: basename
2056 character(len=*),
intent(in) :: title
2057 character(len=*),
intent(in) :: varname
2058 character(len=*),
intent(in) :: desc
2059 character(len=*),
intent(in) :: unit
2060 character(len=*),
intent(in) :: dim_type
2061 character(len=*),
intent(in) :: datatype
2063 integer,
intent(in),
optional :: date(6)
2064 real(DP),
intent(in),
optional :: subsec
2065 logical,
intent(in),
optional :: fill_halo
2066 logical,
intent(in),
optional :: haszcoord
2067 logical,
intent(in),
optional :: append
2068 logical,
intent(in),
optional :: aggregate
2069 character(len=*),
intent(in),
optional :: standard_name
2070 character(len=*),
intent(in),
optional :: cell_measures
2075 log_info(
"FILE_CARTESC_write_2D",
'(1x,2A)')
'Write to file (2D), name : ', trim(varname)
2079 date=date, subsec=subsec, &
2080 haszcoord=haszcoord, &
2081 append=append, aggregate=aggregate )
2085 standard_name=standard_name, &
2086 cell_measures=cell_measures )
2093 end subroutine file_cartesc_write_2d
2097 subroutine file_cartesc_write_3d( &
2100 varname, desc, unit, &
2101 dim_type, datatype, &
2104 append, aggregate, &
2109 real(RP),
intent(in) :: var(:,:,:)
2110 character(len=*),
intent(in) :: basename
2111 character(len=*),
intent(in) :: title
2112 character(len=*),
intent(in) :: varname
2113 character(len=*),
intent(in) :: desc
2114 character(len=*),
intent(in) :: unit
2115 character(len=*),
intent(in) :: dim_type
2116 character(len=*),
intent(in) :: datatype
2118 integer,
intent(in),
optional :: date(6)
2119 real(DP),
intent(in),
optional :: subsec
2120 logical,
intent(in),
optional :: fill_halo
2121 logical,
intent(in),
optional :: append
2122 logical,
intent(in),
optional :: aggregate
2123 character(len=*),
intent(in),
optional :: standard_name
2124 character(len=*),
intent(in),
optional :: cell_measures
2129 log_info(
"FILE_CARTESC_write_3D",
'(1x,2A)')
'Write to file (3D), name : ', trim(varname)
2133 date=date, subsec=subsec, &
2134 append=append, aggregate=aggregate )
2138 standard_name=standard_name, &
2139 cell_measures=cell_measures )
2147 end subroutine file_cartesc_write_3d
2151 subroutine file_cartesc_write_3d_t( &
2154 varname, desc, unit, &
2155 dim_type, datatype, &
2157 timetarg, timeofs, &
2159 append, aggregate, &
2164 real(RP),
intent(in) :: var(:,:,:)
2165 character(len=*),
intent(in) :: basename
2166 character(len=*),
intent(in) :: title
2167 character(len=*),
intent(in) :: varname
2168 character(len=*),
intent(in) :: desc
2169 character(len=*),
intent(in) :: unit
2170 character(len=*),
intent(in) :: dim_type
2171 character(len=*),
intent(in) :: datatype
2172 real(DP),
intent(in) :: timeintv
2173 integer ,
intent(in) :: tsince(6)
2175 integer,
intent(in),
optional :: timetarg
2176 real(DP),
intent(in),
optional :: timeofs
2177 logical,
intent(in),
optional :: fill_halo
2178 logical,
intent(in),
optional :: append
2179 logical,
intent(in),
optional :: aggregate
2180 character(len=*),
intent(in),
optional :: standard_name
2181 character(len=*),
intent(in),
optional :: cell_measures
2189 log_info(
"FILE_CARTESC_write_3D_t",
'(1x,3A)')
'Write to file (3D), name : ', trim(varname),
'with time dimension'
2194 append=append, aggregate=aggregate )
2196 if (
present(timetarg) )
then
2199 nsteps =
size(var,3)
2203 standard_name=standard_name, &
2204 cell_measures=cell_measures, &
2205 timeintv=timeintv, nsteps=nsteps )
2210 timetarg, timeofs, fill_halo )
2213 end subroutine file_cartesc_write_3d_t
2217 subroutine file_cartesc_write_4d( &
2220 varname, desc, unit, &
2221 dim_type, datatype, &
2223 timetarg, timeofs, &
2225 append, aggregate, &
2230 real(RP),
intent(in) :: var(:,:,:,:)
2231 character(len=*),
intent(in) :: basename
2232 character(len=*),
intent(in) :: title
2233 character(len=*),
intent(in) :: varname
2234 character(len=*),
intent(in) :: desc
2235 character(len=*),
intent(in) :: unit
2236 character(len=*),
intent(in) :: dim_type
2237 character(len=*),
intent(in) :: datatype
2238 real(DP),
intent(in) :: timeintv
2239 integer,
intent(in) :: tsince(6)
2241 integer,
intent(in),
optional :: timetarg
2242 real(DP),
intent(in),
optional :: timeofs
2243 logical,
intent(in),
optional :: fill_halo
2244 logical,
intent(in),
optional :: append
2245 logical,
intent(in),
optional :: aggregate
2246 character(len=*),
intent(in),
optional :: standard_name
2247 character(len=*),
intent(in),
optional :: cell_measures
2255 log_info(
"FILE_CARTESC_write_4D",
'(1x,2A)')
'Write to file (4D), name : ', trim(varname)
2260 append=append, aggregate=aggregate )
2262 if (
present(timetarg) )
then
2265 nsteps =
size(var,3)
2269 standard_name=standard_name, &
2270 cell_measures=cell_measures, &
2271 timeintv=timeintv, nsteps=nsteps )
2276 timetarg, timeofs, fill_halo )
2279 end subroutine file_cartesc_write_4d
2285 prc_rank_x, prc_rank_y, &
2286 prc_num_x, prc_num_y, &
2287 prc_periodic_x, prc_periodic_y, &
2288 kmax, okmax, lkmax, ukmax, &
2290 khalo, ihalo, jhalo, &
2291 time, tunits, calendar )
2299 integer,
intent(in) :: fid
2300 integer,
intent(in) :: prc_rank_x, prc_rank_y
2301 integer,
intent(in) :: prc_num_x, prc_num_y
2302 logical,
intent(in) :: prc_periodic_x, prc_periodic_y
2306 real(
dp),
intent(in) :: time
2307 character(len=*),
intent(in) :: tunits
2308 character(len=*),
intent(in) :: calendar
2315 call file_set_attribute( fid,
"global",
"Conventions",
"CF-1.6" )
2319 call file_set_attribute( fid,
"global",
"scale_cartesC_prc_rank_x", (/prc_rank_x/) )
2320 call file_set_attribute( fid,
"global",
"scale_cartesC_prc_rank_y", (/prc_rank_y/) )
2322 call file_set_attribute( fid,
"global",
"scale_cartesC_prc_num_x", (/prc_num_x/) )
2323 call file_set_attribute( fid,
"global",
"scale_cartesC_prc_num_y", (/prc_num_y/) )
2325 call file_set_attribute( fid,
"global",
"scale_cartesC_prc_periodic_z", .false. )
2326 call file_set_attribute( fid,
"global",
"scale_cartesC_prc_periodic_x", prc_periodic_x )
2327 call file_set_attribute( fid,
"global",
"scale_cartesC_prc_periodic_y", prc_periodic_y )
2329 call file_set_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_imaxg", (/
imaxg/) )
2330 call file_set_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_jmaxg", (/
jmaxg/) )
2332 call file_set_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_kmax", (/
kmax/) )
2333 if (
okmax > 0 )
call file_set_attribute( fid,
"global",
"scale_ocean_grid_cartesC_index_kmax", (/
okmax/) )
2334 if (
lkmax > 0 )
call file_set_attribute( fid,
"global",
"scale_land_grid_cartesC_index_kmax", (/
lkmax/) )
2335 if (
ukmax > 0 )
call file_set_attribute( fid,
"global",
"scale_urban_grid_cartesC_index_kmax", (/
ukmax/) )
2337 call file_set_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_khalo", (/
khalo/) )
2338 call file_set_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_ihalo", (/
ihalo/) )
2339 call file_set_attribute( fid,
"global",
"scale_atmos_grid_cartesC_index_jhalo", (/
jhalo/) )
2341 if ( calendar /=
"" )
call file_set_attribute( fid,
"global",
"calendar", calendar )
2342 call file_set_attribute( fid,
"global",
"time_units", tunits )
2343 call file_set_attribute( fid,
"global",
"time_start", (/time/) )
2361 file_set_attribute, &
2370 integer,
intent(in) :: fid
2371 integer,
intent(in) :: dtype
2372 logical,
intent(in) :: hasZ
2379 character(len=2) :: axisname(3)
2381 logical,
save :: set_dim = .false.
2388 if ( .not. set_dim )
then
2407 call file_def_axis( fid,
'zh' ,
'Z (half level)' ,
'm',
'zh' , dtype,
kmax+1, bounds=.true. )
2409 if (
okmax > 0 )
then
2411 call file_def_axis( fid,
'ozh',
'OZ (half level)',
'm',
'ozh', dtype,
okmax+1, bounds=.true. )
2414 if (
lkmax > 0 )
then
2416 call file_def_axis( fid,
'lzh',
'LZ (half level)',
'm',
'lzh', dtype,
lkmax+1, bounds=.true. )
2419 if (
ukmax > 0 )
then
2421 call file_def_axis( fid,
'uzh',
'UZ (half level)',
'm',
'uzh', dtype,
ukmax+1, bounds=.true. )
2425 call file_def_axis( fid,
'x' ,
'X' ,
'm',
'x' , dtype, isize, bounds=.true. )
2426 call file_def_axis( fid,
'xh' ,
'X (half level)' ,
'm',
'xh' , dtype, isize, bounds=.true. )
2427 call file_def_axis( fid,
'y' ,
'Y' ,
'm',
'y' , dtype, jsize, bounds=.true. )
2428 call file_def_axis( fid,
'yh' ,
'Y (half level)' ,
'm',
'yh' , dtype, jsize, bounds=.true. )
2431 call file_def_axis( fid,
'CZ' ,
'Atmos Grid Center Position Z',
'm',
'CZ', dtype,
ka )
2432 call file_def_axis( fid,
'FZ' ,
'Atmos Grid Face Position Z',
'm',
'FZ', dtype,
ka+1 )
2433 call file_def_axis( fid,
'CDZ' ,
'Grid Cell length Z',
'm',
'CZ', dtype,
ka )
2434 call file_def_axis( fid,
'FDZ' ,
'Grid distance Z',
'm',
'FDZ', dtype,
ka-1 )
2435 call file_def_axis( fid,
'CBFZ' ,
'Boundary factor Center Z',
'1',
'CZ', dtype,
ka )
2436 call file_def_axis( fid,
'FBFZ' ,
'Boundary factor Face Z',
'1',
'FZ', dtype,
ka+1 )
2438 if (
okmax > 0 )
then
2439 call file_def_axis( fid,
'OCZ' ,
'Ocean Grid Center Position Z',
'm',
'OCZ', dtype,
okmax )
2440 call file_def_axis( fid,
'OFZ' ,
'Ocean Grid Face Position Z',
'm',
'OFZ', dtype,
okmax+1 )
2441 call file_def_axis( fid,
'OCDZ' ,
'Ocean Grid Cell length Z',
'm',
'OCZ', dtype,
okmax )
2444 if (
lkmax > 0 )
then
2445 call file_def_axis( fid,
'LCZ' ,
'Land Grid Center Position Z',
'm',
'LCZ', dtype,
lkmax )
2446 call file_def_axis( fid,
'LFZ' ,
'Land Grid Face Position Z',
'm',
'LFZ', dtype,
lkmax+1 )
2447 call file_def_axis( fid,
'LCDZ' ,
'Land Grid Cell length Z',
'm',
'LCZ', dtype,
lkmax )
2450 if (
ukmax > 0 )
then
2451 call file_def_axis( fid,
'UCZ' ,
'Urban Grid Center Position Z',
'm',
'UCZ', dtype,
ukmax )
2452 call file_def_axis( fid,
'UFZ' ,
'Urban Grid Face Position Z',
'm',
'UFZ', dtype,
ukmax+1 )
2453 call file_def_axis( fid,
'UCDZ' ,
'Urban Grid Cell length Z',
'm',
'UCZ', dtype,
ukmax )
2457 call file_def_axis( fid,
'CX' ,
'Atmos Grid Center Position X',
'm',
'CX', dtype, iall )
2458 call file_def_axis( fid,
'CY' ,
'Atmos Grid Center Position Y',
'm',
'CY', dtype, jall )
2459 call file_def_axis( fid,
'FX' ,
'Atmos Grid Face Position X',
'm',
'FX', dtype, iall+1 )
2460 call file_def_axis( fid,
'FY' ,
'Atmos Grid Face Position Y',
'm',
'FY', dtype, jall+1 )
2461 call file_def_axis( fid,
'CDX' ,
'Grid Cell length X',
'm',
'CX', dtype, iall )
2462 call file_def_axis( fid,
'CDY' ,
'Grid Cell length Y',
'm',
'CY', dtype, jall )
2463 call file_def_axis( fid,
'FDX' ,
'Grid distance X',
'm',
'FX', dtype, iall+1 )
2464 call file_def_axis( fid,
'FDY' ,
'Grid distance Y',
'm',
'FY', dtype, jall+1 )
2465 call file_def_axis( fid,
'CBFX' ,
'Boundary factor Center X',
'1',
'CX', dtype, iall )
2466 call file_def_axis( fid,
'CBFY' ,
'Boundary factor Center Y',
'1',
'CY', dtype, jall )
2467 call file_def_axis( fid,
'FBFX' ,
'Boundary factor Face X',
'1',
'FX', dtype, iall+1 )
2468 call file_def_axis( fid,
'FBFY' ,
'Boundary factor Face Y',
'1',
'FY', dtype, jall+1 )
2470 call file_def_axis( fid,
'CXG' ,
'Grid Center Position X (global)',
'm',
'CXG', dtype,
iag )
2471 call file_def_axis( fid,
'CYG' ,
'Grid Center Position Y (global)',
'm',
'CYG', dtype,
jag )
2472 call file_def_axis( fid,
'FXG' ,
'Grid Face Position X (global)',
'm',
'FXG', dtype,
iag+1 )
2473 call file_def_axis( fid,
'FYG' ,
'Grid Face Position Y (global)',
'm',
'FYG', dtype,
jag+1 )
2474 call file_def_axis( fid,
'CDXG' ,
'Grid Cell length X (global)',
'm',
'CXG', dtype,
iag )
2475 call file_def_axis( fid,
'CDYG' ,
'Grid Cell length Y (global)',
'm',
'CYG', dtype,
jag )
2476 call file_def_axis( fid,
'FDXG' ,
'Grid distance X (global)',
'm',
'FXG', dtype,
iag+1 )
2477 call file_def_axis( fid,
'FDYG' ,
'Grid distance Y (global)',
'm',
'FYG', dtype,
jag+1 )
2478 call file_def_axis( fid,
'CBFXG',
'Boundary factor Center X (global)',
'1',
'CXG', dtype,
iag )
2479 call file_def_axis( fid,
'CBFYG',
'Boundary factor Center Y (global)',
'1',
'CYG', dtype,
jag )
2480 call file_def_axis( fid,
'FBFXG',
'Boundary factor Face X (global)',
'1',
'FXG', dtype,
iag+1 )
2481 call file_def_axis( fid,
'FBFYG',
'Boundary factor Face Y (global)',
'1',
'FYG', dtype,
jag+1 )
2484 axisname(1:2) = (/
'x ',
'y '/)
2486 axisname(1:2) = (/
'xh',
'y '/)
2488 axisname(1:2) = (/
'x ',
'yh'/)
2490 axisname(1:2) = (/
'xh',
'yh'/)
2492 axisname(1:2) = (/
'x ',
'y '/)
2494 axisname(1:2) = (/
'xh',
'y '/)
2496 axisname(1:2) = (/
'x ',
'yh'/)
2498 axisname(1:2) = (/
'xh',
'yh'/)
2502 axisname(1:2) = (/
'x ',
'y '/)
2505 axisname(1:2) = (/
'x ',
'y '/)
2508 axisname(1:2) = (/
'x ',
'y '/)
2510 axisname(1:2) = (/
'xh',
'y '/)
2512 axisname(1:2) = (/
'x ',
'yh'/)
2514 axisname(1:2) = (/
'xh',
'yh'/)
2517 axisname = (/
'z ',
'x ',
'y '/)
2519 'm', axisname(1:3), dtype )
2520 axisname = (/
'zh',
'x ',
'y '/)
2522 'm', axisname(1:3), dtype )
2524 axisname = (/
'z ',
'xh',
'y '/)
2526 'm2', axisname(1:3), dtype )
2527 axisname = (/
'z ',
'x ',
'yh'/)
2529 'm2', axisname(1:3), dtype )
2530 axisname = (/
'zh',
'xh',
'y '/)
2532 'm2', axisname(1:3), dtype )
2533 axisname = (/
'zh',
'x ',
'yh'/)
2535 'm2', axisname(1:3), dtype )
2536 axisname = (/
'z ',
'x ',
'y '/)
2538 'm2', axisname(1:3), dtype )
2539 axisname = (/
'z ',
'xh',
'yh'/)
2541 'm2', axisname(1:3), dtype )
2542 axisname = (/
'z ',
'xh',
'yh'/)
2544 'm2', axisname(1:3), dtype )
2545 axisname = (/
'z ',
'x ',
'y '/)
2547 'm2', axisname(1:3), dtype )
2549 axisname = (/
'z ',
'x ',
'y '/)
2551 'm3', axisname(1:3), dtype )
2552 axisname = (/
'zh',
'x ',
'y '/)
2554 'm3', axisname(1:3), dtype )
2555 axisname = (/
'z ',
'xh',
'y '/)
2557 'm3', axisname(1:3), dtype )
2558 axisname = (/
'z ',
'x ',
'yh'/)
2560 'm3', axisname(1:3), dtype )
2562 if (
okmax > 0 )
then
2563 axisname = (/
'oz',
'x ',
'y '/)
2565 'm3', axisname(1:3), dtype )
2567 if (
lkmax > 0 )
then
2568 axisname = (/
'lz',
'x ',
'y '/)
2570 'm3', axisname(1:3), dtype )
2572 if (
ukmax > 0 )
then
2573 axisname = (/
'uz',
'x ',
'y '/)
2575 'm3', axisname(1:3), dtype )
2582 if (
okmax > 0 )
then
2583 call file_set_attribute( fid,
'oz' ,
'positive',
'down' )
2584 call file_set_attribute( fid,
'ozh',
'positive',
'down' )
2586 if (
lkmax > 0 )
then
2587 call file_set_attribute( fid,
'lz' ,
'positive',
'down' )
2588 call file_set_attribute( fid,
'lzh',
'positive',
'down' )
2590 if (
ukmax > 0 )
then
2591 call file_set_attribute( fid,
'uz' ,
'positive',
'down' )
2592 call file_set_attribute( fid,
'uzh',
'positive',
'down' )
2594 if (
okmax > 0 )
then
2595 call file_set_attribute( fid,
'OCZ',
'positive',
'down' )
2596 call file_set_attribute( fid,
'OFZ',
'positive',
'down' )
2598 if (
lkmax > 0 )
then
2599 call file_set_attribute( fid,
'LCZ',
'positive',
'down' )
2600 call file_set_attribute( fid,
'LFZ',
'positive',
'down' )
2602 if (
ukmax > 0 )
then
2603 call file_set_attribute( fid,
'UCZ',
'positive',
'down' )
2604 call file_set_attribute( fid,
'UFZ',
'positive',
'down' )
2609 call file_set_attribute( fid,
"x" ,
"size_global" , (/
iag /) )
2610 call file_set_attribute( fid,
"x" ,
"start_global", (/ 1 /) )
2611 call file_set_attribute( fid,
"x" ,
"halo_global" , (/
ihalo,
ihalo /) )
2612 call file_set_attribute( fid,
"x" ,
"halo_local" , (/
ihalo,
ihalo /) )
2614 call file_set_attribute( fid,
"xh",
"size_global" , (/
iag+1 /) )
2615 call file_set_attribute( fid,
"xh",
"start_global", (/ 1 /) )
2616 call file_set_attribute( fid,
"xh",
"halo_global" , (/
ihalo,
ihalo /) )
2617 call file_set_attribute( fid,
"xh",
"halo_local" , (/
ihalo,
ihalo /) )
2619 call file_set_attribute( fid,
"y" ,
"size_global" , (/
jag /) )
2620 call file_set_attribute( fid,
"y" ,
"start_global", (/ 1 /) )
2621 call file_set_attribute( fid,
"y" ,
"halo_global" , (/
jhalo,
jhalo /) )
2622 call file_set_attribute( fid,
"y" ,
"halo_local" , (/
jhalo,
jhalo /) )
2624 call file_set_attribute( fid,
"yh",
"size_global" , (/
jag+1 /) )
2625 call file_set_attribute( fid,
"yh",
"start_global", (/ 1 /) )
2626 call file_set_attribute( fid,
"yh",
"halo_global" , (/
jhalo,
jhalo /) )
2627 call file_set_attribute( fid,
"yh",
"halo_local" , (/
jhalo,
jhalo /) )
2629 call file_set_attribute( fid,
"x" ,
"size_global" , file_cartesc_axis_info(1)%size_global (:) )
2630 call file_set_attribute( fid,
"x" ,
"start_global", file_cartesc_axis_info(1)%start_global(:) )
2631 call file_set_attribute( fid,
"x" ,
"halo_global" , file_cartesc_axis_info(1)%halo_global (:) )
2632 call file_set_attribute( fid,
"x" ,
"halo_local" , file_cartesc_axis_info(1)%halo_local (:) )
2634 call file_set_attribute( fid,
"xh",
"size_global" , file_cartesc_axis_info(2)%size_global (:) )
2635 call file_set_attribute( fid,
"xh",
"start_global", file_cartesc_axis_info(2)%start_global(:) )
2636 call file_set_attribute( fid,
"xh",
"halo_global" , file_cartesc_axis_info(2)%halo_global (:) )
2637 call file_set_attribute( fid,
"xh",
"halo_local" , file_cartesc_axis_info(2)%halo_local (:) )
2639 call file_set_attribute( fid,
"y" ,
"size_global" , file_cartesc_axis_info(3)%size_global (:) )
2640 call file_set_attribute( fid,
"y" ,
"start_global", file_cartesc_axis_info(3)%start_global(:) )
2641 call file_set_attribute( fid,
"y" ,
"halo_global" , file_cartesc_axis_info(3)%halo_global (:) )
2642 call file_set_attribute( fid,
"y" ,
"halo_local" , file_cartesc_axis_info(3)%halo_local (:) )
2644 call file_set_attribute( fid,
"yh",
"size_global" , file_cartesc_axis_info(4)%size_global (:) )
2645 call file_set_attribute( fid,
"yh",
"start_global", file_cartesc_axis_info(4)%start_global(:) )
2646 call file_set_attribute( fid,
"yh",
"halo_global" , file_cartesc_axis_info(4)%halo_global (:) )
2647 call file_set_attribute( fid,
"yh",
"halo_local" , file_cartesc_axis_info(4)%halo_local (:) )
2650 call file_set_attribute( fid,
"x" ,
"periodic" , file_cartesc_axis_info(1)%periodic )
2651 call file_set_attribute( fid,
"xh",
"periodic" , file_cartesc_axis_info(2)%periodic )
2652 call file_set_attribute( fid,
"y" ,
"periodic" , file_cartesc_axis_info(3)%periodic )
2653 call file_set_attribute( fid,
"yh",
"periodic" , file_cartesc_axis_info(4)%periodic )
2658 call file_set_attribute( fid,
"x" ,
"standard_name",
"projection_x_coordinate" )
2659 call file_set_attribute( fid,
"xh",
"standard_name",
"projection_x_coordinate" )
2660 call file_set_attribute( fid,
"y" ,
"standard_name",
"projection_y_coordinate" )
2661 call file_set_attribute( fid,
"yh",
"standard_name",
"projection_y_coordinate" )
2667 call file_set_attribute( fid, &
2674 call file_set_attribute( fid, &
2681 call file_set_attribute( fid, &
2683 "longitude_of_central_meridian", &
2688 call file_set_attribute( fid, &
2690 "longitude_of_projection_origin", &
2695 call file_set_attribute( fid, &
2697 "latitude_of_projection_origin", &
2702 call file_set_attribute( fid, &
2704 "straight_vertical_longitude_from_pole", &
2710 call file_set_attribute( fid, &
2712 "standard_parallel", &
2715 call file_set_attribute( fid, &
2717 "standard_parallel", &
2723 call file_set_attribute( fid, &
2733 call file_set_attribute( fid,
"cell_area",
"standard_name",
"area" )
2734 call file_set_attribute( fid,
"cell_area_uy",
"standard_name",
"area" )
2735 call file_set_attribute( fid,
"cell_area_xv",
"standard_name",
"area" )
2738 call file_set_attribute( fid,
"cell_area_zuy_x",
"standard_name",
"area" )
2739 call file_set_attribute( fid,
"cell_area_zxv_y",
"standard_name",
"area" )
2740 call file_set_attribute( fid,
"cell_area_wuy_x",
"standard_name",
"area" )
2741 call file_set_attribute( fid,
"cell_area_wxv_y",
"standard_name",
"area" )
2742 call file_set_attribute( fid,
"cell_area_zxy_x",
"standard_name",
"area" )
2743 call file_set_attribute( fid,
"cell_area_zuv_y",
"standard_name",
"area" )
2744 call file_set_attribute( fid,
"cell_area_zuv_x",
"standard_name",
"area" )
2745 call file_set_attribute( fid,
"cell_area_zxy_y",
"standard_name",
"area" )
2747 call file_set_attribute( fid,
"cell_volume",
"standard_name",
"volume" )
2748 call file_set_attribute( fid,
"cell_volume_wxy",
"standard_name",
"volume" )
2749 call file_set_attribute( fid,
"cell_volume_zuy",
"standard_name",
"volume" )
2750 call file_set_attribute( fid,
"cell_volume_zxv",
"standard_name",
"volume" )
2752 if (
okmax > 0 )
then
2753 call file_set_attribute( fid,
"cell_volume_oxy",
"standard_name",
"volume" )
2755 if (
lkmax > 0 )
then
2756 call file_set_attribute( fid,
"cell_volume_lxy",
"standard_name",
"volume" )
2758 if (
ukmax > 0 )
then
2759 call file_set_attribute( fid,
"cell_volume_uxy",
"standard_name",
"volume" )
2765 call file_set_attribute( fid,
"grid",
"cf_role",
"grid_topology" )
2766 call file_set_attribute( fid,
"grid",
"topology_dimension", (/ 2 /) )
2767 call file_set_attribute( fid,
"grid",
"node_dimensions",
"xh yh" )
2768 call file_set_attribute( fid,
"grid",
"face_dimensions",
"x: xh (padding: none) y: yh (padding: none)" )
2769 call file_set_attribute( fid,
"grid",
"node_coordinates",
"lon_uv lat_uv" )
2770 call file_set_attribute( fid,
"grid",
"face_coordinates",
"lon lat" )
2771 call file_set_attribute( fid,
"grid",
"edge1_coordinates",
"lon_uy lat_uy" )
2772 call file_set_attribute( fid,
"grid",
"edge2_coordinates",
"lon_xv lat_xv" )
2773 call file_set_attribute( fid,
"grid",
"vertical_dimensions",
"z: zh (padding: none)" )
2775 if (
okmax > 0 )
then
2777 call file_set_attribute( fid,
"grid_ocean",
"cf_role",
"grid_topology" )
2778 call file_set_attribute( fid,
"grid_ocean",
"topology_dimension", (/ 2 /) )
2779 call file_set_attribute( fid,
"grid_ocean",
"node_dimensions",
"xh yh" )
2780 call file_set_attribute( fid,
"grid_ocean",
"face_dimensions",
"x: xh (padding: none) y: yh (padding: none)" )
2781 call file_set_attribute( fid,
"grid_ocean",
"node_coordinates",
"lon_uv lat_uv" )
2782 call file_set_attribute( fid,
"grid_ocean",
"face_coordinates",
"lon lat" )
2783 call file_set_attribute( fid,
"grid_ocean",
"edge1_coordinates",
"lon_uy lat_uy" )
2784 call file_set_attribute( fid,
"grid_ocean",
"edge2_coordinates",
"lon_xv lat_xv" )
2785 call file_set_attribute( fid,
"grid_ocean",
"vertical_dimensions",
"oz: ozh (padding: none)" )
2788 if (
lkmax > 0 )
then
2790 call file_set_attribute( fid,
"grid_land",
"cf_role",
"grid_topology" )
2791 call file_set_attribute( fid,
"grid_land",
"topology_dimension", (/ 2 /) )
2792 call file_set_attribute( fid,
"grid_land",
"node_dimensions",
"xh yh" )
2793 call file_set_attribute( fid,
"grid_land",
"face_dimensions",
"x: xh (padding: none) y: yh (padding: none)" )
2794 call file_set_attribute( fid,
"grid_land",
"node_coordinates",
"lon_uv lat_uv" )
2795 call file_set_attribute( fid,
"grid_land",
"face_coordinates",
"lon lat" )
2796 call file_set_attribute( fid,
"grid_land",
"edge1_coordinates",
"lon_uy lat_uy" )
2797 call file_set_attribute( fid,
"grid_land",
"edge2_coordinates",
"lon_xv lat_xv" )
2798 call file_set_attribute( fid,
"grid_land",
"vertical_dimensions",
"lz: lzh (padding: none)" )
2801 if (
ukmax > 0 )
then
2803 call file_set_attribute( fid,
"grid_urban",
"cf_role",
"grid_topology" )
2804 call file_set_attribute( fid,
"grid_urban",
"topology_dimension", (/ 2 /) )
2805 call file_set_attribute( fid,
"grid_urban",
"node_dimensions",
"xh yh" )
2806 call file_set_attribute( fid,
"grid_urban",
"face_dimensions",
"x: xh (padding: none) y: yh (padding: none)" )
2807 call file_set_attribute( fid,
"grid_urban",
"node_coordinates",
"lon_uv lat_uv" )
2808 call file_set_attribute( fid,
"grid_urban",
"face_coordinates",
"lon lat" )
2809 call file_set_attribute( fid,
"grid_urban",
"edge1_coordinates",
"lon_uy lat_uy" )
2810 call file_set_attribute( fid,
"grid_urban",
"edge2_coordinates",
"lon_xv lat_xv" )
2811 call file_set_attribute( fid,
"grid_urban",
"vertical_dimensions",
"uz: uzh (padding: none)" )
2815 call file_set_attribute( fid,
"grid_model",
"cf_role",
"grid_topology" )
2816 call file_set_attribute( fid,
"grid_model",
"topology_dimension", (/ 2 /) )
2817 call file_set_attribute( fid,
"grid_model",
"node_dimensions",
"FX FY" )
2818 call file_set_attribute( fid,
"grid_model",
"face_dimensions",
"CX: FY (padding: none) CY: FY (padding: none)" )
2819 call file_set_attribute( fid,
"grid_model",
"vertical_dimensions",
"CZ: FZ (padding: none)" )
2822 call file_set_attribute( fid,
"grid_model_global",
"cf_role",
"grid_topology" )
2823 call file_set_attribute( fid,
"grid_model_global",
"topology_dimension", (/ 2 /) )
2824 call file_set_attribute( fid,
"grid_model_global",
"node_dimensions",
"FXG FYG" )
2825 call file_set_attribute( fid,
"grid_model_global",
"face_dimensions",
"CXG: FYG (padding: none) CYG: FYG (padding: none)" )
2826 call file_set_attribute( fid,
"grid_model_global",
"vertical_dimensions",
"CZ: FZ (padding: none)" )
2846 file_write_associatedcoordinate
2897 integer,
intent(in) :: fid
2898 logical,
intent(in) :: haszcoord
2899 integer,
intent(in) :: start(3)
2901 logical :: put_z, put_x, put_y
2902 integer :: XSB, XEB, YSB, YEB
2904 real(RP) :: z_bnds(2,KA), zh_bnds(2,0:KA)
2905 real(RP) :: oz_bnds(2,OKA), ozh_bnds(2,0:OKA)
2906 real(RP) :: lz_bnds(2,LKA), lzh_bnds(2,0:LKA)
2907 real(RP) :: uz_bnds(2,UKA), uzh_bnds(2,0:UKA)
2908 real(RP) :: x_bnds(2,IA), xh_bnds(2,0:IA)
2909 real(RP) :: y_bnds(2,JA), yh_bnds(2,0:JA)
2911 real(RP) :: FDXG(0:IAG), FDYG(0:JAG)
2912 real(RP) :: FDX(0:IA), FDY(0:JA)
2942 if ( haszcoord .and. put_z )
then
2949 call file_write_associatedcoordinate( fid,
'z_bnds', z_bnds(:,
ks:
ke), start(1:1) )
2956 call file_write_associatedcoordinate( fid,
'zh_bnds', zh_bnds(:,
ks-1:
ke), start(1:1) )
2959 if (
okmax > 0 )
then
2965 call file_write_associatedcoordinate( fid,
'oz_bnds', oz_bnds(:,
oks:
oke), start(1:1) )
2974 call file_write_associatedcoordinate( fid,
'ozh_bnds', ozh_bnds(:,
oks-1:
oke), start(1:1) )
2978 if (
lkmax > 0 )
then
2984 call file_write_associatedcoordinate( fid,
'lz_bnds', lz_bnds(:,
lks:
lke), start(1:1) )
2993 call file_write_associatedcoordinate( fid,
'lzh_bnds', lzh_bnds(:,
lks-1:
lke), start(1:1) )
2997 if (
ukmax > 0 )
then
3003 call file_write_associatedcoordinate( fid,
'uz_bnds', uz_bnds(:,
uks:
uke), start(1:1) )
3012 call file_write_associatedcoordinate( fid,
'uzh_bnds', uzh_bnds(:,
uks-1:
uke), start(1:1) )
3023 call file_write_associatedcoordinate( fid,
'x_bnds', x_bnds(:,isb2:ieb2), (/1,start(2)/) )
3031 if ( ieb2 == ia )
then
3036 call file_write_associatedcoordinate( fid,
'xh_bnds', xh_bnds(:,isb2:ieb2), (/1,start(2)/) )
3043 call file_write_associatedcoordinate( fid,
'x_bnds', x_bnds(:,
isb:
ieb), (/1,start(2)/) )
3051 if (
ieb == ia )
then
3056 call file_write_associatedcoordinate( fid,
'xh_bnds', xh_bnds(:,
isb:
ieb), (/1,start(2)/) )
3067 call file_write_associatedcoordinate( fid,
'y_bnds', y_bnds(:,jsb2:jeb2), (/1,start(2)/) )
3075 if ( jeb2 == ja )
then
3080 call file_write_associatedcoordinate( fid,
'yh_bnds', yh_bnds(:,jsb2:jeb2), (/1,start(2)/) )
3087 call file_write_associatedcoordinate( fid,
'y_bnds', y_bnds(:,
jsb:
jeb), (/1,start(2)/) )
3095 if (
jeb == ja )
then
3100 call file_write_associatedcoordinate( fid,
'yh_bnds', yh_bnds(:,
jsb:
jeb), (/1,start(2)/) )
3119 if ( haszcoord .and. put_z )
then
3127 if (
okmax > 0 )
then
3133 if (
lkmax > 0 )
then
3139 if (
ukmax > 0 )
then
3155 call file_write_axis( fid,
'FDX', fdxg(:) )
3156 call file_write_axis( fid,
'FDY', fdyg(:) )
3169 call file_write_axis( fid,
'FDX', fdx(:) )
3170 call file_write_axis( fid,
'FDY', fdy(:) )
3183 call file_write_axis( fid,
'FDXG', fdxg(:) )
3184 call file_write_axis( fid,
'FDYG', fdyg(:) )
3192 call file_write_associatedcoordinate( fid,
'lon' , axis_lon(:,:), start(2:3) )
3193 call file_write_associatedcoordinate( fid,
'lon_uy', axis_lonuy(:,:), start(2:3) )
3194 call file_write_associatedcoordinate( fid,
'lon_xv', axis_lonxv(:,:), start(2:3) )
3195 call file_write_associatedcoordinate( fid,
'lon_uv', axis_lonuv(:,:), start(2:3) )
3196 call file_write_associatedcoordinate( fid,
'lat' , axis_lat(:,:), start(2:3) )
3197 call file_write_associatedcoordinate( fid,
'lat_uy', axis_latuy(:,:), start(2:3) )
3198 call file_write_associatedcoordinate( fid,
'lat_xv', axis_latxv(:,:), start(2:3) )
3199 call file_write_associatedcoordinate( fid,
'lat_uv', axis_latuv(:,:), start(2:3) )
3201 if ( haszcoord )
then
3202 call file_write_associatedcoordinate( fid,
'topo', axis_topo(:,:), start(2:3) )
3204 call file_write_associatedcoordinate( fid,
'lsmask', axis_lsmask(:,:), start(2:3) )
3206 call file_write_associatedcoordinate( fid,
'cell_area', axis_area(:,:), start(2:3) )
3207 call file_write_associatedcoordinate( fid,
'cell_area_uy', axis_areauy(:,:), start(2:3) )
3208 call file_write_associatedcoordinate( fid,
'cell_area_xv', axis_areaxv(:,:), start(2:3) )
3210 if ( haszcoord )
then
3211 call file_write_associatedcoordinate( fid,
'height' , axis_hgt(:,:,:), start(1:3) )
3212 call file_write_associatedcoordinate( fid,
'height_wxy', axis_hgtwxy(:,:,:), start(1:3) )
3214 call file_write_associatedcoordinate( fid,
'cell_area_zuy_x', axis_areazuy_x(:,:,:), start(1:3) )
3215 call file_write_associatedcoordinate( fid,
'cell_area_zxv_y', axis_areazxv_y(:,:,:), start(1:3) )
3216 call file_write_associatedcoordinate( fid,
'cell_area_wuy_x', axis_areawuy_x(:,:,:), start(1:3) )
3217 call file_write_associatedcoordinate( fid,
'cell_area_wxv_y', axis_areawxv_y(:,:,:), start(1:3) )
3218 call file_write_associatedcoordinate( fid,
'cell_area_zxy_x', axis_areazxy_x(:,:,:), start(1:3) )
3219 call file_write_associatedcoordinate( fid,
'cell_area_zuv_y', axis_areazuv_y(:,:,:), start(1:3) )
3220 call file_write_associatedcoordinate( fid,
'cell_area_zuv_x', axis_areazuv_x(:,:,:), start(1:3) )
3221 call file_write_associatedcoordinate( fid,
'cell_area_zxy_y', axis_areazxy_y(:,:,:), start(1:3) )
3223 call file_write_associatedcoordinate( fid,
'cell_volume', axis_vol(:,:,:), start(1:3) )
3224 call file_write_associatedcoordinate( fid,
'cell_volume_wxy', axis_volwxy(:,:,:), start(1:3) )
3225 call file_write_associatedcoordinate( fid,
'cell_volume_zuy', axis_volzuy(:,:,:), start(1:3) )
3226 call file_write_associatedcoordinate( fid,
'cell_volume_zxv', axis_volzxv(:,:,:), start(1:3) )
3228 if (
okmax > 0 )
then
3229 call file_write_associatedcoordinate( fid,
'cell_volume_oxy', axis_volo(:,:,:), start(1:3) )
3231 if (
lkmax > 0 )
then
3232 call file_write_associatedcoordinate( fid,
'cell_volume_lxy', axis_voll(:,:,:), start(1:3) )
3234 if (
ukmax > 0 )
then
3235 call file_write_associatedcoordinate( fid,
'cell_volume_uxy', axis_volu(:,:,:), start(1:3) )
3239 xsb =
isb - isb2 + 1
3241 ysb =
jsb - jsb2 + 1
3244 call file_write_associatedcoordinate( fid,
'lon' , axis_lon(xsb:xeb,ysb:yeb), start(2:3) )
3245 call file_write_associatedcoordinate( fid,
'lon_uy', axis_lonuy(xsb:xeb,ysb:yeb), start(2:3) )
3246 call file_write_associatedcoordinate( fid,
'lon_xv', axis_lonxv(xsb:xeb,ysb:yeb), start(2:3) )
3247 call file_write_associatedcoordinate( fid,
'lon_uv', axis_lonuv(xsb:xeb,ysb:yeb), start(2:3) )
3248 call file_write_associatedcoordinate( fid,
'lat' , axis_lat(xsb:xeb,ysb:yeb), start(2:3) )
3249 call file_write_associatedcoordinate( fid,
'lat_uy', axis_latuy(xsb:xeb,ysb:yeb), start(2:3) )
3250 call file_write_associatedcoordinate( fid,
'lat_xv', axis_latxv(xsb:xeb,ysb:yeb), start(2:3) )
3251 call file_write_associatedcoordinate( fid,
'lat_uv', axis_latuv(xsb:xeb,ysb:yeb), start(2:3) )
3253 if ( haszcoord )
then
3254 call file_write_associatedcoordinate( fid,
'topo', axis_topo(xsb:xeb,ysb:yeb), start(2:3) )
3256 call file_write_associatedcoordinate( fid,
'lsmask', axis_lsmask(xsb:xeb,ysb:yeb), start(2:3) )
3258 call file_write_associatedcoordinate( fid,
'cell_area', axis_area(xsb:xeb,ysb:yeb), start(2:3) )
3259 call file_write_associatedcoordinate( fid,
'cell_area_uy', axis_areauy(xsb:xeb,ysb:yeb), start(2:3) )
3260 call file_write_associatedcoordinate( fid,
'cell_area_xv', axis_areaxv(xsb:xeb,ysb:yeb), start(2:3) )
3262 if ( haszcoord )
then
3263 call file_write_associatedcoordinate( fid,
'height' , axis_hgt(:,xsb:xeb,ysb:yeb), start(1:3) )
3264 call file_write_associatedcoordinate( fid,
'height_wxy', axis_hgtwxy(:,xsb:xeb,ysb:yeb), start(1:3) )
3266 call file_write_associatedcoordinate( fid,
'cell_area_zuy_x', axis_areazuy_x(:,xsb:xeb,ysb:yeb), start(2:3) )
3267 call file_write_associatedcoordinate( fid,
'cell_area_zxv_y', axis_areazxv_y(:,xsb:xeb,ysb:yeb), start(2:3) )
3268 call file_write_associatedcoordinate( fid,
'cell_area_wuy_x', axis_areawuy_x(:,xsb:xeb,ysb:yeb), start(2:3) )
3269 call file_write_associatedcoordinate( fid,
'cell_area_wxv_y', axis_areawxv_y(:,xsb:xeb,ysb:yeb), start(2:3) )
3270 call file_write_associatedcoordinate( fid,
'cell_area_zxy_x', axis_areazxy_x(:,xsb:xeb,ysb:yeb), start(2:3) )
3271 call file_write_associatedcoordinate( fid,
'cell_area_zuv_y', axis_areazuv_y(:,xsb:xeb,ysb:yeb), start(2:3) )
3272 call file_write_associatedcoordinate( fid,
'cell_area_zuv_x', axis_areazuv_x(:,xsb:xeb,ysb:yeb), start(2:3) )
3273 call file_write_associatedcoordinate( fid,
'cell_area_zxy_y', axis_areazxy_y(:,xsb:xeb,ysb:yeb), start(2:3) )
3275 call file_write_associatedcoordinate( fid,
'cell_volume', axis_vol(:,xsb:xeb,ysb:yeb), start(1:3) )
3276 call file_write_associatedcoordinate( fid,
'cell_volume_wxy', axis_volwxy(:,xsb:xeb,ysb:yeb), start(1:3) )
3277 call file_write_associatedcoordinate( fid,
'cell_volume_zuy', axis_volzuy(:,xsb:xeb,ysb:yeb), start(1:3) )
3278 call file_write_associatedcoordinate( fid,
'cell_volume_zxv', axis_volzxv(:,xsb:xeb,ysb:yeb), start(1:3) )
3280 if (
okmax > 0 )
then
3281 call file_write_associatedcoordinate( fid,
'cell_volume_oxy', axis_volo(:,xsb:xeb,ysb:yeb), start(1:3) )
3283 if (
lkmax > 0 )
then
3284 call file_write_associatedcoordinate( fid,
'cell_volume_lxy', axis_voll(:,xsb:xeb,ysb:yeb), start(1:3) )
3286 if (
ukmax > 0 )
then
3287 call file_write_associatedcoordinate( fid,
'cell_volume_uxy', axis_volu(:,xsb:xeb,ysb:yeb), start(1:3) )
3301 varname, desc, unit, &
3302 dim_type, datatype, &
3323 integer,
intent(in) :: fid
3324 character(len=*),
intent(in) :: varname
3325 character(len=*),
intent(in) :: desc
3326 character(len=*),
intent(in) :: unit
3327 character(len=*),
intent(in) :: dim_type
3328 character(len=*),
intent(in) :: datatype
3330 integer,
intent(out) :: vid
3332 character(len=*),
intent(in),
optional :: standard_name
3333 real(
dp),
intent(in),
optional :: timeintv
3334 integer,
intent(in),
optional :: nsteps
3335 character(len=*),
intent(in),
optional :: cell_measures
3337 character(len=H_MID) :: standard_name_
3338 character(len=H_SHORT) :: cell_measures_
3340 character(len=H_SHORT) :: dimtype
3342 integer :: dtype, elm_size, ndims
3350 if ( datatype ==
'REAL8' )
then
3353 elseif( datatype ==
'REAL4' )
then
3360 elseif(
rp == 4 )
then
3364 log_error(
"FILE_CARTESC_def_var",*)
'unsupported data type. Check!', trim(datatype),
' item:',trim(varname)
3370 select case( dim_type )
3389 do n = 1, file_cartesc_ndims
3390 if ( file_cartesc_dims(n)%name == dimtype )
then
3395 if ( dimid <= -1 )
then
3396 log_error(
"FILE_CARTESC_def_var",*)
'dim_type is not supported: ', trim(dimtype)
3400 if (
present(nsteps) )
then
3401 write_buf_amount(fid) = write_buf_amount(fid) + file_cartesc_dims(dimid)%size * elm_size * nsteps
3403 write_buf_amount(fid) = write_buf_amount(fid) + file_cartesc_dims(dimid)%size * elm_size
3406 ndims = file_cartesc_dims(dimid)%ndims
3408 if (
present(standard_name) )
then
3409 standard_name_ = standard_name
3414 if (
present(timeintv) )
then
3416 ndims, file_cartesc_dims(dimid)%dims(1:ndims), dtype, &
3421 ndims, file_cartesc_dims(dimid)%dims(1:ndims), dtype, &
3425 if (
present(cell_measures) )
then
3426 cell_measures_ = cell_measures
3427 select case ( cell_measures )
3429 if ( file_cartesc_dims(dimid)%area ==
"" )
then
3430 log_error(
"FILE_CARTESC_def_var",*)
'area is not supported for ', trim(dimtype),
' as cell_measures'
3434 if ( file_cartesc_dims(dimid)%area ==
"" )
then
3435 log_error(
"FILE_CARTESC_def_var",*)
'area_z is not supported for ', trim(dimtype),
' as cell_measures'
3439 if ( file_cartesc_dims(dimid)%area_x ==
"" )
then
3440 log_error(
"FILE_CARTESC_def_var",*)
'area_x is not supported for ', trim(dimtype),
' as cell_measures'
3444 if ( file_cartesc_dims(dimid)%area_y ==
"" )
then
3445 log_error(
"FILE_CARTESC_def_var",*)
'area_y is not supported for ', trim(dimtype),
' as cell_measures'
3449 if ( file_cartesc_dims(dimid)%volume ==
"" )
then
3450 log_error(
"FILE_CARTESC_def_var",*)
'volume is not supported for ', trim(dimtype),
' as cell_measures'
3454 log_error(
"FILE_CARTESC_def_var",*)
'cell_measures must be "area" or "volume"'
3457 else if ( ndims == 2 )
then
3458 cell_measures_ =
"area"
3459 else if ( ndims == 3 )
then
3460 cell_measures_ =
"volume"
3465 select case( cell_measures_ )
3466 case (
"area",
"area_z" )
3467 call file_set_attribute( fid, varname,
"cell_measures",
"area: "//trim(file_cartesc_dims(dimid)%area) )
3469 call file_set_attribute( fid, varname,
"cell_measures",
"area: "//trim(file_cartesc_dims(dimid)%area_x) )
3471 call file_set_attribute( fid, varname,
"cell_measures",
"area: "//trim(file_cartesc_dims(dimid)%area_y) )
3473 call file_set_attribute( fid, varname,
"cell_measures",
"volume: "//trim(file_cartesc_dims(dimid)%volume) )
3482 if ( file_cartesc_dims(dimid)%location /=
"" )
then
3483 call file_set_attribute( fid, varname,
"grid", file_cartesc_dims(dimid)%grid )
3484 call file_set_attribute( fid, varname,
"location", file_cartesc_dims(dimid)%location )
3514 integer,
intent(in) :: fid
3515 integer,
intent(in) :: vid
3516 real(RP),
intent(in) :: var(:)
3517 character(len=*),
intent(in) :: varname
3518 character(len=*),
intent(in) :: dim_type
3520 integer :: dim1_S, dim1_E
3521 integer :: rankidx(2)
3533 if ( dim_type ==
'Z' )
then
3542 elseif( dim_type ==
'X' )
then
3544 exec = ( rankidx(2) == 0 )
3553 elseif( dim_type ==
'Y' )
then
3555 exec = ( rankidx(1) == 0 )
3565 log_error(
"FILE_CARTESC_write_var_1D",*)
'unsupported dimenstion type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
3569 if( exec )
call file_write( vid, var(dim1_s:dim1_e), &
3570 nowdaysec, nowdaysec, start=start )
3604 integer,
intent(in) :: fid
3605 integer,
intent(in) :: vid
3606 real(RP),
intent(in) :: var(:,:)
3607 character(len=*),
intent(in) :: varname
3608 character(len=*),
intent(in) :: dim_type
3609 logical,
intent(in),
optional :: fill_halo
3611 real(RP) :: varhalo( size(var(:,1)), size(var(1,:)) )
3613 integer :: dim1_S, dim1_E
3614 integer :: dim2_S, dim2_E
3617 logical :: fill_halo_
3618 integer :: rankidx(2)
3633 fill_halo_ = .false.
3634 if(
present(fill_halo) ) fill_halo_ = fill_halo
3636 if ( dim_type ==
'XY' &
3637 .OR. dim_type ==
'UY' &
3638 .OR. dim_type ==
'XV' &
3639 .OR. dim_type ==
'UV' )
then
3652 elseif( dim_type ==
'ZX' )
then
3658 exec = ( rankidx(2) == 0 )
3667 log_error(
"FILE_CARTESC_write_var_2D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
3672 if ( fill_halo_ )
then
3675 varhalo(i,j) = var(i,j)
3682 varhalo(i,j) = rmiss
3688 varhalo(i,j) = rmiss
3694 varhalo(i,j) = rmiss
3700 varhalo(i,j) = rmiss
3704 call file_write( vid, varhalo(dim1_s:dim1_e,dim2_s:dim2_e), &
3705 nowdaysec, nowdaysec, start )
3707 call file_write( vid, var(dim1_s:dim1_e,dim2_s:dim2_e), &
3708 nowdaysec, nowdaysec, start )
3745 integer,
intent(in) :: fid
3746 integer,
intent(in) :: vid
3747 real(RP),
intent(in) :: var(:,:,:)
3748 character(len=*),
intent(in) :: varname
3749 character(len=*),
intent(in) :: dim_type
3751 logical,
intent(in),
optional :: fill_halo
3753 real(RP) :: varhalo( size(var(:,1,1)), size(var(1,:,1)), size(var(1,1,:)) )
3755 integer :: dim1_S, dim1_E, dim1_max
3756 integer :: dim2_S, dim2_E
3757 integer :: dim3_S, dim3_E
3760 logical :: fill_halo_
3761 integer :: rankidx(2)
3769 fill_halo_ = .false.
3770 if(
present(fill_halo) ) fill_halo_ = fill_halo
3779 if ( dim_type ==
'ZXY' &
3780 .OR. dim_type ==
'ZXHY' &
3781 .OR. dim_type ==
'ZXYH' &
3782 .OR. dim_type ==
'ZXHYH' )
then
3786 elseif ( dim_type ==
'ZHXY' &
3787 .OR. dim_type ==
'ZHXHY' &
3788 .OR. dim_type ==
'ZHXYH' )
then
3792 elseif( dim_type ==
'OXY' )
then
3796 elseif( dim_type ==
'LXY' )
then
3800 elseif( dim_type ==
'UXY' )
then
3805 log_error(
"FILE_CARTESC_write_var_3D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
3821 if ( fill_halo_ )
then
3826 varhalo(k,i,j) = var(k,i,j)
3835 varhalo(k,i,j) = rmiss
3843 varhalo(k,i,j) = rmiss
3851 varhalo(k,i,j) = rmiss
3859 varhalo(k,i,j) = rmiss
3864 call file_write( vid, varhalo(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e), &
3865 nowdaysec, nowdaysec, start )
3867 call file_write( vid, var(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e), &
3868 nowdaysec, nowdaysec, start )
3904 integer,
intent(in) :: fid
3905 integer,
intent(in) :: vid
3906 real(RP),
intent(in) :: var(:,:,:)
3907 character(len=*),
intent(in) :: varname
3908 character(len=*),
intent(in) :: dim_type
3909 real(DP),
intent(in) :: timeintv
3911 integer,
intent(in),
optional :: timetarg
3912 real(DP),
intent(in),
optional :: timeofs
3913 logical,
intent(in),
optional :: fill_halo
3915 real(RP) :: varhalo( size(var(:,1,1)), size(var(1,:,1)) )
3917 integer :: dim1_S, dim1_E
3918 integer :: dim2_S, dim2_E
3920 real(DP) :: time_interval, nowtime
3924 logical :: fill_halo_
3925 real(DP) :: timeofs_
3926 integer :: rankidx(2)
3934 fill_halo_ = .false.
3935 if(
present(fill_halo) ) fill_halo_ = fill_halo
3938 if(
present(timeofs) ) timeofs_ = timeofs
3940 time_interval = timeintv
3941 step =
size(var(
isb,
jsb,:))
3946 if ( dim_type ==
'XYT' )
then
3959 log_error(
"FILE_CARTESC_write_var_3D_t",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
3967 if (
present(timetarg) )
then
3968 nowtime = timeofs_ + (timetarg-1) * time_interval
3970 if ( fill_halo_ )
then
3973 varhalo(i,j) = var(i,j,timetarg)
3980 varhalo(i,j) = rmiss
3986 varhalo(i,j) = rmiss
3992 varhalo(i,j) = rmiss
3998 varhalo(i,j) = rmiss
4002 call file_write( vid, varhalo(dim1_s:dim1_e,dim2_s:dim2_e), &
4003 nowtime, nowtime, start )
4005 call file_write( vid, var(dim1_s:dim1_e,dim2_s:dim2_e,timetarg), &
4006 nowtime, nowtime, start )
4011 if ( fill_halo_ )
then
4014 varhalo(i,j) = var(i,j,n)
4021 varhalo(i,j) = rmiss
4027 varhalo(i,j) = rmiss
4033 varhalo(i,j) = rmiss
4039 varhalo(i,j) = rmiss
4043 call file_write( vid, varhalo(dim1_s:dim1_e,dim2_s:dim2_e), &
4044 nowtime, nowtime, start )
4046 call file_write( vid, var(dim1_s:dim1_e,dim2_s:dim2_e,n), &
4047 nowtime, nowtime, start )
4049 nowtime = nowtime + time_interval
4087 integer,
intent(in) :: fid
4088 integer,
intent(in) :: vid
4089 real(RP),
intent(in) :: var(:,:,:,:)
4090 character(len=*),
intent(in) :: varname
4091 character(len=*),
intent(in) :: dim_type
4092 real(DP),
intent(in) :: timeintv
4094 integer,
intent(in),
optional :: timetarg
4095 real(DP),
intent(in),
optional :: timeofs
4096 logical,
intent(in),
optional :: fill_halo
4098 real(RP) :: varhalo( size(var(:,1,1,1)), size(var(1,:,1,1)), size(var(1,1,:,1)) )
4100 integer :: dim1_S, dim1_E, dim1_max
4101 integer :: dim2_S, dim2_E
4102 integer :: dim3_S, dim3_E
4104 real(DP) :: time_interval, nowtime
4107 integer :: i, j, k, n
4108 logical :: fill_halo_
4109 real(DP) :: timeofs_
4110 integer :: rankidx(2)
4118 fill_halo_ = .false.
4119 if(
present(fill_halo) ) fill_halo_ = fill_halo
4122 if(
present(timeofs) ) timeofs_ = timeofs
4132 time_interval = timeintv
4147 if ( dim_type ==
'ZXYT' &
4148 .OR. dim_type ==
'ZXHYT' &
4149 .OR. dim_type ==
'ZXYHT' )
then
4153 elseif ( dim_type ==
'ZHXYT' )
then
4157 elseif( dim_type ==
'OXYT' )
then
4161 elseif( dim_type ==
'OHXYT' )
then
4165 elseif( dim_type ==
'LXYT' )
then
4169 elseif( dim_type ==
'LHXYT' )
then
4173 elseif( dim_type ==
'UXYT' )
then
4177 elseif( dim_type ==
'UHXYT' )
then
4182 log_error(
"FILE_CARTESC_write_var_4D",*)
'unsupported dimension type. Check! dim_type:', trim(dim_type),
', item:',trim(varname)
4186 if (
present(timetarg) )
then
4187 nowtime = timeofs_ + (timetarg-1) * time_interval
4189 if ( fill_halo_ )
then
4193 varhalo(k,i,j) = var(k,i,j,timetarg)
4202 varhalo(k,i,j) = rmiss
4210 varhalo(k,i,j) = rmiss
4218 varhalo(k,i,j) = rmiss
4226 varhalo(k,i,j) = rmiss
4231 call file_write( vid, varhalo(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e), &
4232 nowtime, nowtime, start )
4234 call file_write( vid, var(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e,timetarg), &
4235 nowtime, nowtime, start )
4240 if ( fill_halo_ )
then
4244 varhalo(k,i,j) = var(k,i,j,n)
4253 varhalo(k,i,j) = rmiss
4261 varhalo(k,i,j) = rmiss
4269 varhalo(k,i,j) = rmiss
4277 varhalo(k,i,j) = rmiss
4282 call file_write( vid, varhalo(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e), &
4283 nowtime, nowtime, start )
4285 call file_write( vid, var(dim1_s:dim1_e,dim2_s:dim2_e,dim3_s:dim3_e,n), &
4286 nowtime, nowtime, start )
4289 nowtime = nowtime + time_interval
4315 end subroutine closeall
4318 subroutine check_1d( &
4327 real(RP),
intent(in) :: expected(:)
4328 real(RP),
intent(in) :: buffer(:)
4329 character(len=*),
intent(in) :: name
4337 nmax =
size(expected)
4338 if (
size(buffer) /= nmax )
then
4339 log_error(
"check_1d",*)
'size of coordinate ('//trim(name)//
') is different:', nmax,
size(buffer)
4344 if ( abs(expected(n)) > eps )
then
4345 check = abs(buffer(n)-expected(n)) / abs(buffer(n)+expected(n)) * 2.0_rp
4347 check = abs(buffer(n)-expected(n))
4350 if ( check > file_cartesc_datacheck_criteria )
then
4351 log_error(
"check_1d",*)
'value of coordinate ('//trim(name)//
') at ', n,
' is different:', &
4352 expected(n), buffer(n), check
4358 end subroutine check_1d
4361 subroutine check_2d( &
4370 real(RP),
intent(in) :: expected(:,:)
4371 real(RP),
intent(in) :: buffer(:,:)
4372 character(len=*),
intent(in) :: name
4375 integer :: imax, jmax
4381 imax =
size(expected,1)
4382 jmax =
size(expected,2)
4383 if (
size(buffer,1) /= imax )
then
4384 log_error(
"check_2d",*)
'the first size of coordinate ('//trim(name)//
') is different:', imax,
size(buffer,1)
4387 if (
size(buffer,2) /= jmax )
then
4388 log_error(
"check_2d",*)
'the second size of coordinate ('//trim(name)//
') is different:', jmax,
size(buffer,2)
4394 if ( abs(expected(i,j)) > eps )
then
4395 check = abs(buffer(i,j)-expected(i,j)) / abs(buffer(i,j)+expected(i,j)) * 2.0_rp
4397 check = abs(buffer(i,j)-expected(i,j))
4400 if ( check > file_cartesc_datacheck_criteria )
then
4401 log_error(
"check_2d",*)
'value of coordinate ('//trim(name)//
') at (', i,
',', j,
') is different:', &
4402 expected(i,j), buffer(i,j), check
4409 end subroutine check_2d
4412 subroutine check_3d( &
4422 real(RP),
intent(in) :: expected(:,:,:)
4423 real(RP),
intent(in) :: buffer(:,:,:)
4424 character(len=*),
intent(in) :: name
4425 logical,
intent(in) :: transpose
4428 integer :: imax, jmax, kmax
4434 if ( transpose )
then
4435 kmax =
size(expected,3)
4436 imax =
size(expected,1)
4437 jmax =
size(expected,2)
4439 kmax =
size(expected,1)
4440 imax =
size(expected,2)
4441 jmax =
size(expected,3)
4443 if (
size(buffer,1) /= kmax )
then
4444 log_error(
"check_3d",*)
'the first size of coordinate ('//trim(name)//
') is different:', kmax,
size(buffer,1)
4447 if (
size(buffer,2) /= imax )
then
4448 log_error(
"check_3d",*)
'the second size of coordinate ('//trim(name)//
') is different:', imax,
size(buffer,2)
4451 if (
size(buffer,3) /= jmax )
then
4452 log_error(
"check_3d",*)
'the third size of coordinate ('//trim(name)//
') is different:', jmax,
size(buffer,3)
4456 if ( transpose )
then
4461 if ( abs(expected(k,i,j)) > eps )
then
4462 check = abs(buffer(i,j,k)-expected(k,i,j)) / abs(buffer(i,j,k)+expected(k,i,j)) * 2.0_rp
4464 check = abs(buffer(i,j,k)-expected(k,i,j))
4467 if ( check > file_cartesc_datacheck_criteria )
then
4468 log_error(
"check_3d",*)
'value of coordinate ('//trim(name)//
') at ', i,
',', j,
',', k,
' is different:', &
4469 expected(k,i,j), buffer(i,j,k), check
4479 if ( abs(expected(k,i,j)) > eps )
then
4480 check = abs(buffer(k,i,j)-expected(k,i,j)) / abs(buffer(k,i,j)+expected(k,i,j)) * 2.0_rp
4482 check = abs(buffer(k,i,j)-expected(k,i,j))
4485 if ( check > file_cartesc_datacheck_criteria )
then
4486 log_error(
"check_3d",*)
'value of coordinate ('//trim(name)//
') at ', k,
',', i,
',', j,
' is different:', &
4487 expected(k,i,j), buffer(k,i,j), check
4496 end subroutine check_3d
4519 call set_dimension(
'XY', 2, (/
'x' ,
'y' /),
ia*
ja, .true., area=
'cell_area', location=
'face' )
4520 call set_dimension(
'UY', 2, (/
'xh',
'y ' /),
ia*
ja, .true., area=
'cell_area_uy', location=
'edge1' )
4521 call set_dimension(
'XV', 2, (/
'x ',
'yh' /),
ia*
ja, .true., area=
'cell_area_xv', location=
'edge2' )
4529 area=
'cell_area', area_x=
'cell_area_zxy_x', area_y=
'cell_area_zxy_y', &
4530 volume=
'cell_volume', location=
'face' )
4532 area=
'cell_area', area_x=
'cell_area_wxy_x', area_y=
'cell_area_wxy_y', &
4533 volume=
'cell_volume_wxy', location=
'face' )
4535 area=
'cell_area_uy', area_x=
'cell_area_zuy_x', &
4536 volume=
'cell_volume_zuy', location=
'edge1' )
4538 area=
'cell_area_xv', area_y=
'cell_area_zxv_y', &
4539 volume=
'cell_volume_zxv', location=
'edge2' )
4541 area_x=
'cell_area_zuv_x', area_y=
'cell_area_zuv_y', &
4544 area_x=
'cell_area_wuy_x', &
4547 area_y=
'cell_area_wxv_y', &
4550 if (
okmax > 0 )
then
4551 call set_dimension(
'OXY', 3, (/
'oz',
'x ',
'y ' /),
okmax*
ia*
ja, .true., area=
'cell_area', volume=
'cell_volume_oxy', location=
'face', grid=
'ocean' )
4552 call set_dimension(
'OHXY', 3, (/
'ozh',
'x ',
'y ' /), (
okmax+1)*
ia*
ja, .true., area=
'cell_area', volume=
'cell_volume_oxy', location=
'face', grid=
'ocean' )
4554 if (
lkmax > 0 )
then
4555 call set_dimension(
'LXY', 3, (/
'lz',
'x ',
'y ' /),
lkmax*
ia*
ja, .true., area=
'cell_area', volume=
'cell_volume_lxy', location=
'face', grid=
'land' )
4556 call set_dimension(
'LHXY', 3, (/
'lzh',
'x ',
'y ' /), (
lkmax+1)*
ia*
ja, .true., area=
'cell_area', volume=
'cell_volume_lxy', location=
'face', grid=
'land' )
4558 if (
ukmax > 0 )
then
4559 call set_dimension(
'UXY', 3, (/
'uz',
'x ',
'y ' /),
ukmax*
ia*
ja, .true., area=
'cell_area', volume=
'cell_volume_uxy', location=
'face', grid=
'urban' )
4560 call set_dimension(
'UHXY', 3, (/
'uzh',
'x ',
'y ' /), (
ukmax+1)*
ia*
ja, .true., area=
'cell_area', volume=
'cell_volume_uxy', location=
'face', grid=
'urban' )
4567 file_cartesc_axis_info(1)%periodic = .true.
4568 file_cartesc_axis_info(2)%periodic = .true.
4570 file_cartesc_axis_info(1)%periodic = .false.
4571 file_cartesc_axis_info(2)%periodic = .false.
4575 file_cartesc_axis_info(3)%periodic = .true.
4576 file_cartesc_axis_info(4)%periodic = .true.
4578 file_cartesc_axis_info(3)%periodic = .false.
4579 file_cartesc_axis_info(4)%periodic = .false.
4585 file_cartesc_axis_info(1)%size_global (1) =
imax *
prc_num_x
4586 file_cartesc_axis_info(1)%start_global(1) =
is_ing -
ihalo
4587 file_cartesc_axis_info(1)%halo_global (1) = 0
4588 file_cartesc_axis_info(1)%halo_global (2) = 0
4589 file_cartesc_axis_info(1)%halo_local (1) = 0
4590 file_cartesc_axis_info(1)%halo_local (2) = 0
4592 file_cartesc_axis_info(1)%size_global (1) =
iag
4593 file_cartesc_axis_info(1)%start_global(1) =
isga
4594 file_cartesc_axis_info(1)%halo_global (1) =
ihalo
4595 file_cartesc_axis_info(1)%halo_global (2) =
ihalo
4596 file_cartesc_axis_info(1)%halo_local (1) =
ihalo
4597 file_cartesc_axis_info(1)%halo_local (2) =
ihalo
4598 if(
prc_has_w ) file_cartesc_axis_info(1)%halo_local(1) = 0
4599 if(
prc_has_e ) file_cartesc_axis_info(1)%halo_local(2) = 0
4602 file_cartesc_axis_info(2) = file_cartesc_axis_info(1)
4606 file_cartesc_axis_info(3)%size_global (1) =
jmax *
prc_num_y
4607 file_cartesc_axis_info(3)%start_global(1) =
js_ing -
jhalo
4608 file_cartesc_axis_info(3)%halo_global (1) = 0
4609 file_cartesc_axis_info(3)%halo_global (2) = 0
4610 file_cartesc_axis_info(3)%halo_local (1) = 0
4611 file_cartesc_axis_info(3)%halo_local (2) = 0
4613 file_cartesc_axis_info(3)%size_global (1) =
jag
4614 file_cartesc_axis_info(3)%start_global(1) =
jsga
4615 file_cartesc_axis_info(3)%halo_global (1) =
jhalo
4616 file_cartesc_axis_info(3)%halo_global (2) =
jhalo
4617 file_cartesc_axis_info(3)%halo_local (1) =
jhalo
4618 file_cartesc_axis_info(3)%halo_local (2) =
jhalo
4619 if(
prc_has_s ) file_cartesc_axis_info(3)%halo_local(1) = 0
4620 if(
prc_has_n ) file_cartesc_axis_info(3)%halo_local(2) = 0
4623 file_cartesc_axis_info(4) = file_cartesc_axis_info(3)
4629 subroutine set_dimension( name, ndims, dims, size, mapping, area, area_x, area_y, volume, location, grid )
4632 character(len=*),
intent(in) :: name
4633 integer,
intent(in) :: ndims
4634 character(len=*),
intent(in) :: dims(ndims)
4635 integer,
intent(in) :: size
4636 logical,
intent(in),
optional :: mapping
4637 character(len=*),
intent(in),
optional :: area
4638 character(len=*),
intent(in),
optional :: area_x
4639 character(len=*),
intent(in),
optional :: area_y
4640 character(len=*),
intent(in),
optional :: volume
4641 character(len=*),
intent(in),
optional :: location
4642 character(len=*),
intent(in),
optional :: grid
4644 integer,
save :: dimid = 0
4650 if ( dimid > file_cartesc_ndims )
then
4651 log_error(
"set_dimension",*)
'number of dimensions exceeds the limit', dimid, file_cartesc_ndims
4656 file_cartesc_dims(dimid)%name = name
4658 file_cartesc_dims(dimid)%name = trim(name)//
"T"
4660 file_cartesc_dims(dimid)%ndims = ndims
4661 file_cartesc_dims(dimid)%dims(1:ndims) = dims(:)
4662 file_cartesc_dims(dimid)%size =
size
4664 if (
present(mapping) )
then
4665 file_cartesc_dims(dimid)%mapping = mapping
4667 file_cartesc_dims(dimid)%mapping = .false.
4670 if (
present(area) )
then
4671 file_cartesc_dims(dimid)%area = area
4673 file_cartesc_dims(dimid)%area =
''
4675 if (
present(area_x) )
then
4676 file_cartesc_dims(dimid)%area = area_x
4678 file_cartesc_dims(dimid)%area =
''
4680 if (
present(area_y) )
then
4681 file_cartesc_dims(dimid)%area = area_y
4683 file_cartesc_dims(dimid)%area =
''
4686 if (
present(volume) )
then
4687 file_cartesc_dims(dimid)%volume = volume
4689 file_cartesc_dims(dimid)%volume =
''
4692 if (
present(location) )
then
4693 file_cartesc_dims(dimid)%location = location
4694 if (
present(grid) )
then
4695 file_cartesc_dims(dimid)%grid =
'grid_'//trim(grid)
4697 file_cartesc_dims(dimid)%grid =
'grid'
4700 file_cartesc_dims(dimid)%location =
''
4701 file_cartesc_dims(dimid)%grid =
''
4718 integer :: err, order
4719 integer :: sizes(3), subsizes(3), sub_off(3)
4722 order = mpi_order_fortran
4724 centertypexy = mpi_datatype_null
4725 centertypezx = mpi_datatype_null
4726 centertypezxy = mpi_datatype_null
4727 centertypezhxy = mpi_datatype_null
4728 centertypeocean = mpi_datatype_null
4729 centertypeland = mpi_datatype_null
4730 centertypeurban = mpi_datatype_null
4734 if(
rp == 8 ) etype = mpi_double
4743 startzxy(2:3) = startxy(1:2)
4745 countzxy(2:3) = countxy(1:2)
4756 call mpi_type_create_subarray(3, sizes, subsizes, sub_off, order, etype, centertypezxy, err)
4757 call mpi_type_commit(centertypezxy, err)
4761 startzhxy(2:3) = startxy(1:2)
4762 countzhxy(1) =
kmax+1
4763 countzhxy(2:3) = countxy(1:2)
4768 subsizes(1) =
kmax+1
4774 call mpi_type_create_subarray(3, sizes, subsizes, sub_off, order, etype, centertypezhxy, err)
4775 call mpi_type_commit(centertypezhxy, err)
4777 if (
okmax > 0 )
then
4780 startocean(2:3) = startxy(1:2)
4781 countocean(1) =
okmax
4782 countocean(2:3) = countxy(1:2)
4786 sub_off(1) =
oks - 1
4787 call mpi_type_create_subarray(3, sizes, subsizes, sub_off, order, etype, centertypeocean, err)
4788 call mpi_type_commit(centertypeocean, err)
4791 if (
lkmax > 0 )
then
4794 startland(2:3) = startxy(1:2)
4795 countland(1) =
lkmax
4796 countland(2:3) = countxy(1:2)
4800 sub_off(1) =
lks - 1
4801 call mpi_type_create_subarray(3, sizes, subsizes, sub_off, order, etype, centertypeland, err)
4802 call mpi_type_commit(centertypeland, err)
4805 if (
ukmax > 0 )
then
4808 starturban(2:3) = startxy(1:2)
4809 counturban(1) =
ukmax
4810 counturban(2:3) = countxy(1:2)
4814 sub_off(1) =
uks - 1
4815 call mpi_type_create_subarray(3, sizes, subsizes, sub_off, order, etype, centertypeurban, err)
4816 call mpi_type_commit(centertypeurban, err)
4820 startzx(1) =
khalo+1
4830 sub_off(2) =
isb - 1
4831 call mpi_type_create_subarray(2, sizes, subsizes, sub_off, order, etype, centertypezx, err)
4832 call mpi_type_commit(centertypezx, err)
4846 if( centertypexy /= mpi_datatype_null )
call mpi_type_free(centertypexy, err)
4847 if( centertypezx /= mpi_datatype_null )
call mpi_type_free(centertypezx, err)
4848 if( centertypezxy /= mpi_datatype_null )
call mpi_type_free(centertypezxy, err)
4849 if( centertypezhxy /= mpi_datatype_null )
call mpi_type_free(centertypezhxy, err)
4850 if( centertypeocean /= mpi_datatype_null )
call mpi_type_free(centertypeocean, err)
4851 if( centertypeland /= mpi_datatype_null )
call mpi_type_free(centertypeland, err)
4852 if( centertypeurban /= mpi_datatype_null )
call mpi_type_free(centertypeurban, err)