Friday, December 4, 2009

Climate Variability and Climate change

    The distinction between Climate variability and Climate change inevitably has a degree of arbitrariness and depends on the time frame considered

We can call the natural reversible semi periodic variations which are embedded in the mean state of Climate as Climate variability.

Climate variability is different from seasonal variability which complete its cycle within the period of one year.

some of the examples of climate variabilities are

Indian Ocean Dipole (2 to 3 year)
El-Nino Southern Oscillation (2 to 7 years)
Solar Cycle (about 11 years)
Atlantic Multidecadal Oscillation(AMO) (60 to70 year)
Precession(axis orientation) variation (23000 years)
Obliquity (axis tilt angle) variation (41000 years)
Eccentricity (Ellipticity of orbit ) variation (100000 years)

Mechanisms to which Climate is sensitive

1. Milankovich cycle (Astronomical cycle) are importent in the long term beyond centuaries

2. The solar constant variation is less than 0.1% definitely in the last 25 years, probably in the last century and possibly in the last million years.

3. Green house gases have experienced long term natural and recent anthropogenic changes. The warming effect of green house gases and cooling effect of sulphite aerosols explains the recent warming trend.

4. Deep Ocean Circulation changes can cause climate changes which require mere decades to significantly alter land and sea surface temperature. This has occurred in relatively recent past  of about 10000 years ago and may be possible if triggered by greenhouse warming.

5. The coupled ocean atmosphere system oscillates and produce inter annual and decadal variations in climate, which are predictable in some extend

6. Cloud radiation interaction is another important factor which have strong influence on climate. But no past data is available for the pre satellite era.

7. Land surface changes also have influence on climate but most of them are local and irreversible. One of the major example is the influence of Himalayas orography and Asian monsoon

 

Wednesday, November 11, 2009

Why the ocean current is elliptical with strong western boundary current?

1. The tropical easterly wind causes poleward Ekman transport and the midlatitude westerly wind causes equatorward Ekman transport.

2. The Ekman transport converges at the subtropics causes downwelling. The diverging region of Ekman transport cause upwelling.
(Reason: Continuity and conservation of mass)

3. The downwelling push the thermocline down and squeeze the underling geostrophic layer. The upwelling pull the thermocline up and stretches the geostrophic layer.
(Reason: Continuity and conservation of mass)

4. The squeezing causes equatorward Sverdrup transport and stretching lead to poleward Sverdrup transport.
(Reason: Potential vorticity conservation)

5. The equatorward Sverdrup transport diverges from the midlatitude westerly and converges to the tropical easterly forms an elliptical clockwise gyre in the interior layer of open ocean

6. This large scale equatorward mass transport is compensated by the poleward western boundary transport.
(Reason: Continuity and conservation of mass)

7. Thus the ocean current is elliptical with strong western boundary current.


Key words:

Atmospheric surface wind
Ekman layer mass transport
Potential vorticity
Geostrophic layer
Sverdrup transport









Wednesday, November 4, 2009

Text output of the data from GrADS

I want to take a text output of the data according to my need...I have already used one function "fprintf.gs" for this...It was a good tool.But It will not hep me as my data set is too big and it it is taking so much time to do it....So wats ur suggesion..How can i do it ?

You can use fwrite command with whichever variable you want to write.

fwrite Writes data to file instead of drawing a plot.

The syntax is as follows:

set fwrite fname
set gxout fwrite
display expression
disable fwrite

Here the output will be in Binary. But you need ASCII text output.

i want ascii
bcs this data i want to use for other softwares

Check the link
http://metoce.blogspot.com/search/label/get%20printout%20values%20as%20output?zx=98a27ead578a422a

yeah i used like that.. i modified by including latitudes and longitudes
but now tha problm comes
u given tt=tt+1...
here 1 is constant and giving the incriment
like that i want lat= lat+incriment
..but my lat have no constant incriment
How is the distribution of your lat-increment ? We shall try. Now the solution is very near.
but we cant say such a distribution
say...near to equator it is varying with 0.45 degress
while going to pole ..this incriment is decresing..but not in a specific order
But there should be some order either linear or nonlinear.
i have not find such an order. i want to have a close look for that. anyway linear order is not there. i can send the "ctl" file to u. so that u can have alook on the varying of my latitude.
It can be solved in GrADS. It is possible in two different ways.

1. If we can have ordinary one dimensional array variable in GrADS to store Latitude values and use it inside the loop.

2.
If the philosophy of distribution of latitude is available from the documentation of the model, so that we can regenerate the latitude values using code.

Let us try the first way.

GrADS allows for arrays using the syntax varname.i.j (e.g., for a 2-D array), where i and j must be integers.

For our problem we need a one dimensional array to store latitude values.

let it be lt.i

First you assign all the latitude levels to the array lat.i
lt.1=your first level of latitude
lt.2=your second level and so on

Then use it in your loop by incrementing the counter variable i inside the loop.

Finally code become
--------------
--------------
--------------
while(tt<=tlimit)
'set t 'tt

while(i<=ilimit)
'set lat 'lt.i

while(ln<=lnlimit)
'set lon 'ln

'd variable'
te=subwrd(result,4)
w=write(fname.txt,te)

ln=ln+1
endwhile

i=i+1
endwhile

tt=tt+1
endwhile

'print'
---------------


As u suggested i wrote one script including the array dimension.
This is the final script I am sending...I could get the output now.

Any way pls see my final script( iam attaching herewith)

Thanks a lot


'reinit'
'open goa_may05_dom3_finalattempt.ctl'
'set lon 71.5087'
lat.1 = 13.23363
lat.2 = 13.25990
lat.3 = 13.28616
'set t 1'
count=1
while( count <= 2)
'set t ' count
longi = 71.5087
while(longi <= 75.4507)
'set lon ' longi
i=1
while(i <= 3)
'set lat ' lat.i
'd lat'
lrn=subwrd(result,4)
w=write('new_lat.txt',lrn)
i=i+1
endwhile
longi = longi+0.0270
endwhile
count=count+1
endwhile
'close 1'
Thanks for my friend seemanth to participate in this discussion




Friday, October 2, 2009

Climatology of season JJAS (grads script)

'reinit'
prompt 'Enter the name of new folder : '
pull fld
'!mkdir 'fld''
'open cmip1.ctl'
'q file'
'set lat -20 50'
'set lon 40 130'
'set time 1jun2022 30sep2101'
'define jjas=ave(prate, time=1jun, time=30sep)'
'set gxout shaded'
'd jjas'
'cbarn'
'define clim1=ave(jjas, time=1jun2022, time=30sep2101)'
'set time 1jun2022'
'd clim1*86400'
'set gxout shaded'
'd clim1*86400'
'cbarn'
'draw title cmip1 clomatology of JJAS'
'print climatology.gif'
'print 'fld'/clim1.eps'
'print 'fld'/clim1.gif'
'print 'fld'/clim1.jpg'
'!cd 'fld''
'!ls'






Monday, August 17, 2009

Some Beautifull Pictures




The Marks of Wind

Squall line

A squall line is a line of severe thunderstorms that can form along and/or ahead of a cold front. In the early 20th century, the term was used as a synonym for cold front. It contains heavy precipitation, hail, frequent lightning, strong straight line winds, and possibly tornadoes and waterspouts. Severe weather, in form of strong straight-line winds can be expected where the squall line in areas where the line itself is in the shape of a bow echo, in the portion of the line most bows out. Tornadoes can be found along waves within a line echo wave pattern, or LEWP, where mesoscale low pressure areas are present. Some bow echoes which develop within the summer season are known as derechos, and they move quite fast through large sections of territory. On the back edge of the rain shield associated with mature squall lines, a wake low can be present which are sometimes associated with a heat burst.



Lenticular Cloud


Lenticular clouds are stationary lens-shaped clouds that form at high altitudes, normally aligned perpendicular to the wind direction. Lenticular clouds can be separated into altocumulus standing lenticularis (ACSL), stratocumulus standing lenticular (SCSL), and cirrocumulus standing lenticular (CCSL).






Thursday, July 23, 2009

Diffusion equation


The diffusion equation is a partial differential equation which describes density fluctuations in a material undergoing diffusion. It is also used to describe processes exhibiting diffusive-like behaviour, for instance the 'diffusion' of alleles in a population in population genetics.

The equation is usually written as:

\frac{\partial\phi(\vec{r},t)}{\partial t} = \nabla \cdot \bigg( D(\phi,\vec{r}) \, \nabla\phi(\vec{r},t) \bigg),

where \, \phi(\vec{r},t) is the density of the diffusing material at location \vec{r} and time t and \, D(\phi,\vec{r}) is the collective diffusion coefficient for density φ at location \vec{r}; the nabla symbol \, \nabla represents the vector differential operator del acting on the space coordinates. If the diffusion coefficient depends on the density then the equation is nonlinear, otherwise it is linear. If \, D is constant, then the equation reduces to the following linear equation:

