1c4762a1bSJed Brown 2c4762a1bSJed Brown static char help[] = "Demonstrates PetscFileRetrieve().\n\n"; 3c4762a1bSJed Brown 4c4762a1bSJed Brown #include <petscsys.h> 5c4762a1bSJed Brown int main(int argc,char **argv) 6c4762a1bSJed Brown { 7c4762a1bSJed Brown PetscBool found; 8c4762a1bSJed Brown char localname[PETSC_MAX_PATH_LEN]; 9c4762a1bSJed Brown const char url[] = "https://www.mcs.anl.gov/petsc/index.html"; 10c4762a1bSJed Brown 11c4762a1bSJed Brown /* 12c4762a1bSJed Brown Every PETSc routine should begin with the PetscInitialize() routine. 13c4762a1bSJed Brown argc, argv - These command line arguments are taken to extract the options 14c4762a1bSJed Brown supplied to PETSc and options supplied to MPI. 15c4762a1bSJed Brown help - When PETSc executable is invoked with the option -help, 16c4762a1bSJed Brown it prints the various options that can be applied at 17c4762a1bSJed Brown runtime. The user can use the "help" variable place 18c4762a1bSJed Brown additional help messages in this printout. 19c4762a1bSJed Brown */ 20*327415f7SBarry Smith PetscFunctionBeginUser; 219566063dSJacob Faibussowitsch PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); 229566063dSJacob Faibussowitsch PetscCall(PetscFileRetrieve(PETSC_COMM_WORLD,url,localname,PETSC_MAX_PATH_LEN,&found)); 23c4762a1bSJed Brown if (found) { 249566063dSJacob Faibussowitsch PetscCall(PetscPrintf(PETSC_COMM_WORLD,"Successfully download file %s\n",localname)); 2598921bdaSJacob Faibussowitsch } else SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_PLIB,"Unable to download url %s",url); 26c4762a1bSJed Brown 279566063dSJacob Faibussowitsch PetscCall(PetscFinalize()); 28b122ec5aSJacob Faibussowitsch return 0; 29c4762a1bSJed Brown } 30c4762a1bSJed Brown 31c4762a1bSJed Brown /*TEST 32c4762a1bSJed Brown 33c4762a1bSJed Brown test: 34dfd57a17SPierre Jolivet requires: defined(PETSC_HAVE_POPEN) 35c4762a1bSJed Brown 36c4762a1bSJed Brown TEST*/ 37