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