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