[Thread Prev][Thread Next][Index]
Re: [ferret_users] [Ferret] Can Ferret be used to do iterations like Fortran
Hi Zhen,
Through successive steps of "masking" and "combining" in Ferret
you can shape the variable in the desired way. Since Ferret always works on
the whole data array, rather than individual array elements as in Fortran,
this process is bit tricky. Moreover, the steps involved depends on the
problem. Please note that this masking method uses the "let" command together
with logical expressions like IF/ELSE.
An iteration process through repeat command is tedious compared to the
masking method. If you do it using repeat command, you will be forced to
write out the variable values as individual array elements to an intermediate
file and then read it back.
I could not understand what exactly is being done in the Fortran script
you have given, specifically with the x, read command & t <=NT condition.
Anyway, here is an example for the lat part. This example is just to show
the masking method rather than reproducing the exact result from your
Fortran script.
Please let me know if you have any questions ..
Regards,
Jaison
!----example starts here
\ cancel mode verify
!
! create few dummy variables
define axis/x=1:10:1 xax
define axis/y=1:10:1 yax
let mask_1 = x[gx=xax]*0 + y[gy=yax]
let mask = IF mask_1 LE 5 OR mask_1 GE 8 THEN 1 ELSE 0
let delta = 0.5
let lat = x[gx=xax]*0 + y[gy=yax]
let lat_shf= lat[i=@SHF:-1,j=@SHF:-1]
! now lat for j=1 will be missing values --> handle it as needed
let lat_shf_1 = IF J[GY=lat_shf] EQ 1 THEN lat[i=1,j=10] ELSE lat_shf
! lat for i=1 are also missing values --> set it properly
let lat_shf_2 = lat_shf_1[i=@FNR]
! find the final lat
let lat_shf_3 = lat_shf_2 + delta
! do the tranformation for lat (please note that mask and lat are on
! exactly the same grid
let lat_new = IF mask EQ 1 THEN lat_shf_3 ELSE lat
list mask
list lat_new
!-----end of example----------------------------------------------------
On Wed, 17 Jan 2007 zhen.li@xxxxxxxxxxxxx wrote:
>
> >Hi All:
> >
> >I'd like to use Ferret to do some iterations. I wonder if the
> >"repeat" function or others
> >can perform the similar task as the following Fortran script.
> >
> >While ( mask (i,j)==1 or t <=NT)
> >lat(i,j)=lat(i-1,j-1) + delta
> >x(i,j)=u(i,j,t)*scal
> >t=t+1
> >read(41, *), u(i,j,t)
> >end
> >
> >Thanks,
> >
> >Zhen
>
>
>
>
[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Privacy Policy | Disclaimer | Accessibility Statement