xref: /petsc/src/dm/interface/ftn-custom/zdmf.c (revision d49bb8f946631d5470c2a737c5ecfe1ed81df0b7)
1af0996ceSBarry Smith #include <petsc/private/fortranimpl.h>
2c6db04a5SJed Brown #include <petscdm.h>
3665c2dedSJed Brown #include <petscviewer.h>
49a42bb27SBarry Smith 
59a42bb27SBarry Smith #if defined(PETSC_HAVE_FORTRAN_CAPS)
624e7ded0SBarry Smith #define dmview_                      DMVIEW
75b400853SJed Brown #define dmsetoptionsprefix_          DMSETOPTIONSPREFIX
818fb3ae4SVincent Le Chenadec #define dmsettype_                   DMSETTYPE
918fb3ae4SVincent Le Chenadec #define dmgettype_                   DMGETTYPE
10b412c318SBarry Smith #define dmsetmattype_                DMSETMATTYPE
11b412c318SBarry Smith #define dmsetvectype_                DMSETVECTYPE
12c0dedaeaSBarry Smith #define dmgetmattype_                DMGETMATTYPE
13c0dedaeaSBarry Smith #define dmgetvectype_                DMGETVECTYPE
14c58f1c22SToby Isaac #define dmlabelview_                 DMLABELVIEW
15c58f1c22SToby Isaac #define dmcreatelabel_               DMCREATELABEL
16c58f1c22SToby Isaac #define dmhaslabel_                  DMHASLABEL
17c58f1c22SToby Isaac #define dmgetlabelvalue_             DMGETLABELVALUE
18c58f1c22SToby Isaac #define dmsetlabelvalue_             DMSETLABELVALUE
19c58f1c22SToby Isaac #define dmgetlabelsize_              DMGETLABELSIZE
20c58f1c22SToby Isaac #define dmgetlabelidis_              DMGETLABELIDIS
21a7631e77SMatthew G. Knepley #define dmgetlabelname_              DMGETLABELNAME
22c58f1c22SToby Isaac #define dmgetlabel_                  DMGETLABEL
23c58f1c22SToby Isaac #define dmgetstratumsize_            DMGETSTRATUMSIZE
24c58f1c22SToby Isaac #define dmgetstratumis_              DMGETSTRATUMIS
254de306b1SToby Isaac #define dmsetstratumis_              DMSETSTRATUMIS
26d7188716SSatish Balay #define dmremovelabel_               DMREMOVELABEL
279a42bb27SBarry Smith #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
2824e7ded0SBarry Smith #define dmview_                      dmview
295b400853SJed Brown #define dmsetoptionsprefix_          dmsetoptionsprefix
3018fb3ae4SVincent Le Chenadec #define dmsettype_                   dmsettype
3118fb3ae4SVincent Le Chenadec #define dmgettype_                   dmgettype
32b412c318SBarry Smith #define dmsetmattype_                dmsetmattype
33b412c318SBarry Smith #define dmsetvectype_                dmsetvectype
34c0dedaeaSBarry Smith #define dmgetmattype_                dmgetmattype
35c0dedaeaSBarry Smith #define dmgetvectype_                dmgetvectype
36c58f1c22SToby Isaac #define dmlabelview_                 dmlabelview
37c58f1c22SToby Isaac #define dmcreatelabel_               dmcreatelabel
38c58f1c22SToby Isaac #define dmhaslabel_                  dmhaslabel
39c58f1c22SToby Isaac #define dmgetlabelvalue_             dmgetlabelvalue
40c58f1c22SToby Isaac #define dmsetlabelvalue_             dmsetlabelvalue
41c58f1c22SToby Isaac #define dmgetlabelsize_              dmlabelsize
42c58f1c22SToby Isaac #define dmgetlabelidis_              dmlabelidis
43a7631e77SMatthew G. Knepley #define dmgetlabelname_              dmgetlabelname
44c58f1c22SToby Isaac #define dmgetlabel_                  dmgetlabel
45c58f1c22SToby Isaac #define dmgetstratumsize_            dmgetstratumsize
46c58f1c22SToby Isaac #define dmgetstratumis_              dmgetstratumis
474de306b1SToby Isaac #define dmsetstratumis_              dmsetstratumis
48d7188716SSatish Balay #define dmremovelabel_               dmremovelabel
499a42bb27SBarry Smith #endif
509a42bb27SBarry Smith 
51390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgetmattype_(DM *mm,char* name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
52c0dedaeaSBarry Smith {
53c0dedaeaSBarry Smith   const char *tname;
54c0dedaeaSBarry Smith 
55c0dedaeaSBarry Smith   *ierr = DMGetMatType(*mm,&tname);if (*ierr) return;
56c0dedaeaSBarry Smith   if (name != PETSC_NULL_CHARACTER_Fortran) {
57c0dedaeaSBarry Smith     *ierr = PetscStrncpy(name,tname,len);if (*ierr) return;
58c0dedaeaSBarry Smith   }
59c0dedaeaSBarry Smith   FIXRETURNCHAR(PETSC_TRUE,name,len);
60c0dedaeaSBarry Smith }
61c0dedaeaSBarry Smith 
62390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgetvectype_(DM *mm,char* name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
63c0dedaeaSBarry Smith {
64c0dedaeaSBarry Smith   const char *tname;
65c0dedaeaSBarry Smith 
66c0dedaeaSBarry Smith   *ierr = DMGetVecType(*mm,&tname);if (*ierr) return;
67c0dedaeaSBarry Smith   if (name != PETSC_NULL_CHARACTER_Fortran) {
68c0dedaeaSBarry Smith     *ierr = PetscStrncpy(name,tname,len);if (*ierr) return;
69c0dedaeaSBarry Smith   }
70c0dedaeaSBarry Smith   FIXRETURNCHAR(PETSC_TRUE,name,len);
71c0dedaeaSBarry Smith }
72c0dedaeaSBarry Smith 
738cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL dmview_(DM *da,PetscViewer *vin,PetscErrorCode *ierr)
749a42bb27SBarry Smith {
759a42bb27SBarry Smith   PetscViewer v;
769a42bb27SBarry Smith   PetscPatchDefaultViewers_Fortran(vin,v);
779a42bb27SBarry Smith   *ierr = DMView(*da,v);
789a42bb27SBarry Smith }
79950540a4SJed Brown 
80390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmsetoptionsprefix_(DM *dm,char* prefix PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
815b400853SJed Brown {
825b400853SJed Brown   char *t;
835b400853SJed Brown 
845b400853SJed Brown   FIXCHAR(prefix,len,t);
85*d49bb8f9SBarry Smith   *ierr = DMSetOptionsPrefix(*dm,t);if (*ierr) return;
865b400853SJed Brown   FREECHAR(prefix,t);
875b400853SJed Brown }
88b412c318SBarry Smith 
89390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmsettype_(DM *x,char* type_name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
9018fb3ae4SVincent Le Chenadec {
9118fb3ae4SVincent Le Chenadec   char *t;
9218fb3ae4SVincent Le Chenadec 
9318fb3ae4SVincent Le Chenadec   FIXCHAR(type_name,len,t);
94*d49bb8f9SBarry Smith   *ierr = DMSetType(*x,t);if (*ierr) return;
9518fb3ae4SVincent Le Chenadec   FREECHAR(type_name,t);
9618fb3ae4SVincent Le Chenadec }
9718fb3ae4SVincent Le Chenadec 
98390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgettype_(DM *mm,char* name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
9918fb3ae4SVincent Le Chenadec {
10018fb3ae4SVincent Le Chenadec   const char *tname;
10118fb3ae4SVincent Le Chenadec 
10218fb3ae4SVincent Le Chenadec   *ierr = DMGetType(*mm,&tname);if (*ierr) return;
10318fb3ae4SVincent Le Chenadec   if (name != PETSC_NULL_CHARACTER_Fortran) {
10418fb3ae4SVincent Le Chenadec     *ierr = PetscStrncpy(name,tname,len);if (*ierr) return;
10518fb3ae4SVincent Le Chenadec   }
10618fb3ae4SVincent Le Chenadec   FIXRETURNCHAR(PETSC_TRUE,name,len);
10718fb3ae4SVincent Le Chenadec 
10818fb3ae4SVincent Le Chenadec }
10918fb3ae4SVincent Le Chenadec 
110390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmsetmattype_(DM *dm,char* prefix PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
111b412c318SBarry Smith {
112b412c318SBarry Smith   char *t;
113b412c318SBarry Smith 
114b412c318SBarry Smith   FIXCHAR(prefix,len,t);
115*d49bb8f9SBarry Smith   *ierr = DMSetMatType(*dm,t);if (*ierr) return;
116b412c318SBarry Smith   FREECHAR(prefix,t);
117b412c318SBarry Smith }
118b412c318SBarry Smith 
119b412c318SBarry Smith 
120390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmsetvectype_(DM *dm,char* prefix PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
121b412c318SBarry Smith {
122b412c318SBarry Smith   char *t;
123b412c318SBarry Smith 
124b412c318SBarry Smith   FIXCHAR(prefix,len,t);
125*d49bb8f9SBarry Smith   *ierr = DMSetVecType(*dm,t);if (*ierr) return;
126b412c318SBarry Smith   FREECHAR(prefix,t);
127b412c318SBarry Smith }
128c58f1c22SToby Isaac 
129390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmcreatelabel_(DM *dm, char* name PETSC_MIXED_LEN(lenN), int *ierr PETSC_END_LEN(lenN))
130c58f1c22SToby Isaac {
131c58f1c22SToby Isaac   char *lname;
132c58f1c22SToby Isaac 
133c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
134*d49bb8f9SBarry Smith   *ierr = DMCreateLabel(*dm, lname);if (*ierr) return;
135c58f1c22SToby Isaac   FREECHAR(name, lname);
136c58f1c22SToby Isaac }
137c58f1c22SToby Isaac 
138390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmhaslabel_(DM *dm, char* name PETSC_MIXED_LEN(lenN), PetscBool *hasLabel, int *ierr PETSC_END_LEN(lenN))
139c58f1c22SToby Isaac {
140c58f1c22SToby Isaac   char *lname;
141c58f1c22SToby Isaac 
142c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
143*d49bb8f9SBarry Smith   *ierr = DMHasLabel(*dm, lname, hasLabel);if (*ierr) return;
144c58f1c22SToby Isaac   FREECHAR(name, lname);
145c58f1c22SToby Isaac }
146c58f1c22SToby Isaac 
147390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgetlabelvalue_(DM *dm, char* name PETSC_MIXED_LEN(lenN), PetscInt *point, PetscInt *value, int *ierr PETSC_END_LEN(lenN))
148c58f1c22SToby Isaac {
149c58f1c22SToby Isaac   char *lname;
150c58f1c22SToby Isaac 
151c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
152*d49bb8f9SBarry Smith   *ierr = DMGetLabelValue(*dm, lname, *point, value);if (*ierr) return;
153c58f1c22SToby Isaac   FREECHAR(name, lname);
154c58f1c22SToby Isaac }
155c58f1c22SToby Isaac 
156390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmsetlabelvalue_(DM *dm, char* name PETSC_MIXED_LEN(lenN), PetscInt *point, PetscInt *value, int *ierr PETSC_END_LEN(lenN))
157c58f1c22SToby Isaac {
158c58f1c22SToby Isaac   char *lname;
159c58f1c22SToby Isaac 
160c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
161*d49bb8f9SBarry Smith   *ierr = DMSetLabelValue(*dm, lname, *point, *value);if (*ierr) return;
162c58f1c22SToby Isaac   FREECHAR(name, lname);
163c58f1c22SToby Isaac }
164c58f1c22SToby Isaac 
165390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgetlabelsize_(DM *dm, char* name PETSC_MIXED_LEN(lenN), PetscInt *size, int *ierr PETSC_END_LEN(lenN))
166c58f1c22SToby Isaac {
167c58f1c22SToby Isaac   char *lname;
168c58f1c22SToby Isaac 
169c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
170*d49bb8f9SBarry Smith   *ierr = DMGetLabelSize(*dm, lname, size);if (*ierr) return;
171c58f1c22SToby Isaac   FREECHAR(name, lname);
172c58f1c22SToby Isaac }
173c58f1c22SToby Isaac 
174390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgetlabelidis_(DM *dm, char* name PETSC_MIXED_LEN(lenN), IS *ids, int *ierr PETSC_END_LEN(lenN))
175c58f1c22SToby Isaac {
176c58f1c22SToby Isaac   char *lname;
177c58f1c22SToby Isaac 
178c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
179*d49bb8f9SBarry Smith   *ierr = DMGetLabelIdIS(*dm, lname, ids);if (*ierr) return;
180c58f1c22SToby Isaac   FREECHAR(name, lname);
181c58f1c22SToby Isaac }
182c58f1c22SToby Isaac 
1839566978fSMatthew G. Knepley PETSC_EXTERN void PETSC_STDCALL dmgetlabelname_(DM *dm,PetscInt *n,char* name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
184a7631e77SMatthew G. Knepley {
185a7631e77SMatthew G. Knepley   const char *tmp;
1869566978fSMatthew G. Knepley   *ierr = DMGetLabelName(*dm,*n,&tmp);
187a7631e77SMatthew G. Knepley   *ierr = PetscStrncpy(name,tmp,len);if (*ierr) return;
188a7631e77SMatthew G. Knepley   FIXRETURNCHAR(PETSC_TRUE,name,len);
189a7631e77SMatthew G. Knepley }
190a7631e77SMatthew G. Knepley 
191390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgetlabel_(DM *dm, char* name PETSC_MIXED_LEN(lenN), DMLabel *label, int *ierr PETSC_END_LEN(lenN))
192c58f1c22SToby Isaac {
193c58f1c22SToby Isaac   char *lname;
194c58f1c22SToby Isaac 
195c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
196*d49bb8f9SBarry Smith   *ierr = DMGetLabel(*dm, lname, label);if (*ierr) return;
197c58f1c22SToby Isaac   FREECHAR(name, lname);
198c58f1c22SToby Isaac }
199c58f1c22SToby Isaac 
200390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgetstratumsize_(DM *dm, char* name PETSC_MIXED_LEN(lenN), PetscInt *value, PetscInt *size, int *ierr PETSC_END_LEN(lenN))
201c58f1c22SToby Isaac {
202c58f1c22SToby Isaac   char *lname;
203c58f1c22SToby Isaac 
204c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
205*d49bb8f9SBarry Smith   *ierr = DMGetStratumSize(*dm, lname, *value, size);if (*ierr) return;
206c58f1c22SToby Isaac   FREECHAR(name, lname);
207c58f1c22SToby Isaac }
208c58f1c22SToby Isaac 
209390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmgetstratumis_(DM *dm, char* name PETSC_MIXED_LEN(lenN), PetscInt *value, IS *is, int *ierr PETSC_END_LEN(lenN))
210c58f1c22SToby Isaac {
211c58f1c22SToby Isaac   char *lname;
212c58f1c22SToby Isaac 
213c58f1c22SToby Isaac   FIXCHAR(name, lenN, lname);
214*d49bb8f9SBarry Smith   *ierr = DMGetStratumIS(*dm, lname, *value, is);if (*ierr) return;
21506c2e117SBarry Smith   if (is && !*is) *is = (IS)0;
216c58f1c22SToby Isaac   FREECHAR(name, lname);
217c58f1c22SToby Isaac }
218d7188716SSatish Balay 
219390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmsetstratumis_(DM *dm, char* name PETSC_MIXED_LEN(lenN), PetscInt *value, IS *is, int *ierr PETSC_END_LEN(lenN))
2204de306b1SToby Isaac {
2214de306b1SToby Isaac   char *lname;
2224de306b1SToby Isaac 
2234de306b1SToby Isaac   FIXCHAR(name, lenN, lname);
224*d49bb8f9SBarry Smith   *ierr = DMSetStratumIS(*dm, lname, *value, *is);if (*ierr) return;
2254de306b1SToby Isaac   FREECHAR(name, lname);
2264de306b1SToby Isaac }
2274de306b1SToby Isaac 
228390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL dmremovelabel_(DM *dm, char* name PETSC_MIXED_LEN(lenN), DMLabel *label, int *ierr PETSC_END_LEN(lenN))
229d7188716SSatish Balay {
230d7188716SSatish Balay   char *lname;
231d7188716SSatish Balay 
232d7188716SSatish Balay   FIXCHAR(name, lenN, lname);
233*d49bb8f9SBarry Smith   *ierr = DMRemoveLabel(*dm, lname, label);if (*ierr) return;
234d7188716SSatish Balay   FREECHAR(name, lname);
235d7188716SSatish Balay }
236