NetCDF-Fortran  4.4.4
nf_fortv2.f90
Go to the documentation of this file.
1 ! Netcdf Version 2 Fortran API
2 
3 ! These routines replace the cfortran.h defined functions from fort-v2compat.c
4 ! C_CHAR strings and C_PTR types are used as pass-through variables for
5 ! functions that support multiple data types as void pointers in the C routines
6 !
7 
8 ! Written by: Richard Weed, Ph.D.
9 ! Center for Advanced Vehicular Systems
10 ! Mississippi State University
11 ! rweed@cavs.msstate.edu
12 
13 
14 ! License (and other Lawyer Language)
15 
16 ! This software is released under the Apache 2.0 Open Source License. The
17 ! full text of the License can be viewed at :
18 !
19 ! http:www.apache.org/licenses/LICENSE-2.0.html
20 !
21 ! The author grants to the University Corporation for Atmospheric Research
22 ! (UCAR), Boulder, CO, USA the right to revise and extend the software
23 ! without restriction. However, the author retains all copyrights and
24 ! intellectual property rights explicitly stated in or implied by the
25 ! Apache license
26 
27 ! Version 1: May 2006 - Initial version 2 interfaces
28 ! Version 2: April 2009 - Refactored to pass value data using C_CHAR and C_PTR
29 ! strings and pointers and updated for NetCDF 4.0.1
30 ! Version 3: April 2010 - updated for NetCDF 4.1.1
31 ! Version 4: Jan. 2016 - Code cleanup. Replaced automatic arrays dimensioned
32 ! by NC_MAX_DIMS with allocatable arrays. Fixed
33 ! potential but with strides definitions that
34 ! wasn't caught by checks since no checks for
35 ! the routines that use them exist. Changed name
36 ! processing to reflect change in addCNullchar
37 
38 ! ------------------------------- ncpopt --------------------------------------
39  Subroutine ncpopt(ncopts)
40 
42 
43  Implicit NONE
44 
45  Integer, Intent(IN) :: ncopts
46 
47  Integer(C_INT) :: cncopts
48 
49  cncopts = ncopts
50 
51  Call c_ncpopt(cncopts)
52 
53  End Subroutine ncpopt
54 ! ------------------------------- ncgopt --------------------------------------
55  Subroutine ncgopt(ncopts)
56 
58 
59  Implicit NONE
60 
61  Integer, Intent(INOUT) :: ncopts
62 
63  Integer(C_INT) :: cncopts
64 
65  cncopts = 0
66 
67  Call c_ncgopt(cncopts)
68 
69  ncopts = cncopts
70 
71  End Subroutine ncgopt
72 ! ------------------------------- nccre ---------------------------------------
73  Function nccre(filename, cmode, rcode) RESULT(ncid)
74 
76 
77  Implicit NONE
78 
79  Character(LEN=*), Intent(IN) :: filename
80  Integer, Intent(IN) :: cmode
81  Integer, Intent(OUT) :: rcode
82 
83  Integer :: ncid
84 
85  Character(LEN=(LEN(filename)+1)) :: cfilename
86  Integer :: ilen
87  Integer(C_INT) :: ccmode, crcode, cncid
88 
89  ccmode = cmode
90  cncid = 0
91  rcode = 0
92  crcode = 0
93 
94 ! check for a null character on end of filename
95 
96  cfilename = addcnullchar(filename, ilen)
97 
98  cncid = c_nccre(cfilename(1:ilen), ccmode, crcode )
99 
100  rcode = crcode
101  ncid = cncid
102 
103  End Function nccre
104 ! ------------------------------- ncopn ---------------------------------------
105  Function ncopn(filename, rwmode, rcode) RESULT(ncid)
108 
109  Implicit NONE
110 
111  Character(LEN=*), Intent(IN) :: filename
112  Integer, Intent(IN) :: rwmode
113  Integer, Intent(OUT) :: rcode
114 
115  Integer :: ncid
116 
117  Character(LEN=(LEN(filename)+1)) :: cfilename
118  Integer :: ilen
119  Integer(C_INT) :: crwmode, crcode, cncid
120 
121  crwmode = rwmode
122  rcode = 0
123  crcode = 0
124  cncid = 0
125 
126 ! check for a null character on end of filename
127 
128  cfilename = addcnullchar(filename, ilen)
129 
130  cncid = c_ncopn(cfilename(1:ilen), crwmode, crcode )
131 
132  rcode = crcode
133  ncid = cncid
134 
135  End Function ncopn
136 ! ------------------------------- ncddef --------------------------------------
137  Function ncddef(ncid, dimname, dimlen, rcode) RESULT(ndimid)
140 
141  Implicit NONE
142 
143  Character(LEN=*), Intent(IN) :: dimname
144  Integer, Intent(IN) :: ncid, dimlen
145  Integer, Intent(OUT) :: rcode
146 
147  Integer :: ndimid
148 
149  Character(LEN=(LEN(dimname)+1)) :: cdimname
150  Integer :: ilen
151  Integer(C_INT) :: cncid, cdimlen, cndimid, crcode
152 
153  cncid = ncid
154  cdimlen = dimlen
155  cndimid = 0
156  rcode = 0
157  ndimid = 0
158 
159 ! check for a null character on end of dimname
160 
161  cdimname = addcnullchar(dimname, ilen)
162 
163  cndimid = c_ncddef(cncid, cdimname(1:ilen), cdimlen, crcode )
164 
165  rcode = crcode
166  ndimid = cndimid
167 
168  End Function ncddef
169 ! ------------------------------- ncdid ---------------------------------------
170  Function ncdid(ncid, dimname, rcode) RESULT(ndimid)
173 
174  Implicit NONE
175 
176  Character(LEN=*), Intent(IN) :: dimname
177  Integer, Intent(IN) :: ncid
178  Integer, Intent(OUT) :: rcode
179 
180  Integer :: ndimid
181 
182  Character(LEN=(LEN(dimname)+1)) :: cdimname
183  Integer :: ilen
184  Integer(C_INT) :: cncid, crcode, cndimid
185 
186  cncid = ncid
187  cndimid = 0
188  rcode = 0
189  ndimid = 0
190 
191 ! check for a null character on end of dimname
192 
193  cdimname = addcnullchar(dimname, ilen)
194 
195  cndimid = c_ncdid(cncid, cdimname(1:ilen), crcode )
196 
197  rcode = crcode
198  ndimid = cndimid
199 
200  End Function ncdid
201 ! ------------------------------- ncvdef --------------------------------------
202  Function ncvdef(ncid, varname, vartype, nvdims, vdims, rcode) RESULT(nvarid)
205 
206  Implicit NONE
207 
208  Character(LEN=*), Intent(IN) :: varname
209  Integer, Intent(IN) :: ncid, vartype, nvdims
210  Integer, Intent(IN) :: vdims(*)
211  Integer, Intent(OUT) :: rcode
212 
213  Integer :: nvarid
214 
215  Character(LEN=(LEN(varname)+1)) :: cvarname
216  Integer :: ilen
217  Integer(C_INT) :: cncid, crcode, cnvdims, cvartype, cnvarid
218  Type(c_ptr) :: cvdimsptr
219 
220  Integer(C_INT), ALLOCATABLE, TARGET :: cvdims(:)
221 
222  cncid = ncid
223  cnvdims = nvdims
224  cvartype = vartype
225  crcode = 0
226  rcode = 0
227  nvarid = 0
228  cnvarid = 0
229 
230 ! check for a null character on end of varname
231 
232  cvarname = addcnullchar(varname, ilen)
233 
234  ! mimic f2c_dimids
235  cvdimsptr = c_null_ptr
236 
237  If (nvdims > 0) Then
238  ALLOCATE(cvdims(nvdims))
239  cvdims(1:nvdims) = vdims(nvdims:1:-1) - 1
240  cvdimsptr = c_loc(cvdims)
241  EndIf
242 
243  cnvarid = c_ncvdef(cncid, cvarname(1:ilen), cvartype, &
244  cnvdims, cvdimsptr, crcode )
245 
246  rcode = crcode
247  nvarid = cnvarid
248 
249  cvdimsptr = c_null_ptr
250  If (ALLOCATED(cvdims)) DEALLOCATE(cvdims)
251 
252  End Function ncvdef
253 ! ------------------------------- ncvid ---------------------------------------
254  Function ncvid(ncid, varname, rcode) RESULT(nvarid)
257 
258  Implicit NONE
259 
260  Character(LEN=*), Intent(IN) :: varname
261  Integer, Intent(IN) :: ncid
262  Integer, Intent(OUT) :: rcode
263 
264  Integer :: nvarid
265 
266  Character(LEN=(LEN(varname)+1)) :: cvarname
267  Integer :: ilen
268  Integer(C_INT) :: cncid, crcode, cnvarid
269 
270  cncid = ncid
271  crcode = 0
272  rcode = 0
273  nvarid = 0
274  cnvarid = 0
275 
276 ! check for a null character on end of varname
277 
278  cvarname = addcnullchar(varname, ilen)
279 
280  cnvarid = c_ncvid(cncid, cvarname(1:ilen), crcode)
281 
282  rcode = crcode
283  nvarid = cnvarid
284 
285  End Function ncvid
286 ! ------------------------------- nctlen --------------------------------------
287  Function nctlen(datatype, rcode) RESULT(nvarlen)
290 
291  Implicit NONE
292 
293  Integer, Intent(IN) :: datatype
294  Integer, Intent(OUT) :: rcode
295 
296  Integer :: nvarlen
297 
298  Integer(C_INT) :: crcode, cnvarlen, cdtype
299 
300  cdtype = datatype
301  crcode = 0
302  rcode = 0
303  nvarlen = 0
304  cnvarlen = 0
305 
306  cnvarlen = c_nctlen(cdtype, crcode)
307 
308  rcode = crcode
309  nvarlen = cnvarlen
310 
311  End Function nctlen
312 ! ------------------------------- ncclos -------------------------------------
313  Subroutine ncclos(ncid, rcode)
316 
317  Implicit NONE
318 
319  Integer, Intent(IN) :: ncid
320  Integer, Intent(OUT) :: rcode
321 
322  Integer(C_INT) :: crcode, cncid
323 
324  cncid = ncid
325  crcode = 0
326  rcode = 0
327 
328  Call c_ncclos(cncid, crcode)
329 
330  rcode = crcode
331 
332  End Subroutine ncclos
333 ! ------------------------------- ncredf -------------------------------------
334  Subroutine ncredf(ncid, rcode)
337 
338  Implicit NONE
339 
340  Integer, Intent(IN) :: ncid
341  Integer, Intent(OUT) :: rcode
342 
343  Integer(C_INT) :: crcode, cncid
344 
345  cncid = ncid
346  crcode = 0
347  rcode = 0
348 
349  Call c_ncredf(cncid, crcode)
350 
351  rcode = crcode
352 
353  End Subroutine ncredf
354 ! ------------------------------- ncendf --------------------------------------
355  Subroutine ncendf(ncid, rcode)
358 
359  Implicit NONE
360 
361  Integer, Intent(IN) :: ncid
362  Integer, Intent(OUT) :: rcode
363 
364  Integer(C_INT) :: crcode, cncid
365 
366  cncid = ncid
367  crcode = 0
368  rcode = 0
369 
370  Call c_ncendf(cncid, crcode)
371 
372  rcode = crcode
373 
374  End Subroutine ncendf
375 ! ------------------------------- ncinq ---------------------------------------
376  Subroutine ncinq(ncid, ndims, nvars, natts, recdim, rcode)
379 
380  Implicit NONE
381 
382  Integer, Intent(IN) :: ncid
383  Integer, Intent(OUT) :: ndims, nvars, natts, recdim, rcode
384 
385  Integer(C_INT) :: crcode, cncid, cndims, cnvars, cnatts, crecdim
386 
387  cncid = ncid
388  crcode = 0
389  rcode = 0
390  cndims = 0
391  cnvars = 0
392  cnatts = 0
393  ndims = 0
394  nvars = 0
395  natts = 0
396 
397  Call c_ncinq(cncid, cndims, cnvars, cnatts, crecdim, crcode)
398 
399  ndims = cndims
400  nvars = cnvars
401  natts = cnatts
402  If (crecdim == -1) Then ! no unlimited dimension
403  recdim = -1
404  Else
405  recdim = crecdim + 1 ! shift by plus one for FORTRAN
406  EndIf
407 
408  rcode = crcode
409 
410  End Subroutine ncinq
411 ! ------------------------------- ncsnc ---------------------------------------
412  Subroutine ncsnc(ncid, rcode)
415 
416  Implicit NONE
417 
418  Integer, Intent(IN) :: ncid
419  Integer, Intent(OUT) :: rcode
420 
421  Integer(C_INT) :: crcode, cncid
422 
423  cncid = ncid
424  crcode = 0
425  rcode = 0
426 
427  Call c_ncsnc(cncid, crcode)
428 
429  rcode = crcode
430 
431  End Subroutine ncsnc
432 ! ------------------------------- ncabor --------------------------------------
433  Subroutine ncabor(ncid, rcode)
436 
437  Implicit NONE
438 
439  Integer, Intent(IN) :: ncid
440  Integer, Intent(OUT) :: rcode
441 
442  Integer(C_INT) :: crcode, cncid
443 
444  cncid = ncid
445  crcode = 0
446  rcode = 0
447 
448  Call c_ncabor(cncid, crcode)
449 
450  rcode = crcode
451 
452  End Subroutine ncabor
453 ! ------------------------------- ncdinq --------------------------------------
454  Subroutine ncdinq(ncid, dimid, dimname, dimlen, rcode)
458 
459  Implicit NONE
460 
461  Integer, Intent(IN) :: ncid, dimid
462  Character(LEN=*), Intent(OUT) :: dimname
463  Integer, Intent(OUT) :: dimlen, rcode
464 
465  Integer(C_INT) :: cncid, crcode, cdimlen, cdimid
466  Character(LEN=(NC_MAX_NAME+1)) :: cdimname
467  Integer :: ilen
468 
469  cncid = ncid
470  cdimid = dimid - 1
471  crcode = 0
472  rcode = 0
473  cdimlen = 0
474  cdimname = repeat(" ", len(cdimname))
475  ilen = len(dimname)
476 
477  Call c_ncdinq(cncid, cdimid, cdimname, cdimlen, crcode)
478 
479 ! check for a null character on end of cdimname
480 
481  dimname = stripcnullchar(cdimname, ilen)
482 
483  dimlen = cdimlen
484  rcode = crcode
485 
486  End Subroutine ncdinq
487 ! ------------------------------- ncdren --------------------------------------
488  Subroutine ncdren(ncid, dimid, dimname, rcode)
491 
492  Implicit NONE
493 
494  Character(LEN=*), Intent(IN) :: dimname
495  Integer, Intent(IN) :: ncid, dimid
496  Integer, Intent(OUT) :: rcode
497 
498  Character(LEN=(LEN(dimname)+1)) :: cdimname
499  Integer(C_INT) :: cncid, crcode, cdimid
500  Integer :: ilen
501 
502  cncid = ncid
503  cdimid = dimid - 1
504  crcode = 0
505  rcode = 0
506 
507 ! check for a null character on end of dimname
508 
509  cdimname = addcnullchar(dimname, ilen)
510 
511  Call c_ncdren(cncid, cdimid, cdimname(1:ilen), crcode)
512 
513  rcode = crcode
514 
515  End Subroutine ncdren
516 ! ------------------------------- ncvinq --------------------------------------
517  Subroutine ncvinq(ncid, varid, varname, vartype, nvdims, vdims, &
518  nvatts, rcode)
522 
523  Implicit NONE
524 
525  Integer, Intent(IN) :: ncid, varid
526  Character(LEN=*), Intent(INOUT) :: varname
527  Integer, Intent(OUT) :: vartype, nvdims, nvatts, rcode
528  Integer, Intent(INOUT) :: vdims(*)
529 
530  Integer(C_INT) :: cncid, crcode, cvarid, cvartype, cnvdims, &
531  cnvatts, cstat1
532  Character(LEN=NC_MAX_NAME+1) :: cvarname
533  Integer :: ilen
534 
535  Integer(C_INT), ALLOCATABLE :: cvdims(:)
536 
537  cncid = ncid
538  cvarid = varid - 1
539  crcode = 0
540  rcode = 0
541  vartype = 0
542  nvdims = 0
543  nvatts = 0
544  cnvdims = 0
545  cnvatts = 0
546  cvartype = 0
547  cvarname = repeat(" ", len(cvarname))
548  ilen = len(varname)
549 
550  cstat1 = nc_inq_varndims(cncid, cvarid, cnvdims)
551  rcode = cstat1
552 
553  If (cnvdims > 0) Then
554  ALLOCATE(cvdims(cnvdims))
555  Else
556  ALLOCATE(cvdims(1))
557  EndIf
558 
559  Call c_ncvinq(cncid, cvarid, cvarname, cvartype, cnvdims, cvdims, &
560  cnvatts, crcode)
561 
562  nvdims = cnvdims
563  vartype = cvartype
564  nvatts = cnvatts
565  rcode = crcode
566 
567 ! strip C null character from cvarname
568 
569  varname = stripcnullchar(cvarname, ilen)
570 
571 ! convert C dimids to FORTRAN order and rank
572 ! Replaces call to c2f_dimids in C code
573 
574  If (nvdims > 0) Then
575  vdims(1:nvdims) = cvdims(nvdims:1:-1) + 1
576  End If
577 
578 
579  If (ALLOCATED(cvdims)) DEALLOCATE(cvdims)
580 
581  End Subroutine ncvinq
582 ! ------------------------------- ncvpt1 --------------------------------------
583  Subroutine ncvpt1(ncid, varid, mindex, values, rcode)
587 
588  Implicit NONE
589 
590  Integer, Intent(IN) :: ncid, varid
591  Integer, Intent(IN) :: mindex(*)
592  Character(KIND=C_CHAR), Intent(IN), TARGET :: values(*)
593  Integer, Intent(OUT) :: rcode
594 
595  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
596  Type(c_ptr) :: cmindexptr, cvaluesptr
597  Integer :: ndims
598 
599  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cmindex(:)
600 
601  cncid = ncid
602  cvarid = varid - 1
603  crcode = 0
604  rcode = 0
605  cndims = 0
606  ndims = 0
607 
608  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
609 
610  cmindexptr = c_null_ptr
611  ndims = cndims
612 
613  If (cstatus == nc_noerr) Then ! mimic f2c_coords in C code
614  If (ndims > 0) Then
615  ALLOCATE(cmindex(ndims))
616  cmindex(1:ndims) = mindex(ndims:1:-1) - 1
617  cmindexptr = c_loc(cmindex)
618  Endif
619  Endif
620 
621  cvaluesptr = c_loc(values)
622 
623  Call c_ncvpt1(cncid, cvarid, cmindexptr, cvaluesptr, crcode)
624 
625  rcode = crcode
626 
627 ! Make sure there are no dangling pointers and allocated values
628 
629  cvaluesptr = c_null_ptr
630  cmindexptr = c_null_ptr
631  If (ALLOCATED(cmindex)) DEALLOCATE(cmindex)
632 
633  End Subroutine ncvpt1
634 ! ------------------------------- ncvp1c --------------------------------------
635  Subroutine ncvp1c(ncid, varid, mindex, strings, rcode)
639 
640  Implicit NONE
641 
642  Integer, Intent(IN) :: ncid, varid
643  Integer, Intent(IN) :: mindex(*)
644  Character(LEN=*), Intent(IN) :: strings
645  Integer, Intent(OUT) :: rcode
646 
647  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
648  Type(c_ptr) :: cmindexptr
649  Integer :: ndims
650 
651  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cmindex(:)
652 
653  cncid = ncid
654  cvarid = varid - 1
655  crcode = 0
656  rcode = 0
657  cndims = 0
658  ndims = 0
659 
660  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
661 
662  cmindexptr = c_null_ptr
663  ndims = cndims
664 
665  If (cstatus == nc_noerr) Then ! mimic f2c_coords in C code
666  If (ndims > 0) Then
667  ALLOCATE(cmindex(ndims))
668  cmindex(1:ndims) = mindex(ndims:1:-1) - 1
669  cmindexptr = c_loc(cmindex)
670  Endif
671  Endif
672 
673  Call c_ncvp1c(cncid, cvarid, cmindexptr, strings, crcode)
674 
675  rcode = crcode
676 
677 ! Make sure there are no dangling pointers and allocated values
678 
679  cmindexptr = c_null_ptr
680  If (ALLOCATED(cmindex)) DEALLOCATE(cmindex)
681 
682  End Subroutine ncvp1c
683 ! ------------------------------- ncvpt ---------------------------------------
684  Subroutine ncvpt(ncid, varid, start, counts, values, rcode)
688 
689  Implicit NONE
690 
691  Integer, Intent(IN) :: ncid, varid
692  Integer, Intent(IN) :: start(*), counts(*)
693  Character(KIND=C_CHAR), Intent(IN), TARGET :: values(*)
694  Integer, Intent(OUT) :: rcode
695 
696  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
697  Type(c_ptr) :: cstartptr, ccountsptr
698  Type(c_ptr) :: cvaluesptr
699  Integer :: ndims
700 
701  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cstart(:), ccounts(:)
702 
703  cncid = ncid
704  cvarid = varid - 1
705  crcode = 0
706  rcode = 0
707  cndims = 0
708  ndims = 0
709 
710  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
711 
712  cstartptr = c_null_ptr
713  ccountsptr = c_null_ptr
714  ndims = cndims
715 
716  If (cstatus == nc_noerr) Then ! mimic f2c_coords, etc. in C code
717  If (ndims > 0) Then
718  ALLOCATE(cstart(ndims))
719  ALLOCATE(ccounts(ndims))
720  cstart(1:ndims) = start(ndims:1:-1) - 1
721  ccounts(1:ndims) = counts(ndims:1:-1)
722  cstartptr = c_loc(cstart)
723  ccountsptr = c_loc(ccounts)
724  Endif
725  Endif
726 
727  cvaluesptr = c_loc(values)
728 
729  Call c_ncvpt(cncid, cvarid, cstartptr, ccountsptr, cvaluesptr, crcode)
730 
731  rcode = crcode
732 
733 ! Make sure there are no dangling pointers or allocated values
734 
735  cstartptr = c_null_ptr
736  ccountsptr = c_null_ptr
737  cvaluesptr = c_null_ptr
738  If (ALLOCATED(ccounts)) DEALLOCATE(ccounts)
739  If (ALLOCATED(cstart)) DEALLOCATE(cstart)
740 
741  End Subroutine ncvpt
742 ! ------------------------------- ncvptc---------------------------------------
743  Subroutine ncvptc(ncid, varid, start, counts, strings, lenstr, rcode)
747 
748  Implicit NONE
749 
750  Integer, Intent(IN) :: ncid, varid, lenstr
751  Integer, Intent(IN) :: start(*), counts(*)
752  Character(LEN=*), Intent(INOUT) :: strings
753  Integer, Intent(OUT) :: rcode
754 
755  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims, clenstr
756  Type(c_ptr) :: cstartptr, ccountsptr
757  Integer :: ndims
758 
759  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cstart(:), ccounts(:)
760 
761  cncid = ncid
762  cvarid = varid - 1
763  clenstr = lenstr
764  crcode = 0
765  rcode = 0
766  cndims = 0
767  ndims = 0
768 
769  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
770 
771  cstartptr = c_null_ptr
772  ccountsptr = c_null_ptr
773  ndims = cndims
774 
775  If (cstatus == nc_noerr) Then ! mimic f2c_coords, etc. in C code
776  If (ndims > 0) Then
777  ALLOCATE(cstart(ndims))
778  ALLOCATE(ccounts(ndims))
779  cstart(1:ndims) = start(ndims:1:-1) - 1
780  ccounts(1:ndims) = counts(ndims:1:-1)
781  cstartptr = c_loc(cstart)
782  ccountsptr = c_loc(ccounts)
783  Endif
784  Endif
785 
786  Call c_ncvptc(cncid, cvarid, cstartptr, ccountsptr, strings(1:lenstr),&
787  clenstr, crcode)
788 
789  rcode = crcode
790 
791 ! Make sure there are no dangling pointers or allocated values
792 
793  cstartptr = c_null_ptr
794  ccountsptr = c_null_ptr
795  If (ALLOCATED(ccounts)) DEALLOCATE(ccounts)
796  If (ALLOCATED(cstart)) DEALLOCATE(cstart)
797 
798  End Subroutine ncvptc
799 ! ------------------------------- ncvptg --------------------------------------
800  Subroutine ncvptg(ncid, varid, start, counts, strides, imap, values, &
801  rcode)
805 
806  Implicit NONE
807 
808  Integer, Intent(IN) :: ncid, varid
809  Integer, Intent(IN) :: start(*), counts(*), &
810  strides(*), imap(*)
811  Character(KIND=C_CHAR), Intent(IN), TARGET :: values(*)
812  Integer, Intent(OUT) :: rcode
813 
814  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
815  Type(c_ptr) :: cstartptr, ccountsptr, cimapptr, cstridesptr
816  Type(c_ptr) :: cvaluesptr
817  Integer :: ndims, inullp
818 
819  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cstart(:), ccounts(:)
820  Integer(C_PTRDIFF_T), ALLOCATABLE, TARGET :: cstrides(:), cimap(:)
821 
822  cncid = ncid
823  cvarid = varid - 1
824  crcode = 0
825  rcode = 0
826  cndims = 0
827  ndims = 0
828  inullp = 0
829 
830  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
831 
832  If (cndims > 0) Then
833  ALLOCATE(cimap(cndims))
834  Else
835  ALLOCATE(cimap(1))
836  EndIf
837 
838  Call convert_v2_imap(cncid, cvarid, imap, cimap, inullp)
839 
840  ndims = cndims
841  cstartptr = c_null_ptr
842  ccountsptr = c_null_ptr
843  cstridesptr = c_null_ptr
844  cimapptr = c_loc(cimap)
845  If (inullp /= 0) cimapptr = c_null_ptr
846  If (ndims > 0) Then
847  ALLOCATE(cstart(ndims))
848  ALLOCATE(ccounts(ndims))
849  ALLOCATE(cstrides(ndims))
850  cstart(1:ndims) = start(ndims:1:-1) - 1
851  ccounts(1:ndims) = counts(ndims:1:-1)
852  cstrides(1:ndims) = strides(ndims:1:-1)
853  cstartptr = c_loc(cstart)
854  ccountsptr = c_loc(ccounts)
855  cstridesptr = c_loc(cstrides)
856  Endif
857 
858  cvaluesptr = c_loc(values)
859 
860  Call c_ncvptg(cncid, cvarid, cstartptr, ccountsptr, cstridesptr, &
861  cimapptr, cvaluesptr, crcode)
862 
863  rcode = crcode
864 
865 ! Make sure there are no dangling pointers or allocated values
866 
867  cstartptr = c_null_ptr
868  ccountsptr = c_null_ptr
869  cstridesptr = c_null_ptr
870  cvaluesptr = c_null_ptr
871  cimapptr = c_null_ptr
872  If (ALLOCATED(cimap)) DEALLOCATE(cimap)
873  If (ALLOCATED(cstrides)) DEALLOCATE(cstrides)
874  If (ALLOCATED(ccounts)) DEALLOCATE(ccounts)
875  If (ALLOCATED(cstart)) DEALLOCATE(cstart)
876 
877  End Subroutine ncvptg
878 ! ------------------------------- ncvpgc --------------------------------------
879  Subroutine ncvpgc(ncid, varid, start, counts, strides, imap, string, rcode)
883 
884  Implicit NONE
885 
886  Integer, Intent(IN) :: ncid, varid
887  Integer, Intent(IN) :: start(*), counts(*), strides(*), imap(*)
888  Character(LEN=*), Intent(IN) :: string
889  Integer, Intent(OUT) :: rcode
890 
891  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
892  Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr, cimapptr
893  Integer :: ndims, inullp
894 
895  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cstart(:), ccounts(:)
896  Integer(C_PTRDIFF_T), ALLOCATABLE, TARGET :: cstrides(:), cimap(:)
897 
898  cncid = ncid
899  cvarid = varid - 1
900  crcode = 0
901  rcode = 0
902  cndims = 0
903  ndims = 0
904  inullp = 0
905 
906  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
907 
908  If (cndims > 0) Then
909  ALLOCATE(cimap(cndims))
910  Else
911  ALLOCATE(cimap(1))
912  EndIf
913 
914  Call convert_v2_imap(cncid, cvarid, imap, cimap, inullp)
915  ndims = cndims
916  cstartptr = c_null_ptr
917  ccountsptr = c_null_ptr
918  cstridesptr = c_null_ptr
919  cimapptr = c_loc(cimap)
920  If (inullp /= 0) cimapptr = c_null_ptr
921 
922  If (ndims > 0) Then
923  ALLOCATE(cstart(ndims))
924  ALLOCATE(ccounts(ndims))
925  ALLOCATE(cstrides(ndims))
926  cstart(1:ndims) = start(ndims:1:-1) - 1
927  ccounts(1:ndims) = counts(ndims:1:-1)
928  cstrides(1:ndims) = strides(ndims:1:-1)
929  cstartptr = c_loc(cstart)
930  ccountsptr = c_loc(ccounts)
931  cstridesptr = c_loc(cstrides)
932  Endif
933 
934  Call c_ncvpgc(cncid, cvarid, cstartptr, ccountsptr, cstridesptr, &
935  cimapptr, string, crcode)
936 
937  rcode = crcode
938 
939 
940 ! Make sure there are no dangling pointers or allocated values
941 
942  cstartptr = c_null_ptr
943  ccountsptr = c_null_ptr
944  cstridesptr = c_null_ptr
945  cimapptr = c_null_ptr
946  If (ALLOCATED(cimap)) DEALLOCATE(cimap)
947  If (ALLOCATED(cstrides)) DEALLOCATE(cstrides)
948  If (ALLOCATED(ccounts)) DEALLOCATE(ccounts)
949  If (ALLOCATED(cstart)) DEALLOCATE(cstart)
950 
951  End Subroutine ncvpgc
952 ! ------------------------------- ncvgt1 --------------------------------------
953  Subroutine ncvgt1(ncid, varid, mindex, values, rcode)
957 
958  Implicit NONE
959 
960  Integer, Intent(IN) :: ncid, varid
961  Integer, Intent(IN) :: mindex(*)
962  Character(KIND=C_CHAR), Intent(OUT) :: values(*)
963  Integer, Intent(OUT) :: rcode
964 
965  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
966  Type(c_ptr) :: cmindexptr
967  Integer :: ndims
968 
969  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cmindex(:)
970 
971  cncid = ncid
972  cvarid = varid - 1
973  crcode = 0
974  rcode = 0
975  cndims = 0
976  ndims = 0
977 
978  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
979 
980  cmindexptr = c_null_ptr
981  ndims = cndims
982 
983  If (cstatus == nc_noerr) Then ! mimic f2c_coords in C code
984  If (ndims > 0) Then
985  ALLOCATE(cmindex(ndims))
986  cmindex(1:ndims) = mindex(ndims:1:-1) - 1
987  cmindexptr = c_loc(cmindex)
988  Endif
989  Endif
990 
991  Call c_ncvgt1(cncid, cvarid, cmindexptr, values, crcode)
992 
993  rcode = crcode
994 
995 ! Make sure there are no dangling pointers and allocated values
996 
997  cmindexptr = c_null_ptr
998  If (ALLOCATED(cmindex)) DEALLOCATE(cmindex)
999 
1000  End Subroutine ncvgt1
1001 ! ------------------------------- ncvg1c --------------------------------------
1002  Subroutine ncvg1c(ncid, varid, mindex, string, rcode)
1006 
1007  Implicit NONE
1008 
1009  Integer, Intent(IN) :: ncid, varid
1010  Integer, Intent(IN) :: mindex(*)
1011  Character(LEN=*), Intent(INOUT) :: string
1012  Integer, Intent(OUT) :: rcode
1013 
1014  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
1015  Type(c_ptr) :: cmindexptr
1016  Integer :: ndims
1017 
1018  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cmindex(:)
1019 
1020  cncid = ncid
1021  cvarid = varid - 1
1022  crcode = 0
1023  rcode = 0
1024  cndims = 0
1025  ndims = 0
1026 
1027  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
1028 
1029  cmindexptr = c_null_ptr
1030  ndims = cndims
1031 
1032  If (cstatus == nc_noerr) Then ! mimic f2c_coords in C code
1033  If (ndims > 0) Then
1034  ALLOCATE(cmindex(ndims))
1035  cmindex(1:ndims) = mindex(ndims:1:-1) - 1
1036  cmindexptr = c_loc(cmindex)
1037  Endif
1038  Endif
1039 
1040  Call c_ncvg1c(cncid, cvarid, cmindexptr, string, crcode)
1041 
1042  rcode = crcode
1043 
1044 ! Make sure there are no dangling pointers and allocated values
1045 
1046  cmindexptr = c_null_ptr
1047  If (ALLOCATED(cmindex)) DEALLOCATE(cmindex)
1048 
1049  End Subroutine ncvg1c
1050 ! ------------------------------- ncvgt ---------------------------------------
1051  Subroutine ncvgt(ncid, varid, start, counts, values, rcode)
1055 
1056  Implicit NONE
1057 
1058  Integer, Intent(IN) :: ncid, varid
1059  Integer, Intent(IN) :: start(*), counts(*)
1060  Character(KIND=C_CHAR), Intent(OUT) :: values(*)
1061  Integer, Intent(OUT) :: rcode
1062 
1063  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
1064  Type(c_ptr) :: cstartptr, ccountsptr
1065  Integer :: ndims
1066 
1067  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cstart(:), ccounts(:)
1068 
1069  cncid = ncid
1070  cvarid = varid - 1
1071  crcode = 0
1072  rcode = 0
1073  cndims = 0
1074  ndims = 0
1075 
1076  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
1077 
1078  cstartptr = c_null_ptr
1079  ccountsptr = c_null_ptr
1080  ndims = cndims
1081 
1082  If (cstatus == nc_noerr) Then ! mimic f2c_coords, etc. in C code
1083  If (ndims > 0) Then
1084  ALLOCATE(cstart(ndims))
1085  ALLOCATE(ccounts(ndims))
1086  cstart(1:ndims) = start(ndims:1:-1) - 1
1087  ccounts(1:ndims) = counts(ndims:1:-1)
1088  cstartptr = c_loc(cstart)
1089  ccountsptr = c_loc(ccounts)
1090  Endif
1091  Endif
1092 
1093  Call c_ncvgt(cncid, cvarid, cstartptr, ccountsptr, values, crcode)
1094 
1095  rcode = crcode
1096 
1097 ! Make sure there are no dangling pointers or allocated values
1098 
1099  cstartptr = c_null_ptr
1100  ccountsptr = c_null_ptr
1101  If (ALLOCATED(ccounts)) DEALLOCATE(ccounts)
1102  If (ALLOCATED(cstart)) DEALLOCATE(cstart)
1103 
1104  End Subroutine ncvgt
1105 ! ------------------------------- ncvgtc --------------------------------------
1106  Subroutine ncvgtc(ncid, varid, start, counts, string, lenstr, rcode)
1110 
1111  Implicit NONE
1112 
1113  Integer, Intent(IN) :: ncid, varid, lenstr
1114  Integer, Intent(IN) :: start(*), counts(*)
1115  Character(LEN=*), Intent(INOUT) :: string
1116  Integer, Intent(OUT) :: rcode
1117 
1118  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims, &
1119  clenstr
1120  Type(c_ptr) :: cstartptr, ccountsptr
1121  Character(LEN=lenstr+1) :: cstring
1122  Integer :: ndims, slen
1123 
1124  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cstart(:), ccounts(:)
1125 
1126  cncid = ncid
1127  cvarid = varid - 1
1128  clenstr = lenstr
1129  crcode = 0
1130  rcode = 0
1131  cndims = 0
1132  ndims = 0
1133  string = repeat(" ", len(string))
1134  cstring = repeat(" ", len(cstring))
1135 
1136  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
1137 
1138  cstartptr = c_null_ptr
1139  ccountsptr = c_null_ptr
1140  ndims = cndims
1141 
1142  If (cstatus == nc_noerr) Then ! mimic f2c_coords, etc. in C code
1143  If (ndims > 0) Then
1144  ALLOCATE(cstart(ndims))
1145  ALLOCATE(ccounts(ndims))
1146  cstart(1:ndims) = start(ndims:1:-1) - 1
1147  ccounts(1:ndims) = counts(ndims:1:-1)
1148  cstartptr = c_loc(cstart)
1149  ccountsptr = c_loc(ccounts)
1150  Endif
1151  Endif
1152 
1153  Call c_ncvgtc(cncid, cvarid, cstartptr, ccountsptr, cstring, clenstr, crcode)
1154 
1155  If (len(string) >= lenstr) Then
1156  string(1:lenstr) = cstring(1:lenstr)
1157  Else
1158  slen = len(string)
1159  string(1:slen) = cstring(1:slen)
1160  EndIf
1161 
1162  rcode = crcode
1163 
1164 ! Make sure there are no dangling pointers or allocated values
1165 
1166  cstartptr = c_null_ptr
1167  ccountsptr = c_null_ptr
1168  If (ALLOCATED(ccounts)) DEALLOCATE(ccounts)
1169  If (ALLOCATED(cstart)) DEALLOCATE(cstart)
1170 
1171  End Subroutine ncvgtc
1172 ! ------------------------------- ncvgtg --------------------------------------
1173  Subroutine ncvgtg(ncid, varid, start, counts, strides, imap, values, &
1174  rcode)
1178 
1179  Implicit NONE
1180 
1181  Integer, Intent(IN) :: ncid, varid
1182  Integer, Intent(IN) :: start(*), counts(*), strides(*), imap(*)
1183  Character(KIND=C_CHAR), Intent(OUT) :: values(*)
1184  Integer, Intent(OUT) :: rcode
1185 
1186  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
1187  Type(c_ptr) :: cstartptr, ccountsptr, cimapptr, cstridesptr
1188  Integer :: ndims, inullp
1189 
1190  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cstart(:), ccounts(:)
1191  Integer(C_PTRDIFF_T), ALLOCATABLE, TARGET :: cstrides(:), cimap(:)
1192 
1193  cncid = ncid
1194  cvarid = varid - 1
1195  crcode = 0
1196  rcode = 0
1197  cndims = 0
1198  inullp = 0
1199 
1200  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
1201  If (cndims > 0) Then
1202  ALLOCATE(cimap(cndims))
1203  Else
1204  ALLOCATE(cimap(1))
1205  EndIf
1206 
1207  Call convert_v2_imap(cncid, cvarid, imap, cimap, inullp)
1208 
1209  cstartptr = c_null_ptr
1210  ccountsptr = c_null_ptr
1211  cstridesptr = c_null_ptr
1212  cimapptr = c_loc(cimap)
1213  ndims = cndims
1214 
1215  If (inullp /= 0) cimapptr = c_null_ptr
1216  If (ndims > 0) Then
1217  ALLOCATE(cstart(ndims))
1218  ALLOCATE(ccounts(ndims))
1219  ALLOCATE(cstrides(ndims))
1220  cstart(1:ndims) = start(ndims:1:-1) - 1
1221  ccounts(1:ndims) = counts(ndims:1:-1)
1222  cstrides(1:ndims) = strides(ndims:1:-1)
1223  cstartptr = c_loc(cstart)
1224  ccountsptr = c_loc(ccounts)
1225  cstridesptr = c_loc(cstrides)
1226  Endif
1227 
1228  Call c_ncvgtg(cncid, cvarid, cstartptr, ccountsptr, cstridesptr, &
1229  cimapptr, values, crcode)
1230 
1231  rcode = crcode
1232 
1233 ! Make sure there are no dangling pointers or allocated values
1234 
1235  cstartptr = c_null_ptr
1236  ccountsptr = c_null_ptr
1237  cstridesptr = c_null_ptr
1238  cimapptr = c_null_ptr
1239  If (ALLOCATED(cimap)) DEALLOCATE(cimap)
1240  If (ALLOCATED(cstrides)) DEALLOCATE(cstrides)
1241  If (ALLOCATED(ccounts)) DEALLOCATE(ccounts)
1242  If (ALLOCATED(cstart)) DEALLOCATE(cstart)
1243 
1244  End Subroutine ncvgtg
1245 ! ------------------------------- ncvggc --------------------------------------
1246  Subroutine ncvggc(ncid, varid, start, counts, strides, imap, string, rcode)
1250 
1251  Implicit NONE
1252 
1253  Integer, Intent(IN) :: ncid, varid
1254  Integer, Intent(IN) :: start(*), counts(*), strides(*), imap(*)
1255  Character(LEN=*), Intent(INOUT) :: string
1256  Integer, Intent(OUT) :: rcode
1257 
1258  Integer(C_INT) :: cncid, crcode, cvarid, cstatus, cndims
1259  Character(LEN=(LEN(string)+1)) :: cstring
1260  Type(c_ptr) :: cstartptr, ccountsptr, cstridesptr, &
1261  cimapptr
1262  Integer :: ndims, inullp,slen
1263 
1264  Integer(C_SIZE_T), ALLOCATABLE, TARGET :: cstart(:), ccounts(:)
1265  Integer(C_PTRDIFF_T), ALLOCATABLE, TARGET :: cstrides(:), cimap(:)
1266 
1267  cncid = ncid
1268  cvarid = varid - 1
1269  crcode = 0
1270  rcode = 0
1271  cstart = 0
1272  ccounts = 0
1273  cndims = 0
1274  ndims = 0
1275  inullp = 0
1276  string = repeat(" ", len(string))
1277  cstring = repeat(" ", len(cstring))
1278 
1279  cstatus = nc_inq_varndims(cncid, cvarid, cndims)
1280 
1281  If (cndims > 0) Then
1282  ALLOCATE(cimap(cndims))
1283  Else
1284  ALLOCATE(cimap(1))
1285  EndIf
1286 
1287  Call convert_v2_imap(cncid, cvarid, imap, cimap, inullp)
1288  cstartptr = c_null_ptr
1289  ccountsptr = c_null_ptr
1290  cstridesptr = c_null_ptr
1291  cimapptr = c_loc(cimap)
1292  ndims = cndims
1293 
1294  If (inullp /= 0) cimapptr = c_null_ptr
1295  If (ndims > 0) Then
1296  ALLOCATE(cstart(ndims))
1297  ALLOCATE(ccounts(ndims))
1298  ALLOCATE(cstrides(ndims))
1299  cstart(1:ndims) = start(ndims:1:-1) - 1
1300  ccounts(1:ndims) = counts(ndims:1:-1)
1301  cstrides(1:ndims) = strides(ndims:1:-1)
1302  cstartptr = c_loc(cstart)
1303  ccountsptr = c_loc(ccounts)
1304  cstridesptr = c_loc(cstrides)
1305  Endif
1306 
1307  Call c_ncvggc(cncid, cvarid, cstartptr, ccountsptr, cstridesptr, &
1308  cimapptr, cstring, crcode)
1309 
1310  slen = len(string)
1311  string(1:slen) = cstring(1:slen)
1312 
1313  rcode = crcode
1314 
1315 ! Make sure there are no dangling pointers or allocated values
1316 
1317  cstartptr = c_null_ptr
1318  ccountsptr = c_null_ptr
1319  cstridesptr = c_null_ptr
1320  cimapptr = c_null_ptr
1321  If (ALLOCATED(cimap)) DEALLOCATE(cimap)
1322  If (ALLOCATED(cstrides)) DEALLOCATE(cstrides)
1323  If (ALLOCATED(ccounts)) DEALLOCATE(ccounts)
1324  If (ALLOCATED(cstart)) DEALLOCATE(cstart)
1325 
1326  End Subroutine ncvggc
1327 !-------------------------------- ncvren --------------------------------------
1328  Subroutine ncvren(ncid, varid, newnam, rcode)
1331 
1332  Implicit NONE
1333 
1334  Character(LEN=*), Intent(IN) :: newnam
1335  Integer, Intent(IN) :: ncid, varid
1336  Integer, Intent(OUT) :: rcode
1337 
1338  Character(LEN=(LEN(newnam)+1)) :: cnewnam
1339  Integer(C_INT) :: cncid, cvarid, crcode
1340  Integer :: ilen
1341 
1342  cncid = ncid
1343  cvarid = varid - 1
1344  rcode = 0
1345 
1346 ! check for a null character on end of newnam
1347 
1348  cnewnam = addcnullchar(newnam, ilen)
1349 
1350  Call c_ncvren(cncid, cvarid, cnewnam(1:ilen), crcode )
1351 
1352  rcode = crcode
1353 
1354  End Subroutine ncvren
1355 !-------------------------------- ncapt ---------------------------------------
1356  Subroutine ncapt(ncid, varid, attnam, attype, attlen, value, rcode)
1359 
1360  Implicit NONE
1361 
1362  Character(LEN=*), Intent(IN) :: attnam
1363  Integer, Intent(IN) :: ncid, varid, attype, attlen
1364  Character(KIND=C_CHAR), Intent(IN), TARGET :: value(*)
1365  Integer, Intent(OUT) :: rcode
1366 
1367  Integer(C_INT) :: cncid, cvarid, cattype, crcode
1368  Integer(C_SIZE_T) :: cattlen
1369  Type(c_ptr) :: cvalueptr
1370  Character(LEN=(LEN(attnam)+1)) :: cattnam
1371  Integer :: ilen
1372 
1373  cncid = ncid
1374  cvarid = varid - 1
1375  cattype = attype
1376  cattlen = attlen
1377  rcode = 0
1378 
1379 ! check for a null character on end of attname
1380 
1381  cattnam = addcnullchar(attnam, ilen)
1382 
1383  cvalueptr = c_loc(value)
1384 
1385  Call c_ncapt(cncid, cvarid, cattnam(1:ilen), cattype, &
1386  cattlen, cvalueptr, crcode )
1387 
1388  rcode = crcode
1389 
1390  End Subroutine ncapt
1391 !-------------------------------- ncaptc ------------------------------------
1392  Subroutine ncaptc(ncid, varid, attnam, attype, lenstr, string, rcode)
1395 
1396  Implicit NONE
1397 
1398  Character(LEN=*), Intent(IN) :: attnam
1399  Integer, Intent(IN) :: ncid, varid, attype, lenstr
1400  Character(LEN=*), Intent(IN) :: string
1401  Integer, Intent(OUT) :: rcode
1402 
1403  Integer(C_INT) :: cncid, cvarid, cattype, crcode
1404  Integer(C_SIZE_T) :: clenstr
1405  Character(LEN=(LEN(attnam)+1)) :: cattnam
1406  Integer :: ilen
1407 
1408  cncid = ncid
1409  cvarid = varid - 1
1410  cattype = attype
1411  clenstr = lenstr
1412  rcode = 0
1413 
1414 ! check for a null character on end of attname
1415 
1416  cattnam = addcnullchar(attnam, ilen)
1417 
1418  Call c_ncaptc(cncid, cvarid, cattnam(1:ilen), cattype, &
1419  clenstr, string, crcode )
1420 
1421  rcode = crcode
1422 
1423  End Subroutine ncaptc
1424 !-------------------------------- ncainq --------------------------------------
1425  Subroutine ncainq(ncid, varid, attnam, attype, attlen, rcode)
1428 
1429  Implicit NONE
1430 
1431  Character(LEN=*), Intent(IN) :: attnam
1432  Integer, Intent(IN) :: ncid, varid
1433  Integer, Intent(OUT) :: attype, attlen, rcode
1434 
1435  Integer(C_INT) :: cncid, cvarid, cattype, crcode, cattlen
1436  Character(LEN=(LEN(attnam)+1)) :: cattnam
1437  Integer :: ilen
1438 
1439  cncid = ncid
1440  cvarid = varid - 1
1441  cattype = 0
1442  cattlen = 0
1443  rcode = 0
1444 
1445 ! check for a null character on end of attnam
1446 
1447  cattnam = addcnullchar(attnam, ilen)
1448 
1449  Call c_ncainq(cncid, cvarid, cattnam(1:ilen), cattype, &
1450  cattlen, crcode )
1451 
1452  attype = cattype
1453  attlen = cattlen
1454  rcode = crcode
1455 
1456  End Subroutine ncainq
1457 !-------------------------------- ncagt ---------------------------------------
1458  Subroutine ncagt(ncid, varid, attnam, values, rcode)
1461 
1462  Implicit NONE
1463 
1464  Character(LEN=*), Intent(IN) :: attnam
1465  Integer, Intent(IN) :: ncid, varid
1466  Character(KIND=C_CHAR), Intent(OUT) :: values(*)
1467  Integer, Intent(OUT) :: rcode
1468 
1469  Integer(C_INT) :: cncid, cvarid, crcode
1470  Character(LEN=(LEN(attnam)+1)) :: cattnam
1471  Integer :: ilen
1472 
1473  cncid = ncid
1474  cvarid = varid - 1
1475  rcode = 0
1476 
1477 ! check for a null character on end of attnam
1478 
1479  cattnam = addcnullchar(attnam, ilen)
1480 
1481  Call c_ncagt(cncid, cvarid, cattnam(1:ilen), values, crcode)
1482 
1483  rcode = crcode
1484 
1485  End Subroutine ncagt
1486 !-------------------------------- ncagtc --------------------------------------
1487  Subroutine ncagtc(ncid, varid, attnam, string, lenstr, rcode)
1490 
1491  Implicit NONE
1492 
1493  Character(LEN=*), Intent(IN) :: attnam
1494  Integer, Intent(IN) :: ncid, varid, lenstr
1495  Character(LEN=*), Intent(INOUT) :: string
1496  Integer, Intent(OUT) :: rcode
1497 
1498  Integer(C_INT) :: cncid, cvarid, crcode
1499  Character(LEN=(LEN(attnam)+1)) :: cattnam
1500  Character(LEN=(lenstr+1)) :: cstring
1501  Integer :: ilen
1502 
1503  cncid = ncid
1504  cvarid = varid - 1
1505  rcode = 0
1506  string = repeat(" ", len(string))
1507  cstring = repeat(" ", len(cstring))
1508 
1509 ! check for a null character on end of attnam
1510 
1511  cattnam = addcnullchar(attnam, ilen)
1512 
1513  Call c_ncagtc(cncid, cvarid, cattnam(1:ilen), cstring, lenstr, &
1514  crcode)
1515 
1516  string(1:lenstr) = cstring(1:lenstr)
1517 
1518  rcode = crcode
1519 
1520  End Subroutine ncagtc
1521 !-------------------------------- ncacpy --------------------------------------
1522  Subroutine ncacpy(ncid, varid, attnam, outcdf, outvar, rcode)
1525 
1526  Implicit NONE
1527 
1528  Character(LEN=*), Intent(IN) :: attnam
1529  Integer, Intent(IN) :: ncid, varid, outcdf, outvar
1530  Integer, Intent(OUT) :: rcode
1531 
1532  Integer(C_INT) :: cncid, cvarid, coutcdf, coutvar, crcode
1533  Character(LEN=(LEN(attnam)+1)) :: cattnam
1534  Integer :: ilen
1535 
1536  cncid = ncid
1537  cvarid = varid - 1
1538  coutcdf = outcdf
1539  coutvar = outvar-1
1540  rcode = 0
1541 
1542 ! check for a null character on end of attnam
1543 
1544  cattnam = addcnullchar(attnam, ilen)
1545 
1546  Call c_ncacpy(cncid, cvarid, cattnam(1:ilen), coutcdf, &
1547  coutvar, crcode)
1548 
1549  rcode = crcode
1550 
1551  End Subroutine ncacpy
1552 !-------------------------------- ncanam --------------------------------------
1553  Subroutine ncanam(ncid, varid, attnum, attnam, rcode)
1557 
1558  Implicit NONE
1559 
1560  Character(LEN=*), Intent(INOUT) :: attnam
1561  Integer, Intent(IN) :: ncid, varid, attnum
1562  Integer, Intent(OUT) :: rcode
1563 
1564  Integer :: ilen
1565  Integer(C_INT) :: cncid, cvarid, cattnum, crcode
1566  Character(LEN=NC_MAX_NAME+1) :: cattnam
1567 
1568  cncid = ncid
1569  cvarid = varid - 1
1570  cattnum = attnum - 1
1571  rcode = 0
1572  cattnam = repeat(" ", len(cattnam))
1573  ilen = len(attnam)
1574 
1575  Call c_ncanam(cncid, cvarid, cattnum, cattnam, crcode)
1576 
1577 ! check for a null character on end of cattnam
1578 
1579  attnam = stripcnullchar(cattnam, ilen)
1580 
1581  rcode = crcode
1582 
1583  End Subroutine ncanam
1584 !-------------------------------- ncaren --------------------------------------
1585  Subroutine ncaren(ncid, varid, attnam, newnam, rcode)
1588 
1589  Implicit NONE
1590 
1591  Character(LEN=*), Intent(IN) :: attnam, newnam
1592  Integer, Intent(IN) :: ncid, varid
1593  Integer, Intent(OUT) :: rcode
1594 
1595  Integer(C_INT) :: cncid, cvarid, crcode
1596  Character(LEN=(LEN(attnam)+1)) :: cattnam
1597  Character(LEN=(LEN(newnam)+1)) :: cnewnam
1598  Integer :: ilen, ilen2
1599 
1600  cncid = ncid
1601  cvarid = varid - 1
1602  rcode = 0
1603 
1604 ! check for a null character on end of attnam and newnam
1605 
1606  cattnam = addcnullchar(attnam, ilen)
1607 
1608  cnewnam = addcnullchar(newnam, ilen2)
1609 
1610  Call c_ncaren(cncid, cvarid, cattnam(1:ilen), cnewnam(1:ilen2+1), crcode)
1611 
1612  rcode = crcode
1613 
1614  End Subroutine ncaren
1615 !-------------------------------- ncadel --------------------------------------
1616  Subroutine ncadel(ncid, varid, attnam, rcode)
1619 
1620  Implicit NONE
1621 
1622  Character(LEN=*), Intent(IN) :: attnam
1623  Integer, Intent(IN) :: ncid, varid
1624  Integer, Intent(OUT) :: rcode
1625 
1626  Integer(C_INT) :: cncid, cvarid, crcode
1627  Character(LEN=(LEN(attnam)+1)) :: cattnam
1628  Integer :: ilen
1629 
1630  cncid = ncid
1631  cvarid = varid - 1
1632  rcode = 0
1633 
1634 ! check for a null character on end of attnam
1635 
1636  cattnam = addcnullchar(attnam, ilen)
1637 
1638  Call c_ncadel(cncid, cvarid, cattnam(1:ilen),crcode)
1639 
1640  rcode = crcode
1641 
1642  End Subroutine ncadel
1643 !-------------------------------- ncsfil --------------------------------------
1644  Function ncsfil(ncid, fillmode, rcode) RESULT(currentmode)
1647 
1648  Implicit NONE
1649 
1650  Integer, Intent(IN) :: ncid, fillmode
1651  Integer, Intent(OUT) :: rcode
1652 
1653  Integer :: currentmode
1654 
1655  Integer(C_INT) :: cncid, cfillmode, crcode, cstatus
1656 
1657  cncid = ncid
1658  cfillmode = fillmode
1659 
1660  cstatus = c_ncsfil(cncid, cfillmode, crcode)
1661  rcode = crcode
1662  currentmode = cstatus
1663 
1664  End Function ncsfil
subroutine ncvgtc(ncid, varid, start, counts, string, lenstr, rcode)
Definition: nf_fortv2.f90:1107
subroutine ncvpt1(ncid, varid, mindex, values, rcode)
Definition: nf_fortv2.f90:584
subroutine ncvgt(ncid, varid, start, counts, values, rcode)
Definition: nf_fortv2.f90:1052
subroutine ncsnc(ncid, rcode)
Definition: nf_fortv2.f90:413
subroutine ncdren(ncid, dimid, dimname, rcode)
Definition: nf_fortv2.f90:489
subroutine ncanam(ncid, varid, attnum, attnam, rcode)
Definition: nf_fortv2.f90:1554
subroutine ncabor(ncid, rcode)
Definition: nf_fortv2.f90:434
subroutine ncendf(ncid, rcode)
Definition: nf_fortv2.f90:356
subroutine ncvpt(ncid, varid, start, counts, values, rcode)
Definition: nf_fortv2.f90:685
subroutine ncacpy(ncid, varid, attnam, outcdf, outvar, rcode)
Definition: nf_fortv2.f90:1523
subroutine convert_v2_imap(cncid, cvarid, fmap, cmap, inullp)
subroutine ncagt(ncid, varid, attnam, values, rcode)
Definition: nf_fortv2.f90:1459
subroutine ncaren(ncid, varid, attnam, newnam, rcode)
Definition: nf_fortv2.f90:1586
subroutine ncvgt1(ncid, varid, mindex, values, rcode)
Definition: nf_fortv2.f90:954
subroutine ncredf(ncid, rcode)
Definition: nf_fortv2.f90:335
subroutine ncadel(ncid, varid, attnam, rcode)
Definition: nf_fortv2.f90:1617
subroutine ncaptc(ncid, varid, attnam, attype, lenstr, string, rcode)
Definition: nf_fortv2.f90:1393
integer function ncvid(ncid, varname, rcode)
Definition: nf_fortv2.f90:255
subroutine ncvren(ncid, varid, newnam, rcode)
Definition: nf_fortv2.f90:1329
subroutine ncvptc(ncid, varid, start, counts, strings, lenstr, rcode)
Definition: nf_fortv2.f90:744
integer(c_int), parameter nc_max_name
subroutine ncclos(ncid, rcode)
Definition: nf_fortv2.f90:314
module procedure interfaces for utility routines
integer function ncsfil(ncid, fillmode, rcode)
Definition: nf_fortv2.f90:1645
subroutine ncvpgc(ncid, varid, start, counts, strides, imap, string, rcode)
Definition: nf_fortv2.f90:880
integer function nccre(filename, cmode, rcode)
Definition: nf_fortv2.f90:74
integer(c_int), parameter nc_noerr
subroutine ncvptg(ncid, varid, start, counts, strides, imap, values, rcode)
Definition: nf_fortv2.f90:802
subroutine ncgopt(ncopts)
Definition: nf_fortv2.f90:56
integer function ncopn(filename, rwmode, rcode)
Definition: nf_fortv2.f90:106
subroutine ncvgtg(ncid, varid, start, counts, strides, imap, values, rcode)
Definition: nf_fortv2.f90:1175
subroutine ncinq(ncid, ndims, nvars, natts, recdim, rcode)
Definition: nf_fortv2.f90:377
integer function ncddef(ncid, dimname, dimlen, rcode)
Definition: nf_fortv2.f90:138
subroutine ncvinq(ncid, varid, varname, vartype, nvdims, vdims, nvatts, rcode)
Definition: nf_fortv2.f90:519
subroutine ncvp1c(ncid, varid, mindex, strings, rcode)
Definition: nf_fortv2.f90:636
subroutine ncpopt(ncopts)
Definition: nf_fortv2.f90:40
subroutine ncagtc(ncid, varid, attnam, string, lenstr, rcode)
Definition: nf_fortv2.f90:1488
subroutine ncapt(ncid, varid, attnam, attype, attlen, value, rcode)
Definition: nf_fortv2.f90:1357
subroutine ncvggc(ncid, varid, start, counts, strides, imap, string, rcode)
Definition: nf_fortv2.f90:1247
integer function nctlen(datatype, rcode)
Definition: nf_fortv2.f90:288
subroutine ncdinq(ncid, dimid, dimname, dimlen, rcode)
Definition: nf_fortv2.f90:455
subroutine ncvg1c(ncid, varid, mindex, string, rcode)
Definition: nf_fortv2.f90:1003
integer function ncvdef(ncid, varname, vartype, nvdims, vdims, rcode)
Definition: nf_fortv2.f90:203
subroutine ncainq(ncid, varid, attnam, attype, attlen, rcode)
Definition: nf_fortv2.f90:1426
integer function ncdid(ncid, dimname, rcode)
Definition: nf_fortv2.f90:171

Return to the Main Unidata NetCDF page.
Generated on Thu Nov 9 2017 06:56:52 for NetCDF-Fortran. NetCDF is a Unidata library.