1 #include "nfconfig.inc"
34 Function nf_put_vara_text(ncid, varid, start, counts, text) RESULT(status)
38 USE netcdf_nc_interfaces
42 Integer,
Intent(IN) :: ncid, varid
43 Integer,
Intent(IN) :: start(*), counts(*)
44 Character(LEN=*),
Intent(IN) :: text
48 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
49 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
50 Type(c_ptr) :: cstartptr, ccountsptr
60 cstartptr = c_null_ptr
61 ccountsptr = c_null_ptr
64 If (cstat1 == nc_noerr)
Then
66 cstart(1:ndims) = start(ndims:1:-1)-1
67 ccounts(1:ndims) = counts(ndims:1:-1)
69 cstartptr = c_loc(cstart)
70 ccountsptr = c_loc(ccounts)
77 End Function nf_put_vara_text
79 Function nf_put_vara_text_a(ncid, varid, start, counts, text) RESULT(status)
83 USE netcdf_nc_interfaces
87 Integer,
Intent(IN) :: ncid, varid
88 Integer,
Intent(IN) :: start(*), counts(*)
89 Character(LEN=1),
Intent(IN) :: text(*)
93 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
94 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
95 Type(c_ptr) :: cstartptr, ccountsptr
105 cstartptr = c_null_ptr
106 ccountsptr = c_null_ptr
109 If (cstat1 == nc_noerr)
Then
111 cstart(1:ndims) = start(ndims:1:-1)-1
112 ccounts(1:ndims) = counts(ndims:1:-1)
114 cstartptr = c_loc(cstart)
115 ccountsptr = c_loc(ccounts)
122 End Function nf_put_vara_text_a
124 Function nf_put_vara_int1(ncid, varid, start, counts, i1vals) RESULT(status)
128 USE netcdf_nc_interfaces
132 Integer,
Intent(IN) :: ncid, varid
133 Integer,
Intent(IN) :: start(*), counts(*)
134 Integer(KIND=NFINT1),
Intent(IN) :: i1vals(*)
138 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
139 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
140 Type(c_ptr) :: cstartptr, ccountsptr
143 If (c_signed_char < 0)
Then
155 cstartptr = c_null_ptr
156 ccountsptr = c_null_ptr
159 If (cstat1 == nc_noerr)
Then
161 cstart(1:ndims) = start(ndims:1:-1)-1
162 ccounts(1:ndims) = counts(ndims:1:-1)
164 cstartptr = c_loc(cstart)
165 ccountsptr = c_loc(ccounts)
168 #if NF_INT1_IS_C_SIGNED_CHAR
170 #elif NF_INT1_IS_C_SHORT
172 #elif NF_INT1_IS_C_INT
173 cstatus =
nc_put_vara_int(cncid, cvarid, cstartptr, ccountsptr, i1vals)
174 #elif NF_INT1_IS_C_LONG
180 End Function nf_put_vara_int1
182 Function nf_put_vara_int2(ncid, varid, start, counts, i2vals) RESULT(status)
186 USE netcdf_nc_interfaces
190 Integer,
Intent(IN) :: ncid, varid
191 Integer,
Intent(IN) :: start(*), counts(*)
192 Integer(KIND=NFINT2),
Intent(IN) :: i2vals(*)
196 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
197 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
198 Type(c_ptr) :: cstartptr, ccountsptr
201 If (c_short < 0)
Then
213 cstartptr = c_null_ptr
214 ccountsptr = c_null_ptr
217 If (cstat1 == nc_noerr)
Then
219 cstart(1:ndims) = start(ndims:1:-1)-1
220 ccounts(1:ndims) = counts(ndims:1:-1)
222 cstartptr = c_loc(cstart)
223 ccountsptr = c_loc(ccounts)
226 #if NF_INT2_IS_C_SHORT
228 #elif NF_INT2_IS_C_INT
229 cstatus =
nc_put_vara_int(cncid, cvarid, cstartptr, ccountsptr, i2vals)
230 #elif NF_INT2_IS_C_LONG
236 End Function nf_put_vara_int2
238 Function nf_put_vara_int(ncid, varid, start, counts, ivals) RESULT(status)
242 USE netcdf_nc_interfaces
246 Integer,
Intent(IN) :: ncid, varid
247 Integer,
Intent(IN) :: start(*), counts(*)
248 Integer(NFINT),
Intent(IN) :: ivals(*)
252 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
253 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
254 Type(c_ptr) :: cstartptr, ccountsptr
264 cstartptr = c_null_ptr
265 ccountsptr = c_null_ptr
268 If (cstat1 == nc_noerr)
Then
270 cstart(1:ndims) = start(ndims:1:-1)-1
271 ccounts(1:ndims) = counts(ndims:1:-1)
273 cstartptr = c_loc(cstart)
274 ccountsptr = c_loc(ccounts)
279 #elif NF_INT_IS_C_LONG
285 End Function nf_put_vara_int
287 Function nf_put_vara_real(ncid, varid, start, counts, rvals) RESULT(status)
291 USE netcdf_nc_interfaces
295 Integer,
Intent(IN) :: ncid, varid
296 Integer,
Intent(IN) :: start(*), counts(*)
297 Real(NFREAL),
Intent(IN) :: rvals(*)
301 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
302 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
303 Type(c_ptr) :: cstartptr, ccountsptr
313 cstartptr = c_null_ptr
314 ccountsptr = c_null_ptr
317 If (cstat1 == nc_noerr)
Then
319 cstart(1:ndims) = start(ndims:1:-1)-1
320 ccounts(1:ndims) = counts(ndims:1:-1)
322 cstartptr = c_loc(cstart)
323 ccountsptr = c_loc(ccounts)
326 #if NF_REAL_IS_C_DOUBLE
334 End Function nf_put_vara_real
336 Function nf_put_vara_double(ncid, varid, start, counts, dvals) &
341 USE netcdf_nc_interfaces
345 Integer,
Intent(IN) :: ncid, varid
346 Integer,
Intent(IN) :: start(*), counts(*)
347 Real(RK8),
Intent(IN) :: dvals(*)
351 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
352 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
353 Type(c_ptr) :: cstartptr, ccountsptr
363 cstartptr = c_null_ptr
364 ccountsptr = c_null_ptr
367 If (cstat1 == nc_noerr)
Then
369 cstart(1:ndims) = start(ndims:1:-1)-1
370 ccounts(1:ndims) = counts(ndims:1:-1)
372 cstartptr = c_loc(cstart)
373 ccountsptr = c_loc(ccounts)
380 End Function nf_put_vara_double
382 Function nf_put_vara(ncid, varid, start, counts, values) RESULT(status)
388 USE netcdf_nc_interfaces
392 Integer,
Intent(IN) :: ncid, varid
393 Integer,
Intent(IN) :: start(*), counts(*)
394 Character(KIND=C_CHAR),
Intent(IN),
TARGET :: values(*)
398 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
399 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
400 Type(c_ptr) :: cstartptr, ccountsptr, cvaluesptr
411 cstartptr = c_null_ptr
412 ccountsptr = c_null_ptr
415 If (cstat1 == nc_noerr)
Then
417 cstart(1:ndims) = start(ndims:1:-1)-1
418 ccounts(1:ndims) = counts(ndims:1:-1)
420 cstartptr = c_loc(cstart)
421 ccountsptr = c_loc(ccounts)
424 cvaluesptr = c_loc(values)
426 cstatus =
nc_put_vara(cncid, cvarid, cstartptr, ccountsptr, cvaluesptr)
431 End Function nf_put_vara
433 Function nf_get_vara_text(ncid, varid, start, counts, text) RESULT(status)
437 USE netcdf_nc_interfaces
441 Integer,
Intent(IN) :: ncid, varid
442 Integer,
Intent(IN) :: start(*), counts(*)
443 Character(LEN=*),
Intent(OUT) :: text
447 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
448 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
449 Type(c_ptr) :: cstartptr, ccountsptr
456 text = repeat(
" ", len(text))
460 cstartptr = c_null_ptr
461 ccountsptr = c_null_ptr
464 If (cstat1 == nc_noerr)
Then
466 cstart(1:ndims) = start(ndims:1:-1)-1
467 ccounts(1:ndims) = counts(ndims:1:-1)
469 cstartptr = c_loc(cstart)
470 ccountsptr = c_loc(ccounts)
477 End Function nf_get_vara_text
479 Function nf_get_vara_text_a(ncid, varid, start, counts, text) RESULT(status)
483 USE netcdf_nc_interfaces
487 Integer,
Intent(IN) :: ncid, varid
488 Integer,
Intent(IN) :: start(*), counts(*)
489 Character(LEN=1),
Intent(OUT) :: text(*)
493 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
494 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
495 Type(c_ptr) :: cstartptr, ccountsptr
505 cstartptr = c_null_ptr
506 ccountsptr = c_null_ptr
509 If (cstat1 == nc_noerr)
Then
511 cstart(1:ndims) = start(ndims:1:-1)-1
512 ccounts(1:ndims) = counts(ndims:1:-1)
514 cstartptr = c_loc(cstart)
515 ccountsptr = c_loc(ccounts)
522 End Function nf_get_vara_text_a
524 Function nf_get_vara_int1(ncid, varid, start, counts, i1vals) RESULT(status)
528 USE netcdf_nc_interfaces
532 Integer,
Intent(IN) :: ncid, varid
533 Integer,
Intent(IN) :: start(*), counts(*)
534 Integer(KIND=NFINT1),
Intent(OUT) :: i1vals(*)
538 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
539 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
540 Type(c_ptr) :: cstartptr, ccountsptr
543 If (c_signed_char < 0)
Then
555 cstartptr = c_null_ptr
556 ccountsptr = c_null_ptr
559 If (cstat1 == nc_noerr)
Then
561 cstart(1:ndims) = start(ndims:1:-1)-1
562 ccounts(1:ndims) = counts(ndims:1:-1)
564 cstartptr = c_loc(cstart)
565 ccountsptr = c_loc(ccounts)
568 #if NF_INT1_IS_C_SIGNED_CHAR
570 #elif NF_INT1_IS_C_SHORT
572 #elif NF_INT1_IS_C_INT
573 cstatus =
nc_get_vara_int(cncid, cvarid, cstartptr, ccountsptr, i1vals)
574 #elif NF_INT1_IS_C_LONG
580 End Function nf_get_vara_int1
582 Function nf_get_vara_int2(ncid, varid, start, counts, i2vals) RESULT(status)
586 USE netcdf_nc_interfaces
590 Integer,
Intent(IN) :: ncid, varid
591 Integer,
Intent(IN) :: start(*), counts(*)
592 Integer(KIND=NFINT2),
Intent(OUT) :: i2vals(*)
596 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
597 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
598 Type(c_ptr) :: cstartptr, ccountsptr
601 If (c_short < 0)
Then
613 cstartptr = c_null_ptr
614 ccountsptr = c_null_ptr
617 If (cstat1 == nc_noerr)
Then
619 cstart(1:ndims) = start(ndims:1:-1)-1
620 ccounts(1:ndims) = counts(ndims:1:-1)
622 cstartptr = c_loc(cstart)
623 ccountsptr = c_loc(ccounts)
626 #if NF_INT2_IS_C_SHORT
628 #elif NF_INT2_IS_C_INT
629 cstatus =
nc_get_vara_int(cncid, cvarid, cstartptr, ccountsptr, i2vals)
630 #elif NF_INT2_IS_C_LONG
636 End Function nf_get_vara_int2
638 Function nf_get_vara_int(ncid, varid, start, counts, ivals) RESULT(status)
642 USE netcdf_nc_interfaces
646 Integer,
Intent(IN) :: ncid, varid
647 Integer,
Intent(IN) :: start(*), counts(*)
648 Integer(NFINT),
Intent(OUT) :: ivals(*)
652 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
653 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
654 Type(c_ptr) :: cstartptr, ccountsptr
664 cstartptr = c_null_ptr
665 ccountsptr = c_null_ptr
668 If (cstat1 == nc_noerr)
Then
670 cstart(1:ndims) = start(ndims:1:-1)-1
671 ccounts(1:ndims) = counts(ndims:1:-1)
673 cstartptr = c_loc(cstart)
674 ccountsptr = c_loc(ccounts)
679 #elif NF_INT_IS_C_LONG
685 End Function nf_get_vara_int
687 Function nf_get_vara_real(ncid, varid, start, counts, rvals) RESULT(status)
691 USE netcdf_nc_interfaces
695 Integer,
Intent(IN) :: ncid, varid
696 Integer,
Intent(IN) :: start(*), counts(*)
697 Real(NFREAL),
Intent(OUT) :: rvals(*)
701 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
702 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
703 Type(c_ptr) :: cstartptr, ccountsptr
713 cstartptr = c_null_ptr
714 ccountsptr = c_null_ptr
717 If (cstat1 == nc_noerr)
Then
719 cstart(1:ndims) = start(ndims:1:-1)-1
720 ccounts(1:ndims) = counts(ndims:1:-1)
722 cstartptr = c_loc(cstart)
723 ccountsptr = c_loc(ccounts)
726 #if NF_REAL_IS_C_DOUBLE
734 End Function nf_get_vara_real
736 Function nf_get_vara_double(ncid, varid, start, counts, dvals) &
741 USE netcdf_nc_interfaces
745 Integer,
Intent(IN) :: ncid, varid
746 Integer,
Intent(IN) :: start(*), counts(*)
747 Real(RK8),
Intent(OUT) :: dvals(*)
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 Type(c_ptr) :: cstartptr, ccountsptr
763 cstartptr = c_null_ptr
764 ccountsptr = c_null_ptr
767 If (cstat1 == nc_noerr)
Then
769 cstart(1:ndims) = start(ndims:1:-1)-1
770 ccounts(1:ndims) = counts(ndims:1:-1)
772 cstartptr = c_loc(cstart)
773 ccountsptr = c_loc(ccounts)
780 End Function nf_get_vara_double
782 Function nf_get_vara(ncid, varid, start, counts, values) RESULT(status)
788 USE netcdf_nc_interfaces
792 Integer,
Intent(IN) :: ncid, varid
793 Integer,
Intent(IN) :: start(*), counts(*)
794 Character(KIND=C_CHAR),
Intent(INOUT),
TARGET :: values(*)
798 Integer(KIND=C_INT) :: cncid, cvarid, cndims, cstat1, cstatus
799 Integer(KIND=C_SIZE_T),
TARGET :: cstart(nc_max_dims), ccounts(nc_max_dims)
800 Type(c_ptr) :: cstartptr, ccountsptr
810 cstartptr = c_null_ptr
811 ccountsptr = c_null_ptr
814 If (cstat1 == nc_noerr)
Then
816 cstart(1:ndims) = start(ndims:1:-1)-1
817 ccounts(1:ndims) = counts(ndims:1:-1)
819 cstartptr = c_loc(cstart)
820 ccountsptr = c_loc(ccounts)
823 cstatus =
nc_get_vara(cncid, cvarid, cstartptr, ccountsptr, values)
827 End Function nf_get_vara