read(100,5)temp,a,charac
5 format(A11,i1,A7)
read(100,*)b
read(100,*)c
read(100,*)d
if((a.ne.0.or.b.ne.0.or.c.ne.0&
.or.d.ne.0).and.trim(charac).ne.'spline')then
print*, 'Scenario A'
elseif((a.ne.0.or.b.ne.0.or.c.ne.0&
.or.d.ne.0).and.trim(charac).eq.'spline')then
print*, 'Scenario B'
else
print*, 'Scenario C'
endif
Input file: *---------------------------------------------------------------
My input file from which i am reading these looks as below:
1 spline
0
0
0
*----------------------------------------------------------------
what I want
scenario A is triggered if any of the integers a,b,c,d have a value of "1" and input file not containing the word "spline"
scenario B is triggered if any of the integers a,b,c,d have a value of "1" and input file contains the word "spline"
scenario C is triggered if all of the integers a,b,c,d have a value of "0" and input file not containing the word "spline"
*---------------------------------------------------------------------
I was initially placing some other word in place of spline for Scenario A to trigger, but I require that Scenario A and C trigger if there is nothing written i.e. empty space.
This is the reason that I am using formatting in read, otherwise the read statement goes to the next line when it does not finds any character in that specific line.
I have tried printing the variables and the variables shows correct values to trigger Scenario B but it still triggers A
Aucun commentaire:
Enregistrer un commentaire