\frac{\partial\phi(\vec{r},t)}{\partial t} = D\nabla^2\phi(\vec{r},t),

also called the heat equation. More generally, when D is a symmetric positive definite matrix, the equation describes anisotropic diffusion, which is written (for three dimensional diffusion) as:

\frac{\partial\phi(\vec{r},t)}{\partial t} = \sum_{i=0}^3\sum_{j=0}^3 \frac{\partial}{\partial x_i}\left(D_{ij}(\phi,\vec{r})\frac{\partial \phi(\vec{r},t)}{\partial x_j}\right)

Derivation

The diffusion equation can be derived in a straightforward way from the continuity equation, which states that a change in density in any part of the system is due to inflow and outflow of material into and out of that part of the system. Effectively, no material is created or destroyed:

\frac{\partial\phi}{\partial t}+\nabla\cdot\vec{j}=0,

where \vec{j} is the flux of the diffusing material. The diffusion equation can be obtained easily from this when combined with the phenomenological Fick's first law, which assumes that the flux of the diffusing material in any part of the system is proportional to the local density gradient:

\vec{j}=-D\,(\phi)\,\nabla\,\phi\,(\,\vec{r},t\,).

Historical origin

The particle diffusion equation was originally derived by Adolf Fick in 1855.

Discrete analogs

The diffusion equation is continuous in both time and space. One may discretize space, time, or both space and time, which arise in application. Discretizing time alone just corresponds to taking time slices of the continuous system, and no new phenomena arise. In discretizing space alone, the Green's function becomes the discrete Gaussian kernel, rather than the continuous Gaussian kernel. In discretizing both time and space, one obtains the random walk.









Wednesday, July 22, 2009

List of candidates selected for the award of SPM Fellowship-2009


(Interviews held on 13th & 14th July 2009)



SNo
Roll No.
Name of the Candidate
Subject

1
114473
CHANDRABALI BHATTACHARYA
Chemical Sciences

2
115334
SATYAJIT GUPTA
Chemical Sciences

3
199351
KRISHNANKA SHEKHAR
Chemical Sciences

4
116453
PROSENJIT DAW
Chemical Sciences

5
116728
SOURAV KUMAR DEY
Chemical Sciences

6
CY7110754
DIPAK SAMANTA
Chemical Sciences

7
501422
SUPRIT SINGH
Physical Sciences

8
506733
RUDRANEL BASU
Physical Sciences

9
508448
KOLEKAR SANVED VINOD
Physical Sciences

10
505280
GOKHALE SHREYAS SHASHANK
Physical Sciences

11
327558
NEELANJANA J
Life Sciences

12
318092
SUMIT SEN SANTARA
Life Sciences

13
327145
WAREED AHMED
Life Sciences

14
330265
VIDHI MATHUR
Life Sciences

15
301959
SAKSHI ARORA
Life Sciences

16
XL8280315
PRIYANKA BAJAJ
Life Sciences

17
328230
NEHA NANDWANI
Life Sciences

18
409780
SUBHAMAY SAHA
Math. Sciences

19
404927
B RAVINDER
Math. Sciences

20
201132
KASTURI BHATTACHARYYA
Earth Sciences

21
201500
TAMOGHNA ACHARYYA
Earth Sciences

Source: http://csirhrdg.res.in/SPMF09result.htm
----------------------------------------------------------------------------
Shortlist before core committee interview
http://csirhrdg.res.in/spmf09%20final%20shortlisted.pdf

Sunday, June 7, 2009

Electromagnetic spectrum (wave length)

Solar radiation : 0.2 micrometer to 5 micrometer
Terrestrial radiation : 5 to 100 micrometer

note : 1000 nm = 1 micrometer


less than 100 nm : Photo-ionisation band : photo-ionisation of N2, O2, O gives molecular ions and free electron.

100 to 200 nm : photo-dissociation band : Photo dissociation of oxygen gives atomic oxygen.

200 to 280 nm : Ultraviolet-C : Absorption by oxygen molecule

280 to 320 nm : Ultraviolet-B : Absorption by ozone molecule

320 to 400 nm : Ultra violet-A : weak ultra violet

400 to -- nm : violet

-- to 450 nm : indigo

450 to 520 nm : blue

520 to 590 nm : green

590 to -- nm : yellow

-- to 620 nm : orange

620 to 680 nm : red

680 to 1100 nm : near-infrared

Infrared


CIE division scheme of Infrared

The International Commission on Illumination (CIE) recommended the division of optical radiation into the following three bands:

  • IR-A: 700 nm–1400 nm
  • IR-B: 1400 nm–3000 nm
  • IR-C: 3000 nm–1 mm

A commonly used sub-division scheme is:

  • Near-infrared (NIR, IR-A DIN): 0.75-1.4 µm in wavelength, defined by the water absorption, and commonly used in fiber optic telecommunication because of low attenuation losses in the SiO2 glass (silica) medium. Image intensifiers are sensitive to this area of the spectrum. Examples include night vision devices such as night vision goggles.
  • Short-wavelength infrared (SWIR, IR-B DIN): 1.4-3 µm, water absorption increases significantly at 1,450 nm. The 1,530 to 1,560 nm range is the dominant spectral region for long-distance telecommunications.
  • Mid-wavelength infrared (MWIR, IR-C DIN) also called intermediate infrared (IIR): 3-8 µm. In guided missile technology the 3-5 µm portion of this band is the atmospheric window in which the homing heads of passive IR 'heat seeking' missiles are designed to work, homing on to the IR signature of the target aircraft, typically the jet engine exhaust plume.
  • Long-wavelength infrared (LWIR, IR-C DIN): 8–15 µm. This is the "thermal imaging" region, in which sensors can obtain a completely passive picture of the outside world based on thermal emissions only and requiring no external light or thermal source such as the sun, moon or infrared illuminator. Forward-looking infrared (FLIR) systems use this area of the spectrum. Sometimes also called the "far infrared."
  • Far infrared (FIR): 15-1,000 µm (see also far infrared laser).

NIR and SWIR is sometimes called "reflected infrared" while MWIR and LWIR is sometimes referred to as "thermal infrared." Due to the nature of the blackbody radiation curves, typical 'hot' objects, such as exhaust pipes, often appear brighter in the MW compared to the same object viewed in the LW.

Sensor response division scheme

Plot of atmospheric transmittance in part of the infrared region.

A third scheme divides up the band based on the response of various detectors:[7]

  • Near infrared: from 0.7 to 1.0 micrometers (from the approximate end of the response of the human eye to that of silicon).
  • Short-wave infrared: 1.0 to 3 micrometers (from the cut off of silicon to that of the MWIR atmospheric window. InGaAs covers to about 1.8 micrometers; the less sensitive lead salts cover this region.
  • Mid-wave infrared: 3 to 5 micrometers (defined by the atmospheric window and covered by Indium antimonide [InSb] and HgCdTe and partially by lead selenide [PbSe]).
  • Long-wave infrared: 8 to 12, or 7 to 14 micrometers: the atmospheric window (Covered by HgCdTe and microbolometers).
  • Very-long wave infrared (VLWIR): 12 to about 30 micrometers, covered by doped silicon.

Monday, June 1, 2009

Electromagnetic Spectrum

1. Radio wave

Long wavelength, low frequency, low energy

SubHertz
subHz 0 < 3 Hz
> 100,000 km
Natural and man-made electromagnetic waves millihertz, microhertz, nanohertz from earth, ionosphere, sun, planets, etc

Extremely low frequency ELF 1 3–30 Hz
100,000 km – 10,000 km Communication with submarines

Super low frequency SLF 2 30–300 Hz
10,000 km – 1000 km Communication with submarines

Ultra low frequency ULF 3 300–3000 Hz
1000 km – 100 km Communication within mines

Very low frequency VLF 4 3–30 kHz
100 km – 10 km Submarine communication, avalanche beacons, wireless heart rate monitors, geophysics

Low frequency LF 5 30–300 kHz
10 km – 1 km Navigation, time signals, AM longwave broadcasting, RFID

Medium frequency MF 6 300–3000 kHz
1 km – 100 m AM (Medium-wave) broadcasts

High frequency HF 7 3–30 MHz
100 m – 10 m Shortwave broadcasts, amateur radio and over-the-horizon aviation communications, RFID

Very high frequency VHF 8 30–300 MHz
10 m – 1 m FM, television broadcasts and line-of-sight ground-to-aircraft and aircraft-to-aircraft communications. Land Mobile and Maritime Mobile communications

Ultra high frequency UHF 9 300–3000 MHz
1 m – 100 mm television broadcasts, microwave ovens, mobile phones, wireless LAN, Bluetooth, GPS and Two-Way Radios such as Land Mobile, FRS and GMRS Radios

Super high frequency SHF 10 3–30 GHz
100 mm – 10 mm microwave devices, wireless LAN, most modern Radars

Extremely high frequency(EHF) 11 30–300 GHz
10 mm – 1 mm Radio astronomy, high-frequency microwave radio relay

Terahertz(THz) 300–30,000 GHz 1 mm – 90 um
Terahertz imaging - a potential replacement for x-rays in some medical applications, ultrafast molecular dynamics, Condensed-matter physics, Terahertz time-domain spectroscopy, terahertz computing/communications

Aircraft and shiping band
Amplitude modulation radio band
Short wave radio
Frequency modulation radio and television

2. Microwave
Microwaves are electromagnetic waves with wavelengths ranging from 1mm - 1m, or frequencies between 0.3 GHz and 300 GHz.

Television
Radar
Microwave ovan

3. Infrared

Saturday, May 30, 2009

Development of operational power regression models for long range monsoon rainfall forecasts

1. Eight parameter and ten parameter power-regression models (Rajeevan et al. 2004)

During the period of 1988–2002, IMD’s operational forecasts were based on the 16-parameter power regression and parametric models (Gowariker et al.
1989, 1991). The sixteen parameter model give out its forecast on May 25. A particular advantage of having two power-regression models is that the first forecast can be generated in April itself with the 8-parameter model. The 10-parameter model provides flexibility for fine-tuning the April forecast on the basis of developments in June, particularly the El Nino/La Nina tendency.

The 8-parameter and 10-parameter models were developed using data of 38 years (1958–95). Another seven years’ data (1996–2002) were used for independent verification of the models. As part of the development of new power regression models for monsoon rainfall forecasts, every parameter in the 16-parameter model was examined for statistical stability over time by calculating running 21-year window correlations. The analysis revealed that all six April–May parameters and four winter–spring parameters showed weakening correlations. This lead to the removal of ten parameters from the set. The extensive data analysis yielded four new more stable and physically related predictors, for use in the long-range forecast model. A new parameter set consisting of six old and four new parameters was thus formulated for the purpose of further model development.

In the following list the parameters 1, 2, 4, 6, 7 are 8 old parameter taken from 16 parameter model and retained in the new model. All the others are new parameters freshly identified and used in the new models. The first eight parameters in the list are used for eight parameter model while the ten parameter model take first ten parameters in the list. The three other parameters in the list are used in some models other than these two.

1. Arabian sea SST (January and February)
2. Eurasian snow cover (December)
3. Northwest Europe temperature
4. Nino3 SST anomaly (previous year July to September)
5. South Indian Ocean SST index (March)
6. East Asia pressure (February and March)
7. Northern hemisphere 50 hPa wind pattern (January and February)
8. Europe pressure gradient (January)
9. South Indian Ocean 850 hPa zonal wind (june)
10. Nino3.4 SST tendency (April to June and January to March)
11. South Indian Ocean SST index (March to May)
12. North Indian Ocean and North Pacific Ocean 850 hPa zonal wind diffrence (May)
13. North atlantic Ocean SST (December , January and February)

2. six parameter models (Rajeevan et al. 2006)

The statistical models (Rajeevan et al. 2006) for the long range forecast of Indian Summer monsoon rainfall is based on the following techniques

1 Ensemble multiple linear regression
2 Projection pursuit regression

The parameters used for first stage (April) forecast are

A1 North Atlantic SST anomaly (20N–30N, 100W–80W)December and January
A2 Equatorial SE Indian Ocean SST anomaly (20S–10S, 100E–120E) February and March
A3 East Asia surface pressure anomaly (35N–45N, 120E–130E) February and March
A4 Europe land surface air temperature anomaly Five stations January
A5 Northwest Europe surface pressure anomaly tendency(65N–75N, 20E–40E) DJF(0)-SON(–1)
A6 WWV anomaly (5S–5N, 120E–80W) February and March

The parameters used for second stage (June) forecast are

J1 North Atlantic SST anomaly(20N–30N, 100W–80W) December and January
J2 Equatorial SE Indian Ocean SST anomaly(20S–10S, 100E–120E) February and March
J3 East Asia surface pressure anomaly(35N–45N, 120E–130E) February and March
J4 Nino-3.4 SST anomaly tendency(5S–5N, 170W–120W) MAM(0) – DJF(0)
J5 North Atlantic surface pressure anomaly(35N–45N, 30W–10W) May
J6 North Central Pacific zonal wind anomaly at 850 hPa(5N–15N, 180E–150W) May


1. Rajeevan,M.;Pai†,D. S.; Dikshit, S. K.; Kelkar, R. R.; 2004
IMD’s new operational models for long-range forecast of southwest monsoon rainfall over India and their verification for 2003


2. Rajeevan, M.; Pai,D. S.; Anil Kumar,R.; Lal,B.; 2006 New statistical models for long-range forecasting of southwest monsoon rainfall over India

Friday, May 29, 2009

Be a responsible Indian


Hi  friends,

 

Well i found this intereting one Letter of Dr.ABDUL KALAM

 

EVERY INDIAN HAS TO READ THIS....

 

 


 

Why is the media here so negative?
Why are we in India so embarrassed to recognize our own strengths, our achievements?
We are such a great nation. We have so many amazing success stories but we refuse to acknowledge them. Why?
We are the first in milk production.
We are number one in Remote sensing satellites.
We are the second largest producer of wheat.
We are the second largest producer of rice.
Look at Dr. Sudarshan , he has transferred the tribal village into a self-sustaining, self-driving unit. There are millions of such achievements but our media is only obsessed in the bad news and failures and disasters.
I was in Tel Aviv once and I was reading the Israeli newspaper. It was the day after a lot of attacks and bombardments and deaths had taken place. The Hamas had struck. But the front page of the newspaper had the picture of a Jewish gentleman who in five years had transformed his desert into an orchid and a granary. It was this inspiring picture that everyone woke up to. The gory details of killings, bombardments, deaths, were inside in the newspaper, buried among other news.

In India we only read about death, sickness, terrorism, crime.. Why are we so NEGATIVE? Another question: Why are we, as a nation so obsessed with foreign things? We want foreign T.Vs, we want foreign shirts. We want foreign technology.

Why this obsession with everything imported. Do we not realize that self-respect comes with self-reliance? I was in Hyderabad giving this lecture, when a 14 year old girl asked me for my autograph. I asked her what her goal in life is. She replied: I want to live in a developed India . For her, you and I will have to build this developed India . You must proclaim. India is not an under-developed nation; it is a highly developed nation.
Do you have 10 minutes? Allow me to come back with a vengeance.

Got 10 minutes for your country? If yes, then read; otherwise, choice is yours.
YOU say that our government is inefficient.
YOU say that our laws are too old.
YOU say that the municipality does not pick up the garbage.
YOU say that the phones don't work, the railways are a joke. The airline is the worst in the world, mails never reach their destination.
YOU say that our country has been fed to the dogs and is the absolute pits.

YOU say, say and say. What do YOU do about it?

Take a person on his way to Singapore . Give him a name - 'YOURS'. Give him a face - 'YOURS'. YOU walk out of the airport and you are at your International best. In Singapore you don't throw cigarette butts on the roads or eat in the stores. YOU are as proud of their Underground links as they are. You pay $5 (approx. Rs. 60) to drive through Orchard Road (equivalent of Mahim Causeway or Pedder Road) between 5 PM and 8 PM. YOU come back to the parking lot to punch your parking ticket if you have over stayed in a restaurant or a shopping mall irrespective of your status identity… In Singapore you don't say anything, DO YOU? YOU wouldn't dare to eat in public during Ramadan, in Dubai . YOU would not dare to go out without your head covered in Jeddah.
YOU would not dare to buy an employee of the telephone exchange in London at 10 pounds (Rs.650) a month to, 'see to it that my STD and ISD calls are billed to someone else.'YOU would not dare to speed beyond 55 mph (88 km/h) in Washington and then tell the traffic cop, 'Jaanta hai main kaun hoon (Do you know who I am?). I am so and so's son. Take your two bucks and get lost.' YOU wouldn't chuck an empty coconut shell anywhere other than the garbage pail on the beaches in Australia and New Zealand .
Why don't YOU spit Paan on the streets of Tokyo ? Why don't YOU use examination jockeys or buy fake certificates in Boston ??? We are still talking of the same YOU. YOU who can respect and conform to a foreign system in other countries but cannot in your own. You who will throw papers and cigarettes on the road the moment you touch Indian ground. If you can be an involved and appreciative citizen in an alien country, why cannot you be the same here in India ?

Once in an interview, the famous Ex-municipal commissioner of Bombay , Mr. Tinaikar, had a point to make. 'Rich people's dogs are walked on the streets to leave their affluent droppings all over the place,' he said. 'And then the same people turn around to criticize and blame the authorities for inefficiency and dirty pavements. What do they expect the officers to do? Go down with a broom every time their dog feels the pressure in his bowels?
In America every dog owner has to clean up after his pet has done the job. Same in Japan .
Will the Indian citizen do that here?' He's right. We go to the polls to choose a government and after that forfeit all responsibility.
We sit back wanting to be pampered and expect the government to do everything for us whilst our contribution is totally negative. We expect the government to clean up but we are not going to stop chucking garbage all over the place nor are we going to stop to pick a up a stray piece of paper and throw it in the bin. We expect the railways to provide clean bathrooms but we are not going to learn the proper use of bathrooms.
We want Indian Airlines and Air India to provide the best of food and toiletries but we are not going to stop pilfering at the least opportunity.
This applies even to the staff who is known not to pass on the service to the public.

When it comes to burning social issues like those related to women, dowry, girl child! and others, we make loud drawing room protestations and continue to do the reverse at home. Our excuse? 'It's the whole system which has to change, how will it matter if I alone forego my sons' rights to a dowry.' So who's going to change the system?
What does a system consist of? Very conveniently for us it consists of our neighbours, other households, other cities, other communities and the government. But definitely not me and YOU. When it comes to us actually making a positive contribution to the system we lock ourselves along with our families into a safe cocoon and look into the distance at countries far away and wait for a Mr.Clean to come along & work miracles for us with a majestic sweep of his hand or we leave the country and run away.
Like lazy cowards hounded by our fears we run to America to bask in their glory and praise their system. When New York becomes insecure we run to England . When England experiences unemployment, we take the next flight out to the Gulf. When the Gulf is war struck, we demand to be rescued and brought home by the Indian government. Everybody is out to abuse and rape the country. Nobody thinks of feeding the system. Our conscience is mortgaged to money.

Dear Indians, The article is highly thought inductive, calls for a great deal of introspection and pricks one's conscience too…. I am echoing J. F. Kennedy's words to his fellow Americans to relate to Indians…..

'ASK WHAT WE CAN DO FOR INDIA AND DO WHAT HAS TO BE DONE TO MAKE INDIA WHAT AMERICA AND OTHER WESTERN COUNTRIES ARE TODAY'

Lets do what India needs from us.

Forward this mail to each Indian for a change instead of sending Jokes or junk mails.

Thank you,

Dr. Abdul Kalam


--
Gibies George
http://gibies.blogspot.com/

Tuesday, April 28, 2009

Tex

This section describes some of the major advantages that TeX systems enjoy.
Compared to word processors

Most people have used a word processor, so a comparison may be helpful.

With a word processors your text is placed while you type it, referred to as "what you see is what you get." In contrast, TeX is a formatter: it separates the steps of entering the material and placing it on the page.

To see the difference, consider how a typical user of each system might start a new section. In a word processor a typical user might start that section by hitting twice to get two lines of vertical space, typing "Section 1.2: New results", clicking to highlight that text, clicking to select a larger type size, clicking to select a new type style, and finally entering two more lines of vertical space. A typical user TeX user will type into a file the line "\section{New results}". That is, a word processing user is formatting the text as they enter it, while the TeX user describes the meaning of the text and later TeX will format it.

Beginners like word processing but when they graduate to complex jobs the appeal fades. Word processing a twenty page technical article is hard; for instance, keeping the vertical space between sections uniform is error-prone, and so is making sure that all of the bibliographic entries follow the required format. In particular, very few people have both the knowledge and the eye to correctly lay out equations — people often say their equations "just don't look right." That is, as a user becomes more experienced and knowledgable the TeX approach of having the typesetting done by the program becomes the better choice. (Some word processors offer as advanced features TeX-like facilities for organizing input text, although few users take advantage of them.)

Wednesday, April 1, 2009

Grads code for active-break cross anomaly

Prompt 'Enter the folder name: '
pull fld
'!mkdir ../'fld

'reinit'
prompt 'Enter the starting year:'
pull y1
prompt 'Enter the ending year:'
pull yn

newseas=y
while(newseas=y)
'clear'
prompt 'Enter the season : '
pull season

prompt ' enter the starting month as number: '
pull m1
n=m1
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmm1=mmm
prompt 'Enter the starting day: '
pull d1
prompt ' enter the ending month as number: '
pull mn
n=mn
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmmn=mmm
prompt 'Enter the ending day: '
pull dn

'open sst6098.ctl'
'set lat -25 25'
'set lon 50 180'
'set time 'dn''mmmn''yn''
'set sdfwrite clim.'key'.nc'
'define cp=0'
'define ct=0'
'define cu=0'
'close 1'

'open sst6098.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''y1' 'dn''mmmn''yn''
'define t=ave(sst,time='d1''mmm1',time='dn''mmmn')'
'set time 'dn''mmmn''yn''
'define ct=ave(t,time='d1''mmm1''y1',time='dn''mmmn''yn')'
'undefine t'
'set grads off'
'set gxout shaded'
'set clevs 298.5 299 299.5 300 300.5 301 301.5 302 302.5 303 303.5 304'
'set ccols 9 14 4 11 5 13 3 10 7 12 8 2 6'
'd ct'
'cbarn'
'set gxout contour'
*'set ccolor 0'
'd ct'
'sdfwrite ct'
*'undefine ct'
'close 1'
'draw title sst climatology 'season''
'printim ../'fld'/climatology_'season'_'sst'.jpg white'

'clear'
'sdfopen slp.nc'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''y1' 'dn''mmmn''yn''
'define p=ave(slp,time='d1''mmm1',time='dn''mmmn')'
'set time 'dn''mmmn''yn''
'define cp=ave(p,time='d1''mmm1''y1',time='dn''mmmn''yn')'
'undefine p'
'set grads off'
'set gxout shaded'
'd cp'
'cbarn'
'set gxout contour'
'set ccolor 0'
'd cp'
'sdfwrite cp'
*'undefine cp'
'close 1'
'draw title slp climatology 'season''
'printim ../'fld'/climatology_'season'_'slp'.jpg white'

'clear'
'open u850.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''y1' 'dn''mmmn''yn''
'define uw=ave(u,time='d1''mmm1',time='dn''mmmn')'
'set time 'dn''mmmn''yn''
'define cu=ave(uw,time='d1''mmm1''y1',time='dn''mmmn''yn')'
'undefine uw'
'set grads off'
'set gxout shaded'
'd cu'
'cbarn'
'set gxout contour'
'd cu'
'cbarn'
'sdfwrite ct'
*'undefine cu'
'close 1'
'draw title u wind climatology 'season''
'printim ../'fld'/climatology_'season'_'uwind'.jpg white'






num=1

'sdfopen slp.nc'
'open sst6098.ctl'
'open u850.ctl'
'set time 31dec1960'
'set lat -25 25'
'set lon 50 180'
'define sp1=0'
'define st1=0'
'define su1=0'
'close 3'
'close 2'
'close 1'

prompt 'Enter the Key word (Active/Break) : '
pull key
prompt 'Enter the year:'
pull yyyy


while(yyyy>1950)
prompt ' enter the starting month as number: '
pull m1
n=m1
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmm1=mmm
prompt 'Enter the starting day: '
pull d1
prompt ' enter the ending month as number: '
pull mn
n=mn
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmmn=mmm
prompt 'Enter the ending day: '
pull dn


'clear'
'sdfopen slp.nc'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1'1960'
'define p=ave(slp,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'set time 31dec1960'
'define sp1=sp1+p'
'undefine p'
'define csp=sp1/'num''
'set grads off'
'set gxout shaded'
'd csp'
'cbarn'
'set gxout contour'
'd csp'
'draw title slp climatology 'season'\'key''
'printim ../'fld'/climatology_'key'_'season'_'slp'.jpg white'
'clear'
'set gxout shaded'
'd csp-cp'
'cbarn'
'set gxout contour'
'd csp-cp'
'draw title slp Anomaly 'season'\'key''
'printim ../'fld'/Anomaly_'key'_'season'_'slp'.jpg white'
'undefine csp'
'close 1'

'clear'
if (yyyy<=1998)
'open sst6098.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''1960''
'define t=ave(sst,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'define st1=st1+t'
'undefine t'
'define cst=st1/'num''
'set grads off'
'set gxout shaded'
'd cst'
'cbarn'
'set gxout contour'
'd cst'
'draw title sst climatology 'season'\'key''
'printim ../'fld'/climatology_'key'_'season'_'sst'.jpg white'
'clear'
'set gxout shaded'
'd cst-ct'
'cbarn'
'set gxout contour'
'd cst-ct'
'draw title sst Anomaly 'season'\'key''
'printim ../'fld'/Anomaly_'key'_'season'_'sst'.jpg white'
'undefine cst'
'close 1'
endif

'clear'
'open u850.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''1960''
'define uwnd=ave(u,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'define su1=su1+uwnd'
'undefine uwnd'
'define csu=su1/'num''
'set grads off'
'set gxout shaded'
'd csu'
'cbarn'
'set gxout contour'
'd csu'
'draw title u wind climatology 'season'\'key''
'printim ../'fld'/climatology_'key'_'season'_'uwind'.jpg white'
'clear'
'set gxout shaded'
'd csu-cu'
'cbarn'
'set gxout contour'
'd csu-cu'
'draw title u wind Anomaly 'season'\'key''
'printim ../'fld'/Anomaly_'key'_'season'_'uwind'.jpg white'
'undefine csu'
'close 1'

prompt 'Enter the next year:'
pull yyyy

num=num+1
endwhile
'define csp1=sp1/('num'-1)'
'undefine sp1'
'define cst1=st1/('num'-1)'
'undefine st1'
'define csu1=su1/('num'-1)'
'undefine su1'

num=1

'sdfopen slp.nc'
'open sst6098.ctl'
'open u850.ctl'
'set time 31dec1960'
'set lat -25 25'
'set lon 50 180'
'define sp2=0'
'define st2=0'
'define su2=0'
'close 3'
'close 2'
'close 1'

prompt 'Enter the Key word (Active/Break) : '
pull key
prompt 'Enter the year:'
pull yyyy

while(yyyy>1950)
prompt ' enter the starting month as number: '
pull m1
n=m1
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmm1=mmm
prompt 'Enter the starting day: '
pull d1
prompt ' enter the ending month as number: '
pull mn
n=mn
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmmn=mmm
prompt 'Enter the ending day: '
pull dn


'clear'
'sdfopen slp.nc'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1'1960'
'define p=ave(slp,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'set time 31dec1960'
'define sp2=sp2+p'
'undefine p'
'define csp=sp2/'num''
'set grads off'
'set gxout shaded'
'd csp'
'cbarn'
'set gxout contour'
'd csp'
'draw title slp climatology 'season'\'key''
'printim ../'fld'/climatology_'key'_'season'_'slp'.jpg white'
'clear'
'set gxout shaded'
'd csp-cp'
'cbarn'
'set gxout contour'
'd csp-cp'
'draw title slp Anomaly 'season'\'key''
'printim ../'fld'/Anomaly_'key'_'season'_'slp'.jpg white'
'undefine csp'
'close 1'

'clear'
if (yyyy<=1998)
'open sst6098.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''1960''
'define t=ave(sst,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'define st2=st2+t'
'undefine t'
'define cst=st2/'num''
'set grads off'
'set gxout shaded'
'd cst-ct'
'cbarn'
'set gxout contour'
'd cst'
'draw title sst climatology 'season'\'key''
'printim ../'fld'/climatology_'key'_'season'_'sst'.jpg white'
'clear'
'set gxout shaded'
'd cst-ct'
'cbarn'
'set gxout contour'
'd cst-ct'
'draw title sst Anomaly 'season'\'key''
'printim ../'fld'/Anomaly_'key'_'season'_'sst'.jpg white'
'undefine cst'
'close 1'
endif

'clear'
'open u850.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''1960''
'define uwnd=ave(u,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'define su2=su2+uwnd'
'undefine uwnd'
'define csu=su2/'num''
'set grads off'
'set gxout shaded'
'd csu'
'cbarn'
'set gxout contour'
'd csu'
'draw title u wind climatology 'season'\'key''
'printim ../'fld'/climatology_'key'_'season'_'uwind'.jpg white'
'clear'
'set gxout shaded'
'd csu-cu'
'cbarn'
'set gxout contour'
'd csu-cu'
'draw title u wind Anomaly 'season'\'key''
'printim ../'fld'/Anomaly_'key'_'season'_'uwind'.jpg white'
'undefine csu'
'close 1'

prompt 'Enter the next year:'
pull yyyy

num=num+1
endwhile
'define csp2=sp2/('num'-1)'
'undefine sp2'
'define cst2=st2/('num'-1)'
'undefine st2'
'define csu2=su2/('num'-1)'
'undefine su2'
'clear'
'set gxout shaded'
'set clevs -240 -200 -160 -120 -80 -40 0 40 80 120 160 200 240'
'set ccols 9 14 4 11 5 13 3 10 7 12 8 2 6'
'd csp1-csp2'
'cbarn'
'set gxout contour'
'd csp1-csp2'
'undefine csp1'
'undefine csp2'
'draw title 'season' slp climatology cross anomaly'
'printim ../'fld'/climatology_cross_anomaly_'season'_'slp'.jpg white'
'clear'
'set gxout shaded'
'set clevs -1.2 -1.0 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1.0 1.2'
'set ccols 9 14 4 11 5 13 3 10 7 12 8 2 6'
'd cst1-cst2'
'cbarn'
'set gxout contour'
'd cst1-cst2'
'draw title 'season' sst climatology cross anomaly'
'printim ../'fld'/climatology_cross_anomaly_'season'_'sst'.jpg white'
'undefine cst1'
'undefine cst2'
'clear'
'set gxout shaded'
'set clevs -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12'
'set ccols 9 14 4 11 5 13 3 10 7 12 8 2 6'
'd csu1-csu2'
'cbarn'
'set gxout contour'
'd csu1-csu2'
'draw title 'season' u wind climatology cross anomaly'
'printim ../'fld'/climatology_cross_anomaly_'season'_'uwind'.jpg white'
'undefine csu1'
'undefine csu2'
'clear'
prompt 'Do you have another season: '
pull newseas
endwhile

Friday, March 27, 2009

Climatology of Seasonal mean using Daily data in GrADS

Prompt 'Enter the folder name: '
pull fld
'!mkdir ../'fld
ans=y
while(ans=y)

prompt 'Enter the starting year:'
pull y1
prompt 'Enter the ending year:'
pull yn
'reinit'
prompt ' enter the starting month as number: '
pull m1
n=m1
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmm1=mmm
prompt 'Enter the starting day: '
pull d1
prompt ' enter the ending month as number: '
pull mn
n=mn
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmmn=mmm
prompt 'Enter the ending day: '
pull dn
prompt 'Enter the Key word (Active/Break) : '
pull key


'open sst6098.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''y1' 'dn''mmmn''yn''
'define t=ave(sst,time='d1''mmm1',time='dn''mmmn')'
'set time 'dn''mmmn''yn''
'define ct=ave(t,time='d1''mmm1''y1',time='dn''mmmn''yn')'
'undefine t'
'set grads off'
'set gxout shaded'
'set clevs 298.5 299 299.5 300 300.5 301 301.5 302 302.5 303 303.5 304'
'set ccols 9 14 4 11 5 13 3 10 7 12 8 2 6'
'd ct'
'cbarn'
'set gxout contour'
*'set ccolor 0'
*'d ct'
'undefine ct'
'close 1'
'draw title sst climatology 'key''
'printim ../'fld'/'key'_'sst'.jpg white'

'clear'
'sdfopen slp.nc'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''y1' 'dn''mmmn''yn''
'define p=ave(slp,time='d1''mmm1',time='dn''mmmn')'
'set time 'dn''mmmn''yn''
'define cp=ave(p,time='d1''mmm1''y1',time='dn''mmmn''yn')'
'undefine p'
'set grads off'
'set gxout shaded'
*'set clevs 1006.0 1007.0 1008.0 1009.0 1010.0 1011.0 1012.0 1013.0 1014.0 1015.0 1016.0'
*'set ccols 9 14 4 11 5 13 3 10 7 12 8 2'
'd cp'
'cbarn'
'set gxout contour'
'set ccolor 0'
'd cp'
'undefine cp'
'close 1'

'draw title slp climatology 'key''
'printim ../'fld'/'key'_'slp'.jpg white'

'clear'
'open u850.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''y1' 'dn''mmmn''yn''
'define uw=ave(u,time='d1''mmm1',time='dn''mmmn')'
'set time 'dn''mmmn''yn''
'define cu=ave(uw,time='d1''mmm1''y1',time='dn''mmmn''yn')'
'undefine uw'
'set grads off'
'set gxout shaded'
'd cu'
'set gxout contour'
'd cu'
'cbarn'
'draw title u wind climatology 'key''
'printim ../'fld'/'key'_'uwind'.jpg white'
'undefine cu'
'close 1'

prompt 'Do you have another one: '
pull ans
endwhile

Thursday, March 26, 2009

Code for Climatology of Selected time Average using daily data in GrADS

Prompt 'Enter the folder name: '
pull fld
'!mkdir ../'fld
num=1
'reinit'
'sdfopen slp.nc'
'open sst6098.ctl'
'open u850.ctl'
'set time 31dec1960'
'set lat -25 25'
'set lon 50 180'
'define sp=0'
'define st=0'
'define su=0'
'close 3'
'close 2'
'close 1'
prompt 'Enter the Key word (Active/Break) : '
pull key

prompt 'Enter the year:'
pull yyyy

while(yyyy>1950)
prompt ' enter the starting month as number: '
pull m1
n=m1
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmm1=mmm
prompt 'Enter the starting day: '
pull d1
prompt ' enter the ending month as number: '
pull mn
n=mn
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmmn=mmm
prompt 'Enter the ending day: '
pull dn

'clear'
'sdfopen slp.nc'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1'1960'
'define p=ave(slp,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'set time 31dec1960'
'define sp=sp+p'
'undefine p'
'define cp=sp/'num''
'set grads off'
'set gxout shaded'
*'set clevs 1006.0 1007.0 1008.0 1009.0 1010.0 1011.0 1012.0 1013.0 1014.0 1015.0 1016.0'
*'set ccols 9 14 4 11 5 13 3 10 7 12 8 2'
'd cp'
'cbarn'
'set gxout contour'
'd cp'
'undefine cp'
'draw title slp climatology 'key''
'printim ../'fld'/'key'_'slp'.jpg white'
'close 1'

'clear'
if (yyyy<=1998)
'open sst6098.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''1960''
'define t=ave(sst,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'define st=st+t'
'undefine t'
'define ct=st/'num''
'set grads off'
'set gxout shaded'
'set clevs 298 298.5 299 299.5 300 300.5 301 301.5 302 302.5 303 303.5 304'
'set ccols 9 14 4 11 5 13 3 10 7 12 8 2 6'
'd ct'
'cbarn'
'set gxout contour'
'd ct'
'draw title sst climatology 'key''
'printim ../'fld'/'key'_'sst'.jpg white'
'undefine ct'
'close 1'
endif

'clear'
'open u850.ctl'
'set lat -25 25'
'set lon 50 180'
*'set mproj scaled'
'set time 'd1''mmm1''1960''
'define uwnd=ave(u,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'define su=su+uwnd'
'undefine uwnd'
'define cu=su/'num''
'set grads off'
'set gxout shaded'
'd cu'
'set gxout contour'
'd cu'
'draw title u wind climatology 'key''
'printim ../'fld'/'key'_'uwind'.jpg white'
'undefine cu'
'close 1'

prompt 'Enter the next year:'
pull yyyy

num=num+1
endwhile

Thursday, March 12, 2009

Spatial distribution

Prompt 'Enter the folder name: '
pull fld
'!mkdir ../'fld

prompt 'Enter the starting year:'
pull y1
prompt 'Enter the starting year:'
pull yn
yyyy=y1
While (yyyy<=yn)

ans='yes'
while(ans='yes')
'reinit'
prompt 'enter the onset month as number'
pull m1
n=m1
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmm1=mmm
prompt mmm1' '
prompt 'Enter the onset day: '
pull d1
prompt 'enter the withdrowal month as number'
pull mn
n=mn
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
mmmn=mmm
prompt mmmn' '
prompt 'Enter the withdraw day: '
pull dn
'open rf_5103.ctl'
'set lat 5 25'
'set lon 60 90'
'set time 'dn''mmm''yyyy''
'define smr=ave(rf,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'set grads off'
'set gxout shaded'
'set clev 10 20 30 40 50 60 70 80 90 100'
'd r'
'undefine r'
'close 1'

if (yyyy<=1998)
'open sst6098.ctl'
'set lat 5 25'
'set lon 60 90'
'set time 'dd''mmm''yyyy''
'define t=ave(sst,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'set grads off'
'set gxout shaded'
'set clev 298 298.5 299 299.5 300 300.5 301 301.5 302'
'd t'
'undefine t'
'close 1'
endif

'sdfopen slp.nc'
'set lat 5 25'
'set lon 60 90'
'set time 'dd''mmm''yyyy''
'define p=ave(slp,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy')'
'set grads off'
'set gxout contour'
'set ccolor 15'
'd p'
'undefine p'
'close 1'

'open u850.ctl'
'set lat 5 25'
'set lon 60 90'
'set time 'dd''mmm''yyyy''
'define uwnd=ave(u,t-2,t+2)'
'set grads off'
'set gxout contour'
'set ccolor 2'
*'d uwnd'
'undefine uwnd'
'close 1'

'draw title contour 'yyyy' 'mmm' 'dd' '
'printim ../'fld'/contour'yyyy''n''dd'.jpg white'


prompt 'Do you want to plot another pulse: '
pull ans
endwhile
yyyy=yyyy+1
endwhile

Tuesday, March 10, 2009

GrADS code to plot Rainfall slp and zonal wind of Northeast monsoon over southern peninsular India

Prompt 'Enter the folder name: '
pull fld
'!mkdir ../'fld

yyyy=1951
while(yyyy<=2003)

'reinit'
'set grads off'

'set vpage 0 8 0 11 '
'set parea .5 8 8.5 10'
'set mproj scaled'
'sdfopen slp.nc'
'set lat 10'
'set lon 75'
'set time 01Oct'yyyy' 31Dec'yyyy
'define ap=aave(slp,lon=65,lon=75,lat=5,lat=15)'
'define pentp=ave(ap,t-2,t+2)'
'define meanp=ave(ap,time=01Oct'yyyy',time=31Dec'yyyy')'
'd pentp'
'd meanp'
'draw title slp lon=65,lon=75,lat=5,lat=15 'yyyy' '
'close 1'
'undefine ap'
'undefine pentp'
'undefine meanp'

