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