Index: /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/create_weights.py
===================================================================
--- /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/create_weights.py	(revision 13025)
+++ /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/create_weights.py	(revision 13025)
@@ -0,0 +1,113 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import os
+import subprocess
+import re
+from netCDF4 import Dataset
+
+#
+# BEGIN USER MODIFICATIONS
+#
+
+# Directory with domccfg target file
+DOMCFG_DIR="../DOMAINcfg"
+# Suffix of domcfg files
+RAD='domain_cfg.nc'
+# Directory with original forcing on native grid
+FORCING_DIR='/Users/rblod/DATA/NEMO/NEMO_v4/ORCA2_ICE_v4.0/'
+# Forcing file names, interpolation method (default bilin), and weigth file name (optional), lon(optional), lat(optional)  
+FILES=[
+['chlorophyll.nc'  ,'bilin','','',''],
+['geothermal_heating.nc'  ,'bilin','','',''],
+['eddy_viscosity_3D.nc'   ,'bilin','','',''],
+['resto.nc'               ,'bilin','','',''],
+['sss_data.nc'            ,'bilin','','',''],
+['q_10.15JUNE2009_fill.nc','bilin','','',''],
+['q_10.15JUNE2009_fill.nc','bicub','','','']
+]
+
+#
+# END USER MODIFICATIONS
+#
+mycmd="ls "+DOMCFG_DIR+"/?_"+RAD
+returned_output = subprocess.check_output(mycmd, shell=True)
+listcfg = (returned_output.decode("utf-8")).split()
+
+
+
+for i in range(len(listcfg)):
+	print ('Computing weights for cfg file %s :' % listcfg[i])
+	print()
+
+	for myfile in FILES:
+		print('Input file is %s with %s interpolation' % (myfile[0],  myfile[1]))
+		if len(myfile[2]) == 0 :
+			wfile=str(i+1)+'_'+myfile[1]+'_'+myfile[0]
+		else:
+			wfile=str(i+1)+'_'+myfile[2]
+		print('   Performing weights computation ...')
+		if myfile[1]=='namelist_bicub':
+			namelist='namelist_bicub'
+		else :
+			namelist='namelist_bilin'
+
+		myfilename=FORCING_DIR+'/'+myfile[0]
+		dataset=Dataset(myfilename)
+		
+#		if len(myfile[3])==0: 
+#			for key in dataset.variables:
+#				if len(dataset.variables[key].dimensions) >=2:
+#					myvar=key
+#					break
+#		else:
+#			myvar=myfile[3]
+#		print('   Interpolation based on variable %s ...' % myvar)		
+		
+		if len(myfile[3])==0 or len(myfile[4])==0: 
+			for key in dataset.variables:
+				if re.search('lat',key.lower()):
+					mylat=key
+				if re.search('lon',key.lower()):
+					mylon=key
+		else:
+			mylon=myfile[3]
+			mylat=myfile[4]
+		print('   Interpolation based on longitude %s ...' % mylon)		
+		print('   Interpolation based on latitude  %s ...' % mylat)		
+
+		f2=open("namelist_new","w+")
+		with open(namelist,"r") as f:
+			for line in f:
+				match = re.search('nemo_file',line)
+				match2 = re.search('input_file',line)
+				match3 = re.search('input_lon',line)
+				match4 = re.search('input_lat',line)
+				match5 = re.search('output_file',line)
+				match6 = re.search('output_name',line)
+				if match != None :
+					line='nemo_file=''\''+listcfg[i]+'\''"\n"
+				if match2 != None :
+					line='input_file=''\''+myfilename+'\''"\n"
+				if match3 != None :
+					line='input_lon=''\''+mylon+'\''"\n"
+				if match4 != None :
+					line='input_lat=''\''+mylat+'\''"\n"
+				if match5 != None :
+					line='output_file=''\''+wfile+'\''"\n"
+			#	if match5 != None :
+		##			line='output_name=''\''+myvar+'\''"\n"
+				f2.write(line)
+			f.close()
+			f2.close()
+		mycheck=subprocess.check_output('./scripgrid.exe namelist_new',shell=True	)
+		mycheck=subprocess.check_output('./scrip.exe namelist_new',shell=True	)
+		mycheck=subprocess.check_output('./scripshape.exe namelist_new',shell=True	)
+		print('   Success ...')
+		print('   => weight file is %s' % wfile)
+
+	print()
+
+
+				
+
Index: /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/kinds_mod.f90
===================================================================
--- /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/kinds_mod.f90	(revision 13024)
+++ /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/kinds_mod.f90	(revision 13025)
@@ -41,5 +41,5 @@
 !-----------------------------------------------------------------------
 
