Opened 4 weeks ago

Last modified 28 hours ago

#2078 reopened Defect

cn_dir corrupts AGRIF input filenames

Reported by:Franziska Schwarzkopf Component: OPA
Version: release-3.6 Severity: minor
Keywords: AGRIF Cc: fschwarzkopf@…
Management
Owned by: Milestone:
Priority: low

Description (last modified by Nicolas MARTIN)

Context

Input files (forcing etc.) cannot be found if cn_dir differs from ./ in nested configurations.

Analysis

In AGRIF configurations, when cn_dir differs from ./ inputfiles for the child grid(s) cannot be found. The prefix for the child(s)-filenames is inserted after the first / in cn_dir and not in front of the filename itself.

Example:

filename = 'myfile'
cn_dir = './'

—> /1_myfile

filename = 'myfile'
cn_dir = '/path/to/my/file/'

—> /1_path/to/my/file/myfile
instead of /path/to/my/file/1_myfile

Commit History (0)

(No commits)

Change History (4)

comment:1 Changed 3 weeks ago by Nicolas MARTIN

  • Description modified (diff)

comment:2 Changed 2 days ago by Claire Levy

  • Resolution set to wontfix
  • Status changed from new to closed

Yes, this is the way AGRIF works…

comment:3 Changed 44 hours ago by Claire Levy

  • Resolution wontfix deleted
  • Status changed from closed to reopened

comment:4 Changed 28 hours ago by Markus Scheinert

On one hand, the effective path to some input-file is meant to be composed by cn_dir//clname, isn't it?
On the other hand any nest-specific file (not the path) needs a prefix consisting of the number of the nest and an underscore, e.g. '1_'.

And this works perfectly without any nests or with nests but with cn_dir only containing a simple './'. But with AGRIF the logic fails if the path in cn_dir has more than one sub-directory in it, because the Fortran function "INDEX()" (see code below) only returns the first position of a pattern, which is "/" in the case on hand. However, the actual position of interest in this pattern-search is the LAST occurrence of "/" in the string clname - in order to extract the filename from the full path without knowing about the original cn_dir.

see iom.F90:

      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

Erroneous result for the given example

Given cn_dir='/path/to/my/file/' and an already composed clname='/path/to/my/file/my_file', the INDEX() call results in iln=1 instead of iln=17 and thus the extracted filename becomes 'path/to/my/file/my_file'. And consequently for the first nest we get: '1_path/to/my/file/my_file' instead of the intended '/path/to/my/file/1_my_file'.

Proposed SOLUTION:

Find the last occurrence of "/" by searching from the right to the left. Enable back-search in the INDEX() call when diagnosing iln in the code excerpt from above:

         iln    = INDEX(clname,'/',BACK=.true.)
Note: See TracTickets for help on using tickets.