CNS errors before/after recompilation

Dear Eiso,

Where did you edit the MXRTP ?. Could you please let me know file name and location ?

Thanking you !

in rtf.inc in the source directory

1 Like

Thanks you Dr. Alexandre Bonvin, , finally it is working after i did four modifications ! I hope it will be helpful to someone :slight_smile:

first modification
set MXFPEPS2 value to 8192 in machvar.inc

second modification
removed flag -fastm in make file

third modification
MXRTP to 4000 in rtf.inc in the source directory

fourth modification

add the below line in the machvar.f
WRITE (6,’(I6,E10.3,E10.3)’) I, ONEP, ONEM
just above line 67, which looks like this:
IF (ONE .EQ. ONEP .OR. ONE .EQ. ONEM) THEN

These are two unrelated errors:

What @eiso was dealing with is a problem of the number of parameters and the ‘dynamic’ memory allocation of CNS.

What @srinivas_penumutchu found happens quite often in Mac OSX and for some reason is only solved with the solution you posted, which just adds a print statement… This will add a bunch of unnecessary output to the CNS initialization headers though… Would be great if someone with more FORTRAN skills could take a look at it!

Suggestion for a proper solution to this problem:

Replace the SETFPEPS subroutine as follows

C ==========================================================================
C
SUBROUTINE SETFPEPS
C
IMPLICIT NONE
C I/O
INCLUDE ‘numbers.inc’
INCLUDE ‘machvar.inc’
C
C Determine the machine epsilon i.e. the smallest FPEPS such that both
C 1+FPEPS and 1-FPEPS are different from 1.
C
C local
DOUBLE PRECISION ONEDP
DOUBLE COMPLEX DBCOMP
C
C external
C NONE
C
C begin
C
C ONEDP doesn’t really need to be defined - EPSILON() only needs to know
C the type
ONEDP=(1.00)
FPEPS = EPSILON(ONEDP)
DBCOMP = DCMPLX(ZERO,ZERO)
CALL DECLAR(‘FP_EPSILON’, ‘DP’, ’ ', DBCOMP, FPEPS)
RETURN
END

Thanks Brian - is this generic for any OS? Or OSX-specific?

Hi Alexandre,

This should be a generic solution. I see the issue on LINUX (CentOS 7) with gcc 4.8.5.

Brian

Hi Srinivas sir,
Can you please explain how to remove flag -fastm in the makefile?

After replacing subrotines in machvar.f file
and then recompile cns_solve
shows error:

make[3]: Target '../bin/cns_solve' not remade because of errors.
Makefile:58: recipe for target 'cns_solve' failed
make[2]: *** [cns_solve] Error 2
Makefile:64: recipe for target 'cns_solve' failed
make[1]: *** [cns_solve] Error 2

Garima,
We need to see more of the compiler log to see what your error might be.

After compiling CNS with make install and then source cns_solve_env after entering into C-shell tcsh
I was trying to run cns after typing cns
drriturajpurohit-CELSIUS-M740Bpower:~/Downloads/cns_solve_1.3> cns
Program will stop immediately.
============================================================
Maximum dynamic memory allocation: 0 bytes
Maximum dynamic memory overhead: 0 bytes
Program started at: on
Program stopped at: 08:12:32 on 16-Dec-2017
CPU time used: 0.0040 seconds
============================================================
drriturajpurohit-CELSIUS-M740Bpower:~/Downloads/cns_solve_1.3>

Hello everyone,
I also got these errors and was able to resolve them.
Just take care of installation steps of CNS:
-> After registration, download xyz.tar.gz file “xyz = cns_solve downloaded version”
-> Enter the command in terminal: gunzip xyz.tar.gz
-> Then enter: tar xvf xyz.tar
-> This will create a new cns_solve directory. Now enter into this directory and copy the path.
-> Now open the file cns_solve_env and paste the copied path in place of ‘location of CNSsolve directory’
-> Then open the terminal in this directory, and enter the command:tcsh
-> Then you entered into C-shell, now enter the command: source cns_solve_env
->Then enter: cns
-> Your software will definitely run without any error.

Dear Dr. Bonvin,

I am having the same problem with CNS installation, but I cannot figure out how should I remove -fast-math flag. In my Makefile I don’t have such flag. I tried to run make no-fastm after make clean but it looks like compilation still runs with fortran -ffast-math option.

Thank you

Depending on your operating system, when installing CNS a directory specific for your OS will be created, e.g. intel-x86_64bit-linux/source on a Linux 64bits system.

Go into that directory and edit the Makefile script.

Then in that dir try: make cns_solve

Thank you very much! I think it’s fine now

Hello,

I did exactly those steps and when I entered cns there was the error: cns: Command not found.

any idea what did i do wrong?

In order to use cns you must first source the cns_solve_env from the installation directory (provided you edited it properly. And check that the compilation was successful

Dear all,

I have tried making all the modifications that have been suggested so far in the forum. I am still getting the following error -

%SETFPEPS Machine epsilon determined to be 0.494-323
%SETFPEPS error encountered: Machine epsilon value is too small
(CNS is in mode: SET ABORT=NORMal END)
WARNING: program encountered a fatal error.
However, in interactive mode, program execution
will continue. Proceed at your own risk.
Program will stop immediately.
============================================================
Maximum dynamic memory allocation: 0 bytes
Maximum dynamic memory overhead: 0 bytes
Program started at: on
Program stopped at: 14:13:57 on 29-Oct-2019
CPU time used: 0.0082 seconds
============================================================
Note: The following floating-point exceptions are signalling: IEEE_UNDERFLOW_FLAG IEEE_DENORMAL

I am using 64 bit Ubuntu 18.04.3 LTS. Kindly advise if I can try any other value of MXFPEPS2. I tried 8192 and it gave the same error.

Thanks in advance.
P.S. replacing the entire SETFPEPS subrouting from bosmith produced a fatal error.

I recently recompiled CNS on OSX and CentOS7 using gfortran.

The compiler flags are:

F77 = gfortran
F77STD = -fdefault-integer-8 -w
F77OPT = -O3 $(CNS_MALIGN_I86) -funroll-loops -ffast-math -static
F77FLAGS = $(F77STD) $(F77OPT) $(EXT_F77FLAGS) $(F77BUG)

# C options
CC = gcc
CPP = g++
CCFLAGS = -O -DINTEGER='long int' -DCNS_ARCH_TYPE_$(CNS_ARCH_TYPE) $(EXT_CCFLAGS)

# link options
LD = gfortran
LDFLAGS = -w $(EXT_LDFLAGS)

The machine.f file looks like:

C ==========================================================================
C
      SUBROUTINE DPSTOR(X)
C
      IMPLICIT NONE
C I/O
      INCLUDE 'machvar.inc'
      DOUBLE PRECISION  X
C
C FORCES THE ARGUMENT VALUE X TO BE STORED IN MEMORY LOCATION V.
C Source code taken from fftpack41/tfftpk.f
C
      DPTMPV=X
      RETURN
      END
C
C ==========================================================================
C
      DOUBLE PRECISION FUNCTION DPTRUNC(X)
C
      IMPLICIT NONE
C I/O
      INCLUDE 'machvar.inc'
      DOUBLE PRECISION  X
C
C DPTRUNC IS A PORTABLE FORTRAN FUNCTION WHICH TRUNCATES A VALUE TO THE
C MACHINE DOUBLE PRECISION WORD SIZE, REGARDLESS OF WHETHER LONGER
C PRECISION INTERNAL REGISTERS ARE USED FOR FLOATING POINT ARITHMETIC IN
C COMPUTING THE VALUE INPUT TO DPTRUNC.  THE METHOD USED IS TO FORCE A
C STORE INTO MEMORY BY USING A COMMON BLOCK IN ANOTHER SUBROUTINE.
C Source code taken from fftpack41/tfftpk.f
C
      CALL DPSTOR(X)
      DPTRUNC=DPTMPV
      RETURN
      END
C
C ==========================================================================
C
      SUBROUTINE SETFPEPS
C
      IMPLICIT NONE
C I/O
      INCLUDE 'numbers.inc'
      INCLUDE 'machvar.inc'
C
C Determine the machine epsilon i.e. the smallest FPEPS such that both
C 1+FPEPS and 1-FPEPS are different from 1.
C
C local
      DOUBLE PRECISION ONEDP
      DOUBLE COMPLEX DBCOMP
C
C external
C NONE
C
C begin
C
C ONEDP doesn't really need to be defined - EPSILON() only needs to know
C the type
      ONEDP=(1.00)
      FPEPS = EPSILON(ONEDP)
      DBCOMP = DCMPLX(ZERO,ZERO)
      CALL DECLAR('FP_EPSILON', 'DP', ' ', DBCOMP, FPEPS)
      RETURN
      END
C
C ==========================================================================
C

Dear Dr. Bonvin,
Thank you very much for your prompt reply. ‘cns’ seems to be working now.
Thanks again.