[Thread Prev][Thread Next][Index]

[ferret_users] how to refer to multiple identical filenames in Ferret



Hi all -

This is an answer rather than a question. Maybe this is obvious to some, but it wasn't to me ....

When an OGCM is run repeatedly with different forcing, you may end up with identical filenames in different directories. For example I run MOM4 with various forcing anomalies, and the filenames describe the date of each snapshot, while the directories they are in describe the model run. For example I have files:

/data/Models/mom4/seasonal_cycle/ocean_day_2002_10_05.nc ! a seasonal cycle run
/data/Models/mom4/EXP_1003/ocean_day_2002_10_05.nc ! a run with modified winds

If typing in commands by hand, I can easily do operations on the files, for example:

yes? shade/z=0 temp[d=2] - temp[d=1] ! plot anomaly of SST

But suppose I want to do this in a script that would open the two files and do the comparison. Then I can't assume that the datasets are 1 and 2. Nor can I use the filename to distinguish them, since they are identical.

You can do this in a script using unix soft links. Here's an example script to do this:
---------------------------------------------------
! $1=experiment number (e.g. 1003)
! $2,3,4=yr,mon,day (e.g. 2002 10 05)
! $5=depth level

! use the input values to construct the filename
def sym fname "ocean_day_$2_$3_$4"

! use soft links to define temporary names for these files
! ==>> must be soft links (ln -s)!! Else will delete the actual file! <<==
! first get rid of previous definitions
can dat/noerr seasonal
can dat/noerr anomalies
sp \rm seasonal.nc
sp \rm anomalies.nc
sp ln -s /data/Models/mom4/EXP_$1/($fname).nc anomalies.nc
sp ln -s /data/Models/mom4/seasonal_cycle/($fname).nc seasonal.nc

! bring in and use the identical filenames under new descriptive names
use seasonal.nc
use anomalies.nc

shade/z=$5 temp[d=anomalies] - temp[d=seasonal]
---------------------------------------------------

Billy K

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement