184 max_len_string_array, max_len_notrim_string_array
195 use netcdf,
only: nf90_inquire, nf90_inquire_variable, &
196 nf90_inquire_dimension, nf90_def_dim, nf90_def_var, &
197 nf90_def_var_deflate, nf90_def_var_chunking, nf90_put_var, &
198 nf90_byte, nf90_short, nf90_int, nf90_float, nf90_double, &
199 nf90_char, nf90_max_name, nf90_chunked
202 #ifdef enable_action_msgs
203 nclayer_enable_action, nclayer_actionm, &
208 nclayer_error, nclayer_warning, nclayer_info, nclayer_check
221 integer(i_long),
intent(in) :: multiplier
238 integer(i_llong),
intent(in) :: var_index
240 integer :: i, max_len
242 character(len=1000) :: data_uneven_msg
251 (max_len /= -1))
then 254 write (data_uneven_msg,
"(A, I0, A, I0, A)")
"Amount of data written in " // &
258 " does not match the variable length" // &
264 call nclayer_error(trim(data_uneven_msg))
266 call nclayer_warning(trim(data_uneven_msg))
276 integer(i_long) :: ndims, nvars, var_index, type_index
277 integer(i_long) :: rel_index, i, nobs_size
279 character(len=NF90_MAX_NAME) :: tmp_var_name
280 integer(i_long) :: tmp_var_type, tmp_var_ndims
282 integer(i_long),
dimension(:),
allocatable :: tmp_var_dimids, tmp_var_dim_sizes
283 character(len=NF90_MAX_NAME) ,
allocatable :: tmp_var_dim_names(:)
285 logical :: is_data2d_var
288 call nclayer_check(nf90_inquire(
ncid, ndimensions = ndims, &
293 do var_index = 1, nvars
295 call nclayer_check(nf90_inquire_variable(
ncid, var_index, name = tmp_var_name, ndims = tmp_var_ndims))
298 allocate(tmp_var_dimids(tmp_var_ndims))
299 allocate(tmp_var_dim_names(tmp_var_ndims))
300 allocate(tmp_var_dim_sizes(tmp_var_ndims))
304 call nclayer_check(nf90_inquire_variable(
ncid, var_index, dimids = tmp_var_dimids, &
305 xtype = tmp_var_type))
307 if ((tmp_var_ndims == 2) .OR. &
308 ((tmp_var_ndims == 3) .AND. (tmp_var_type == nf90_char)))
then 309 is_data2d_var = .false.
311 do i = 1, tmp_var_ndims
312 call nclayer_check(nf90_inquire_dimension(
ncid, tmp_var_dimids(i), tmp_var_dim_names(i), &
313 tmp_var_dim_sizes(i)))
315 if (tmp_var_dim_names(i) ==
"nobs")
then 316 nobs_size = tmp_var_dim_sizes(i)
317 if (tmp_var_type /= nf90_char)
then 318 is_data2d_var = .true.
319 else if (tmp_var_type == nf90_char)
then 320 if (index(tmp_var_dim_names(1),
"_str_dim") /= 0) &
321 is_data2d_var = .true.
326 if (is_data2d_var)
then 337 rel_index = nobs_size
339 if (tmp_var_type == nf90_byte)
then 342 else if (tmp_var_type == nf90_short)
then 345 else if (tmp_var_type == nf90_int)
then 348 else if (tmp_var_type == nf90_float)
then 351 else if (tmp_var_type == nf90_double)
then 354 else if (tmp_var_type == nf90_char)
then 359 call nclayer_error(
"NetCDF4 type invalid!")
362 if (tmp_var_type == nf90_char)
then 368 print *, trim(tmp_var_name),
"rel index", rel_index
381 deallocate(tmp_var_dimids)
382 deallocate(tmp_var_dim_names)
383 deallocate(tmp_var_dim_sizes)
390 logical,
intent(in),
optional :: internal
392 integer(i_byte) :: data_type
393 character(len=100) :: data2d_name
395 integer(i_llong) :: curdatindex, j
396 integer(i_long) :: nc_data_type
397 integer(i_long) :: tmp_dim_id
398 character(len=120) :: data_dim_name
399 character(len=120) :: data_dim_str_name
400 integer(i_long) :: max_len
401 integer(i_long) :: max_str_len, msl_tmp
403 character(len=:),
allocatable :: string_arr(:)
405 #ifdef ENABLE_ACTION_MSGS 406 character(len=1000) :: action_str
408 if (nclayer_enable_action)
then 409 if (
present(internal))
then 410 write(action_str,
"(A, L, A)")
"nc_diag_data2d_write_def(internal = ", internal,
")" 412 write(action_str,
"(A)")
"nc_diag_data2d_write_def(internal = (not specified))" 414 call nclayer_actionm(trim(action_str))
428 call nclayer_info(
"data2d: defining " // trim(data2d_name))
430 if (data_type ==
nlayer_byte) nc_data_type = nf90_byte
431 if (data_type ==
nlayer_short) nc_data_type = nf90_short
432 if (data_type ==
nlayer_long) nc_data_type = nf90_int
433 if (data_type ==
nlayer_float) nc_data_type = nf90_float
438 print *,
"data2d part 1" 442 write (data_dim_name,
"(A, A)") trim(data2d_name),
"_arr_dim" 449 call nclayer_check(nf90_def_dim(
ncid, data_dim_name, max_len,
diag_data2d_store%var_dim_ids(curdatindex)))
456 write (data_dim_name,
"(A, A)") trim(data2d_name),
"_maxstrlen" 463 allocate(
character(10000) :: string_arr(diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j)))
465 diag_data2d_store%m_string(diag_data2d_store%stor_i_arr(curdatindex)%index_arr(j) &
466 : diag_data2d_store%stor_i_arr(curdatindex)%index_arr(j) + &
467 diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j))
470 write(*,
"(A, I0)")
"DEBUG DATA2D: tmp array size is: ", diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j)
474 msl_tmp = max_len_string_array(string_arr, &
475 diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j))
477 if (msl_tmp > max_str_len) max_str_len = msl_tmp
480 write (*,
"(A, A, A, I0, A, I0)")
"DEBUG DATA2D DEF WRITE: at data2d_name ", trim(data2d_name),
", msl_tmp computes to ", msl_tmp,
", max_str_len computes to ", max_str_len
481 print *,
"DEBUG DATA2D DEF WRITE: string array dump follows:" 482 call string_array_dump(string_arr)
486 deallocate(string_arr)
489 write (*,
"(A, A, A, I0, A, I0)")
"DEBUG DATA2D DEF WRITE: ** at data2d_name ", trim(data2d_name),
", FINAL max_str_len computes to ", max_str_len,
", max_len computes to ", max_len
493 diag_data2d_store%max_str_lens(curdatindex) = max_str_len
497 write (data_dim_str_name,
"(A, A)") trim(data2d_name),
"_str_dim" 499 call nclayer_check(nf90_def_dim(
ncid, data_dim_str_name, &
500 diag_data2d_store%max_str_lens(curdatindex), tmp_dim_id))
503 print *,
"Defining char var type..." 507 call nclayer_check(nf90_def_var(
ncid, data2d_name, nc_data_type, &
508 (/ tmp_dim_id, diag_data2d_store%var_dim_ids(curdatindex), &
510 diag_data2d_store%var_ids(curdatindex)))
513 write (*,
"(A, A, A, I0, A, I0)")
"DEBUG DATA2D DEF WRITE: ** at data2d_name ", trim(data2d_name),
", result VID is ", diag_data2d_store%var_ids(curdatindex)
514 write (*,
"(A, I0, A, I0)")
"DEBUG DATA2D DEF WRITE: ** result dim is unlim x max_len = ", max_len,
" x max_str_len = ", diag_data2d_store%max_str_lens(curdatindex)
515 print *,
"data2d part 2" 519 print *,
"Done defining char var type..." 523 print *,
"Definition for variable " // trim(data2d_name) //
":" 524 print *, diag_data2d_store%max_lens(curdatindex),
"x unlimited (NetCDF order)" 527 call nclayer_check(nf90_def_var(
ncid, data2d_name, nc_data_type, &
529 diag_data2d_store%var_ids(curdatindex)))
533 diag_data2d_store%types(curdatindex), &
534 diag_data2d_store%var_ids(curdatindex))
539 print *,
"Defining compression 1 (chunking)..." 544 call nclayer_check(nf90_def_var_chunking(
ncid, diag_data2d_store%var_ids(curdatindex), &
545 nf90_chunked, (/ diag_data2d_store%max_str_lens(curdatindex), &
548 call nclayer_check(nf90_def_var_chunking(
ncid, diag_data2d_store%var_ids(curdatindex), &
549 nf90_chunked, (/ diag_data2d_store%max_lens(curdatindex),
nlayer_chunking /)))
553 print *,
"Defining compression 2 (gzip)..." 556 call nclayer_check(nf90_def_var_deflate(
ncid, diag_data2d_store%var_ids(curdatindex), &
560 print *,
"Done defining compression..." 564 diag_data2d_store%def_lock = .true.
567 if(.NOT.
present(internal)) &
568 call nclayer_error(
"Can't write definitions - definitions have already been written and locked!")
577 logical,
intent(in),
optional :: flush_data_only
579 integer(i_byte) :: data_type
580 character(len=100) :: data2d_name
586 integer(i_long) :: curdatindex = 1, j
592 integer(i_byte),
dimension(:, :),
allocatable :: byte_arr
593 integer(i_short),
dimension(:, :),
allocatable :: short_arr
594 integer(i_long),
dimension(:, :),
allocatable :: long_arr
595 real(r_single),
dimension(:, :),
allocatable :: rsingle_arr
596 real(r_double),
dimension(:, :),
allocatable :: rdouble_arr
597 character(len=:),
dimension(:, :),
allocatable :: string_arr
599 integer(i_long) :: max_str_len
601 integer(i_llong) :: data_length_counter
602 character(len=100) :: counter_data_name
603 integer(i_llong) :: current_length_count
604 character(len=1000) :: data_uneven_msg
606 #ifdef ENABLE_ACTION_MSGS 607 character(len=1000) :: action_str
609 if (nclayer_enable_action)
then 610 if (
present(flush_data_only))
then 611 write(action_str,
"(A, L, A)")
"nc_diag_data2d_write_data(flush_data_only = ", flush_data_only,
")" 613 write(action_str,
"(A)")
"nc_diag_data2d_write_data(flush_data_only = (not specified))" 615 call nclayer_actionm(trim(action_str))
626 data_length_counter = -1
627 current_length_count = -1
638 call nclayer_info(
"data2d: writing " // trim(data2d_name))
641 if (.NOT. (
present(flush_data_only) .AND. flush_data_only))
then 645 if (data_length_counter == -1)
then 646 data_length_counter = current_length_count
647 counter_data_name = data2d_name
649 if (data_length_counter /= current_length_count)
then 652 write (data_uneven_msg,
"(A, I0, A, I0, A)")
"Amount of data written in " // &
653 trim(data2d_name) //
" (", &
654 current_length_count, &
656 " differs from variable " // trim(counter_data_name) // &
657 " (", data_length_counter,
")!" 660 call nclayer_error(trim(data_uneven_msg))
662 call nclayer_warning(trim(data_uneven_msg))
693 write (data_uneven_msg,
"(A, I0, A, I0, A)")
"Amount of data written in " // &
694 trim(data2d_name) //
" (", &
697 " does not match the variable length" // &
701 call nclayer_error(trim(data_uneven_msg))
703 call nclayer_warning(trim(data_uneven_msg))
714 call nclayer_check(nf90_put_var(&
735 write (data_uneven_msg,
"(A, I0, A, I0, A)")
"Amount of data written in " // &
736 trim(data2d_name) //
" (", &
739 " does not match the variable length" // &
743 call nclayer_error(trim(data_uneven_msg))
745 call nclayer_warning(trim(data_uneven_msg))
756 call nclayer_check(nf90_put_var(&
764 deallocate(short_arr)
779 write (*,
"(A)")
"************ DEBUG: INITIAL var array for " // trim(data2d_name)
781 print *, long_arr(:, j)
791 write (data_uneven_msg,
"(A, I0, A, I0, A)")
"Amount of data written in " // &
792 trim(data2d_name) //
" (", &
795 " does not match the variable length" // &
799 call nclayer_error(trim(data_uneven_msg))
801 call nclayer_warning(trim(data_uneven_msg))
806 write (*,
"(A, I0, A)")
"Adding to long_arr, index ", j,
":" 811 write (*,
"(A, I0)")
" -> length of subarr: ",
diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j)
821 write (*,
"(A)")
"************ DEBUG: INTERMEDIATE var array for " // trim(data2d_name)
823 print *, long_arr(:, i)
829 write (*,
"(A, I0, A, I0, A, I0, A, I0, A)") &
830 "Writing long with start = (", 1,
", ", &
835 write (*,
"(A, I0, A, I0)")
"************ DEBUG: dim for " // trim(data2d_name) //
": ", &
838 write (*,
"(A)")
"************ DEBUG: var array for " // trim(data2d_name)
841 print *, long_arr(:, j)
845 call nclayer_check(nf90_put_var(&
866 write (data_uneven_msg,
"(A, I0, A, I0, A)")
"Amount of data written in " // &
867 trim(data2d_name) //
" (", &
870 " does not match the variable length" // &
874 call nclayer_error(trim(data_uneven_msg))
876 call nclayer_warning(trim(data_uneven_msg))
888 call nclayer_check(nf90_put_var(&
896 deallocate(rsingle_arr)
911 write (data_uneven_msg,
"(A, I0, A, I0, A)")
"Amount of data written in " // &
912 trim(data2d_name) //
" (", &
915 " does not match the variable length" // &
919 call nclayer_error(trim(data_uneven_msg))
921 call nclayer_warning(trim(data_uneven_msg))
932 call nclayer_check(nf90_put_var(&
939 deallocate(rdouble_arr)
947 call nclayer_error(
"BUG: diag_data2d_store%max_str_lens not allocated yet!")
950 allocate(
character(max_str_len) :: &
951 string_arr(diag_data2d_store%max_lens(curdatindex), &
952 diag_data2d_store%stor_i_arr(curdatindex)%icount &
957 do j = 1, diag_data2d_store%stor_i_arr(curdatindex)%icount
959 if (diag_data2d_store%max_lens(curdatindex) /= &
960 diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j))
then 963 write (data_uneven_msg,
"(A, I0, A, I0, A)")
"Amount of data written in " // &
964 trim(data2d_name) //
" (", &
965 diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j), &
967 " does not match the variable length" // &
968 " (", diag_data2d_store%max_lens(curdatindex),
")!" 970 if (diag_data2d_store%strict_check)
then 971 call nclayer_error(trim(data_uneven_msg))
973 call nclayer_warning(trim(data_uneven_msg))
977 string_arr(1 : diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j), j) = &
978 diag_data2d_store%m_string( &
979 diag_data2d_store%stor_i_arr(curdatindex)%index_arr(j) : &
980 diag_data2d_store%stor_i_arr(curdatindex)%index_arr(j) + &
981 diag_data2d_store%stor_i_arr(curdatindex)%length_arr(j) - 1)
984 if (
allocated(diag_data2d_store%max_str_lens))
then 985 call nclayer_check(nf90_put_var(&
986 ncid, diag_data2d_store%var_ids(curdatindex), &
988 (/ 1, 1, 1 + diag_data2d_store%rel_indexes(curdatindex) /), &
989 (/ diag_data2d_store%max_str_lens(curdatindex), &
990 diag_data2d_store%max_lens(curdatindex), &
991 diag_data2d_store%stor_i_arr(curdatindex)%icount /) &
994 call nclayer_error(
"BUG: diag_data2d_store%max_str_lens not allocated yet!")
997 deallocate(string_arr)
1002 if (
present(flush_data_only) .AND. flush_data_only)
then 1003 diag_data2d_store%rel_indexes(curdatindex) = &
1004 diag_data2d_store%rel_indexes(curdatindex) + &
1005 diag_data2d_store%stor_i_arr(curdatindex)%icount
1006 diag_data2d_store%stor_i_arr(curdatindex)%icount = 0
1009 print *,
"diag_data2d_store%rel_indexes(curdatindex) is now:" 1010 print *, diag_data2d_store%rel_indexes(curdatindex)
1017 if (
present(flush_data_only) .AND. flush_data_only)
then 1019 print *,
"In buffer flush mode!" 1023 diag_data2d_store%acount = 0
1026 diag_data2d_store%data_lock = .true.
1028 print *,
"In data lock mode!" 1032 call nclayer_error(
"Can't write data - data have already been written and locked!")
1035 call nclayer_error(
"Can't write data - NetCDF4 layer not initialized yet!")
1039 print *,
"All done writing data2d data" 1045 logical,
intent(in) :: enable_strict
1050 call nclayer_error(
"Can't set strictness level for data2d - NetCDF4 layer not initialized yet!")
1056 integer(i_llong),
intent(in) :: num_of_addl_vars
1057 #ifdef ENABLE_ACTION_MSGS 1058 character(len=1000) :: action_str
1060 if (nclayer_enable_action)
then 1061 write(action_str,
"(A, I0, A)")
"nc_diag_data2d_prealloc_vars(num_of_addl_vars = ", num_of_addl_vars,
")" 1062 call nclayer_actionm(trim(action_str))
1146 call nclayer_error(
"NetCDF4 layer not initialized yet!")
1152 integer(i_byte),
intent(in) :: nclayer_type
1153 integer(i_llong),
intent(in) :: num_of_addl_slots
1155 #ifdef ENABLE_ACTION_MSGS 1156 character(len=1000) :: action_str
1158 if (nclayer_enable_action)
then 1159 write(action_str,
"(A, I0, A, I0, A)")
"nc_diag_data2d_prealloc_vars_storage(nclayer_type = ", nclayer_type,
", num_of_addl_slots = ", num_of_addl_slots,
")" 1160 call nclayer_actionm(trim(action_str))
1177 call nclayer_error(
"Invalid type specified for variable storage preallocation!")
1183 integer(i_llong),
intent(in) :: num_of_addl_slots
1184 integer(i_long) :: i
1186 #ifdef ENABLE_ACTION_MSGS 1187 character(len=1000) :: action_str
1189 if (nclayer_enable_action)
then 1190 write(action_str,
"(A, I0, A)")
"nc_diag_data2d_prealloc_vars_storage_all(num_of_addl_slots = ", num_of_addl_slots,
")" 1191 call nclayer_actionm(trim(action_str))
1201 integer(i_llong) :: addl_fields
1204 logical :: meta_realloc
1206 meta_realloc = .false.
1212 call nclayer_debug(
"INITIAL value of diag_data2d_store%alloc_s_multi:")
1219 call nclayer_debug(
"Reallocating diag_data2d_store%names...")
1221 print *, addl_fields
1225 call nclayer_debug(
"Reallocated diag_data2d_store%names. Size:")
1228 meta_realloc = .true.
1232 call nclayer_debug(
"Allocating diag_data2d_store%names for first time...")
1239 call nclayer_debug(
"Allocated diag_data2d_store%names. Size:")
1247 call nclayer_debug(
"Reallocating diag_data2d_store%types...")
1249 print *, addl_fields
1252 meta_realloc = .true.
1261 call nclayer_debug(
"Reallocating diag_data2d_store%stor_i_arr...")
1267 meta_realloc = .true.
1276 meta_realloc = .true.
1286 meta_realloc = .true.
1296 meta_realloc = .true.
1306 meta_realloc = .true.
1316 meta_realloc = .true.
1326 meta_realloc = .true.
1333 if (meta_realloc)
then 1336 print *,
"Incrementing alloc_s_multi... new value:" 1341 call nclayer_error(
"NetCDF4 layer not initialized yet!")
1347 character(len=*),
intent(in) :: data2d_name
1365 character(len=*),
intent(in) :: data2d_name
1366 integer(i_byte),
dimension(:),
intent(in) :: data2d_value
1368 integer(i_long) :: var_index
1369 integer(i_llong) :: input_size
1371 #ifdef ENABLE_ACTION_MSGS 1372 character(len=1000) :: action_str
1373 integer(i_llong) :: data_value_size
1375 if (nclayer_enable_action)
then 1376 data_value_size =
size(data2d_value)
1377 write(action_str,
"(A, I0, A, I0, A, I0, A, I0, A)") &
1378 "nc_diag_data2d_byte(data2d_name = " // data2d_name // &
1379 ", data2d_value = array with length of ", &
1384 data2d_value(data_value_size), &
1386 call nclayer_actionm(trim(action_str))
1391 call nclayer_error(
"Can't add new data - data have already been written and locked!")
1396 if (var_index == -1)
then 1399 call nclayer_error(
"Can't add new variable - definitions have already been written and locked!")
1413 input_size =
size(data2d_value)
1417 call nclayer_error(
"Cannot expand variable size after locking variable definitions!")
1436 character(len=*),
intent(in) :: data2d_name
1437 integer(i_short),
dimension(:),
intent(in) :: data2d_value
1439 integer(i_long) :: var_index
1440 integer(i_llong) :: input_size
1442 #ifdef ENABLE_ACTION_MSGS 1443 character(len=1000) :: action_str
1444 integer(i_llong) :: data_value_size
1446 if (nclayer_enable_action)
then 1447 data_value_size =
size(data2d_value)
1448 write(action_str,
"(A, I0, A, I0, A, I0, A, I0, A)") &
1449 "nc_diag_data2d_short(data2d_name = " // data2d_name // &
1450 ", data2d_value = array with length of ", &
1455 data2d_value(data_value_size), &
1457 call nclayer_actionm(trim(action_str))
1462 call nclayer_error(
"Can't add new data - data have already been written and locked!")
1467 if (var_index == -1)
then 1470 call nclayer_error(
"Can't add new variable - definitions have already been written and locked!")
1484 input_size =
size(data2d_value)
1488 call nclayer_error(
"Cannot expand variable size after locking variable definitions!")
1507 character(len=*),
intent(in) :: data2d_name
1508 integer(i_long),
dimension(:),
intent(in) :: data2d_value
1510 integer(i_long) :: var_index
1511 integer(i_llong) :: input_size
1513 #ifdef ENABLE_ACTION_MSGS 1514 character(len=1000) :: action_str
1515 integer(i_llong) :: data_value_size
1517 if (nclayer_enable_action)
then 1518 data_value_size =
size(data2d_value)
1519 write(action_str,
"(A, I0, A, I0, A, I0, A, I0, A)") &
1520 "nc_diag_data2d_long(data2d_name = " // data2d_name // &
1521 ", data2d_value = array with length of ", &
1526 data2d_value(data_value_size), &
1528 call nclayer_actionm(trim(action_str))
1533 call nclayer_error(
"Can't add new data - data have already been written and locked!")
1538 if (var_index == -1)
then 1541 call nclayer_error(
"Can't add new variable - definitions have already been written and locked!")
1555 call nclayer_debug(
"Current total:")
1560 input_size =
size(data2d_value)
1564 call nclayer_error(
"Cannot expand variable size after locking variable definitions!")
1583 character(len=*),
intent(in) :: data2d_name
1584 real(r_single),
dimension(:),
intent(in) :: data2d_value
1586 integer(i_long) :: var_index
1587 integer(i_llong) :: input_size
1589 #ifdef ENABLE_ACTION_MSGS 1590 character(len=1000) :: action_str
1591 integer(i_llong) :: data_value_size
1593 if (nclayer_enable_action)
then 1594 data_value_size =
size(data2d_value)
1595 write(action_str,
"(A, I0, A, F0.5, A, F0.5, A)") &
1596 "nc_diag_data2d_rsingle(data2d_name = " // data2d_name // &
1597 ", data2d_value = array with length of ", &
1602 data2d_value(data_value_size), &
1604 call nclayer_actionm(trim(action_str))
1609 call nclayer_error(
"Can't add new data - data have already been written and locked!")
1614 if (var_index == -1)
then 1617 call nclayer_error(
"Can't add new variable - definitions have already been written and locked!")
1620 write (*,
"(A, A, A, F)")
"NEW data2d: ", data2d_name,
" | First value: ", data2d_value
1633 input_size =
size(data2d_value)
1637 call nclayer_error(
"Cannot expand variable size after locking variable definitions!")
1656 character(len=*),
intent(in) :: data2d_name
1657 real(r_double),
dimension(:),
intent(in) :: data2d_value
1659 integer(i_long) :: var_index
1660 integer(i_llong) :: input_size
1662 #ifdef ENABLE_ACTION_MSGS 1663 character(len=1000) :: action_str
1664 integer(i_llong) :: data_value_size
1666 if (nclayer_enable_action)
then 1667 data_value_size =
size(data2d_value)
1668 write(action_str,
"(A, I0, A, F0.5, A, F0.5, A)") &
1669 "nc_diag_data2d_rdouble(data2d_name = " // data2d_name // &
1670 ", data2d_value = array with length of ", &
1675 data2d_value(data_value_size), &
1677 call nclayer_actionm(trim(action_str))
1682 call nclayer_error(
"Can't add new data - data have already been written and locked!")
1687 if (var_index == -1)
then 1690 call nclayer_error(
"Can't add new variable - definitions have already been written and locked!")
1704 input_size =
size(data2d_value)
1708 call nclayer_error(
"Cannot expand variable size after locking variable definitions!")
1727 character(len=*),
intent(in) :: data2d_name
1728 character(len=*),
dimension(:),
intent(in) :: data2d_value
1730 integer(i_long) :: var_index
1731 integer(i_long) :: max_str_len
1732 integer(i_llong) :: input_size
1734 #ifdef ENABLE_ACTION_MSGS 1735 character(len=1000) :: action_str
1736 integer(i_llong) :: data_value_size
1738 if (nclayer_enable_action)
then 1739 data_value_size =
size(data2d_value)
1740 write(action_str,
"(A, I0, A, A)") &
1741 "nc_diag_data2d_string(data2d_name = " // data2d_name // &
1742 ", data2d_value = array with length of ", &
1745 trim(data2d_value(1)) // &
1747 trim(data2d_value(data_value_size)) // &
1749 call nclayer_actionm(trim(action_str))
1754 call nclayer_error(
"Can't add new data - data have already been written and locked!")
1759 if (var_index == -1)
then 1762 call nclayer_error(
"Can't add new variable - definitions have already been written and locked!")
1776 print *,
"len_trim(data2d_value) = ", len_trim(data2d_value)
1777 print *,
"diag_data2d_store%max_str_lens(var_index) = ",
diag_data2d_store%max_str_lens(var_index)
1782 input_size =
size(data2d_value)
1786 call nclayer_error(
"Cannot expand variable size after locking variable definitions!")
1789 max_str_len = max_len_string_array(data2d_value, &
1793 print *,
"max_str_len: ", max_str_len
1794 print *,
"diag_data2d_store%max_str_lens(var_index): ",
diag_data2d_store%max_str_lens(var_index)
1798 call nclayer_error(
"Cannot expand variable string length after locking variable definitions!")
1812 if (max_len_notrim_string_array(data2d_value, int(input_size)) /= &
1814 call nclayer_error(
"Cannot change string size when trimming is disabled!")
type(diag_data2d), allocatable diag_data2d_store
subroutine nc_diag_data2d_load_def
subroutine nc_diag_data2d_allocmulti(multiplier)
integer(i_long), parameter nlayer_multi_base
integer, parameter, public i_byte
integer(i_byte), parameter nlayer_short
integer(i_long), parameter nlayer_fill_long
integer, parameter, public i_long
integer(i_byte), parameter nlayer_fill_byte
subroutine nc_diag_data2d_rsingle(data2d_name, data2d_value)
subroutine nc_diag_data2d_resize_iarr_type(addl_num_entries)
integer(i_byte), parameter nlayer_double
subroutine nc_diag_data2d_resize_rdouble(addl_num_entries, update_acount_in)
subroutine nc_diag_data2d_resize_rsingle(addl_num_entries, update_acount_in)
type(diag_varattr), allocatable diag_varattr_store
integer(i_byte), parameter nlayer_string
subroutine nc_diag_data2d_write_data(flush_data_only)
subroutine nc_diag_data2d_long(data2d_name, data2d_value)
subroutine nc_diag_data2d_resize_byte(addl_num_entries, update_acount_in)
integer function nc_diag_data2d_lookup_var(data2d_name)
subroutine nc_diag_data2d_prealloc_vars(num_of_addl_vars)
subroutine nc_diag_data2d_resize_long(addl_num_entries, update_acount_in)
subroutine nc_diag_data2d_prealloc_vars_storage_all(num_of_addl_slots)
integer(i_long), parameter nlayer_compression
integer(i_short), parameter nlayer_fill_short
integer function nc_diag_data2d_max_len_var(var_index)
subroutine nc_diag_data2d_resize_iarr(iarr_index, addl_num_entries, update_icount_in)
subroutine nc_diag_data2d_resize_short(addl_num_entries, update_acount_in)
subroutine nc_diag_data2d_write_def(internal)
subroutine nc_diag_data2d_expand
subroutine nc_diag_data2d_prealloc_vars_storage(nclayer_type, num_of_addl_slots)
integer, parameter, public i_short
subroutine nc_diag_data2d_rdouble(data2d_name, data2d_value)
integer(i_byte), parameter nlayer_byte
character, parameter nlayer_fill_char
subroutine nc_diag_varattr_add_var(var_name, var_type, var_id)
integer(i_short), parameter nlayer_default_ent
subroutine nc_diag_data2d_short(data2d_name, data2d_value)
subroutine nc_diag_data2d_set_strict(enable_strict)
subroutine nc_diag_data2d_string(data2d_name, data2d_value)
subroutine nc_diag_data2d_resize_string(addl_num_entries, update_acount_in)
real(r_single), parameter nlayer_fill_float
integer, parameter, public r_double
integer(i_long), parameter nlayer_chunking
integer, parameter, public r_single
subroutine nc_diag_data2d_byte(data2d_name, data2d_value)
integer, parameter, public i_llong
integer(i_byte), parameter nlayer_float
integer(i_byte), parameter nlayer_long
real(r_double), parameter nlayer_fill_double
subroutine nc_diag_varattr_make_nobs_dim