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

Return to the Main Unidata NetCDF page.
Generated on Sun Dec 27 2015 13:19:49 for NetCDF-Fortran. NetCDF is a Unidata library.