1! --- 2! Copyright (C) 1996-2016 The SIESTA group 3! This file is distributed under the terms of the 4! GNU General Public License: see COPYING in the top directory 5! or http://www.gnu.org/copyleft/gpl.txt . 6! See Docs/Contributors.txt for a list of contributors. 7! --- 8program simple 9 10! A very simple driver for Siesta-as-subroutine (or siesta-as-server) 11! This version uses MPI and siesta as a subroutine. It must be compiled 12! together with siesta. 13 14 use mpi 15 use fsiesta 16 17 implicit none 18 integer,parameter:: dp = kind(1.d0) 19 20 integer,parameter :: na = 3 21 integer :: error, ia, myNode=0 22 real(dp):: e, fa(3,na), xa(3,na) 23 24 data xa / 0.0, 0.0, 0.0, & 25 0.7, 0.7, 0.0, & 26 -0.7, 0.7, 0.0 / 27 28! Initialize MPI and get my node's index 29 call MPI_Init( error ) 30 call MPI_Comm_Rank( MPI_Comm_World, myNode, error ) 31 32! Set physical units 33 call siesta_units( 'Ang', 'eV' ) 34 35! Launch a siesta process using all available MPI processes 36 call siesta_launch( 'h2o' ) 37 if (myNode==0) print*, 'siesta launched' 38 39! Find forces 40 call siesta_forces( 'h2o', na, xa, energy=e, fa=fa ) 41 if (myNode==0) & 42 print'(/,a,/,(3f12.6,3x,3f12.6))', 'xa, fa =', (xa(:,ia),fa(:,ia),ia=1,na) 43 44! Find forces for another geometry 45 xa(1,1) = 0.1 46 call siesta_forces( 'h2o', na, xa, energy=e, fa=fa ) 47 if (myNode==0) & 48 print'(/,a,/,(3f12.6,3x,3f12.6))', 'xa, fa =', (xa(:,ia),fa(:,ia),ia=1,na) 49 50! Quit siesta process 51 call siesta_quit( 'h2o' ) 52 53! Finalize MPI 54 call MPI_Finalize( error ) 55 56end program simple 57 58