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