'set vpage 0 8 0 11 '
'set parea .5 8 6.5 8'
'set mproj scaled'
'open u850.ctl'
'set lat 10'
'set lon 75'
'set time 01Oct'yyyy' 31Dec'yyyy
'define au=aave(u,lon=70,lon=80,lat=13,lat=15)'
'define pentu=ave(au,t-2,t+2)'
'define meanu=ave(au,time=01Oct'yyyy',time=31Dec'yyyy')'
'd pentu'
'd meanu'
'draw title u850 lon=70,lon=80,lat=13,lat=15 'yyyy' '
'close 1'
'undefine au'
'undefine pentu'
'undefine meanu'


'set vpage 0 8 0 11'
'set parea .5 8 4.5 6'
'set mproj scaled'
'open rf_5103.ctl'
'set lat 10'
'set lon 75'
'set time 01Oct'yyyy' 31Dec'yyyy
'define r=aave(rf,lon=70,lon=80,lat=8,lat=13)'
'define pentr=ave(r,t-2,t+2)'
'define meanr=ave(r,time=01Oct'yyyy',time=31Dec'yyyy')'
'd pentr'
'd meanr'
'draw title Rain lon=70,lon=80,lat=8,lat=13 'yyyy' '
'close 1'
'undefine r'
'undefine pentr'
'undefine meanr'

