1 #include "nfconfig.inc"
34 Function nf_put_vars_text(ncid, varid, start, counts, strides, text) &
39 USE netcdf_nc_interfaces
43 Integer,
Intent(IN) :: ncid, varid
44 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
45 Character(LEN=*),
Intent(IN) :: text
49 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
50 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
51 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
52 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
63 cstartptr = c_null_ptr
64 ccountsptr = c_null_ptr
65 cstridesptr = c_null_ptr
68 If (cstat1 == nc_noerr)
Then
70 cstart(1:ndims) = start(ndims:1:-1)-1
71 ccounts(1:ndims) = counts(ndims:1:-1)
72 cstrides(1:ndims) = strides(ndims:1:-1)
74 cstartptr = c_loc(cstart)
75 ccountsptr = c_loc(ccounts)
76 cstridesptr = c_loc(cstrides)
84 End Function nf_put_vars_text
86 Function nf_put_vars_text_a(ncid, varid, start, counts, strides, text) &
92 USE netcdf_nc_interfaces
96 Integer,
Intent(IN) :: ncid, varid
97 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
98 Character(LEN=1),
Intent(IN) :: text(*)
102 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
103 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
104 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
105 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
116 cstartptr = c_null_ptr
117 ccountsptr = c_null_ptr
118 cstridesptr = c_null_ptr
121 If (cstat1 == nc_noerr)
Then
123 cstart(1:ndims) = start(ndims:1:-1)-1
124 ccounts(1:ndims) = counts(ndims:1:-1)
125 cstrides(1:ndims) = strides(ndims:1:-1)
127 cstartptr = c_loc(cstart)
128 ccountsptr = c_loc(ccounts)
129 cstridesptr = c_loc(cstrides)
136 End Function nf_put_vars_text_a
138 Function nf_put_vars_int1(ncid, varid, start, counts, strides, i1vals) &
143 USE netcdf_nc_interfaces
147 Integer,
Intent(IN) :: ncid, varid
148 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
149 Integer(KIND=NFINT1),
Intent(IN) :: i1vals(*)
153 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
154 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
155 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
156 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
159 If (c_signed_char < 0)
Then
172 cstartptr = c_null_ptr
173 ccountsptr = c_null_ptr
174 cstridesptr = c_null_ptr
177 If (cstat1 == nc_noerr)
Then
179 cstart(1:ndims) = start(ndims:1:-1)-1
180 ccounts(1:ndims) = counts(ndims:1:-1)
181 cstrides(1:ndims) = strides(ndims:1:-1)
183 cstartptr = c_loc(cstart)
184 ccountsptr = c_loc(ccounts)
185 cstridesptr = c_loc(cstrides)
188 #if NF_INT1_IS_C_SIGNED_CHAR
191 #elif NF_INT1_IS_C_SHORT
194 #elif NF_INT1_IS_C_INT
197 #elif NF_INT1_IS_C_LONG
204 End Function nf_put_vars_int1
206 Function nf_put_vars_int2(ncid, varid, start, counts, strides, i2vals) &
211 USE netcdf_nc_interfaces
215 Integer,
Intent(IN) :: ncid, varid
216 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
217 Integer(KIND=NFINT2),
Intent(IN) :: i2vals(*)
221 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
222 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
223 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
224 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
227 If (c_short < 0)
Then
240 cstartptr = c_null_ptr
241 ccountsptr = c_null_ptr
242 cstridesptr = c_null_ptr
245 If (cstat1 == nc_noerr)
Then
247 cstart(1:ndims) = start(ndims:1:-1)-1
248 ccounts(1:ndims) = counts(ndims:1:-1)
249 cstrides(1:ndims) = strides(ndims:1:-1)
251 cstartptr = c_loc(cstart)
252 ccountsptr = c_loc(ccounts)
253 cstridesptr = c_loc(cstrides)
256 #if NF_INT2_IS_C_SHORT
259 #elif NF_INT2_IS_C_INT
262 #elif NF_INT2_IS_C_LONG
269 End Function nf_put_vars_int2
271 Function nf_put_vars_int(ncid, varid, start, counts, strides, ivals) &
276 USE netcdf_nc_interfaces
280 Integer,
Intent(IN) :: ncid, varid
281 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
282 Integer(NFINT),
Intent(IN) :: ivals(*)
286 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
287 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
288 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
289 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
300 cstartptr = c_null_ptr
301 ccountsptr = c_null_ptr
302 cstridesptr = c_null_ptr
305 If (cstat1 == nc_noerr)
Then
307 cstart(1:ndims) = start(ndims:1:-1)-1
308 ccounts(1:ndims) = counts(ndims:1:-1)
309 cstrides(1:ndims) = strides(ndims:1:-1)
311 cstartptr = c_loc(cstart)
312 ccountsptr = c_loc(ccounts)
313 cstridesptr = c_loc(cstrides)
319 #elif NF_INT_IS_C_LONG
326 End Function nf_put_vars_int
328 Function nf_put_vars_real(ncid, varid, start, counts, strides, rvals) &
333 USE netcdf_nc_interfaces
337 Integer,
Intent(IN) :: ncid, varid
338 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
339 Real(NFREAL),
Intent(IN) :: rvals(*)
343 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
344 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
345 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
346 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
357 cstartptr = c_null_ptr
358 ccountsptr = c_null_ptr
359 cstridesptr = c_null_ptr
362 If (cstat1 == nc_noerr)
Then
364 cstart(1:ndims) = start(ndims:1:-1)-1
365 ccounts(1:ndims) = counts(ndims:1:-1)
366 cstrides(1:ndims) = strides(ndims:1:-1)
368 cstartptr = c_loc(cstart)
369 ccountsptr = c_loc(ccounts)
370 cstridesptr = c_loc(cstrides)
373 #if NF_REAL_IS_C_DOUBLE
383 End Function nf_put_vars_real
385 Function nf_put_vars_double(ncid, varid, start, counts, strides, dvals) &
390 USE netcdf_nc_interfaces
394 Integer,
Intent(IN) :: ncid, varid
395 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
396 Real(RK8),
Intent(IN) :: dvals(*)
400 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
401 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
402 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
403 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
414 cstartptr = c_null_ptr
415 ccountsptr = c_null_ptr
416 cstridesptr = c_null_ptr
419 If (cstat1 == nc_noerr)
Then
421 cstart(1:ndims) = start(ndims:1:-1)-1
422 ccounts(1:ndims) = counts(ndims:1:-1)
423 cstrides(1:ndims) = strides(ndims:1:-1)
425 cstartptr = c_loc(cstart)
426 ccountsptr = c_loc(ccounts)
427 cstridesptr = c_loc(cstrides)
435 End Function nf_put_vars_double
437 Function nf_put_vars(ncid, varid, start, counts, strides, values) &
444 USE netcdf_nc_interfaces
448 Integer,
Intent(IN) :: ncid, varid
449 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
450 Character(KIND=C_CHAR),
Intent(IN),
TARGET :: values(*)
454 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
455 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
456 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
457 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr, &
470 cstartptr = c_null_ptr
471 ccountsptr = c_null_ptr
472 cstridesptr = c_null_ptr
475 If (cstat1 == nc_noerr)
Then
477 cstart(1:ndims) = start(ndims:1:-1)-1
478 ccounts(1:ndims) = counts(ndims:1:-1)
479 cstrides(1:ndims) = strides(ndims:1:-1)
481 cstartptr = c_loc(cstart)
482 ccountsptr = c_loc(ccounts)
483 cstridesptr = c_loc(cstrides)
486 cvaluesptr = c_loc(values)
488 cstatus =
nc_put_vars(cncid, cvarid, cstartptr, ccountsptr, &
489 cstridesptr, cvaluesptr)
495 End Function nf_put_vars
497 Function nf_get_vars_text(ncid, varid, start, counts, strides, text) &
502 USE netcdf_nc_interfaces
506 Integer,
Intent(IN) :: ncid, varid
507 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
508 Character(LEN=*),
Intent(OUT) :: text
512 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
513 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
514 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
515 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
523 text = repeat(
" ", len(text))
527 cstartptr = c_null_ptr
528 ccountsptr = c_null_ptr
529 cstridesptr = c_null_ptr
532 If (cstat1 == nc_noerr)
Then
534 cstart(1:ndims) = start(ndims:1:-1)-1
535 ccounts(1:ndims) = counts(ndims:1:-1)
536 cstrides(1:ndims) = strides(ndims:1:-1)
538 cstartptr = c_loc(cstart)
539 ccountsptr = c_loc(ccounts)
540 cstridesptr = c_loc(cstrides)
548 End Function nf_get_vars_text
550 Function nf_get_vars_text_a(ncid, varid, start, counts, strides, text) &
555 USE netcdf_nc_interfaces
559 Integer,
Intent(IN) :: ncid, varid
560 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
561 Character(LEN=1),
Intent(OUT) :: text(*)
565 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
566 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
567 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
568 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
579 cstartptr = c_null_ptr
580 ccountsptr = c_null_ptr
581 cstridesptr = c_null_ptr
584 If (cstat1 == nc_noerr)
Then
586 cstart(1:ndims) = start(ndims:1:-1)-1
587 ccounts(1:ndims) = counts(ndims:1:-1)
588 cstrides(1:ndims) = strides(ndims:1:-1)
591 cstartptr = c_loc(cstart)
592 ccountsptr = c_loc(ccounts)
593 cstridesptr = c_loc(cstrides)
601 End Function nf_get_vars_text_a
603 Function nf_get_vars_int1(ncid, varid, start, counts, strides, i1vals) &
608 USE netcdf_nc_interfaces
612 Integer,
Intent(IN) :: ncid, varid
613 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
614 Integer(KIND=NFINT1),
Intent(OUT) :: i1vals(*)
618 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
619 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
620 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
621 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
624 If (c_signed_char < 0)
Then
637 cstartptr = c_null_ptr
638 ccountsptr = c_null_ptr
639 cstridesptr = c_null_ptr
642 If (cstat1 == nc_noerr)
Then
644 cstart(1:ndims) = start(ndims:1:-1)-1
645 ccounts(1:ndims) = counts(ndims:1:-1)
646 cstrides(1:ndims) = strides(ndims:1:-1)
648 cstartptr = c_loc(cstart)
649 ccountsptr = c_loc(ccounts)
650 cstridesptr = c_loc(cstrides)
653 #if NF_INT1_IS_C_SIGNED_CHAR
656 #elif NF_INT1_IS_C_SHORT
659 #elif NF_INT1_IS_C_INT
662 #elif NF_INT1_IS_C_LONG
669 End Function nf_get_vars_int1
671 Function nf_get_vars_int2(ncid, varid, start, counts, strides, i2vals) &
676 USE netcdf_nc_interfaces
680 Integer,
Intent(IN) :: ncid, varid
681 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
682 Integer(KIND=NFINT2),
Intent(OUT) :: i2vals(*)
686 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
687 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
688 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
689 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
692 If (c_short < 0)
Then
705 cstartptr = c_null_ptr
706 ccountsptr = c_null_ptr
707 cstridesptr = c_null_ptr
710 If (cstat1 == nc_noerr)
Then
712 cstart(1:ndims) = start(ndims:1:-1)-1
713 ccounts(1:ndims) = counts(ndims:1:-1)
714 cstrides(1:ndims) = strides(ndims:1:-1)
716 cstartptr = c_loc(cstart)
717 ccountsptr = c_loc(ccounts)
718 cstridesptr = c_loc(cstrides)
721 #if NF_INT2_IS_C_SHORT
724 #elif NF_INT2_IS_C_INT
727 #elif NF_INT2_IS_C_LONG
734 End Function nf_get_vars_int2
736 Function nf_get_vars_int(ncid, varid, start, counts, strides, ivals) &
741 USE netcdf_nc_interfaces
745 Integer,
Intent(IN) :: ncid, varid
746 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
747 Integer(NFINT),
Intent(OUT) :: ivals(*)
751 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
752 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
753 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
754 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
765 cstartptr = c_null_ptr
766 ccountsptr = c_null_ptr
767 cstridesptr = c_null_ptr
770 If (cstat1 == nc_noerr)
Then
772 cstart(1:ndims) = start(ndims:1:-1)-1
773 ccounts(1:ndims) = counts(ndims:1:-1)
774 cstrides(1:ndims) = strides(ndims:1:-1)
776 cstartptr = c_loc(cstart)
777 ccountsptr = c_loc(ccounts)
778 cstridesptr = c_loc(cstrides)
784 #elif NF_INT_IS_C_LONG
791 End Function nf_get_vars_int
793 Function nf_get_vars_real(ncid, varid, start, counts, strides, rvals) &
798 USE netcdf_nc_interfaces
802 Integer,
Intent(IN) :: ncid, varid
803 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
804 Real(NFREAL),
Intent(OUT) :: rvals(*)
808 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
809 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
810 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
811 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
822 cstartptr = c_null_ptr
823 ccountsptr = c_null_ptr
824 cstridesptr = c_null_ptr
827 If (cstat1 == nc_noerr)
Then
829 cstart(1:ndims) = start(ndims:1:-1)-1
830 ccounts(1:ndims) = counts(ndims:1:-1)
831 cstrides(1:ndims) = strides(ndims:1:-1)
833 cstartptr = c_loc(cstart)
834 ccountsptr = c_loc(ccounts)
835 cstridesptr = c_loc(cstrides)
838 #if NF_REAL_IS_C_DOUBLE
848 End Function nf_get_vars_real
850 Function nf_get_vars_double(ncid, varid, start, counts, strides, dvals) &
855 USE netcdf_nc_interfaces
859 Integer,
Intent(IN) :: ncid, varid
860 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
861 Real(RK8),
Intent(OUT) :: dvals(*)
865 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
866 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
867 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
868 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
879 cstartptr = c_null_ptr
880 ccountsptr = c_null_ptr
881 cstridesptr = c_null_ptr
884 If (cstat1 == nc_noerr)
Then
886 cstart(1:ndims) = start(ndims:1:-1)-1
887 ccounts(1:ndims) = counts(ndims:1:-1)
888 cstrides(1:ndims) = strides(ndims:1:-1)
890 cstartptr = c_loc(cstart)
891 ccountsptr = c_loc(ccounts)
892 cstridesptr = c_loc(cstrides)
900 End Function nf_get_vars_double
902 Function nf_get_vars(ncid, varid, start, counts, strides, values) &
909 USE netcdf_nc_interfaces
913 Integer,
Intent(IN) :: ncid, varid
914 Integer,
Intent(IN) :: start(*), counts(*), strides(*)
915 Character(KIND=C_CHAR),
Intent(INOUT) :: values
920 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
921 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
922 Integer(KIND=C_PTRDIFF_T),
TARGET :: cstrides(nc_max_dims)
923 Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr
934 cstartptr = c_null_ptr
935 ccountsptr = c_null_ptr
936 cstridesptr = c_null_ptr
939 If (cstat1 == nc_noerr)
Then
941 cstart(1:ndims) = start(ndims:1:-1)-1
942 ccounts(1:ndims) = counts(ndims:1:-1)
943 cstrides(1:ndims) = strides(ndims:1:-1)
945 cstartptr = c_loc(cstart)
946 ccountsptr = c_loc(ccounts)
947 cstridesptr = c_loc(cstrides)
950 cstatus =
nc_get_vars(cncid, cvarid, cstartptr, ccountsptr, &
955 End Function nf_get_vars