-      integer, parameter :: char_len  = 80, &
+      integer, parameter :: char_len  = 200, &
                             int_kind  = kind(1), &
                             log_kind  = kind(.true.), &
Index: /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scrip.F90
===================================================================
--- /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scrip.F90	(revision 13024)
+++ /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scrip.F90	(revision 13025)
@@ -90,18 +90,11 @@
 
       character (char_len) :: nm_in
-#if defined ARGC
-      integer :: iargc
-      external iargc
-
-      if (iargc() == 1) then
-        call getarg(1, nm_in)
-      else
-        write(6,*) 'need name of namelist file'
-        stop
-      endif
-#else
-      write(6,*) 'enter name for namelist file'
-      read(5,*) nm_in
-#endif
+
+  if (COMMAND_ARGUMENT_COUNT() == 1) then
+    CALL GET_COMMAND_ARGUMENT(1, nm_in)
+  else
+  write(6,*) 'enter name of namelist file'
+  read(5,*) nm_in
+  endif
 
 !-----------------------------------------------------------------------
Index: /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scripgrid.F90
===================================================================
--- /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scripgrid.F90	(revision 13024)
+++ /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scripgrid.F90	(revision 13025)
@@ -7,20 +7,12 @@
   CHARACTER(char_len) :: infile
 
-#if defined ARGC
-  INTEGER :: IARGC
-  EXTERNAL IARGC
-
-  if (IARGC() == 1) then
-    CALL GETARG(1, infile)
-    CALL convert( infile )
-  ELSE
-    write(6,*) 'need to supply a namelist file'
-  ENDIF
-#else
+  if (COMMAND_ARGUMENT_COUNT() == 1) then
+    CALL GET_COMMAND_ARGUMENT(1, infile)
+  else
   write(6,*) 'enter name of namelist file'
   read(5,*) infile
+  endif
 
   CALL convert( infile )
-#endif
 
 END PROGRAM scripgrid
Index: /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scripshape.F90
===================================================================
--- /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scripshape.F90	(revision 13024)
+++ /utils/tools_dev_r12970_AGRIF_CMEMS/WEIGHTS/src/scripshape.F90	(revision 13025)
@@ -24,8 +24,4 @@
       REAL(KIND=8), ALLOCATABLE :: src1(:,:),dst1(:,:),wgt1(:,:)
       LOGICAL  :: around, verbose
-#if defined ARGC
-      INTEGER(KIND=4) :: iargc
-      EXTERNAL :: iargc
-#endif
 
       CHARACTER(LEN=256) :: interp_file, output_file, name_file
@@ -45,15 +41,12 @@
 !     ew_wrap     = 2
 !
-#if defined ARGC
-      IF (iargc() == 1) THEN
-        CALL getarg(1, name_file)
-      ELSE
-        WRITE(*,*) 'Usage: scripshape namelist_file'
-        STOP
-      ENDIF
-#else
-      WRITE(6,*) 'enter name of namelist file'
-      READ(5,*) name_file
-#endif
+
+  if (COMMAND_ARGUMENT_COUNT() == 1) then
+    CALL GET_COMMAND_ARGUMENT(1, name_file)
+  else
+  write(6,*) 'enter name of namelist file'
+  read(5,*) name_file
+  endif
+
       interp_file = 'none'
       output_file = 'none'