'set vpage 0 8 0 11 '
'set parea .5 8 2.5 4'
'set mproj scaled'
'open u850.ctl'
'set lat 10'
'set lon 75'
'set time 01Oct'yyyy' 31Dec'yyyy
'define au=aave(u,lon=70,lon=80,lat=8,lat=13)'
'define pentu=ave(au,t-2,t+2)'
'define meanu=ave(au,time=01Oct'yyyy',time=31Dec'yyyy')'
'd pentu'
'd meanu'
'draw title u850 lon=70,lon=80,lat=8,lat=13 'yyyy' '
'close 1'
'undefine au'
'undefine pentu'
'undefine meanu'

'set vpage 0 8 0 11 '
'set parea .5 8 0.5 2'
'set mproj scaled'
'sdfopen slp.nc'
'set lat 10'
'set lon 75'
'set time 01Oct'yyyy' 31Dec'yyyy
'define ap=aave(slp,lon=80,lon=90,lat=5,lat=15)'
'define pentp=ave(ap,t-2,t+2)'
'define meanp=ave(ap,time=01Oct'yyyy',time=31Dec'yyyy')'
'd pentp'
'd meanp'
'draw title slp lon=80,lon=90,lat=5,lat=15 'yyyy' '
'close 1'
'undefine ap'
'undefine pentp'
'undefine meanp'

'printim ../'fld'/wind'yyyy'.jpg white'

yyyy=yyyy+1
endwhile

Saturday, February 28, 2009

JRF applications

CSIR-JRF register numbers
200167 of June 2008
200377 of December 2008

PRL application register number 01383.
IISc application register number 355797

IIT Kharagpur application send on 24th March 2009


Applied for IITM JRF
(
Advertisement No:PER/4/ 2009 dt. 19 May 09)

SPL VSSC application number RBZ7V51

Space application centre
01091409000022


Joined IITM as Research Fellow under Dr SuryaChandra Rao on 15 sep 2009

Friday, February 20, 2009

control structors in GrADS

Prompt 'Enter the folder name: '
pull fld
'!mkdir ../'fld
prompt 'enter the year as yyyy :'
pull yyyy
prompt 'enter the month as number 1 to 12 :'
pull n
if(n=1)
mmm='jan'
endif
if(n=2)
mmm='feb'
endif
if(n=3)
mmm='mar'
endif
if(n=4)
mmm='apr'
endif
if(n=5)
mmm='may'
endif
if(n=6)
mmm='jun'
endif
if(n=7)
mmm='jul'
endif
if(n=8)
mmm='aug'
endif
if(n=9)
mmm='sep'
endif
if(n=10)
mmm='oct'
endif
if(n=11)
mmm='nov'
endif
if(n=12)
mmm='dec'
endif
prompt mmm' '
prompt

dd=1
while(dd<=30)

