mouhamet
Civil/Environmental
- Oct 18, 2016
- 2
Hello everybody
0
down vote
favorite
I need some help, well let's get started:
I'm working with numerical weather forecast named as follow:
sub_gfsanl_4_2011MMDD-IIII-FFFF.grb2
-MM stands for month from 01 to 12 -DD stands for days from 01 to 31 -IIII stands for initialisation time, the first and second digits are for hours the third and last are for minutes -FFFF stands for forecast hour , the first and second digits are for hours the third and last are for minutes
in my directory i have several files for a given days of a given months. A day has 4 data, one at every six hours IIII=0000 ,0600,1200,1800.
What i'm trying to do is to list all files of a given days, here the f90 code i wrote:
[pre]program test_ec
implicit none
!==variable declaration==
integer :: mi,di,dil,mil
character*3 :: temp
!==Program instructions==
mil=1
write(temp,'(i2.2)') mil
read(temp,'(i2.2)') mi
!convert the month into a two digit value mi=01
! change to directory where the data are stored
CALL chdir('/media/Hello/ncfiles/GFS' )
do dil=1,31
!loop over days
write(temp,'(i2.2)') dil
read(temp,'(i2.2)') di
! converting day number into a two digit number, store this value into di. ex dil=9 then di=09
CALL execute_command_line( 'ls sub_gfsanl_4_2011${mi}${di}*.nc > yes.txt' )
!list all files with the correct month and days and store it to yes.txt
end do
end program test_ec[/pre]
I would greatly appreciate any help of advises, for some reasons the execute_command_line doesn't seem to like the $ for variable...
Thanks!
0
down vote
favorite
I need some help, well let's get started:
I'm working with numerical weather forecast named as follow:
sub_gfsanl_4_2011MMDD-IIII-FFFF.grb2
-MM stands for month from 01 to 12 -DD stands for days from 01 to 31 -IIII stands for initialisation time, the first and second digits are for hours the third and last are for minutes -FFFF stands for forecast hour , the first and second digits are for hours the third and last are for minutes
in my directory i have several files for a given days of a given months. A day has 4 data, one at every six hours IIII=0000 ,0600,1200,1800.
What i'm trying to do is to list all files of a given days, here the f90 code i wrote:
[pre]program test_ec
implicit none
!==variable declaration==
integer :: mi,di,dil,mil
character*3 :: temp
!==Program instructions==
mil=1
write(temp,'(i2.2)') mil
read(temp,'(i2.2)') mi
!convert the month into a two digit value mi=01
! change to directory where the data are stored
CALL chdir('/media/Hello/ncfiles/GFS' )
do dil=1,31
!loop over days
write(temp,'(i2.2)') dil
read(temp,'(i2.2)') di
! converting day number into a two digit number, store this value into di. ex dil=9 then di=09
CALL execute_command_line( 'ls sub_gfsanl_4_2011${mi}${di}*.nc > yes.txt' )
!list all files with the correct month and days and store it to yes.txt
end do
end program test_ec[/pre]
I would greatly appreciate any help of advises, for some reasons the execute_command_line doesn't seem to like the $ for variable...
Thanks!