From 1b190cd4e5a7491053661c8cbdef90aaad44c74a Mon Sep 17 00:00:00 2001 From: Katetc Date: Fri, 19 Nov 2021 16:42:50 -0700 Subject: [PATCH 1/5] Updates to old slap fortran code so modern compilers are a little happier --- libglimmer-solve/SLAP/dlapqc.f | 16 ++++++++-------- libglimmer-solve/SLAP/xersla.f | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libglimmer-solve/SLAP/dlapqc.f b/libglimmer-solve/SLAP/dlapqc.f index b7200ec8..c97b366f 100644 --- a/libglimmer-solve/SLAP/dlapqc.f +++ b/libglimmer-solve/SLAP/dlapqc.f @@ -574,7 +574,7 @@ SUBROUTINE DRMGEN( NELTMX, FACTOR, IERR, N, NELT, ISYM, DOUBLE PRECISION FACTOR, A(NELTMX) DOUBLE PRECISION F(N), SOLN(N), DSUM(N) INTEGER DUMMY - REAL, EXTERNAL :: RAND + REAL, EXTERNAL :: SLRAND C C Start by setting the random number generator seed. C This is done for reproducablility in debuggin. Remove @@ -582,7 +582,7 @@ SUBROUTINE DRMGEN( NELTMX, FACTOR, IERR, N, NELT, ISYM, C C***FIRST EXECUTABLE STATEMENT DRMGEN DUMMY = 16381 - ISEED = RAND( DUMMY ) + ISEED = SLRAND( DUMMY ) IERR = 0 DO 10 I = 1, N IDIAG(I) = 0 @@ -599,7 +599,7 @@ SUBROUTINE DRMGEN( NELTMX, FACTOR, IERR, N, NELT, ISYM, C C To keep things sparse divide by two, three or four or ... C - INUM = (IFIX( RAND(DUMMY)*NL ) + 1)/3 + INUM = (IFIX( SLRAND(DUMMY)*NL ) + 1)/3 CALL DMPL( NL, INUM, ITMP ) C C Set up this column (and row, if non-sym structure). @@ -616,7 +616,7 @@ SUBROUTINE DRMGEN( NELTMX, FACTOR, IERR, N, NELT, ISYM, IF( IA(NELT).EQ.ICOL ) THEN IDIAG(ICOL) = NELT ELSE - A(NELT) = -RAND(DUMMY) + A(NELT) = -SLRAND(DUMMY) DSUM(ICOL) = DSUM(ICOL) + A(NELT) IF( ISYM.EQ.0 ) THEN C @@ -666,7 +666,7 @@ SUBROUTINE DRMGEN( NELTMX, FACTOR, IERR, N, NELT, ISYM, CVD$ NOVECTOR CVD$ NOCONCUR DO 50 I = 1, N - SOLN(I) = RAND(DUMMY) + SOLN(I) = SLRAND(DUMMY) F(I) = 0.0D0 50 CONTINUE C @@ -702,7 +702,7 @@ SUBROUTINE DMPL( N, M, INDX ) C***ROUTINES CALLED RAND C***END PROLOGUE IMPLICIT DOUBLE PRECISION(A-H,O-Z) - REAL, EXTERNAL :: RAND + REAL, EXTERNAL :: SLRAND INTEGER DUMMY INTEGER N, M, INDX(M) C @@ -712,10 +712,10 @@ SUBROUTINE DMPL( N, M, INDX ) IF( N*M.LT.0 .OR. M.GT.N ) RETURN C C.. Set the indeicies. - INDX(1) = IFIX( RAND(DUMMY)*N ) + 1 + INDX(1) = IFIX( SLRAND(DUMMY)*N ) + 1 CVD$ NOCONCUR DO 30 I = 2, M - 10 ID = IFIX( RAND(DUMMY)*N ) + 1 + 10 ID = IFIX( SLRAND(DUMMY)*N ) + 1 C C.. Check to see if id has already been chosen. CVD$ NOVECTOR diff --git a/libglimmer-solve/SLAP/xersla.f b/libglimmer-solve/SLAP/xersla.f index 78e8049a..c9062eb4 100644 --- a/libglimmer-solve/SLAP/xersla.f +++ b/libglimmer-solve/SLAP/xersla.f @@ -29,7 +29,7 @@ subroutine xerabt(messg,nmessg) c 1982. c***routines called (none) c***end prologue xerabt - dimension messg(nmessg) + character*(*) messg c***first executable statement xerabt stop 1 end @@ -300,7 +300,7 @@ subroutine xerrwv(messg,nmessg,nerr,level,ni,i1,i2,nr,r1,r2) if (lkntrl.le.0) go to 40 c error number write (iunit,30) lerr - 30 format (15h error number =,i10) + 30 format ('15h error number =',i10) 40 continue 50 continue c trace-back @@ -380,8 +380,8 @@ subroutine xersav(messg,nmessg,nerr,level,icount) if (iunit.eq.0) iunit = i1mach(4) c print table header write (iunit,10) - 10 format (32h0 error message summary/ - 1 51h message start nerr level count) + 10 format ('32h0 error message summary'/ + 1 '51h message start , nerr, level, count') c print body of table do 20 i=1,10 if (kount(i).eq.0) go to 30 @@ -391,7 +391,7 @@ subroutine xersav(messg,nmessg,nerr,level,icount) 30 continue c print number of other errors if (kountx.ne.0) write (iunit,40) kountx - 40 format (41h0other errors not individually tabulated=,i10) + 40 format ('41h0other errors not individually tabulated=',i10) write (iunit,50) 50 format (1x) 60 continue @@ -811,8 +811,8 @@ subroutine xsetun(iunit) junk = j4save(5,1,.true.) return end - FUNCTION RAND(R) -C***BEGIN PROLOGUE RAND + FUNCTION SLRAND(R) +C***BEGIN PROLOGUE SLRAND C***DATE WRITTEN 770401 (YYMMDD) C***REVISION DATE 861211 (YYMMDD) C***CATEGORY NO. L6A21 @@ -823,7 +823,7 @@ FUNCTION RAND(R) C***DESCRIPTION C C This pseudo-random number generator is portable among a wide -C variety of computers. RAND(R) undoubtedly is not as good as many +C variety of computers. SLRAND(R) undoubtedly is not as good as many C readily available installation dependent versions, and so this C routine is not recommended for widespread usage. Its redeeming C feature is that the exact same random numbers (to within final round- @@ -887,18 +887,18 @@ FUNCTION RAND(R) C possible use in a restart procedure. C If R .GT. 0., the sequence of random numbers will start with C the seed R mod 1. This seed is also returned as the value of -C RAND provided the arithmetic is done exactly. +C SLRAND provided the arithmetic is done exactly. C C Output Value -- -C RAND a pseudo-random number between 0. and 1. +C SLRAND a pseudo-random number between 0. and 1. C***REFERENCES (NONE) C***ROUTINES CALLED (NONE) -C***END PROLOGUE RAND +C***END PROLOGUE SLRAND SAVE IA1, IA0, IA1MA0, IC, IX1, IX0 DATA IA1, IA0, IA1MA0 /1536, 1029, 507/ DATA IC /1731/ DATA IX1, IX0 /0, 0/ -C***FIRST EXECUTABLE STATEMENT RAND +C***FIRST EXECUTABLE STATEMENT SLRAND IF (R.LT.0.) GO TO 10 IF (R.GT.0.) GO TO 20 C @@ -912,8 +912,8 @@ FUNCTION RAND(R) IY1 = IY1 + (IY0-IX0)/2048 IX1 = MOD (IY1, 2048) C - 10 RAND = IX1*2048 + IX0 - RAND = RAND / 4194304. + 10 SLRAND = IX1*2048 + IX0 + SLRAND = SLRAND / 4194304. RETURN C 20 IX1 = AMOD(R,1.)*4194304. + 0.5 From fb8341498c51c1ee16c928c95e722674d9439cc6 Mon Sep 17 00:00:00 2001 From: Katetc Date: Fri, 19 Nov 2021 16:45:41 -0700 Subject: [PATCH 2/5] Line to load modules correctly on cheyenne --- builds/cheyenne-intel/cheyenne-intel-cmake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/cheyenne-intel/cheyenne-intel-cmake.sh b/builds/cheyenne-intel/cheyenne-intel-cmake.sh index b6fcf777..c94d55df 100644 --- a/builds/cheyenne-intel/cheyenne-intel-cmake.sh +++ b/builds/cheyenne-intel/cheyenne-intel-cmake.sh @@ -16,7 +16,7 @@ else fi echo CISM: "${cism_top}" - +source /etc/profile.d/modules.sh module purge module load ncarenv/1.2 From 952d73db1a07f9e5b1704bb860794243b23a0f2e Mon Sep 17 00:00:00 2001 From: Katetc Date: Fri, 19 Nov 2021 16:47:05 -0700 Subject: [PATCH 3/5] Add use statement to prevent link error --- libglint/glint_initialise.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/libglint/glint_initialise.F90 b/libglint/glint_initialise.F90 index 73ffdeea..5225d02c 100644 --- a/libglint/glint_initialise.F90 +++ b/libglint/glint_initialise.F90 @@ -557,6 +557,7 @@ subroutine glint_i_end(instance) !> Tidy up use glide + use glide_stop use glimmer_ncio implicit none type(glint_instance), intent(inout) :: instance !> The instance being initialised. From f8adc69f6d5e5932a6c11463afb64fe0153b13e2 Mon Sep 17 00:00:00 2001 From: Katetc Date: Fri, 19 Nov 2021 16:56:12 -0700 Subject: [PATCH 4/5] Update dome test to python 3 --- tests/dome/netCDF.py | 6 +++--- tests/dome/runDome.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/dome/netCDF.py b/tests/dome/netCDF.py index 2640e87b..09e31828 100644 --- a/tests/dome/netCDF.py +++ b/tests/dome/netCDF.py @@ -20,9 +20,9 @@ import pycdf netCDF_module = 'pycdf' except ImportError: - print 'Unable to import any of the following python modules:' - print ' Scientific.IO.NetCDF \n netcdf4 \n pycdf' - print 'One of them must be installed.' + print('Unable to import any of the following python modules:') + print(' Scientific.IO.NetCDF \n netcdf4 \n pycdf') + print('One of them must be installed.') raise ImportError('No netCDF module found') def NCtype(value): diff --git a/tests/dome/runDome.py b/tests/dome/runDome.py index 31e67c30..ec220d3c 100755 --- a/tests/dome/runDome.py +++ b/tests/dome/runDome.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python #FIXME: More detailed description of this test case!!! """ @@ -15,7 +15,7 @@ import sys import errno import subprocess -import ConfigParser +import configparser import numpy import netCDF @@ -125,7 +125,7 @@ def main(): scale_factor = 2 ** args.scale try: - config_parser = ConfigParser.SafeConfigParser() + config_parser = configparser.ConfigParser() config_parser.read( args.config ) nz = int(config_parser.get('grid','upn')) @@ -141,10 +141,10 @@ def main(): try: forcing_name = config_parser.get('CF forcing','name') forcing_root, forcing_ext = os.path.splitext(forcing_name) - except ConfigParser.NoSectionError as noForce: + except configparser.NoSectionError as noForce: forcing_name = '' - except ConfigParser.Error as error: + except configparser.Error as error: print("Error parsing " + args.config ) print(" "), print(error) @@ -179,7 +179,7 @@ def main(): forcing_name = forcing_root+mod+forcing_ext config_parser.set('CF forcing', 'name', forcing_name) - with open(config_name, 'wb') as config_file: + with open(config_name, 'w') as config_file: config_parser.write(config_file) From 1bd26efd938d46a6da8870bc01a639abad497bbe Mon Sep 17 00:00:00 2001 From: Katetc Date: Fri, 19 Nov 2021 17:00:25 -0700 Subject: [PATCH 5/5] Update Changelog --- ChangeLog | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e7be9648..1180f7cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ CISM Changelog -Changes in CISM tag cism_main_2.01.002 +Changes in CISM tag cism_main_2.01.011 +====================================== + +Changes to update old SLAP code and make it slightly nicer for modern compilers. Plus add in one missing use statement and update the dome python scripts to python3. + +Changes in CISM tag cism_main_2.01.003 ====================================== ESCOMP/cism/main 792e43f and 410b384