Wrong parsing of filename in call to iom_open by agrif zooms
When agrif zoom(s) open input or restart files with iom_open
the grid prefix substitution is automatically done in iom.F90
clname = trim(cdname)
IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN
iln = INDEX(clname,'/')
cltmpn = clname(1:iln)
clname = clname(iln+1:LEN_TRIM(clname))
clname=TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname)
ENDIF
Unfortunately, when the input file path is different from ./
, e.g. absolute path is provided, the grid prefix substitution is placed just after the first occurence of the path separator by iln = INDEX(clname,'/')
Here a practical example for the temperature initial condition, where the input path is '/data/user/input_for_nemo' and the filename is 'WOA18_temperature.nc':
the above code will return clname
= /1_data/user/input_for_nemo/ORCA025_WOA18_temperature.nc
instead of /data/user/input_for_nemo/1_ORCA025_WOA18_temperature.nc
To fix this behaviour and correctly split the pathname and the basename, INDEX
function should be carried out in backward
direction applying the following fix
diff --git a/src/OCE/IOM/iom.F90 b/src/OCE/IOM/iom.F90
index dbccf2c..f6ac95b 100644
--- a/src/OCE/IOM/iom.F90
+++ b/src/OCE/IOM/iom.F90
@@ -751,7 +751,7 @@ CONTAINS
! =============
clname = trim(cdname)
IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN
- iln = INDEX(clname,'/')
+ iln = INDEX(clname,'/', BACK=.TRUE.)
cltmpn = clname(1:iln)
clname = clname(iln+1:LEN_TRIM(clname))
clname=TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname)