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