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