anchor.diff:       ! read nvars
        call parse_next_line(unt, line, parsed_line, nfields, err)
        if (err < 0) then
  +        write(0,*) "ERROR: invalid formatted input file"
  +        stop
  +     end if
  +     read(parsed_line, *, iostat=err) nvars
  +     if (err < 0) then
  +        write(0,*) "check n. of features"
  +        stop
  +     end if
  +
  +     ! read nclasses
  +     call parse_next_line(unt, line, parsed_line, nfields, err)
  +     if (err < 0) then
           write(0,*) "input file can be converted to a valid checkpoint file"
           stop
        end if
  -     read(parsed_line, *, iostat=err) nvars
  -     if (err < 0) then
  -        write(0,*) "check n. of features"
  -        stop
  -     end if
  -
  -     ! read nclasses
  +     read(parsed_line, *, iostat=err) nclasses
  +     if (err < 0) then
  +        write(0,*) "check n. of classes"
  +        stop
  +     end if
  +
  +     ! read data type
        call parse_next_line(unt, line, parsed_line, nfields, err)
        if (err < 0) then
           write(0,*) "input file can be converted to a valid checkpoint file"
           stop
        end if
  -     read(parsed_line, *, iostat=err) nclasses
  -     if (err < 0) then
  -        write(0,*) "check n. of classes"
  -        stop
  -     end if
  -
  -     ! read data type
  +     read(parsed_line, *, iostat=err) data_type
  +     if (err < 0) then
  +        write(0,*) "check output data type format"
  +        stop
  +     end if
  +
  +     ! read ndata
        call parse_next_line(unt, line, parsed_line, nfields, err)
        if (err < 0) then
           write(0,*) "input file can be converted to a valid checkpoint file"
           stop
        end if
  -     read(parsed_line, *, iostat=err) data_type
  -     if (err < 0) then
  -        write(0,*) "check output data type format"
  -        stop
  -     end if
  -
  -     ! read ndata
  -     call parse_next_line(unt, line, parsed_line, nfields, err)
  -     if (err < 0) then
  -        write(0,*) "input file can be converted to a valid checkpoint file"
  -        stop
  -     end if
        read(parsed_line, *, iostat=err) ndata
        if (err < 0) then
           write(0,*) "check n. of samples in .chk file"
           stop
        end if
  -     
  +
        ! if the first lines are ok, allocate
        allocate(prm(nvars*nclasses + nvars*(nvars - 1)*nclasses**2/2),stat=err)
        prm = 0.0_kflt
  
positive.code:         if (flag == 0) then
             flag = 2
          else
             write(0,*) "either -u <unformatted_file > or -f <formatted_file> option"
             stop
          end if
          iarg = iarg + 1
          call read_opt_arg(iarg,nargs,source,err)
          if (err == 2) then
             write(0,*) 'ERROR ! missing argument: '//trim(arg)//' <filename>'
             stop
          end if
       case('-d', '--digits')
  
negative.code:            k = nvars * nclasses + (k - 1) * nclasses**2
             read(parsed_line, *) jv, iv, prm(k + 1 : k + nclasses**2)
          else
             write(0,*) "invalid checkpoint file"
             stop
          end if
       end do
       close(unt)
  