@@ -136,6 +136,8 @@ program mlff_select
136136logical :: eval_stat(10 ) ! the progress for evaluation loops
137137logical :: no_adf ! if no angular distribution functions shall be calculated
138138logical ,allocatable :: atom_used(:) ! boolean mask for blocking of treated atoms
139+ integer :: alloc_stat ! if allocation of array was successful
140+ character (len= 100 ):: alloc_err ! the error message for failed allocation
139141! for time measurement
140142character (8 ) :: date
141143character (10 ) :: time
@@ -1036,9 +1038,20 @@ program mlff_select
10361038allocate (el_nums_confs(nelems_glob,conf_num))
10371039allocate (el_nums_tmp(nelems_glob))
10381040! The geometries (cartesian coordinates)
1039- allocate (xyz(3 ,natoms_max,conf_num))
1041+ allocate (xyz(3 ,natoms_max,conf_num),stat= alloc_stat,errmsg= alloc_err)
1042+ if (alloc_stat .ne. 0 ) then
1043+ write (* ,* ) " Allocation of xyz array failed:" ,trim (alloc_err)
1044+ write (* ,* ) " Please read in a smaller ML_AB or increase memory!"
1045+ stop
1046+ end if
10401047! The geometries (direct coordinates
1041- allocate (xyz_dir(3 ,natoms_max,conf_num))
1048+ allocate (xyz_dir(3 ,natoms_max,conf_num),stat= alloc_stat,errmsg= alloc_err)
1049+ if (alloc_stat .ne. 0 ) then
1050+ write (* ,* ) " Allocation of xyz_dir array failed:" ,trim (alloc_err)
1051+ write (* ,* ) " Please read in a smaller ML_AB or increase memory!"
1052+ stop
1053+ end if
1054+
10421055! The unit cell shapes
10431056allocate (cells(3 ,3 ,conf_num))
10441057! The CTIFOR values
@@ -1048,7 +1061,13 @@ program mlff_select
10481061! The reference energies
10491062allocate (energies(conf_num))
10501063! The reference gradients
1051- allocate (grads(3 ,natoms_max,conf_num))
1064+ allocate (grads(3 ,natoms_max,conf_num),stat= alloc_stat,errmsg= alloc_err)
1065+ if (alloc_stat .ne. 0 ) then
1066+ write (* ,* ) " Allocation of grads array failed:" ,trim (alloc_err)
1067+ write (* ,* ) " Please read in a smaller ML_AB or increase memory!"
1068+ stop
1069+ end if
1070+
10521071! The reference stress tensors
10531072allocate (stress(6 ,conf_num))
10541073
@@ -1057,7 +1076,13 @@ program mlff_select
10571076!
10581077! Again open the ML_AB file
10591078!
1060- open (unit= 56 ,file= mlab_list(l),status= " old" )
1079+ open (unit= 56 ,file= mlab_list(l),status= " old" ,iostat= readstat)
1080+ if (readstat .ne. 0 ) then
1081+ write (* ,* )
1082+ write (* ,* ) " The file " ,trim (mlab_list(l))," is not there!"
1083+ write (* ,* )
1084+ stop
1085+ end if
10611086
10621087 write (* ,* ) " Read body of the file " ,trim (mlab_list(l))," ..."
10631088 write (34 ,* ) " Read body of the file " ,trim (mlab_list(l))," ..."
@@ -1302,17 +1327,43 @@ program mlff_select
13021327allocate (gradnorm_all(natoms_sum))
13031328! The number of atoms in the surrounding (sorted by core charges)
13041329allocate (num_around(nelems,natoms_sum))
1330+ allocate (num_around(nelems,natoms_sum),stat= alloc_stat,errmsg= alloc_err)
1331+ if (alloc_stat .ne. 0 ) then
1332+ write (* ,* ) " Allocation of num_around array failed:" ,trim (alloc_err)
1333+ write (* ,* ) " Please read in a smaller ML_AB or increase memory!"
1334+ stop
1335+ end if
13051336! The coordinates of atoms in the surrounding (for xyz printout)
1306- allocate (environ(3 ,max_environ,natoms_sum))
1337+ allocate (environ(3 ,max_environ,natoms_sum),stat= alloc_stat,errmsg= alloc_err)
1338+ if (alloc_stat .ne. 0 ) then
1339+ write (* ,* ) " Allocation of environ array failed:" ,trim (alloc_err)
1340+ write (* ,* ) " Please read in a smaller ML_AB or increase memory!"
1341+ stop
1342+ end if
13071343! The core charges/elements of atoms in surrounding
1308- allocate (ind_env(max_environ,natoms_sum))
1344+ allocate (ind_env(max_environ,natoms_sum),stat= alloc_stat,errmsg= alloc_err)
1345+ if (alloc_stat .ne. 0 ) then
1346+ write (* ,* ) " Allocation of ind_env array failed:" ,trim (alloc_err)
1347+ write (* ,* ) " Please read in a smaller ML_AB or increase memory!"
1348+ stop
1349+ end if
13091350! The list of distances to atoms within surrounding (local)
13101351allocate (dist_list(max_environ))
13111352! The radial distribution functions around all atoms
1312- allocate (rdf_all(ngrid,natoms_sum))
1353+ allocate (rdf_all(ngrid,natoms_sum),stat= alloc_stat,errmsg= alloc_err)
1354+ if (alloc_stat .ne. 0 ) then
1355+ write (* ,* ) " Allocation of rdf_all array failed:" ,trim (alloc_err)
1356+ write (* ,* ) " Please read in a smaller ML_AB or increase memory!"
1357+ stop
1358+ end if
13131359! The angular distribution functions around all atoms
13141360if (.not. no_adf) then
1315- allocate (adf_all(ngrid,natoms_sum))
1361+ allocate (adf_all(ngrid,natoms_sum),stat= alloc_stat,errmsg= alloc_err)
1362+ if (alloc_stat .ne. 0 ) then
1363+ write (* ,* ) " Allocation of adf_all array failed:" ,trim (alloc_err)
1364+ write (* ,* ) " Please read in a smaller ML_AB or increase memory!"
1365+ stop
1366+ end if
13161367end if
13171368! The local list of angles in the environment
13181369allocate (angles(max_environ* max_environ))
0 commit comments