'reinit'
'sdfopen slp.'yyyy'.nc'

'set lat 5 25'
'set lon 60 90'
'set time 'dd''mmm''yyyy''

'set grads off'
'set gxout shaded'
'd slp'
'cbarn'
'draw title slp 'yyyy' 'mmm' 'dd' '
'printim ../'fld'/slp'yyyy''n''dd'.jpg white'

dd=dd+1
endwhile






Friday, February 6, 2009

Trend using 3year running mean (Grads)

*warning:this is a very difficult job using the extreme of your processors ability.
*so be careful... the program take very much time
*trend analysis
'!mkdir trend3out'
'reinit'
'open rf_5103.ctl'
'clear'
'set lat 10'
'set lon 75'
'set time 01Oct1951 31Dec2003'
'set grads off'
'define r=aave(rf,lon=70,lon=80,lat=8,lat=13)'

'define s0=ave(r,time=01Oct,time=31Dec)'
'd s0'

'draw title Rain trend 1951-2003 '
'printim trend3out/rain_trend0.jpg white'

i=1
while(i<=50)

'define s'i'=ave(s'i-1',t-365,t+365)'
'undefine s'i-1
'clear'
'd s'i''
'draw title Rain trend 1951-2003 '
'printim trend3out/rain_trend'i'.jpg white'

i=i+1
endwhile

Interannual variation of rainfall as bar chart(GrADS)

'reinit'
'open rf_5103.ctl'
'set lat 10'
'set lon 75'
'set grads off'
'set time 01jan1951 31Dec2003'
'define valr=aave(rf,lon=70,lon=80,lat=8,lat=13)'
'define mean=ave(valr,time=1oct,time=31dec)'
'set gxout bar'
'd mean'
'fprintf mean unni.txt'

penta-day running mean (GrADS)

'!mkdir rain9'
yyyy=1951
while(yyyy<=2003)

'reinit'
'open rf_5103.ctl'
'set lat 10'
'set lon 75'

'set time 01Oct'yyyy' 31Dec'yyyy
'set grads off'
'define r=aave(rf,lon=70,lon=80,lat=8,lat=13)'
'define pent=ave(r,t-2,t+2)'
'd pent'
'define mean=ave(r,time=01Oct'yyyy',time=31Dec'yyyy')'
'd mean'
'draw title Rain 'yyyy' '
'printim rain9/rain'yyyy'.jpg white'

yyyy=yyyy+1
endwhile

Thursday, February 5, 2009

RMS of deviation(grads)

'!mkdir rain7'
yyyy=1951
while(yyyy<=2003)

'reinit'
'open rf_5103.ctl'
'set lat 10'
'set lon 75'

'set time 01Oct'yyyy' 31Dec'yyyy
'set grads off'
'define r=aave(rf,lon=70,lon=80,lat=8,lat=13)'
'd r'
'define mean=ave(r,time=01Oct'yyyy',time=31Dec'yyyy')'
'define dev=((r-mean)*(r-mean))'
'define rmsdev=sqrt(ave(dev,time=01Oct'yyyy',time=31Dec'yyyy'))'

'd mean-rmsdev'

'd mean'

'd mean+rmsdev'


'draw title Rain 'yyyy' '
'printim rain7/rain'yyyy'.jpg white'

yyyy=yyyy+1
endwhile

Mean and mean deviation (grads)

'!mkdir rain4'
yyyy=1951
while(yyyy<=2003)

'reinit'
'open rf_5103.ctl'
'set lat 10'
'set lon 75'

'set time 01Oct'yyyy' 31Dec'yyyy
'set grads off'
'define r=aave(rf,lon=70,lon=80,lat=8,lat=13)'
'd r'
'define mean=ave(r,time=01Oct'yyyy',time=31Dec'yyyy')'
'define dev=abs(r-mean)'
'define mdev=ave(dev,time=01Oct'yyyy',time=31Dec'yyyy')'

'd mean-mdev'

'd mean'

'd mean+mdev'


'draw title Rain 'yyyy' '
'printim rain4/rain'yyyy'.jpg white'

yyyy=yyyy+1
endwhile






rf_5103.ctl

DSET rf_5103.grd

TITLE 1.0 degr analyzed grids 1951-2003

UNDEF -99.90

XDEF 35 LINEAR 66.5 1.0

YDEF 32 LINEAR 6.5 1.0

ZDEF 1 linear 1 1

TDEF 19358 LINEAR 1jan1951 1DY

VARS 1

rf 0 99 GRIDDED RAINFALL

ENDVARS






Hoffmuller (latitude-time)

prompt 'Enter the keyword: '
pull key
'!mkdir hoff_'key
lon=0
while lat<180


'reinit'
'sdfopen monmeandata/'key'.mon.mean.nc'
'q file'
'set lat -90 90
'set lon 'lon
'set t 1 12'
'set xyrev on'
'd 'key
'draw xlab Longitude'
'draw ylab Time'



'printim hoff_'key'/'lat'.jpg white'

lat=lat+1
endwhile

Tuesday, February 3, 2009

Litrature review

1.
On the variability and prediction of rainfall in the postmonsoon season over india
by Nityanad Sigh and N.A. Sontakke,Indian Institute of Tropical Meteorology,Pune
published in International journal of climatology(1999), page 309-339.

2.
Objective ditermination of Northeast Monsoon Onset dates over costal Tamil Nadu for
the period of1901-'90 by Y.E.A Raj, Regional Meteorological Centre, Madras
published in Mausam(1992)43,3 page 273-282.

3.
Inter and Intra-seasonal variation of thermodynamic parameters of the atmosphere
over costal Tamil Nadu during Northeast Monsoon
by Y.E.A Raj, Regional Meteorological Centre, Madras
published in Mausam(1996)47,3 page 259-268

4.
Unrevelling the mystery of Indion Ocean Monsoon failure during El-Nino
by K. Krishnakumar, Balaji Rajagopalan, Martin Hoerling, Gary Bales, Mark Cane

5.
Air-Sea interaction on a seasonal scale over North Indian Ocean Part 1
Inter-anual variation of seasurface temperature and Indian summer Monsoon Rainfall
by P.V. Joseph and P.V. Pillai,Meteorological office, Pune
Published on Mausam(1984) 35,3 Pages 323-330

6.
Air-Sea interaction on a seasonal scale over North Indian Ocean Part 2
Monthly mean atmospheric and oceanic parameters during 1972 and 1973
by P.V. Joseph and P.V. Pillai,Meteorological office, Pune
Published on Mausam(1986) 37,2 Pages 159-168

7.
An Ocean Atmosphere interaction mechanism for the active break cycle of the
Asian Summer Monsoon by P.V. Joseph and T.P. Sabin
published in Climate Dynamics(2008)30 Pages 553-566.

Saturday, January 31, 2009

Northeast monsoon area average (GrADS)

prompt 'Enter south boundary: '
pull s
prompt 'Enter north boundry: '
pull n
prompt 'Enter west boundary: '
pull w
prompt 'Enter east boundary: '
pull e

'!mkdir 'rain'_'s'_'n'_'w'_'e

yyyy=1951
while(yyyy<=2003)



'reinit'
'open rf_5103.ctl'
'set lat 10'
'set lon 75'

'set time 01Oct'yyyy' 31Dec'yyyy
'set grads off'
'define r=aave(rf,lon='w',lon='e',lat='s',lat='n')'
'd r'
'draw title Rain area ave 'w'e 'e'e 's'n 'n'n'
'printim rain_'s'_'n'_'w'_'e'/rain'yyyy'.jpg white'

yyyy=yyyy+1
endwhile

Friday, January 23, 2009

Indian ocean Dipole using grads

yyyy=1960
while(yyyy<=1979)

'reinit'
'open sst6079.ctl'

'set lat 10'
'set lon 75'

'set time 01Oct'yyyy' 31Dec'yyyy
'set grads off'
'define sste=aave(sst,lon=90,lon=110,lat=-10,lat=0)'
'd sste'
'define sstw=aave(sst,lon=50,lon=70,lat=-10,lat=10)'
'd sstw'
'define sstd=sstw-sste'
'd sstd'
'draw title sst control run'
'printim sst1/sst'yyyy'.jpg white'

yyyy=yyyy+1
endwhile


yyyy=1980
while(yyyy<=1998)

'reinit'
'open sst8098.ctl'

'set lat 10'
'set lon 75'

'set time 01Oct'yyyy' 31Dec'yyyy
'set grads off'
'define sste=aave(sst.2,lon=90,lon=110,lat=-10,lat=0)'
'd sste'
'define sstw=aave(sst.2,lon=50,lon=70,lat=-10,lat=10)'
'd sstw'
'define sstd=sstw-sste'
'd sstd'
'draw title sst control run'
'printim sst1/sst'yyyy'.jpg white'

yyyy=yyyy+1
endwhile

Tuesday, January 20, 2009

rain NE monsoon

