xref: /petsc/src/sys/tests/ex51.c (revision 57d508425293f0bb93f59574d14951d8faac9af8)
1 static char help[] = "Demonstrates PetscFileRetrieve().\n\n";
2 
3 #include <petscsys.h>
4 int main(int argc, char **argv)
5 {
6   PetscBool  found;
7   char       localname[PETSC_MAX_PATH_LEN];
8   const char url[] = "https://web.cels.anl.gov/projects/petsc/download/datafiles/matrices/tiny";
9 
10   /*
11     Every PETSc routine should begin with the PetscInitialize() routine.
12     argc, argv - These command line arguments are taken to extract the options
13                  supplied to PETSc and options supplied to MPI.
14     help       - When PETSc executable is invoked with the option -help,
15                  it prints the various options that can be applied at
16                  runtime.  The user can use the "help" variable place
17                  additional help messages in this printout.
18   */
19   PetscFunctionBeginUser;
20   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
21   PetscCall(PetscFileRetrieve(PETSC_COMM_WORLD, url, localname, PETSC_MAX_PATH_LEN, &found));
22   PetscCheck(found, PETSC_COMM_WORLD, PETSC_ERR_PLIB, "Unable to download url %s", url);
23   PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Successfully download file %s\n", localname));
24 
25   PetscCall(PetscFinalize());
26   return 0;
27 }
28 
29 /*TEST
30 
31    test:
32      requires: defined(PETSC_HAVE_POPEN)
33 
34 TEST*/
35