xref: /petsc/src/sys/tests/ex51.c (revision 030f984af8d8bb4c203755d35bded3c05b3d83ce)
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   PetscErrorCode ierr;
14   PetscBool      found;
15   char           localname[PETSC_MAX_PATH_LEN];
16   const char     url[] = "https://www.mcs.anl.gov/petsc/index.html";
17 
18   /*
19     Every PETSc routine should begin with the PetscInitialize() routine.
20     argc, argv - These command line arguments are taken to extract the options
21                  supplied to PETSc and options supplied to MPI.
22     help       - When PETSc executable is invoked with the option -help,
23                  it prints the various options that can be applied at
24                  runtime.  The user can use the "help" variable place
25                  additional help messages in this printout.
26   */
27   ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
28   ierr = PetscFileRetrieve(PETSC_COMM_WORLD,url,localname,PETSC_MAX_PATH_LEN,&found);CHKERRQ(ierr);
29   if (found) {
30     ierr = PetscPrintf(PETSC_COMM_WORLD,"Successfully download file %s\n",localname);CHKERRQ(ierr);
31   } else SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_PLIB,"Unable to download url %s\n",url);
32 
33   ierr = PetscFinalize();
34   return ierr;
35 }
36 
37 /*TEST
38 
39    test:
40      requires: define(PETSC_HAVE_POPEN)
41 
42 TEST*/
43