yyyy=1951
while(yyyy<=2003)

'reinit'
'open rf_5103.ctl'
'set lat 10'
'set lon 75'

'set time 01Oct'yyyy' 31Dec'yyyy
'set grads off'
'define r=aave(rf,lon=70,lon=75,lat=8,lat=15)'
'd r'
'draw title Rain control run'
'printim rain1/rain'yyyy'.jpg white'

yyyy=yyyy+1
endwhile

Monday, January 12, 2009

Project topic

Topic:Intra seasonal variability of Northeast Monsoon and various physical parameters ditermining it.

Work Plan
1.Collecting daily dataof rainfall, SST, SLP, wind, etc.

2.Time series analysis of spacial average of precipitation over southern peninsular India. (Between 8N and 15N latitude, and between 74E and 80E longitude)

3. Determine the periodicity of intra-seasonal variability of rainfall during Northeast monsoon.

4. Cross examining and correlating the northeast monsoon rainfall variabilities with the parameters such as Indian ocean Sea surface temperature, Sea level pressure, wind speed, wind direction, cloud cover, over the tropical Indian Ocean and Southern peninsular India.

5. Identify if there is any other parameters which have its influence on the northeast monsoon precipitation.

6. The relationship of the periodicity of intra-seasonal variability of Northeast monsoon with various phenomenas such as

*Indian Ocean dipole
*Equatorial Indian Ocean Oscillation
*Global circulation pattern
*El-Nino Southern Oscillation
*Quasi Biennial Oscillation
*Madden Julian Oscillation
etc if time and resources are available.

7. The proposed study shall lead to a better understanding of Intra-seasonal variability Northeast monsoon and its dependence on various parameters and Global Meteorological Phenomenas

EPSS109

C Programming - File management in C


C Programming - File management in C

In this tutorial you will learn about C Programming - File management in C, File operation functions in C, Defining and opening a file, Closing a file, The getw and putw functions, The fprintf & fscanf functions, Random access to files and fseek function.



C supports a number of functions that have the ability to perform basic file operations, which include:
1. Naming a file
2. Opening a file
3. Reading from a file
4. Writing data into a file
5. Closing a file


  • Real life situations involve large volume of data and in such cases, the console oriented I/O operations pose two major problems
  • It becomes cumbersome and time consuming to handle large volumes of data through terminals.
  • The entire data is lost when either the program is terminated or computer is turned off therefore it is necessary to have more flexible approach where data can be stored on the disks and read whenever necessary, without destroying the data. This method employs the concept of files to store data.

File operation functions in C:

Function Name


Operation


fopen()


Creates a new file for use
Opens a new existing file for use


fclose


Closes a file which has been opened for use


getc()


Reads a character from a file


putc()


Writes a character to a file


fprintf()


Writes a set of data values to a file


fscanf()


Reads a set of data values from a file


getw()


Reads a integer from a file


putw()


Writes an integer to the file


fseek()


Sets the position to a desired point in the file


ftell()


Gives the current position in the file


rewind()


Sets the position to the begining of the file


Defining and opening a file:

If we want to store data in a file into the secondary memory, we must specify certain things about the file to the operating system. They include the fielname, data structure, purpose.


The general format of the function used for opening a file is


FILE *fp;
fp=fopen(“filename”,”mode”);

The first statement declares the variable fp as a pointer to the data type FILE. As stated earlier, File is a structure that is defined in the I/O Library. The second statement opens the file named filename and assigns an identifier to the FILE type pointer fp. This pointer, which contains all the information about the file, is subsequently used as a communication link between the system and the program.
The second statement also specifies the purpose of opening the file. The mode does this job.

R open the file for read only.
W open the file for writing only.
A open the file for appending data to it.

Consider the following statements:


FILE *p1, *p2;
p1=fopen(“data”,”r”);
p2=fopen(“results”,”w”);


In these statements the p1 and p2 are created and assigned to open the files data and results respectively the file data is opened for reading and result is opened for writing. In case the results file already exists, its contents are deleted and the files are opened as a new file. If data file does not exist error will occur.


Closing a file:

The input output library supports the function to close a file; it is in the following format.
fclose(file_pointer);

A file must be closed as soon as all operations on it have been completed. This would close the file associated with the file pointer.
Observe the following program.


….
FILE *p1 *p2;
p1=fopen (“Input”,”w”);
p2=fopen (“Output”,”r”);
….

fclose(p1);
fclose(p2)


The above program opens two files and closes them after all operations on them are completed, once a file is closed its file pointer can be reversed on other file.

The getc and putc functions are analogous to getchar and putchar functions and handle one character at a time. The putc function writes the character contained in character variable c to the file associated with the pointer fp1. ex putc(c,fp1); similarly getc function is used to read a character from a file that has been open in read mode. c=getc(fp2).


The program shown below displays use of a file operations. The data enter through the keyboard and the program writes it. Character by character, to the file input. The end of the data is indicated by entering an EOF character, which is control-z. the file input is closed at this signal.

#include<>
main()
{
file *f1;
printf(“Data input output”);
f1=fopen(“Input”,”w”); /*Open the file Input*/
while((c=getchar())!=EOF) /*get a character from key board*/
putc(c,f1); /*write a character to input*/
fclose(f1); /*close the file input*/
printf(“\nData output\n”);
f1=fopen(“INPUT”,”r”); /*Reopen the file input*/
while((c=getc(f1))!=EOF)
printf(“%c”,c);
fclose(f1);
}


The getw and putw functions:

These are integer-oriented functions. They are similar to get c and putc functions and are used to read and write integer values. These functions would be usefull when we deal with only integer data. The general forms of getw and putw are:


putw(integer,fp);
getw(fp);


/*Example program for using getw and putw functions*/
#include<>
main()
{
FILE *f1,*f2,*f3;
int number I;
printf(“Contents of the data file\n\n”);
f1=fopen(“DATA”,”W”);
for(I=1;I< 30;I++)
{
scanf(“%d”,&number);
if(number==-1)
break;
putw(number,f1);
}
fclose(f1);
f1=fopen(“DATA”,”r”);
f2=fopen(“ODD”,”w”);
f3=fopen(“EVEN”,”w”);
while((number=getw(f1))!=EOF)/* Read from data file*/
{
if(number%2==0)
putw(number,f3);/*Write to even file*/
else
putw(number,f2);/*write to odd file*/
}
fclose(f1);
fclose(f2);
fclose(f3);
f2=fopen(“ODD”,”r”);
f3=fopen(“EVEN”,”r”);
printf(“\n\nContents of the odd file\n\n”);
while(number=getw(f2))!=EOF)
printf(“%d%d”,number);
printf(“\n\nContents of the even file”);
while(number=getw(f3))!=EOF)
printf(“%d”,number);
fclose(f2);
fclose(f3);
}


The fprintf & fscanf functions:

The fprintf and scanf functions are identical to printf and scanf functions except that they work on files. The first argument of theses functions is a file pointer which specifies the file to be used. The general form of fprintf is


fprintf(fp,”control string”, list);


Where fp id a file pointer associated with a file that has been opened for writing. The control string is file output specifications list may include variable, constant and string.


fprintf(f1,%s%d%f”,name,age,7.5);


Here name is an array variable of type char and age is an int variable
The general format of fscanf is


fscanf(fp,”controlstring”,list);


This statement would cause the reading of items in the control string.

Example:

fscanf(f2,”5s%d”,item,&quantity”);


Like scanf, fscanf also returns the number of items that are successfully read.

/*Program to handle mixed data types*/
#include<>
main()
{
FILE *fp;
int num,qty,I;
float price,value;
char item[10],filename[10];
printf(“Input filename”);
scanf(“%s”,filename);
fp=fopen(filename,”w”);
printf(“Input inventory data\n\n”0;
printf(“Item namem number price quantity\n”);
for I=1;I< =3;I++)
{
fscanf(stdin,”%s%d%f%d”,item,&number,&price,&quality);
fprintf(fp,”%s%d%f%d”,itemnumber,price,quality);
}
fclose (fp);
fprintf(stdout,”\n\n”);
fp=fopen(filename,”r”);
printf(“Item name number price quantity value”);
for(I=1;I< =3;I++)
{
fscanf(fp,”%s%d%f%d”,item,&number,&prince,&quality);
value=price*quantity”);
fprintf(“stdout,”%s%d%f%d%d\n”,item,number,price,quantity,value);
}
fclose(fp);
}


Random access to files:

Sometimes it is required to access only a particular part of the and not the complete file. This can be accomplished by using the following function:


1 > fseek


fseek function:

The general format of fseek function is a s follows:


fseek(file pointer,offset, position);


This function is used to move the file position to a desired location within the file. Fileptr
is a pointer to the file concerned. Offset is a number or variable of type long, and position in an integer number. Offset specifies the number of positions (bytes) to be moved from the location specified bt the position. The position can take the 3 values.


Value Meaning
0 Beginning of the file
1 Current position
2 End of the file.